Class SnippetRegistry
java.lang.Object
org.eclipse.lemminx.commons.snippets.SnippetRegistry
A registry for snippets which uses the same format than vscode snippet.
- Author:
- Angelo ZERR
-
Constructor Summary
ConstructorsConstructorDescriptionSnippetRegistry(String languageId, boolean loadDefault) Snippet registry for a given language id. -
Method Summary
Modifier and TypeMethodDescriptionList<org.eclipse.lsp4j.CompletionItem>getCompletionItems(org.eclipse.lsp4j.Range replaceRange, String lineDelimiter, boolean canSupportMarkdown, boolean snippetsSupported, BiPredicate<ISnippetContext<?>, Map<String, String>> contextFilter, ISuffixPositionProvider suffixProvider) Returns the snippet completion items according to the context filter.Returns all snippets.voidregisterSnippet(Snippet snippet) Register the given snippet.voidRegister the snippets from the given JSON input stream.voidregisterSnippets(InputStream in, com.google.gson.TypeAdapter<? extends ISnippetContext<?>> contextDeserializer) Register the snippets from the given JSON stream with a context.voidregisterSnippets(InputStream in, ISnippetContext<?> defaultContext) Register the snippets from the given JSON stream with a context.voidregisterSnippets(InputStream in, ISnippetContext<?> defaultContext, com.google.gson.TypeAdapter<? extends ISnippetContext<?>> contextDeserializer) Register the snippets from the given JSON stream with a context.voidRegister the snippets from the given JSON reader.voidregisterSnippets(Reader in, com.google.gson.TypeAdapter<? extends ISnippetContext<?>> contextDeserializer) Register the snippets from the given JSON reader with a context.voidregisterSnippets(Reader in, ISnippetContext<?> defaultContext) Register the snippets from the given JSON stream with a context.voidregisterSnippets(Reader in, ISnippetContext<?> defaultContext, com.google.gson.TypeAdapter<? extends ISnippetContext<?>> contextDeserializer) Register the snippets from the given JSON stream with a context.
-
Constructor Details
-
SnippetRegistry
public SnippetRegistry() -
SnippetRegistry
Snippet registry for a given language id.- Parameters:
languageId- the language id and null otherwise.loadDefault- true if default snippets from SPI must be loaded and false otherwise.
-
-
Method Details
-
registerSnippet
Register the given snippet.- Parameters:
snippet- the snippet to register.
-
registerSnippets
Register the snippets from the given JSON input stream.- Parameters:
in- the JSON input stream which declares snippets with vscode snippet format.- Throws:
IOException
-
registerSnippets
public void registerSnippets(InputStream in, com.google.gson.TypeAdapter<? extends ISnippetContext<?>> contextDeserializer) throws IOException Register the snippets from the given JSON stream with a context.- Parameters:
in- the JSON input stream which declares snippets with vscode snippet format.contextDeserializer- the GSON context deserializer used to create Java context.- Throws:
IOException
-
registerSnippets
Register the snippets from the given JSON stream with a context.- Parameters:
in- the JSON input stream which declares snippets with vscode snippet format.defaultContext- the default context.- Throws:
IOException
-
registerSnippets
public void registerSnippets(InputStream in, ISnippetContext<?> defaultContext, com.google.gson.TypeAdapter<? extends ISnippetContext<?>> contextDeserializer) throws IOException Register the snippets from the given JSON stream with a context.- Parameters:
in- the JSON input stream which declares snippets with vscode snippet format.defaultContext- the default context.contextDeserializer- the GSON context deserializer used to create Java context.- Throws:
IOException
-
registerSnippets
Register the snippets from the given JSON reader.- Parameters:
in- the JSON reader which declares snippets with vscode snippet format.- Throws:
IOException
-
registerSnippets
public void registerSnippets(Reader in, com.google.gson.TypeAdapter<? extends ISnippetContext<?>> contextDeserializer) throws IOException Register the snippets from the given JSON reader with a context.- Parameters:
in- the JSON reader which declares snippets with vscode snippet format.contextDeserializer- the GSON context deserializer used to create Java context.- Throws:
IOException
-
registerSnippets
Register the snippets from the given JSON stream with a context.- Parameters:
in- the JSON reader which declares snippets with vscode snippet format.defaultContext- the default context.- Throws:
IOException
-
registerSnippets
public void registerSnippets(Reader in, ISnippetContext<?> defaultContext, com.google.gson.TypeAdapter<? extends ISnippetContext<?>> contextDeserializer) throws IOException Register the snippets from the given JSON stream with a context.- Parameters:
in- the JSON reader which declares snippets with vscode snippet format.defaultContext- the default context.contextDeserializer- the GSON context deserializer used to create Java context.- Throws:
IOException
-
getSnippets
Returns all snippets.- Returns:
- all snippets.
-
getCompletionItems
public List<org.eclipse.lsp4j.CompletionItem> getCompletionItems(org.eclipse.lsp4j.Range replaceRange, String lineDelimiter, boolean canSupportMarkdown, boolean snippetsSupported, BiPredicate<ISnippetContext<?>, Map<String, String>> contextFilter, ISuffixPositionProvider suffixProvider) Returns the snippet completion items according to the context filter.- Parameters:
replaceRange- the replace range.lineDelimiter- the line delimiter.canSupportMarkdown- true if markdown is supported to generate documentation and false otherwise.contextFilter- the context filter.- Returns:
- the snippet completion items according to the context filter.
-