Class SnippetRegistry
- java.lang.Object
-
- org.eclipse.lemminx.commons.snippets.SnippetRegistry
-
public class SnippetRegistry extends Object
A registry for snippets which uses the same format than vscode snippet.- Author:
- Angelo ZERR
-
-
Constructor Summary
Constructors Constructor Description SnippetRegistry()SnippetRegistry(String languageId, boolean loadDefault)Snippet registry for a given language id.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.List<Snippet>getSnippets()Returns all snippets.voidregisterSnippet(Snippet snippet)Register the given snippet.voidregisterSnippets(InputStream in)Register 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.voidregisterSnippets(Reader in)Register 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 Detail
-
SnippetRegistry
public SnippetRegistry()
-
SnippetRegistry
public SnippetRegistry(String languageId, boolean loadDefault)
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 Detail
-
registerSnippet
public void registerSnippet(Snippet snippet)
Register the given snippet.- Parameters:
snippet- the snippet to register.
-
registerSnippets
public void registerSnippets(InputStream in) throws IOException
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
public void registerSnippets(InputStream in, ISnippetContext<?> defaultContext) 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.- 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
public void registerSnippets(Reader in) throws IOException
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
public void registerSnippets(Reader in, ISnippetContext<?> defaultContext) 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.- 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
-
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.
-
-