feat: add Placeholders for Snippets
This commit is contained in:
parent
028a005b01
commit
8acd8c7ff1
@ -41,8 +41,9 @@ public class JavaTXTextDocumentService implements org.eclipse.lsp4j.services.Tex
|
||||
|
||||
for(SnippetWithName elem : codeSnippetOptions.getSnippets()) {
|
||||
CompletionItem item = new CompletionItem(elem.getName());
|
||||
item.setKind(CompletionItemKind.Text);
|
||||
item.setKind(CompletionItemKind.Snippet);
|
||||
item.setInsertText(elem.getSnippet());
|
||||
item.setInsertTextFormat(InsertTextFormat.Snippet);
|
||||
completions.add(item);
|
||||
}
|
||||
client.showMessage(new MessageParams(MessageType.Info, "Returning completion suggestions: " + completions));
|
||||
|
@ -14,15 +14,15 @@ public class CodeSnippetOptions {
|
||||
}
|
||||
|
||||
public SnippetWithName getMainSnippet(){
|
||||
return new SnippetWithName("main", "public main(args){\n System.out.println(\"Hello World\");\n}\n");
|
||||
return new SnippetWithName("main", "public main(args){\n ${1:}\n}\n");
|
||||
}
|
||||
|
||||
public SnippetWithName getForLoopSnippet(){
|
||||
return new SnippetWithName("forLoop", "for(i = 0; i < list.size(); i++){\n\n}");
|
||||
return new SnippetWithName("forLoop", "for(i = 0; i < ${1:listSize}; i++){\n\n}");
|
||||
}
|
||||
|
||||
public SnippetWithName getForEachSnippet(){
|
||||
return new SnippetWithName("forEachLoop", "for(el : list){\n\n}");
|
||||
return new SnippetWithName("forEachLoop", "for(el : ${1:listSize}){\n\n}");
|
||||
}
|
||||
|
||||
public ArrayList<SnippetWithName> getSnippets() {
|
||||
|
Loading…
Reference in New Issue
Block a user