diff --git a/LanguageServer/pom.xml b/LanguageServer/pom.xml index 81bfb00..5d690e2 100644 --- a/LanguageServer/pom.xml +++ b/LanguageServer/pom.xml @@ -8,10 +8,38 @@ 1.0-SNAPSHOT + + junit + junit + 4.11 + test + + org.antlr - antlr4-runtime - 4.13.0 + antlr4 + 4.11.1 + + + commons-io + commons-io + 2.6 + + + io.github.classgraph + classgraph + 4.8.172 + + + com.google.guava + guava + 33.2.0-jre + + + + org.ow2.asm + asm + 9.5 org.eclipse.lsp4j @@ -38,8 +66,8 @@ org.apache.maven.plugins maven-compiler-plugin - 11 - 11 + 23 + 23 @@ -53,7 +81,7 @@ - com.dhbw.JavaTXLanguageServerLauncher + de.dhbw.JavaTXLanguageServerLauncher diff --git a/LanguageServer/src/main/java/com/dhbw/JavaTXLanguageServer.java b/LanguageServer/src/main/java/de/dhbw/JavaTXLanguageServer.java similarity index 98% rename from LanguageServer/src/main/java/com/dhbw/JavaTXLanguageServer.java rename to LanguageServer/src/main/java/de/dhbw/JavaTXLanguageServer.java index ba7a8c2..e272313 100644 --- a/LanguageServer/src/main/java/com/dhbw/JavaTXLanguageServer.java +++ b/LanguageServer/src/main/java/de/dhbw/JavaTXLanguageServer.java @@ -1,4 +1,4 @@ -package com.dhbw; +package de.dhbw; import org.eclipse.lsp4j.*; import org.eclipse.lsp4j.services.LanguageClient; diff --git a/LanguageServer/src/main/java/com/dhbw/JavaTXLanguageServerLauncher.java b/LanguageServer/src/main/java/de/dhbw/JavaTXLanguageServerLauncher.java similarity index 66% rename from LanguageServer/src/main/java/com/dhbw/JavaTXLanguageServerLauncher.java rename to LanguageServer/src/main/java/de/dhbw/JavaTXLanguageServerLauncher.java index 3a49e8d..2bc7cd3 100644 --- a/LanguageServer/src/main/java/com/dhbw/JavaTXLanguageServerLauncher.java +++ b/LanguageServer/src/main/java/de/dhbw/JavaTXLanguageServerLauncher.java @@ -1,16 +1,22 @@ -package com.dhbw; +package de.dhbw; +import de.dhbw.compiler.syntaxtree.type.RefType; +import de.dhbw.compiler.typedeployment.KindOfTypeInsertPoint; +import de.dhbw.compiler.typedeployment.TypeInsert; +import de.dhbw.compiler.typedeployment.TypeInsertPoint; +import org.antlr.v4.runtime.Token; import org.eclipse.lsp4j.launch.LSPLauncher; import org.eclipse.lsp4j.services.LanguageClient; +import java.util.HashSet; + public class JavaTXLanguageServerLauncher { public static void main(String[] args) { try { JavaTXLanguageServer server = new JavaTXLanguageServer(); - var launcher = LSPLauncher.createServerLauncher(server, System.in, System.out); LanguageClient client = launcher.getRemoteProxy(); diff --git a/LanguageServer/src/main/java/com/dhbw/JavaTXTextDocumentService.java b/LanguageServer/src/main/java/de/dhbw/JavaTXTextDocumentService.java similarity index 89% rename from LanguageServer/src/main/java/com/dhbw/JavaTXTextDocumentService.java rename to LanguageServer/src/main/java/de/dhbw/JavaTXTextDocumentService.java index 7139a23..59798f2 100644 --- a/LanguageServer/src/main/java/com/dhbw/JavaTXTextDocumentService.java +++ b/LanguageServer/src/main/java/de/dhbw/JavaTXTextDocumentService.java @@ -1,18 +1,18 @@ -package com.dhbw; +package de.dhbw; -import com.dhbw.helper.CodeSnippetOptions; -import com.dhbw.model.ParseError.DiagnoseErrorListener; -import com.dhbw.model.SnippetWithName; -import com.dhbw.parser.Java17Lexer; -import com.dhbw.parser.Java17Parser; -import com.dhbw.parser.Java17ParserBaseListener; +import de.dhbw.compiler.typedeployment.TypeInsert; +import de.dhbw.compiler.typedeployment.TypeInsertPoint; +import de.dhbw.helper.CodeSnippetOptions; +import de.dhbw.model.ParseError.DiagnoseErrorListener; +import de.dhbw.model.SnippetWithName; +import de.dhbw.parser.Java17Lexer; +import de.dhbw.parser.Java17Parser; +import de.dhbw.parser.Java17ParserBaseListener; import org.eclipse.lsp4j.*; import org.eclipse.lsp4j.jsonrpc.messages.Either; import org.eclipse.lsp4j.services.LanguageClient; import org.eclipse.lsp4j.services.TextDocumentService; -import java.io.File; -import java.nio.charset.StandardCharsets; import java.util.*; import java.util.concurrent.CompletableFuture; import java.util.concurrent.atomic.AtomicReference; @@ -39,7 +39,7 @@ public class JavaTXTextDocumentService implements org.eclipse.lsp4j.services.Tex List completions = new ArrayList<>(); - for(SnippetWithName elem : codeSnippetOptions.getSnippets()) { + for (SnippetWithName elem : codeSnippetOptions.getSnippets()) { CompletionItem item = new CompletionItem(elem.getName()); item.setKind(CompletionItemKind.Snippet); item.setInsertText(elem.getSnippet()); @@ -197,10 +197,29 @@ public class JavaTXTextDocumentService implements org.eclipse.lsp4j.services.Tex return null; } + public String getWordOfLineAndCharacter(int line, int character, String document) { + var textArr = document.split("\n"); + var selectedLine = textArr[line]; + + var hoverWord = ""; + + var index = 0; + for (String word : selectedLine.split(" ")) { + index += word.length(); + + if (index - word.length() <= character && index >= character) { + hoverWord = word; + } + } + + return hoverWord; + } + @Override public CompletableFuture hover(HoverParams params) { - String hoverText = "Test"; + + String hoverText = getWordOfLineAndCharacter(params.getPosition().getLine(), params.getPosition().getCharacter(), currentTextDocument); // Verwende MarkupContent für den Hover-Inhalt MarkupContent markupContent = new MarkupContent(); @@ -213,7 +232,6 @@ public class JavaTXTextDocumentService implements org.eclipse.lsp4j.services.Tex } - @Override public CompletableFuture signatureHelp(SignatureHelpParams params) { return null; diff --git a/LanguageServer/src/main/java/com/dhbw/JavaTXWorkspaceService.java b/LanguageServer/src/main/java/de/dhbw/JavaTXWorkspaceService.java similarity index 96% rename from LanguageServer/src/main/java/com/dhbw/JavaTXWorkspaceService.java rename to LanguageServer/src/main/java/de/dhbw/JavaTXWorkspaceService.java index 4c782b0..2cfb889 100644 --- a/LanguageServer/src/main/java/com/dhbw/JavaTXWorkspaceService.java +++ b/LanguageServer/src/main/java/de/dhbw/JavaTXWorkspaceService.java @@ -1,4 +1,4 @@ -package com.dhbw; +package de.dhbw; import org.eclipse.lsp4j.DidChangeConfigurationParams; import org.eclipse.lsp4j.services.WorkspaceService; diff --git a/LanguageServer/src/main/java/com/dhbw/helper/CodeSnippetOptions.java b/LanguageServer/src/main/java/de/dhbw/helper/CodeSnippetOptions.java similarity index 92% rename from LanguageServer/src/main/java/com/dhbw/helper/CodeSnippetOptions.java rename to LanguageServer/src/main/java/de/dhbw/helper/CodeSnippetOptions.java index 43a4318..d6c39d7 100644 --- a/LanguageServer/src/main/java/com/dhbw/helper/CodeSnippetOptions.java +++ b/LanguageServer/src/main/java/de/dhbw/helper/CodeSnippetOptions.java @@ -1,6 +1,6 @@ -package com.dhbw.helper; +package de.dhbw.helper; -import com.dhbw.model.SnippetWithName; +import de.dhbw.model.SnippetWithName; import java.util.ArrayList; diff --git a/LanguageServer/src/main/java/com/dhbw/model/ParseError/DiagnoseErrorListener.java b/LanguageServer/src/main/java/de/dhbw/model/ParseError/DiagnoseErrorListener.java similarity index 98% rename from LanguageServer/src/main/java/com/dhbw/model/ParseError/DiagnoseErrorListener.java rename to LanguageServer/src/main/java/de/dhbw/model/ParseError/DiagnoseErrorListener.java index 66c0d2f..ef82272 100644 --- a/LanguageServer/src/main/java/com/dhbw/model/ParseError/DiagnoseErrorListener.java +++ b/LanguageServer/src/main/java/de/dhbw/model/ParseError/DiagnoseErrorListener.java @@ -1,4 +1,4 @@ -package com.dhbw.model.ParseError; +package de.dhbw.model.ParseError; import org.antlr.v4.runtime.*; import org.antlr.v4.runtime.atn.ATNConfigSet; diff --git a/LanguageServer/src/main/java/com/dhbw/model/SnippetWithName.java b/LanguageServer/src/main/java/de/dhbw/model/SnippetWithName.java similarity index 95% rename from LanguageServer/src/main/java/com/dhbw/model/SnippetWithName.java rename to LanguageServer/src/main/java/de/dhbw/model/SnippetWithName.java index 26824c0..e74978a 100644 --- a/LanguageServer/src/main/java/com/dhbw/model/SnippetWithName.java +++ b/LanguageServer/src/main/java/de/dhbw/model/SnippetWithName.java @@ -1,4 +1,4 @@ -package com.dhbw.model; +package de.dhbw.model; public class SnippetWithName { private String name; diff --git a/LanguageServer/src/main/java/com/dhbw/parser/Java17Lexer.interp b/LanguageServer/src/main/java/de/dhbw/parser/Java17Lexer.interp similarity index 100% rename from LanguageServer/src/main/java/com/dhbw/parser/Java17Lexer.interp rename to LanguageServer/src/main/java/de/dhbw/parser/Java17Lexer.interp diff --git a/LanguageServer/src/main/java/com/dhbw/parser/Java17Lexer.java b/LanguageServer/src/main/java/de/dhbw/parser/Java17Lexer.java similarity index 99% rename from LanguageServer/src/main/java/com/dhbw/parser/Java17Lexer.java rename to LanguageServer/src/main/java/de/dhbw/parser/Java17Lexer.java index 98b200c..f34d1b4 100644 --- a/LanguageServer/src/main/java/com/dhbw/parser/Java17Lexer.java +++ b/LanguageServer/src/main/java/de/dhbw/parser/Java17Lexer.java @@ -1,4 +1,4 @@ -package com.dhbw.parser;// Generated from /home/ruben/Documents/JavaCompilerCore/src/main/antlr4/de/dhbwstuttgart/parser/antlr/Java17Lexer.g4 by ANTLR 4.13.1 +package de.dhbw.parser;// Generated from /home/ruben/Documents/JavaCompilerCore/src/main/antlr4/de/dhbwstuttgart/parser/antlr/Java17Lexer.g4 by ANTLR 4.13.1 import org.antlr.v4.runtime.Lexer; import org.antlr.v4.runtime.CharStream; import org.antlr.v4.runtime.*; diff --git a/LanguageServer/src/main/java/com/dhbw/parser/Java17Lexer.tokens b/LanguageServer/src/main/java/de/dhbw/parser/Java17Lexer.tokens similarity index 100% rename from LanguageServer/src/main/java/com/dhbw/parser/Java17Lexer.tokens rename to LanguageServer/src/main/java/de/dhbw/parser/Java17Lexer.tokens diff --git a/LanguageServer/src/main/java/com/dhbw/parser/Java17Parser.interp b/LanguageServer/src/main/java/de/dhbw/parser/Java17Parser.interp similarity index 100% rename from LanguageServer/src/main/java/com/dhbw/parser/Java17Parser.interp rename to LanguageServer/src/main/java/de/dhbw/parser/Java17Parser.interp diff --git a/LanguageServer/src/main/java/com/dhbw/parser/Java17Parser.java b/LanguageServer/src/main/java/de/dhbw/parser/Java17Parser.java similarity index 99% rename from LanguageServer/src/main/java/com/dhbw/parser/Java17Parser.java rename to LanguageServer/src/main/java/de/dhbw/parser/Java17Parser.java index 9ef5484..4e6a492 100644 --- a/LanguageServer/src/main/java/com/dhbw/parser/Java17Parser.java +++ b/LanguageServer/src/main/java/de/dhbw/parser/Java17Parser.java @@ -1,4 +1,4 @@ -package com.dhbw.parser;// Generated from /home/ruben/Documents/JavaCompilerCore/src/main/antlr4/de/dhbwstuttgart/parser/antlr/Java17Parser.g4 by ANTLR 4.13.1 +package de.dhbw.parser;// Generated from /home/ruben/Documents/JavaCompilerCore/src/main/antlr4/de/dhbwstuttgart/parser/antlr/Java17Parser.g4 by ANTLR 4.13.1 import org.antlr.v4.runtime.atn.*; import org.antlr.v4.runtime.dfa.DFA; import org.antlr.v4.runtime.*; diff --git a/LanguageServer/src/main/java/com/dhbw/parser/Java17Parser.tokens b/LanguageServer/src/main/java/de/dhbw/parser/Java17Parser.tokens similarity index 100% rename from LanguageServer/src/main/java/com/dhbw/parser/Java17Parser.tokens rename to LanguageServer/src/main/java/de/dhbw/parser/Java17Parser.tokens diff --git a/LanguageServer/src/main/java/com/dhbw/parser/Java17ParserBaseListener.java b/LanguageServer/src/main/java/de/dhbw/parser/Java17ParserBaseListener.java similarity index 99% rename from LanguageServer/src/main/java/com/dhbw/parser/Java17ParserBaseListener.java rename to LanguageServer/src/main/java/de/dhbw/parser/Java17ParserBaseListener.java index e5aedd8..6d84b8c 100644 --- a/LanguageServer/src/main/java/com/dhbw/parser/Java17ParserBaseListener.java +++ b/LanguageServer/src/main/java/de/dhbw/parser/Java17ParserBaseListener.java @@ -1,4 +1,4 @@ -package com.dhbw.parser;// Generated from /home/ruben/Documents/JavaCompilerCore/src/main/antlr4/de/dhbwstuttgart/parser/antlr/Java17Parser.g4 by ANTLR 4.13.1 +package de.dhbw.parser;// Generated from /home/ruben/Documents/JavaCompilerCore/src/main/antlr4/de/dhbwstuttgart/parser/antlr/Java17Parser.g4 by ANTLR 4.13.1 import org.antlr.v4.runtime.ParserRuleContext; import org.antlr.v4.runtime.tree.ErrorNode; diff --git a/LanguageServer/src/main/java/com/dhbw/parser/Java17ParserBaseVisitor.java b/LanguageServer/src/main/java/de/dhbw/parser/Java17ParserBaseVisitor.java similarity index 99% rename from LanguageServer/src/main/java/com/dhbw/parser/Java17ParserBaseVisitor.java rename to LanguageServer/src/main/java/de/dhbw/parser/Java17ParserBaseVisitor.java index 3c07412..6c249c9 100644 --- a/LanguageServer/src/main/java/com/dhbw/parser/Java17ParserBaseVisitor.java +++ b/LanguageServer/src/main/java/de/dhbw/parser/Java17ParserBaseVisitor.java @@ -1,4 +1,4 @@ -package com.dhbw.parser;// Generated from /home/ruben/Documents/JavaCompilerCore/src/main/antlr4/de/dhbwstuttgart/parser/antlr/Java17Parser.g4 by ANTLR 4.13.1 +package de.dhbw.parser;// Generated from /home/ruben/Documents/JavaCompilerCore/src/main/antlr4/de/dhbwstuttgart/parser/antlr/Java17Parser.g4 by ANTLR 4.13.1 import org.antlr.v4.runtime.tree.AbstractParseTreeVisitor; /** diff --git a/LanguageServer/src/main/java/com/dhbw/parser/Java17ParserListener.java b/LanguageServer/src/main/java/de/dhbw/parser/Java17ParserListener.java similarity index 99% rename from LanguageServer/src/main/java/com/dhbw/parser/Java17ParserListener.java rename to LanguageServer/src/main/java/de/dhbw/parser/Java17ParserListener.java index 8f82bbd..d40068a 100644 --- a/LanguageServer/src/main/java/com/dhbw/parser/Java17ParserListener.java +++ b/LanguageServer/src/main/java/de/dhbw/parser/Java17ParserListener.java @@ -1,4 +1,4 @@ -package com.dhbw.parser;// Generated from /home/ruben/Documents/JavaCompilerCore/src/main/antlr4/de/dhbwstuttgart/parser/antlr/Java17Parser.g4 by ANTLR 4.13.1 +package de.dhbw.parser;// Generated from /home/ruben/Documents/JavaCompilerCore/src/main/antlr4/de/dhbwstuttgart/parser/antlr/Java17Parser.g4 by ANTLR 4.13.1 import org.antlr.v4.runtime.tree.ParseTreeListener; /** diff --git a/LanguageServer/src/main/java/com/dhbw/parser/Java17ParserVisitor.java b/LanguageServer/src/main/java/de/dhbw/parser/Java17ParserVisitor.java similarity index 99% rename from LanguageServer/src/main/java/com/dhbw/parser/Java17ParserVisitor.java rename to LanguageServer/src/main/java/de/dhbw/parser/Java17ParserVisitor.java index 93ebd2a..fe90e75 100644 --- a/LanguageServer/src/main/java/com/dhbw/parser/Java17ParserVisitor.java +++ b/LanguageServer/src/main/java/de/dhbw/parser/Java17ParserVisitor.java @@ -1,4 +1,4 @@ -package com.dhbw.parser;// Generated from /home/ruben/Documents/JavaCompilerCore/src/main/antlr4/de/dhbwstuttgart/parser/antlr/Java17Parser.g4 by ANTLR 4.13.1 +package de.dhbw.parser;// Generated from /home/ruben/Documents/JavaCompilerCore/src/main/antlr4/de/dhbwstuttgart/parser/antlr/Java17Parser.g4 by ANTLR 4.13.1 import org.antlr.v4.runtime.tree.ParseTreeVisitor; /**