8 Commits

Author SHA1 Message Date
Ruben
01616ee985 feat: update vscode client 2025-09-17 19:11:55 +02:00
Ruben
29f0e6a05a Merge remote-tracking branch 'origin/main'
# Conflicts:
#	Clients/VisualStudioCode/JavaTXLanguageServer-1.0-SNAPSHOT-jar-with-dependencies.jar
#	Clients/VisualStudioCode/package.json
2025-09-17 19:08:53 +02:00
Ruben
ed26f869c3 feat #40: only insert Type as normal name without package reference as it is implicitly imported 2025-09-17 14:29:46 +02:00
Ruben
ee0b51868c feat: move compilation into compiler 2025-09-17 11:32:46 +02:00
Ruben
98b32fd418 feat #40: remove Diagnostic if it has been selected 2025-09-17 11:08:07 +02:00
Ruben
7bc07d9ac1 feat: update vscode client 2025-09-15 18:51:24 +02:00
Ruben
558fcb5ebb feat: initially check syntax when opening document 2025-09-15 13:50:20 +02:00
Ruben
1e4541b705 feat: update 2025-09-11 12:53:41 +02:00
15 changed files with 113 additions and 147 deletions

View File

@@ -1,3 +1,3 @@
# lspclient README
# Java-TX Language Server
This is the README for the Java-TX LSP Client.
This is the official Plugin for Java-TX.

View File

@@ -3,7 +3,7 @@
"name": "java-tx-language-extension",
"displayName": "Java-TX Language Extension",
"description": "The Language Extension for Java-TX with Typehints and Syntax Checks",
"version": "0.0.5",
"version": "0.0.7",
"engines": {
"vscode": "^1.94.0"
},

View File

