2 Commits

Author SHA1 Message Date
Ruben
a447cd3f39 Merge remote-tracking branch 'origin/main' 2025-01-08 17:01:51 +01:00
Ruben
0173dd86da fix & feat: implement Display of Parameter in Code and Fix System.out 2025-01-08 17:01:35 +01:00
4 changed files with 24 additions and 11 deletions

View File

@@ -157,6 +157,17 @@ public class JavaTXTextDocumentService implements org.eclipse.lsp4j.services.Tex
List<InlayHint> typeHint = new ArrayList<>();
for (var typeOfMethod : typesOfMethods) {
var paramTypes = typeFinder.infereParameterType(currentTextDocument, typeOfMethod.getName());
for (var paramType : paramTypes) {
InlayHint inlayHint = new InlayHint();
inlayHint.setLabel(":" + paramType.getType());
inlayHint.setPosition(new Position(paramType.getLine()-1, paramType.getCharPosition()-1));
inlayHint.setKind(InlayHintKind.Type);
typeHint.add(inlayHint);
}
InlayHint inlayHint = new InlayHint();
inlayHint.setLabel(":" + typeOfMethod.getType());
inlayHint.setPosition(new Position(typeOfMethod.getLine()-1, typeOfMethod.getCharPosition()+1));

View File

@@ -18,7 +18,7 @@ public class LanguageServerInterface {
* */
public LanguageServerTransferObject getResultSetAndAbstractSyntax(String input) throws IOException, ClassNotFoundException {
//System.setOut(new PrintStream(OutputStream.nullOutputStream()));
System.setOut(new PrintStream(OutputStream.nullOutputStream()));
File tempSourcefile = File.createTempFile("temp", ".java");
tempSourcefile.deleteOnExit();
@@ -28,7 +28,7 @@ public class LanguageServerInterface {
JavaTXCompiler tx = new JavaTXCompiler(tempSourcefile);
var test = tx.getResultSetAndAbstractSyntax(tempSourcefile);
//System.setOut(System.out);
System.setOut(System.out);
return test;
}
}

View File

@@ -114,7 +114,7 @@ public class TypeFinder {
}
paramTypes.add(possibleTypes.toString().substring(3));
}catch (Exception e) {
} catch (Exception e) {
paramTypes.add("java.lang.Object");
}
} else {
@@ -141,7 +141,7 @@ public class TypeFinder {
return methodNameWithTypeList;
}
public ArrayList<ParameterNameWithType> infereParameterType(String input) throws IOException, ClassNotFoundException {
public ArrayList<ParameterNameWithType> infereParameterType(String input, String methodName) throws IOException, ClassNotFoundException {
var transferObj = languageServer.getResultSetAndAbstractSyntax(input);
System.out.println(transferObj.getResultSets().toString());
System.out.println(transferObj.getPrintedAst());
@@ -149,6 +149,7 @@ public class TypeFinder {
ArrayList<ParameterNameWithType> ParameterNameWithType = new ArrayList<>();
for (var method : transferObj.getAst().getAllMethods()) {
if (method.name.equals(methodName)) {
int index = 0;
for (var param : method.getParameterList()) {
@@ -159,6 +160,7 @@ public class TypeFinder {
}
}
}
return ParameterNameWithType;
}

View File

@@ -57,7 +57,7 @@ public class CompilerInterfaceTest {
"String i = \"test\";" +
"return i;" +
"}" +
"}"
"}", "main"
);
inferedMethods.forEach(el -> System.out.println(el.getName() + ": " + el.getType()));