feat: changed package name and add Hover of hovered Element
This commit is contained in:
parent
8acd8c7ff1
commit
782ea67831
@ -8,10 +8,38 @@
|
|||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
<version>4.11</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
<!-- https://mvnrepository.com/artifact/org.antlr/antlr4 -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.antlr</groupId>
|
<groupId>org.antlr</groupId>
|
||||||
<artifactId>antlr4-runtime</artifactId>
|
<artifactId>antlr4</artifactId>
|
||||||
<version>4.13.0</version>
|
<version>4.11.1</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-io</groupId>
|
||||||
|
<artifactId>commons-io</artifactId>
|
||||||
|
<version>2.6</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>io.github.classgraph</groupId>
|
||||||
|
<artifactId>classgraph</artifactId>
|
||||||
|
<version>4.8.172</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.guava</groupId>
|
||||||
|
<artifactId>guava</artifactId>
|
||||||
|
<version>33.2.0-jre</version>
|
||||||
|
</dependency>
|
||||||
|
<!-- https://mvnrepository.com/artifact/org.ow2.asm/asm -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.ow2.asm</groupId>
|
||||||
|
<artifactId>asm</artifactId>
|
||||||
|
<version>9.5</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.eclipse.lsp4j</groupId>
|
<groupId>org.eclipse.lsp4j</groupId>
|
||||||
@ -38,8 +66,8 @@
|
|||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>11</source> <!-- Stelle sicher, dass dies mit deiner installierten Java-Version übereinstimmt -->
|
<source>23</source>
|
||||||
<target>11</target>
|
<target>23</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
@ -53,7 +81,7 @@
|
|||||||
</descriptorRefs>
|
</descriptorRefs>
|
||||||
<archive>
|
<archive>
|
||||||
<manifest>
|
<manifest>
|
||||||
<mainClass>com.dhbw.JavaTXLanguageServerLauncher</mainClass> <!-- Deine Main-Klasse -->
|
<mainClass>de.dhbw.JavaTXLanguageServerLauncher</mainClass> <!-- Deine Main-Klasse -->
|
||||||
</manifest>
|
</manifest>
|
||||||
</archive>
|
</archive>
|
||||||
</configuration>
|
</configuration>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package com.dhbw;
|
package de.dhbw;
|
||||||
|
|
||||||
import org.eclipse.lsp4j.*;
|
import org.eclipse.lsp4j.*;
|
||||||
import org.eclipse.lsp4j.services.LanguageClient;
|
import org.eclipse.lsp4j.services.LanguageClient;
|
@ -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.launch.LSPLauncher;
|
||||||
import org.eclipse.lsp4j.services.LanguageClient;
|
import org.eclipse.lsp4j.services.LanguageClient;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
|
||||||
public class JavaTXLanguageServerLauncher {
|
public class JavaTXLanguageServerLauncher {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
try {
|
try {
|
||||||
JavaTXLanguageServer server = new JavaTXLanguageServer();
|
JavaTXLanguageServer server = new JavaTXLanguageServer();
|
||||||
|
|
||||||
|
|
||||||
var launcher = LSPLauncher.createServerLauncher(server, System.in, System.out);
|
var launcher = LSPLauncher.createServerLauncher(server, System.in, System.out);
|
||||||
LanguageClient client = launcher.getRemoteProxy();
|
LanguageClient client = launcher.getRemoteProxy();
|
||||||
|
|
@ -1,18 +1,18 @@
|
|||||||
package com.dhbw;
|
package de.dhbw;
|
||||||
|
|
||||||
import com.dhbw.helper.CodeSnippetOptions;
|
import de.dhbw.compiler.typedeployment.TypeInsert;
|
||||||
import com.dhbw.model.ParseError.DiagnoseErrorListener;
|
import de.dhbw.compiler.typedeployment.TypeInsertPoint;
|
||||||
import com.dhbw.model.SnippetWithName;
|
import de.dhbw.helper.CodeSnippetOptions;
|
||||||
import com.dhbw.parser.Java17Lexer;
|
import de.dhbw.model.ParseError.DiagnoseErrorListener;
|
||||||
import com.dhbw.parser.Java17Parser;
|
import de.dhbw.model.SnippetWithName;
|
||||||
import com.dhbw.parser.Java17ParserBaseListener;
|
import de.dhbw.parser.Java17Lexer;
|
||||||
|
import de.dhbw.parser.Java17Parser;
|
||||||
|
import de.dhbw.parser.Java17ParserBaseListener;
|
||||||
import org.eclipse.lsp4j.*;
|
import org.eclipse.lsp4j.*;
|
||||||
import org.eclipse.lsp4j.jsonrpc.messages.Either;
|
import org.eclipse.lsp4j.jsonrpc.messages.Either;
|
||||||
import org.eclipse.lsp4j.services.LanguageClient;
|
import org.eclipse.lsp4j.services.LanguageClient;
|
||||||
import org.eclipse.lsp4j.services.TextDocumentService;
|
import org.eclipse.lsp4j.services.TextDocumentService;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.nio.charset.StandardCharsets;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
@ -197,10 +197,29 @@ public class JavaTXTextDocumentService implements org.eclipse.lsp4j.services.Tex
|
|||||||
return null;
|
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
|
@Override
|
||||||
public CompletableFuture<Hover> hover(HoverParams params) {
|
public CompletableFuture<Hover> hover(HoverParams params) {
|
||||||
|
|
||||||
String hoverText = "Test";
|
|
||||||
|
String hoverText = getWordOfLineAndCharacter(params.getPosition().getLine(), params.getPosition().getCharacter(), currentTextDocument);
|
||||||
|
|
||||||
// Verwende MarkupContent für den Hover-Inhalt
|
// Verwende MarkupContent für den Hover-Inhalt
|
||||||
MarkupContent markupContent = new MarkupContent();
|
MarkupContent markupContent = new MarkupContent();
|
||||||
@ -213,7 +232,6 @@ public class JavaTXTextDocumentService implements org.eclipse.lsp4j.services.Tex
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CompletableFuture<SignatureHelp> signatureHelp(SignatureHelpParams params) {
|
public CompletableFuture<SignatureHelp> signatureHelp(SignatureHelpParams params) {
|
||||||
return null;
|
return null;
|
@ -1,4 +1,4 @@
|
|||||||
package com.dhbw;
|
package de.dhbw;
|
||||||
|
|
||||||
import org.eclipse.lsp4j.DidChangeConfigurationParams;
|
import org.eclipse.lsp4j.DidChangeConfigurationParams;
|
||||||
import org.eclipse.lsp4j.services.WorkspaceService;
|
import org.eclipse.lsp4j.services.WorkspaceService;
|
@ -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;
|
import java.util.ArrayList;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.dhbw.model.ParseError;
|
package de.dhbw.model.ParseError;
|
||||||
|
|
||||||
import org.antlr.v4.runtime.*;
|
import org.antlr.v4.runtime.*;
|
||||||
import org.antlr.v4.runtime.atn.ATNConfigSet;
|
import org.antlr.v4.runtime.atn.ATNConfigSet;
|
@ -1,4 +1,4 @@
|
|||||||
package com.dhbw.model;
|
package de.dhbw.model;
|
||||||
|
|
||||||
public class SnippetWithName {
|
public class SnippetWithName {
|
||||||
private String name;
|
private String name;
|
@ -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.Lexer;
|
||||||
import org.antlr.v4.runtime.CharStream;
|
import org.antlr.v4.runtime.CharStream;
|
||||||
import org.antlr.v4.runtime.*;
|
import org.antlr.v4.runtime.*;
|
@ -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.atn.*;
|
||||||
import org.antlr.v4.runtime.dfa.DFA;
|
import org.antlr.v4.runtime.dfa.DFA;
|
||||||
import org.antlr.v4.runtime.*;
|
import org.antlr.v4.runtime.*;
|
@ -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.ParserRuleContext;
|
||||||
import org.antlr.v4.runtime.tree.ErrorNode;
|
import org.antlr.v4.runtime.tree.ErrorNode;
|
@ -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;
|
import org.antlr.v4.runtime.tree.AbstractParseTreeVisitor;
|
||||||
|
|
||||||
/**
|
/**
|
@ -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;
|
import org.antlr.v4.runtime.tree.ParseTreeListener;
|
||||||
|
|
||||||
/**
|
/**
|
@ -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;
|
import org.antlr.v4.runtime.tree.ParseTreeVisitor;
|
||||||
|
|
||||||
/**
|
/**
|
Loading…
Reference in New Issue
Block a user