@@ -13,12 +13,12 @@ function createClient(context: vscode.ExtensionContext): LanguageClient {
const serverOptions: ServerOptions = {
run: {
command: 'java',
args: ['-Xss2m', '-jar', workspaceFolder + "/JavaTXLanguageServer-1.0-SNAPSHOT-jar-with-dependencies.jar"],
args: ['-Xss10m', '-jar', workspaceFolder + "/JavaTXLanguageServer-1.0-SNAPSHOT-jar-with-dependencies.jar"],
},
debug: {
command: 'java',
args: [
'-Xss2m',
'-Xss10m',
'-jar',
workspaceFolder + '/JavaTXLanguageServer-1.0-SNAPSHOT-jar-with-dependencies.jar',
],
@@ -26,7 +26,7 @@ function createClient(context: vscode.ExtensionContext): LanguageClient {
};
const clientOptions: LanguageClientOptions = {
documentSelector: [{ scheme: 'file', language: 'java' }],
documentSelector: [{ scheme: 'file', pattern: '**/*.jav' }],
synchronize: {
fileEvents: vscode.workspace.createFileSystemWatcher('**/*.jav')
},

View File

@@ -55,7 +55,7 @@ public class JavaTXTextDocumentService implements org.eclipse.lsp4j.services.Tex
this.logService = new LogService(clientService);
this.formattingHandler = new FormattingHandler(textDocumentService);
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, conversionHelper);
this.saveHandler = new SaveHandler(typeResolver, textDocumentService, logService, cacheService, conversionHelper, clientService, parserService);
this.changeHandler = new ChangeHandler(textDocumentService, parserService, conversionHelper, clientService, typeResolver, cacheService, logService);
}
@@ -109,6 +109,10 @@ public class JavaTXTextDocumentService implements org.eclipse.lsp4j.services.Tex
public void didOpen(DidOpenTextDocumentParams params) {
cacheService.reset();
typeResolver.reset();
List<Diagnostic> syntaxErrors = parserService.getDiagnosticsOfErrors(params.getTextDocument().getText(), params.getTextDocument().getUri());
if (!syntaxErrors.isEmpty()) {
clientService.publishDiagnostics(params.getTextDocument().getUri(), syntaxErrors);
}
client.refreshDiagnostics();
client.refreshInlayHints();
textDocuments.put(params.getTextDocument().getUri(), params.getTextDocument().getText());

View File

@@ -3,11 +3,11 @@ package de.dhbw.handler;
import com.google.common.base.Stopwatch;
import de.dhbw.helper.ConversionHelper;
import de.dhbw.helper.TypeResolver;
import de.dhbw.model.DiagnosticsAndTypehints;
import de.dhbw.model.DocumentChanges;
import de.dhbw.model.LSPVariable;
import de.dhbw.model.LineCharPosition;
import de.dhbw.model.*;
import de.dhbw.service.*;
import de.dhbwstuttgart.syntaxtree.factory.NameGenerator;
import de.dhbwstuttgart.syntaxtree.type.RefTypeOrTPHOrWildcardOrGeneric;
import de.dhbwstuttgart.typeinference.result.PairTPHequalRefTypeOrWildcardType;
import org.eclipse.lsp4j.*;
import java.io.BufferedWriter;
@@ -40,27 +40,32 @@ public class ChangeHandler {
public static String findAddedWord(String str1, String str2) {
String[] words1 = str1.split("\\s+");
String[] words2 = str2.split("\\s+");
int i = 0, j = 0;
while (i < words1.length && j < words2.length) {
if (words1[i].equals(words2[j])) {
i++;
j++;
} else {
return words2[j]; // Unterschied gefunden
}
// Suche den ersten Unterschied
while (i < str1.length() && j < str2.length() && str1.charAt(i) == str2.charAt(j)) {
i++;
j++;
}
// Falls das neue Wort am Ende steht
if (j < words2.length) {
return words2[j];
// Falls alles gleich ist, gibt es nichts Neues
if (i == str1.length() && j == str2.length()) {
return null;
}
return null; // Kein Unterschied gefunden
// Suche ab Ende rückwärts, um den gemeinsamen Suffix zu finden
int iEnd = str1.length() - 1;
int jEnd = str2.length() - 1;
while (iEnd >= i && jEnd >= j && str1.charAt(iEnd) == str2.charAt(jEnd)) {
iEnd--;
jEnd--;
}
// Der Unterschied liegt nun zwischen j und jEnd in str2
return str2.substring(j, jEnd + 1);
}
public void didChange(DidChangeTextDocumentParams params) {
String currentText = textDocumentService.getFileOfUri(params.getTextDocument().getUri());
@@ -70,6 +75,7 @@ public class ChangeHandler {
List<Diagnostic> syntaxErrors = parserService.getDiagnosticsOfErrors(summedUp.get(), params.getTextDocument().getUri());
if (!syntaxErrors.isEmpty()) {
clientService.publishDiagnostics(params.getTextDocument().getUri(), syntaxErrors);
}
@@ -77,41 +83,27 @@ public class ChangeHandler {
if (syntaxErrors.isEmpty()) {
DocumentChanges documentChanges = textDocumentService.calculateDifference(currentText, summedUp.get());
HashMap<LineCharPosition, String> preciseChanges = documentChanges.getPreciseChanges();
HashMap<Integer, List<String>> textChanges;
String type = findAddedWord(currentText, summedUp.get());
logService.log("ADDED TYPE IS: " + type);
//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())) {
DocumentChanges changesFromOldSave = textDocumentService.calculateDifference(cacheService.getLastSavedFiles().get(params.getTextDocument().getUri()), summedUp.get());
;
textChanges = changesFromOldSave.getTextChanges();
preciseChanges = changesFromOldSave.getPreciseChanges();
logService.log(textChanges.values().stream().map(el -> String.join(", ", el)).collect(Collectors.joining("\n")));
} else {
textChanges = documentChanges.getTextChanges();
}
String input = summedUp.get();
logService.log("Variables are: " + cacheService.getVariables().size());
boolean shouldCalculate = false;
AtomicBoolean needToCalculate = new AtomicBoolean(false);
cacheService.getVariables().forEach(
el -> el.getPossibleTypes().forEach(pos -> needToCalculate.set(needToCalculate.get() || pos.getType().equalsIgnoreCase(type)))
);
logService.log("Type is here: " + type);
for (LSPVariable variable : cacheService.getVariables()) {
for (Type variableType : variable.getPossibleTypes()) {
logService.log(variableType.getType() + " <> "+ type.replaceAll(" ", "") + ": " + type.replaceAll(" ", "").contains(variableType.getType().replaceAll(" ", "")));
shouldCalculate = shouldCalculate || type.replaceAll(" ", "").contains(variableType.getType().replaceAll(" ", ""));
if (shouldCalculate) {
break;
}
}
}
logService.log("Should Calculate is: " + shouldCalculate);
if (false) {
typeResolver.reduceCurrent(preciseChanges, cacheService.getVariables());
try {
File tempDir = new File(System.getProperty("java.io.tmpdir"));
File tempFile = File.createTempFile("newText", ".tmp", tempDir);
@@ -126,33 +118,20 @@ public class ChangeHandler {
logService.log(e.getMessage());
}
var sWatch = Stopwatch.createUnstarted();
sWatch.start();
try {
String currentInput = textDocumentService.getFileOfUri(params.getTextDocument().getUri());
if (currentInput == null) {
logService.log("[didChange] Input of Text Document is null in TextDocument-Hashmap.", MessageType.Error);
}
ArrayList<LSPVariable> typesOfMethodAndParameters = typeResolver.infereChangeInput();
DiagnosticsAndTypehints diagnosticsAndTypehints = conversionHelper.variablesToDiagnosticsAndTypehints(typesOfMethodAndParameters, params.getTextDocument().getUri());
List<InlayHint> typeHint = diagnosticsAndTypehints.getInlayHints();
List<Diagnostic> diagnostics = diagnosticsAndTypehints.getDiagnostics();
cacheService.updateGlobalMaps(diagnostics, typeHint, params.getTextDocument().getUri());
} catch (Exception e) {
logService.log("[didChange] Error trying to get Inlay-Hints and Diagnostics for Client: " + e.getMessage(), MessageType.Error);
for (var stackTrace : e.getStackTrace()) {
logService.log(stackTrace.toString());
}
@@ -165,54 +144,24 @@ public class ChangeHandler {
logService.log("[didChange] Finished Calculating in [" + sWatch.elapsed().toSeconds() + "s]", MessageType.Info);
}
//updatePositions(params, offsetPerLine);
cacheService.getGlobalInlayHintMap().put(params.getTextDocument().getUri(), cacheService.getGlobalInlayHintMap().get(params.getTextDocument().getUri()).stream().filter(el -> {
//TODO: Hier das Label aufspalten an | weil die Typehints immer mit und getrennt sind und so jeder Typhint für sich durchlaufen werden kann.
logService.log(el.getLabel().getLeft().replaceAll(" ", "") + "<>" + String.join(",", textChanges.get(el.getPosition().getLine())) + ": " + (!textChanges.get(el.getPosition().getLine()).contains(el.getLabel().getLeft().replaceAll(" ", "")) ? "true" : "false"), MessageType.Info);
return !textChanges.get(el.getPosition().getLine()).contains(el.getLabel().getLeft().replaceAll(" ", ""));
}).toList());
cacheService.getGlobalDiagnosticsMap().put(params.getTextDocument().getUri(), cacheService.getGlobalDiagnosticsMap().get(params.getTextDocument().getUri()).stream().filter(el -> {
logService.log(el.getMessage().replaceAll(" ", "") + "<>" + String.join(",", textChanges.get(el.getRange().getStart().getLine())) + ": " + (!textChanges.get(el.getRange().getStart().getLine()).contains(el.getMessage().replaceAll(" ", "")) ? "true" : "false"), MessageType.Info);
return !textChanges.get(el.getRange().getStart().getLine()).contains(el.getMessage().replaceAll(" ", ""));
}).toList());
List<Diagnostic> typeDiagnostics = cacheService.getGlobalDiagnosticsMap().get(params.getTextDocument().getUri());
List<Diagnostic> parserErrors = parserService.getDiagnosticsOfErrors(input, params.getTextDocument().getUri());
ArrayList<Diagnostic> allDiagnostics = new ArrayList<>(typeDiagnostics);
allDiagnostics.addAll(parserErrors);
clientService.publishDiagnostics(params.getTextDocument().getUri(), allDiagnostics);
} else {
logService.log("Calculating again.");
var sWatch = Stopwatch.createUnstarted();
sWatch.start();
try {
String fileInput = input;
logService.log("Input ist:");
logService.log(fileInput);
// cacheService.getLastSavedFiles().put(didSaveTextDocumentParams.getTextDocument().getUri(), fileInput);
// typeResolver.getCompilerInput(didSaveTextDocumentParams.getTextDocument().getUri(), fileInput);
try {
File tempDir2 = new File(System.getProperty("java.io.tmpdir"));
File tempFile2 = File.createTempFile("newText", ".tmp", tempDir2);
FileWriter fileWriter = new FileWriter(tempFile2, true);
BufferedWriter bw = new BufferedWriter(fileWriter);
bw.write(fileInput);
bw.write(input);
bw.close();
if (fileInput == null) {
logService.log("[didSave] Input of Text Document is null in TextDocument-Hashmap.", MessageType.Error);
}
ArrayList<LSPVariable> variables = typeResolver.infereInput(tempFile2.toURI().toString(), fileInput, false);
ArrayList<LSPVariable> variables = typeResolver.infereInput(tempFile2.toURI().toString(), input, false);
cacheService.setVariables(variables);
DiagnosticsAndTypehints diagnosticsAndTypehints = conversionHelper.variablesToDiagnosticsAndTypehintsWithInput(variables, input);
@@ -223,7 +172,7 @@ public class ChangeHandler {
cacheService.updateGlobalMaps(diagnostics, typeHint, params.getTextDocument().getUri());
List<Diagnostic> allDiagnostics = new ArrayList<>(diagnostics);
allDiagnostics.addAll(parserService.getDiagnosticsOfErrors(fileInput, params.getTextDocument().getUri()));
allDiagnostics.addAll(parserService.getDiagnosticsOfErrors(input, params.getTextDocument().getUri()));
clientService.publishDiagnostics(params.getTextDocument().getUri(), allDiagnostics);
@@ -240,7 +189,6 @@ public class ChangeHandler {
} finally {
sWatch.stop();
logService.log("[didSave] Finished Calculating in [" + sWatch.elapsed().toSeconds() + "s]", MessageType.Info);
}
} catch (Exception e) {

View File

@@ -1,5 +1,6 @@
package de.dhbw.handler;
import de.dhbw.helper.ConversionHelper;
import de.dhbw.helper.TextHelper;
import de.dhbw.helper.TypeResolver;
import de.dhbw.service.CacheService;
@@ -22,13 +23,15 @@ public class CodeActionHandler {
private final CacheService cacheService;
private final TypeResolver typeResolver;
private final LogService logService;
private final ConversionHelper conversionHelper;
public CodeActionHandler(TextHelper textHelper, TextDocumentService textDocumentService, CacheService cacheService, TypeResolver typeResolver, LogService logService) {
public CodeActionHandler(TextHelper textHelper, TextDocumentService textDocumentService, CacheService cacheService, TypeResolver typeResolver, LogService logService, ConversionHelper conversionHelper) {
this.textHelper = textHelper;
this.textDocumentService = textDocumentService;
this.cacheService = cacheService;
this.typeResolver = typeResolver;
this.logService = logService;
this.conversionHelper = conversionHelper;
}
public static Range wholeDocumentRange(String text) {
@@ -103,7 +106,7 @@ public class CodeActionHandler {
Range rangeOfInsert = params.getRange();
//All Diagnostics that are in range of the hover -> All Diagnostics of the selected Variable and thus all Types of the Variable
Map<String, List<PlaceholderVariable>> typeInsertsOverlapping = getOverlapping(typeResolver.getInserts(), rangeOfInsert.getStart().getLine()+1, rangeOfInsert.getStart().getCharacter(), rangeOfInsert.getEnd().getCharacter());
Map<String, List<PlaceholderVariable>> typeInsertsOverlapping = getOverlapping(typeResolver.getInserts(), rangeOfInsert.getStart().getLine() + 1, rangeOfInsert.getStart().getCharacter(), rangeOfInsert.getEnd().getCharacter());
logService.log("Inserts are:");
typeResolver.getInserts().forEach((key, value) -> logService.log(key));
logService.log("Size is: " + typeInsertsOverlapping.size());
@@ -113,6 +116,8 @@ public class CodeActionHandler {
for (var typeInsertList : typeInsertsOverlapping.values()) {
for (var typeInsert : typeInsertList) {
try {
logService.log("NEW TEXT OF FILE BEFORE INSERT IS:");
logService.log(textDocumentService.getFileOfUri(documentUri));
String typeWithReplacedVariable = typeInsert.insert(textDocumentService.getFileOfUri(documentUri));
ArrayList<TextEdit> listOfChanges = new ArrayList<>();
@@ -127,7 +132,7 @@ public class CodeActionHandler {
WorkspaceEdit edit = new WorkspaceEdit();
edit.setChanges(changes);
CodeAction action = new CodeAction("Insert " + typeInsert.getInsertString());
CodeAction action = new CodeAction("Insert " + conversionHelper.cleanType(typeInsert.getInsertString()));
action.setKind(CodeActionKind.QuickFix);
action.setEdit(edit);
actions.add(Either.forRight(action));

View File

@@ -74,7 +74,6 @@ public class SaveHandler {
cacheService.updateGlobalMaps(diagnostics, typeHint, didSaveTextDocumentParams.getTextDocument().getUri());
List<Diagnostic> allDiagnostics = new ArrayList<>(diagnostics);
allDiagnostics.addAll(parserService.getDiagnosticsOfErrors(fileInput, didSaveTextDocumentParams.getTextDocument().getUri()));
clientService.publishDiagnostics(didSaveTextDocumentParams.getTextDocument().getUri(), allDiagnostics);

View File

@@ -20,12 +20,16 @@ public class ConversionHelper {
this.textDocumentService = textDocumentService;
}
public String cleanType(String type){
return type.replaceAll("java.lang.", "").replaceAll("java.util.", "");
}
public InlayHint getInlayHint(LSPVariable variable) {
InlayHint inlayHint = new InlayHint();
String typeDisplay = "";
for (Type type : variable.getPossibleTypes()) {
typeDisplay += " | " + type.getType().replaceAll("GTV ", "");
typeDisplay += " | " + cleanType(type.getType().replaceAll("GTV ", ""));
}
@@ -45,7 +49,7 @@ public class ConversionHelper {
Diagnostic diagnostic = new Diagnostic(
errorRange,
//TODO: REMOVE! Temporary Fix because GTV, like TPH can be thrown away in the TypeResolver
type.getType().replaceAll("GTV ", ""),
cleanType(type.getType().replaceAll("GTV ", "")),
DiagnosticSeverity.Hint,
"JavaTX Language Server"
);
@@ -62,7 +66,7 @@ public class ConversionHelper {
Diagnostic diagnostic = new Diagnostic(
errorRange,
//TODO: REMOVE! Temporary Fix because GTV, like TPH can be thrown away in the TypeResolver
type.getType().replaceAll("GTV ", ""),
cleanType(type.getType().replaceAll("GTV ", "")),
DiagnosticSeverity.Hint,
"JavaTX Language Server"
);
@@ -71,7 +75,7 @@ public class ConversionHelper {
return diagnostic;
}
public List<Diagnostic> parseErrorToDiagnostic(List<ParserError> parserErrors){
public List<Diagnostic> parseErrorToDiagnostic(List<ParserError> parserErrors) {
return parserErrors.stream().map(el -> {
Range errorRange = new Range(
new Position(el.getLine() - 1, el.getCharPositionInLine()), // Startposition
@@ -86,7 +90,7 @@ public class ConversionHelper {
}).toList();
}
public DiagnosticsAndTypehints variablesToDiagnosticsAndTypehints(ArrayList<LSPVariable> typesOfMethodAndParameters, String uri){
public DiagnosticsAndTypehints variablesToDiagnosticsAndTypehints(ArrayList<LSPVariable> typesOfMethodAndParameters, String uri) {
List<InlayHint> typeHint = new ArrayList<>();
ArrayList<Diagnostic> diagnostics = new ArrayList<>();
@@ -103,7 +107,8 @@ public class ConversionHelper {
return new DiagnosticsAndTypehints(diagnostics, typeHint);
}
public DiagnosticsAndTypehints variablesToDiagnosticsAndTypehintsWithInput(ArrayList<LSPVariable> typesOfMethodAndParameters, String input){
public DiagnosticsAndTypehints variablesToDiagnosticsAndTypehintsWithInput(ArrayList<LSPVariable> typesOfMethodAndParameters, String input) {
List<InlayHint> typeHint = new ArrayList<>();
ArrayList<Diagnostic> diagnostics = new ArrayList<>();

View File

@@ -19,6 +19,7 @@ public class PlaceholderPlacer extends AbstractASTWalker {
this.genericsResult = genericsResult;
pkgName = forSourceFile.getPkgName();
forSourceFile.accept(this);
inserts.forEach(el -> el.reducePackage());
return inserts;
}

View File

@@ -115,12 +115,21 @@ public class TypeResolver {
}
}
inserts = insertsOnLines;
ArrayList<LSPVariable> variables = new ArrayList<>(insertsOnLines.entrySet().stream().map(el -> new LSPVariable("test", new ArrayList<>(el.getValue().stream().map(typeinsert -> new Type(typeinsert.getInsertString(), typeinsert.point.isGenericClassInsertPoint())).toList()), el.getValue().getFirst().point.point.getLine(), el.getValue().getFirst().point.point.getCharPositionInLine(), el.getValue().get(0).point.point.getStopIndex(), el.getValue().get(0).getResultPair().getLeft())).toList());
for (var variable : variables) {
Set<Type> set = new HashSet<>(variable.getPossibleTypes().stream().map(el -> new Type(el.getType().replaceAll(" ", ""), el.isGeneric())).toList());
variable.getPossibleTypes().clear();
variable.getPossibleTypes().addAll(set);
HashMap<String, Type> uniqueType = new HashMap<>();
for (var type : variable.getPossibleTypes()) {
if (!uniqueType.containsKey(type.getType().replaceAll(" ", ""))) {
uniqueType.put(type.getType(), type);
}
}
variable.setPossibleTypes(new ArrayList<>(uniqueType.values()));
logger.info(variable.getLine() + ":" + variable.getCharPosition());
for (Type t : variable.getPossibleTypes()) {
logger.info(t.getType());
@@ -134,39 +143,20 @@ public class TypeResolver {
public ArrayList<LSPVariable> infereInput(String pathString, String input, boolean a) throws IOException, ClassNotFoundException, URISyntaxException {
System.setOut(new PrintStream(OutputStream.nullOutputStream()));
var uri = new URI(pathString);
var path = Path.of(uri);
LanguageServerInterface languageServerInterface = new LanguageServerInterface();
LanguageServerTransferObject lsTransfer = languageServerInterface.getResultSetAndAbstractSyntax(pathString);
logger.info("Path is for calculation: " + path.toString());
var file = path.toFile();
NameGenerator.resetTo("A");
Files.createDirectories(path.getParent().resolve("out"));
var compiler = new JavaTXCompiler(List.of(file), List.of(path.getParent().toFile()), path.getParent().resolve("out").toFile());
var parsedSource = compiler.sourceFiles.get(file);
var tiResults = compiler.typeInference(file);
var parsedSource = lsTransfer.getAst();
var tiResults = lsTransfer.getResultSets();
Set<PlaceholderVariable> tips = new HashSet<>();
// for (var sf : compiler.sourceFiles.values()) {
// Map<JavaClassName, byte[]> bytecode = compiler.generateBytecode(sf, tiResults);
// logger.info("Path for Class-File is: " + path.getParent().resolve("out").toFile());
// Files.createDirectories(path.getParent().resolve("out"));
// compiler.writeClassFile(bytecode, path.getParent().resolve("out").toFile(), false);
//
// }
Map<JavaClassName, byte[]> bytecode = compiler.generateBytecode(parsedSource, tiResults);
logger.info("Path for Class-File is: " + path.getParent().resolve("out").toFile());
Files.createDirectories(path.getParent().resolve("out"));
compiler.writeClassFile(bytecode, path.getParent().resolve("out").toFile(), false);
generatedGenerics = compiler.getGeneratedGenerics().get(compiler.sourceFiles.get(file));
generatedGenerics = lsTransfer.getGeneratedGenerics().get(lsTransfer.getAst());
for (int i = 0; i < tiResults.size(); i++) {
ResultSet tiResult = tiResults.get(i);
tips.addAll(ASTTransformationHelper.createTypeInsertPoints(parsedSource, tiResult, compiler.getGeneratedGenerics().get(compiler.sourceFiles.get(file)).get(i)));
tips.addAll(ASTTransformationHelper.createTypeInsertPoints(parsedSource, tiResult, lsTransfer.getGeneratedGenerics().get(lsTransfer.getAst()).get(i)));
}
System.setOut(System.out);
this.current = new LanguageServerTransferObject(tiResults, parsedSource, "", compiler.getGeneratedGenerics());
this.current = lsTransfer;
HashMap<String, List<PlaceholderVariable>> insertsOnLines = new HashMap<>();
@@ -180,9 +170,20 @@ public class TypeResolver {
inserts = insertsOnLines;
insertsOnLines.forEach((key, value) -> value.forEach(type -> logger.info(type.insert(input))));
logger.info("TYPES ARE:");
insertsOnLines.forEach((key, value) -> value.forEach(type -> logger.info(type.point.getInsertString())));
ArrayList<LSPVariable> variables = new ArrayList<>();
ArrayList<LSPVariable> variables = new ArrayList<>(insertsOnLines.entrySet().stream().map(el -> new LSPVariable("test", new ArrayList<>(el.getValue().stream().map(typeinsert -> new Type(typeinsert.getInsertString(), typeinsert.point.isGenericClassInsertPoint())).toList()), el.getValue().getFirst().point.point.getLine(), el.getValue().getFirst().point.point.getCharPositionInLine(), el.getValue().get(0).point.point.getStopIndex(), el.getValue().get(0).getResultPair().getLeft())).toList());
for(var entrySet : insertsOnLines.entrySet()){
ArrayList<Type> typesOfVariable = new ArrayList<>();
for(PlaceholderVariable typeinsert : entrySet.getValue()){
typesOfVariable.add(new Type(typeinsert.getInsertString(), typeinsert.point.isGenericClassInsertPoint()));
}
variables.add(new LSPVariable("test",typesOfVariable , entrySet.getValue().getFirst().point.point.getLine(), entrySet.getValue().getFirst().point.point.getCharPositionInLine(), entrySet.getValue().get(0).point.point.getStopIndex(), entrySet.getValue().get(0).getResultPair().getLeft()));
}
for (var variable : variables) {

View File

@@ -12,6 +12,10 @@ public class PlaceholderPoint {
private int extraOffset = 0;
private PlaceholderType kind;
public void setInsertString(String insertString){
this.insertString = insertString;
}
public PlaceholderPoint(Token point, String toInsert, PlaceholderType kind){
this.point = point;
this.kind = kind;
@@ -37,12 +41,7 @@ public class PlaceholderPoint {
public int getPositionInCode() {
return point.getStartIndex() + extraOffset;
}
/* PL 2018-06-19
* Zwei TypeInsertPoint's sind gleich, wenn ihre point's gleich sind
* eingefuegt damit man TypeReplaceMarker vergleichen kann
* @see java.lang.Object#equals(java.lang.Object)
*/
public boolean equals(Object obj) {
return this == obj;
/*

View File

@@ -12,6 +12,8 @@ public class PlaceholderVariable {
Set<PlaceholderPoint> inserts;
ResultPair<?, ?> resultPair;
public PlaceholderVariable(PlaceholderPoint point, Set<PlaceholderPoint> additionalPoints, ResultPair<?, ?> resultPair) {
this.point = point;
inserts = additionalPoints;
@@ -38,6 +40,9 @@ public class PlaceholderVariable {
return point.getInsertString();
}
public void reducePackage(){point.setInsertString(point.getInsertString().replaceAll("java\\.lang\\.", "").replaceAll("java\\.util\\.", ""));
}
public ResultPair<?, ?> getResultPair() {
return this.resultPair;
}

View File

@@ -48,7 +48,6 @@ public class CacheService {
typeResolver = new TypeResolver();
fileRoot = null;
singleFileOpened = false;
variables = new ArrayList<>();
typeInserts = null;
}