Compare commits
2 Commits
d6dc0a5d20
...
028a005b01
Author | SHA1 | Date | |
---|---|---|---|
|
028a005b01 | ||
|
1fbcc78085 |
@ -1,6 +1,8 @@
|
|||||||
package com.dhbw;
|
package com.dhbw;
|
||||||
|
|
||||||
|
import com.dhbw.helper.CodeSnippetOptions;
|
||||||
import com.dhbw.model.ParseError.DiagnoseErrorListener;
|
import com.dhbw.model.ParseError.DiagnoseErrorListener;
|
||||||
|
import com.dhbw.model.SnippetWithName;
|
||||||
import com.dhbw.parser.Java17Lexer;
|
import com.dhbw.parser.Java17Lexer;
|
||||||
import com.dhbw.parser.Java17Parser;
|
import com.dhbw.parser.Java17Parser;
|
||||||
import com.dhbw.parser.Java17ParserBaseListener;
|
import com.dhbw.parser.Java17ParserBaseListener;
|
||||||
@ -26,6 +28,8 @@ public class JavaTXTextDocumentService implements org.eclipse.lsp4j.services.Tex
|
|||||||
|
|
||||||
String currentTextDocument;
|
String currentTextDocument;
|
||||||
|
|
||||||
|
CodeSnippetOptions codeSnippetOptions = new CodeSnippetOptions();
|
||||||
|
|
||||||
public void setClient(LanguageClient client) {
|
public void setClient(LanguageClient client) {
|
||||||
this.client = client;
|
this.client = client;
|
||||||
}
|
}
|
||||||
@ -34,11 +38,13 @@ public class JavaTXTextDocumentService implements org.eclipse.lsp4j.services.Tex
|
|||||||
public CompletableFuture<Either<List<CompletionItem>, CompletionList>> completion(CompletionParams params) {
|
public CompletableFuture<Either<List<CompletionItem>, CompletionList>> completion(CompletionParams params) {
|
||||||
List<CompletionItem> completions = new ArrayList<>();
|
List<CompletionItem> completions = new ArrayList<>();
|
||||||
|
|
||||||
CompletionItem item = new CompletionItem("HelloWorld");
|
|
||||||
item.setKind(CompletionItemKind.Text);
|
|
||||||
item.setInsertText("Hello, JavaTX World!");
|
|
||||||
completions.add(item);
|
|
||||||
|
|
||||||
|
for(SnippetWithName elem : codeSnippetOptions.getSnippets()) {
|
||||||
|
CompletionItem item = new CompletionItem(elem.getName());
|
||||||
|
item.setKind(CompletionItemKind.Text);
|
||||||
|
item.setInsertText(elem.getSnippet());
|
||||||
|
completions.add(item);
|
||||||
|
}
|
||||||
client.showMessage(new MessageParams(MessageType.Info, "Returning completion suggestions: " + completions));
|
client.showMessage(new MessageParams(MessageType.Info, "Returning completion suggestions: " + completions));
|
||||||
|
|
||||||
return CompletableFuture.completedFuture(Either.forLeft(completions));
|
return CompletableFuture.completedFuture(Either.forLeft(completions));
|
||||||
|
@ -0,0 +1,31 @@
|
|||||||
|
package com.dhbw.helper;
|
||||||
|
|
||||||
|
import com.dhbw.model.SnippetWithName;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class CodeSnippetOptions {
|
||||||
|
private ArrayList<SnippetWithName> snippets = new ArrayList<>();
|
||||||
|
|
||||||
|
public CodeSnippetOptions() {
|
||||||
|
snippets.add(getMainSnippet());
|
||||||
|
snippets.add(getForLoopSnippet());
|
||||||
|
snippets.add(getForEachSnippet());
|
||||||
|
}
|
||||||
|
|
||||||
|
public SnippetWithName getMainSnippet(){
|
||||||
|
return new SnippetWithName("main", "public main(args){\n System.out.println(\"Hello World\");\n}\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
public SnippetWithName getForLoopSnippet(){
|
||||||
|
return new SnippetWithName("forLoop", "for(i = 0; i < list.size(); i++){\n\n}");
|
||||||
|
}
|
||||||
|
|
||||||
|
public SnippetWithName getForEachSnippet(){
|
||||||
|
return new SnippetWithName("forEachLoop", "for(el : list){\n\n}");
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayList<SnippetWithName> getSnippets() {
|
||||||
|
return snippets;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
package com.dhbw.model;
|
||||||
|
|
||||||
|
public class SnippetWithName {
|
||||||
|
private String name;
|
||||||
|
private String snippet;
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSnippet() {
|
||||||
|
return snippet;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSnippet(String snippet) {
|
||||||
|
this.snippet = snippet;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SnippetWithName(String name, String snippet) {
|
||||||
|
this.name = name;
|
||||||
|
this.snippet = snippet;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user