Package org.eclipse.lemminx.commons.snippets

## 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
`SnippetRegistry()`
`SnippetRegistry​(String languageId, boolean loadDefault)` Snippet registry for a given language id.

### Method Summary

All Methods Instance Methods Concrete Methods
`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.
`void` `registerSnippet​(Snippet snippet)` Register the given snippet.
`void` `registerSnippets​(InputStream in)` Register the snippets from the given JSON input stream.
`void` `registerSnippets​(InputStream in, com.google.gson.TypeAdapter<? extends ISnippetContext<?>> contextDeserializer)` Register the snippets from the given JSON stream with a context.
`void` `registerSnippets​(InputStream in, ISnippetContext<?> defaultContext)` Register the snippets from the given JSON stream with a context.
`void` `registerSnippets​(InputStream in, ISnippetContext<?> defaultContext, com.google.gson.TypeAdapter<? extends ISnippetContext<?>> contextDeserializer)` Register the snippets from the given JSON stream with a context.
`void` `registerSnippets​(Reader in)` Register the snippets from the given JSON reader.
`void` `registerSnippets​(Reader in, com.google.gson.TypeAdapter<? extends ISnippetContext<?>> contextDeserializer)` Register the snippets from the given JSON reader with a context.
`void` `registerSnippets​(Reader in, ISnippetContext<?> defaultContext)` Register the snippets from the given JSON stream with a context.
`void` `registerSnippets​(Reader in, ISnippetContext<?> defaultContext, com.google.gson.TypeAdapter<? extends ISnippetContext<?>> contextDeserializer)` Register the snippets from the given JSON stream with a context.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### 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`

#### getSnippets

    public List<Snippet> 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.