feat: add Placeholders for Snippets

This commit is contained in:
Ruben 2024-11-07 16:27:35 +01:00
parent 028a005b01
commit 8acd8c7ff1
2 changed files with 5 additions and 4 deletions

View File

@ -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));

View File

@ -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() {