Compare commits
5 Commits
bb9be2c319
...
0.0.4
Author | SHA1 | Date | |
---|---|---|---|
|
e119d42148 | ||
|
1e125407f1 | ||
|
579d736efc | ||
|
c5760210fe | ||
|
2e6be4079a |
Binary file not shown.
BIN
LanguageServer/lib/JavaTXcompiler-0.1-jar-with-dependencies.jar
Normal file
BIN
LanguageServer/lib/JavaTXcompiler-0.1-jar-with-dependencies.jar
Normal file
Binary file not shown.
@@ -8,7 +8,6 @@ import org.eclipse.lsp4j.services.TextDocumentService;
|
|||||||
import org.eclipse.lsp4j.services.WorkspaceService;
|
import org.eclipse.lsp4j.services.WorkspaceService;
|
||||||
import org.eclipse.lsp4j.services.LanguageServer;
|
import org.eclipse.lsp4j.services.LanguageServer;
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
/**
|
/**
|
||||||
|
@@ -10,8 +10,6 @@ import de.dhbw.helper.TextHelper;
|
|||||||
import de.dhbw.helper.TypeResolver;
|
import de.dhbw.helper.TypeResolver;
|
||||||
import de.dhbw.model.SnippetWithName;
|
import de.dhbw.model.SnippetWithName;
|
||||||
import de.dhbw.service.ParserService;
|
import de.dhbw.service.ParserService;
|
||||||
import org.apache.log4j.LogManager;
|
|
||||||
import org.apache.log4j.Logger;
|
|
||||||
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;
|
||||||
@@ -39,7 +37,6 @@ public class JavaTXTextDocumentService implements org.eclipse.lsp4j.services.Tex
|
|||||||
private final ChangeHandler changeHandler;
|
private final ChangeHandler changeHandler;
|
||||||
private final TextHelper textHelper;
|
private final TextHelper textHelper;
|
||||||
private final CodeActionHandler codeActionHandler;
|
private final CodeActionHandler codeActionHandler;
|
||||||
private final InlayHintAdjusterDiffUtils inlayHintAdjusterDiffUtils;
|
|
||||||
|
|
||||||
LanguageClient client;
|
LanguageClient client;
|
||||||
HashMap<String, String> textDocuments = new HashMap<>();
|
HashMap<String, String> textDocuments = new HashMap<>();
|
||||||
@@ -50,7 +47,6 @@ public class JavaTXTextDocumentService implements org.eclipse.lsp4j.services.Tex
|
|||||||
|
|
||||||
public JavaTXTextDocumentService() {
|
public JavaTXTextDocumentService() {
|
||||||
this.textHelper = new TextHelper();
|
this.textHelper = new TextHelper();
|
||||||
this.inlayHintAdjusterDiffUtils = new InlayHintAdjusterDiffUtils();
|
|
||||||
this.cacheService = new CacheService();
|
this.cacheService = new CacheService();
|
||||||
this.clientService = new ClientService(null);
|
this.clientService = new ClientService(null);
|
||||||
this.typeResolver = new TypeResolver();
|
this.typeResolver = new TypeResolver();
|
||||||
@@ -61,7 +57,7 @@ public class JavaTXTextDocumentService implements org.eclipse.lsp4j.services.Tex
|
|||||||
this.parserService = new ParserService(conversionHelper, clientService, cacheService);
|
this.parserService = new ParserService(conversionHelper, clientService, cacheService);
|
||||||
this.codeActionHandler = new CodeActionHandler(textHelper, textDocumentService, cacheService, typeResolver, logService);
|
this.codeActionHandler = new CodeActionHandler(textHelper, textDocumentService, cacheService, typeResolver, logService);
|
||||||
this.saveHandler = new SaveHandler(typeResolver, textDocumentService, logService, cacheService, conversionHelper, clientService, parserService);
|
this.saveHandler = new SaveHandler(typeResolver, textDocumentService, logService, cacheService, conversionHelper, clientService, parserService);
|
||||||
this.changeHandler = new ChangeHandler(textDocumentService, parserService, conversionHelper, clientService, typeResolver, cacheService, logService, inlayHintAdjusterDiffUtils);
|
this.changeHandler = new ChangeHandler(textDocumentService, parserService, conversionHelper, clientService, typeResolver, cacheService, logService);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setClient(LanguageClient client) {
|
public void setClient(LanguageClient client) {
|
||||||
|
@@ -3,13 +3,8 @@ package de.dhbw;
|
|||||||
import org.apache.log4j.LogManager;
|
import org.apache.log4j.LogManager;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.eclipse.lsp4j.*;
|
import org.eclipse.lsp4j.*;
|
||||||
import org.eclipse.lsp4j.jsonrpc.messages.Either;
|
|
||||||
import org.eclipse.lsp4j.services.WorkspaceService;
|
import org.eclipse.lsp4j.services.WorkspaceService;
|
||||||
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* Handles Actions in Workspace
|
* Handles Actions in Workspace
|
||||||
|
@@ -10,6 +10,9 @@ import de.dhbw.model.LineCharPosition;
|
|||||||
import de.dhbw.service.*;
|
import de.dhbw.service.*;
|
||||||
import org.eclipse.lsp4j.*;
|
import org.eclipse.lsp4j.*;
|
||||||
|
|
||||||
|
import java.io.BufferedWriter;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileWriter;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@@ -23,9 +26,8 @@ public class ChangeHandler {
|
|||||||
private final TypeResolver typeResolver;
|
private final TypeResolver typeResolver;
|
||||||
private final CacheService cacheService;
|
private final CacheService cacheService;
|
||||||
private final LogService logService;
|
private final LogService logService;
|
||||||
private final InlayHintAdjusterDiffUtils inlayHintAdjusterDiffUtils;
|
|
||||||
|
|
||||||
public ChangeHandler(TextDocumentService textDocumentService, ParserService parserService, ConversionHelper conversionHelper, ClientService clientService, TypeResolver typeResolver, CacheService cacheService, LogService logService, InlayHintAdjusterDiffUtils inlayHintAdjusterDiffUtils) {
|
public ChangeHandler(TextDocumentService textDocumentService, ParserService parserService, ConversionHelper conversionHelper, ClientService clientService, TypeResolver typeResolver, CacheService cacheService, LogService logService) {
|
||||||
this.textDocumentService = textDocumentService;
|
this.textDocumentService = textDocumentService;
|
||||||
this.parserService = parserService;
|
this.parserService = parserService;
|
||||||
this.conversionHelper = conversionHelper;
|
this.conversionHelper = conversionHelper;
|
||||||
@@ -33,7 +35,6 @@ public class ChangeHandler {
|
|||||||
this.typeResolver = typeResolver;
|
this.typeResolver = typeResolver;
|
||||||
this.cacheService = cacheService;
|
this.cacheService = cacheService;
|
||||||
this.logService = logService;
|
this.logService = logService;
|
||||||
this.inlayHintAdjusterDiffUtils = inlayHintAdjusterDiffUtils;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void didChange(DidChangeTextDocumentParams params) {
|
public void didChange(DidChangeTextDocumentParams params) {
|
||||||
@@ -47,13 +48,11 @@ public class ChangeHandler {
|
|||||||
DocumentChanges documentChanges = textDocumentService.calculateDifference(currentText, summedUp.get());
|
DocumentChanges documentChanges = textDocumentService.calculateDifference(currentText, summedUp.get());
|
||||||
HashMap<LineCharPosition, String> preciseChanges = documentChanges.getPreciseChanges();
|
HashMap<LineCharPosition, String> preciseChanges = documentChanges.getPreciseChanges();
|
||||||
HashMap<Integer, List<String>> textChanges;
|
HashMap<Integer, List<String>> textChanges;
|
||||||
ArrayList<Integer> offsetPerLine = documentChanges.getOffsetPerLine();
|
|
||||||
|
|
||||||
|
|
||||||
//Have to check of old saved Input because the result set and Inlay Hints will be updated according to the old AST which contains the old Positions
|
//Have to check of old saved Input because the result set and Inlay Hints will be updated according to the old AST which contains the old Positions
|
||||||
if(cacheService.getLastSavedFiles().containsKey(params.getTextDocument().getUri())){
|
if(cacheService.getLastSavedFiles().containsKey(params.getTextDocument().getUri())){
|
||||||
DocumentChanges changesFromOldSave = textDocumentService.calculateDifference(cacheService.getLastSavedFiles().get(params.getTextDocument().getUri()), summedUp.get());
|
DocumentChanges changesFromOldSave = textDocumentService.calculateDifference(cacheService.getLastSavedFiles().get(params.getTextDocument().getUri()), summedUp.get());;
|
||||||
offsetPerLine = changesFromOldSave.getOffsetPerLine();
|
|
||||||
textChanges = changesFromOldSave.getTextChanges();
|
textChanges = changesFromOldSave.getTextChanges();
|
||||||
preciseChanges = changesFromOldSave.getPreciseChanges();
|
preciseChanges = changesFromOldSave.getPreciseChanges();
|
||||||
logService.log(textChanges.values().stream().map(el -> String.join(", ", el)).collect(Collectors.joining("\n")));
|
logService.log(textChanges.values().stream().map(el -> String.join(", ", el)).collect(Collectors.joining("\n")));
|
||||||
@@ -66,6 +65,21 @@ public class ChangeHandler {
|
|||||||
|
|
||||||
|
|
||||||
typeResolver.reduceCurrent(preciseChanges, cacheService.getVariables());
|
typeResolver.reduceCurrent(preciseChanges, cacheService.getVariables());
|
||||||
|
try{
|
||||||
|
File tempDir = new File(System.getProperty("java.io.tmpdir"));
|
||||||
|
File tempFile = File.createTempFile("newText", ".tmp", tempDir);
|
||||||
|
FileWriter fileWriter = new FileWriter(tempFile, true);
|
||||||
|
System.out.println(tempFile.getAbsolutePath());
|
||||||
|
BufferedWriter bw = new BufferedWriter(fileWriter);
|
||||||
|
bw.write(summedUp.get());
|
||||||
|
bw.close();
|
||||||
|
typeResolver.updateAst(tempFile.toURI().getPath());
|
||||||
|
tempFile.delete();
|
||||||
|
}catch (Exception e){
|
||||||
|
logService.log(e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var sWatch = Stopwatch.createUnstarted();
|
var sWatch = Stopwatch.createUnstarted();
|
||||||
sWatch.start();
|
sWatch.start();
|
||||||
@@ -106,7 +120,7 @@ public class ChangeHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
updatePositions(params, offsetPerLine);
|
//updatePositions(params, offsetPerLine);
|
||||||
|
|
||||||
|
|
||||||
cacheService.getGlobalInlayHintMap().put(params.getTextDocument().getUri(), cacheService.getGlobalInlayHintMap().get(params.getTextDocument().getUri()).stream().filter(el -> {
|
cacheService.getGlobalInlayHintMap().put(params.getTextDocument().getUri(), cacheService.getGlobalInlayHintMap().get(params.getTextDocument().getUri()).stream().filter(el -> {
|
||||||
@@ -130,31 +144,4 @@ public class ChangeHandler {
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void updatePositions(DidChangeTextDocumentParams params, ArrayList<Integer> offsetPerLine, String old, String newText){
|
|
||||||
cacheService.getGlobalInlayHintMap().put(params.getTextDocument().getUri(), inlayHintAdjusterDiffUtils.adjustInlayHintsByLineDiff(old, newText, cacheService.getGlobalInlayHintMap().get(params.getTextDocument().getUri())));
|
|
||||||
|
|
||||||
for (var diagnostic : cacheService.getGlobalDiagnosticsMap().get(params.getTextDocument().getUri())) {
|
|
||||||
diagnostic.getRange().getStart().setCharacter(diagnostic.getRange().getStart().getCharacter() + offsetPerLine.get(diagnostic.getRange().getStart().getLine()));
|
|
||||||
diagnostic.getRange().getEnd().setCharacter(diagnostic.getRange().getEnd().getCharacter() + offsetPerLine.get(diagnostic.getRange().getEnd().getLine()));
|
|
||||||
}
|
|
||||||
|
|
||||||
clientService.updateClient();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void updatePositions(DidChangeTextDocumentParams params, ArrayList<Integer> offsetPerLine){
|
|
||||||
for (var inlayHint : cacheService.getGlobalInlayHintMap().get(params.getTextDocument().getUri())) {
|
|
||||||
inlayHint.getPosition().setCharacter(inlayHint.getPosition().getCharacter() + offsetPerLine.get(inlayHint.getPosition().getLine()));
|
|
||||||
}
|
|
||||||
|
|
||||||
for (var diagnostic : cacheService.getGlobalDiagnosticsMap().get(params.getTextDocument().getUri())) {
|
|
||||||
diagnostic.getRange().getStart().setCharacter(diagnostic.getRange().getStart().getCharacter() + offsetPerLine.get(diagnostic.getRange().getStart().getLine()));
|
|
||||||
diagnostic.getRange().getEnd().setCharacter(diagnostic.getRange().getEnd().getCharacter() + offsetPerLine.get(diagnostic.getRange().getEnd().getLine()));
|
|
||||||
}
|
|
||||||
|
|
||||||
clientService.updateClient();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@@ -1,55 +0,0 @@
|
|||||||
package de.dhbw.handler;
|
|
||||||
|
|
||||||
import com.github.difflib.DiffUtils;
|
|
||||||
import com.github.difflib.patch.AbstractDelta;
|
|
||||||
import com.github.difflib.patch.DeltaType;
|
|
||||||
import com.github.difflib.patch.Patch;
|
|
||||||
|
|
||||||
import org.eclipse.lsp4j.InlayHint;
|
|
||||||
import org.eclipse.lsp4j.Position;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class InlayHintAdjusterDiffUtils {
|
|
||||||
|
|
||||||
public List<InlayHint> adjustInlayHintsByLineDiff(String oldText, String newText, List<InlayHint> oldHints) {
|
|
||||||
List<String> oldLines = Arrays.asList(oldText.split("\n", -1));
|
|
||||||
List<String> newLines = Arrays.asList(newText.split("\n", -1));
|
|
||||||
|
|
||||||
Patch<String> patch = DiffUtils.diff(oldLines, newLines);
|
|
||||||
List<AbstractDelta<String>> deltas = patch.getDeltas();
|
|
||||||
|
|
||||||
List<InlayHint> adjusted = new ArrayList<>();
|
|
||||||
for (InlayHint hint : oldHints) {
|
|
||||||
int oldLine = hint.getPosition().getLine();
|
|
||||||
int lineShift = calculateLineShift(deltas, oldLine);
|
|
||||||
int newLine = Math.max(0, oldLine + lineShift);
|
|
||||||
|
|
||||||
adjusted.add(new InlayHint(new Position(newLine, hint.getPosition().getCharacter()), hint.getLabel()));
|
|
||||||
}
|
|
||||||
|
|
||||||
return adjusted;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static int calculateLineShift(List<AbstractDelta<String>> deltas, int oldLine) {
|
|
||||||
int shift = 0;
|
|
||||||
for (AbstractDelta<String> delta : deltas) {
|
|
||||||
int deltaLine = delta.getSource().getPosition();
|
|
||||||
int linesRemoved = delta.getSource().size();
|
|
||||||
int linesAdded = delta.getTarget().size();
|
|
||||||
|
|
||||||
if (oldLine > deltaLine) {
|
|
||||||
if (delta.getType() == DeltaType.INSERT) {
|
|
||||||
shift += linesAdded;
|
|
||||||
} else if (delta.getType() == DeltaType.DELETE) {
|
|
||||||
shift -= linesRemoved;
|
|
||||||
} else if (delta.getType() == DeltaType.CHANGE) {
|
|
||||||
shift += linesAdded - linesRemoved;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return shift;
|
|
||||||
}
|
|
||||||
}
|
|
@@ -5,7 +5,6 @@ import de.dhbw.service.TextDocumentService;
|
|||||||
import de.dhbw.model.LSPVariable;
|
import de.dhbw.model.LSPVariable;
|
||||||
import de.dhbw.model.Type;
|
import de.dhbw.model.Type;
|
||||||
import de.dhbwstuttgart.languageServerInterface.model.ParserError;
|
import de.dhbwstuttgart.languageServerInterface.model.ParserError;
|
||||||
import jdk.jshell.Diag;
|
|
||||||
import org.eclipse.lsp4j.*;
|
import org.eclipse.lsp4j.*;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@@ -2,8 +2,6 @@ package de.dhbw.helper;
|
|||||||
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class TextHelper {
|
public class TextHelper {
|
||||||
|
@@ -4,11 +4,9 @@ package de.dhbw.helper;
|
|||||||
import de.dhbw.model.*;
|
import de.dhbw.model.*;
|
||||||
import de.dhbwstuttgart.languageServerInterface.LanguageServerInterface;
|
import de.dhbwstuttgart.languageServerInterface.LanguageServerInterface;
|
||||||
import de.dhbwstuttgart.languageServerInterface.model.LanguageServerTransferObject;
|
import de.dhbwstuttgart.languageServerInterface.model.LanguageServerTransferObject;
|
||||||
|
import de.dhbwstuttgart.syntaxtree.SourceFile;
|
||||||
import org.apache.log4j.LogManager;
|
import org.apache.log4j.LogManager;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.eclipse.lsp4j.MessageParams;
|
|
||||||
import org.eclipse.lsp4j.MessageType;
|
|
||||||
import org.eclipse.lsp4j.services.LanguageClient;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
@@ -27,6 +25,9 @@ public class TypeResolver {
|
|||||||
private final DuplicationUtils duplicationUtils;
|
private final DuplicationUtils duplicationUtils;
|
||||||
private final boolean ENABLE_GENERICS = true;
|
private final boolean ENABLE_GENERICS = true;
|
||||||
|
|
||||||
|
//Somehow you have to reset to the Letter N to keep the naming of the TPHs consistent
|
||||||
|
private final String RESET_TO_LETTER = "N";
|
||||||
|
|
||||||
private LanguageServerTransferObject current;
|
private LanguageServerTransferObject current;
|
||||||
|
|
||||||
public TypeResolver() {
|
public TypeResolver() {
|
||||||
@@ -57,14 +58,14 @@ public class TypeResolver {
|
|||||||
|
|
||||||
public void getCompilerInput(String path, String input) throws IOException, URISyntaxException, ClassNotFoundException {
|
public void getCompilerInput(String path, String input) throws IOException, URISyntaxException, ClassNotFoundException {
|
||||||
LanguageServerInterface languageServer = new LanguageServerInterface();
|
LanguageServerInterface languageServer = new LanguageServerInterface();
|
||||||
var transferObj = languageServer.getResultSetAndAbstractSyntax(path, input);
|
var transferObj = languageServer.getResultSetAndAbastractSyntax(path, RESET_TO_LETTER);
|
||||||
current = transferObj;
|
current = transferObj;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LanguageServerTransferObject updateIfNotPresent(String path, String input) throws IOException, URISyntaxException, ClassNotFoundException {
|
public LanguageServerTransferObject updateIfNotPresent(String path, String input) throws IOException, URISyntaxException, ClassNotFoundException {
|
||||||
if (current == null) {
|
if (current == null) {
|
||||||
LanguageServerInterface languageServer = new LanguageServerInterface();
|
LanguageServerInterface languageServer = new LanguageServerInterface();
|
||||||
LanguageServerTransferObject transferObj = languageServer.getResultSetAndAbstractSyntax(path, input);
|
LanguageServerTransferObject transferObj = languageServer.getResultSetAndAbstractSyntax(path);
|
||||||
return transferObj;
|
return transferObj;
|
||||||
}
|
}
|
||||||
return current;
|
return current;
|
||||||
@@ -100,6 +101,35 @@ public class TypeResolver {
|
|||||||
return methodsWithParametersLSPVariableList;
|
return methodsWithParametersLSPVariableList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ArrayList<LSPVariable> infereInput(String input, String path, SourceFile sourceFile) throws IOException, ClassNotFoundException, URISyntaxException {
|
||||||
|
logger.info("Infering Types for Input.");
|
||||||
|
|
||||||
|
current = updateIfNotPresent(path, input);
|
||||||
|
LanguageServerTransferObject transferObj = current;
|
||||||
|
|
||||||
|
transferObj = new LanguageServerTransferObject(transferObj.getResultSets(), sourceFile, "", transferObj.getGeneratedGenerics());
|
||||||
|
|
||||||
|
|
||||||
|
ArrayList<LSPVariable> methodsWithParametersLSPVariableList = new ArrayList<>();
|
||||||
|
|
||||||
|
|
||||||
|
methodsWithParametersLSPVariableList.addAll(astTransformationHelper.constructorToVariable(transferObj));
|
||||||
|
methodsWithParametersLSPVariableList.addAll(astTransformationHelper.fieldDeclToVariable(transferObj));
|
||||||
|
|
||||||
|
|
||||||
|
if (!transferObj.getResultSets().isEmpty()) {
|
||||||
|
//TODO: Hier noch irgendwie die Klasse rausfinden oder durchgehen.
|
||||||
|
|
||||||
|
if (ENABLE_GENERICS) {
|
||||||
|
methodsWithParametersLSPVariableList.addAll(astTransformationHelper.addGenericClassPosition(transferObj, input));
|
||||||
|
}
|
||||||
|
|
||||||
|
methodsWithParametersLSPVariableList.addAll(astTransformationHelper.methodsWithParameterToVariable(transferObj, ENABLE_GENERICS));
|
||||||
|
}
|
||||||
|
|
||||||
|
return methodsWithParametersLSPVariableList;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void reduceCurrent(HashMap<LineCharPosition, String> combinedList, List<LSPVariable> variables) {
|
public void reduceCurrent(HashMap<LineCharPosition, String> combinedList, List<LSPVariable> variables) {
|
||||||
|
|
||||||
@@ -119,4 +149,14 @@ public class TypeResolver {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SourceFile getNewAst(String uri) throws IOException, URISyntaxException, ClassNotFoundException {
|
||||||
|
LanguageServerInterface languageServerInterface = new LanguageServerInterface();
|
||||||
|
return languageServerInterface.getAst(uri, RESET_TO_LETTER);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateAst(String uri) throws IOException, URISyntaxException, ClassNotFoundException {
|
||||||
|
current = new LanguageServerTransferObject(current.getResultSets(), getNewAst(uri), "", current.getGeneratedGenerics());
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@@ -3,7 +3,6 @@ package de.dhbw.helper;
|
|||||||
import de.dhbw.model.Type;
|
import de.dhbw.model.Type;
|
||||||
import de.dhbwstuttgart.syntaxtree.Method;
|
import de.dhbwstuttgart.syntaxtree.Method;
|
||||||
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
|
||||||
import de.dhbwstuttgart.target.generate.GenericsResult;
|
|
||||||
import de.dhbwstuttgart.typeinference.result.ResultSet;
|
import de.dhbwstuttgart.typeinference.result.ResultSet;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@@ -1,6 +1,5 @@
|
|||||||
|
|
||||||
import de.dhbw.helper.CodeSnippetOptions;
|
import de.dhbw.helper.CodeSnippetOptions;
|
||||||
import de.dhbw.model.SnippetWithName;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
@@ -1,6 +1,7 @@
|
|||||||
|
|
||||||
import de.dhbw.helper.TextHelper;
|
import de.dhbw.helper.TextHelper;
|
||||||
import de.dhbw.helper.TypeResolver;
|
import de.dhbw.helper.TypeResolver;
|
||||||
|
import de.dhbwstuttgart.languageServerInterface.LanguageServerInterface;
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
@@ -49,18 +50,16 @@ public class CompilerInterfaceTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testConstraintTypes() throws IOException, ClassNotFoundException {
|
public void testConstraintTypes() throws IOException, ClassNotFoundException, URISyntaxException {
|
||||||
// LanguageServerInterface languageServer = new LanguageServerInterface();
|
LanguageServerInterface languageServer = new LanguageServerInterface();
|
||||||
// TypeResolver typeResolver = new TypeResolver();
|
TypeResolver typeResolver = new TypeResolver();
|
||||||
//
|
|
||||||
//
|
|
||||||
// var res = typeResolver.infereInput("import java.lang.Integer; public class test{\n" +
|
var res = languageServer.getResultSetAndAbstractSyntax("/home/ruben/Documents/JavaTXLanguageServer/test/test.jav");
|
||||||
// " \n" +
|
|
||||||
// " public main(testa){\n" +
|
var res2 = languageServer.getResultSetAndAbstractSyntax("/home/ruben/Documents/JavaTXLanguageServer/test/test.jav");
|
||||||
// " return testa;\n" +
|
|
||||||
// " }\n" +
|
System.out.println("");
|
||||||
// "}");
|
|
||||||
// res.forEach(el -> el.getPossibleTypes().forEach(el2 -> System.out.println(el2.getType() + " " + (el2.isGeneric() ? "GENERIC" : "NO GENERIC"))));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
@@ -1,7 +1,3 @@
|
|||||||
import de.dhbw.JavaTXTextDocumentService;
|
|
||||||
import de.dhbw.helper.CodeSnippetOptions;
|
|
||||||
import org.eclipse.lsp4j.DidSaveTextDocumentParams;
|
|
||||||
import org.eclipse.lsp4j.TextDocumentIdentifier;
|
|
||||||
import org.junit.Ignore;
|
import org.junit.Ignore;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
5
test/test.jav
Normal file
5
test/test.jav
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
public class t{
|
||||||
|
public test(){
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user