Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
254edf25af | ||
|
fc628f7547 |
Binary file not shown.
@@ -13,6 +13,8 @@ import org.eclipse.lsp4j.*;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.net.URI;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
@@ -93,7 +95,7 @@ public class ChangeHandler {
|
||||
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(" ", "")));
|
||||
logService.log(variableType.getType() + " <> " + type.replaceAll(" ", "") + ": " + type.replaceAll(" ", "").contains(variableType.getType().replaceAll(" ", "")));
|
||||
shouldCalculate = shouldCalculate || type.replaceAll(" ", "").contains(variableType.getType().replaceAll(" ", ""));
|
||||
if (shouldCalculate) {
|
||||
break;
|
||||
@@ -154,14 +156,15 @@ public class ChangeHandler {
|
||||
|
||||
try {
|
||||
try {
|
||||
File tempDir2 = new File(System.getProperty("java.io.tmpdir"));
|
||||
File tempFile2 = File.createTempFile("newText", ".tmp", tempDir2);
|
||||
File tempDir2 = Path.of(new URI(params.getTextDocument().getUri())).getParent().toFile();
|
||||
File tempFile2 = File.createTempFile("jtx_temp", ".tmp", tempDir2);
|
||||
FileWriter fileWriter = new FileWriter(tempFile2, true);
|
||||
BufferedWriter bw = new BufferedWriter(fileWriter);
|
||||
bw.write(input);
|
||||
bw.close();
|
||||
|
||||
ArrayList<LSPVariable> variables = typeResolver.infereInput(tempFile2.toURI().toString(), input, false);
|
||||
try {
|
||||
ArrayList<LSPVariable> variables = typeResolver.infereInput(tempFile2.toURI().toString(), input, true);
|
||||
cacheService.setVariables(variables);
|
||||
|
||||
DiagnosticsAndTypehints diagnosticsAndTypehints = conversionHelper.variablesToDiagnosticsAndTypehintsWithInput(variables, input);
|
||||
@@ -175,7 +178,15 @@ public class ChangeHandler {
|
||||
allDiagnostics.addAll(parserService.getDiagnosticsOfErrors(input, params.getTextDocument().getUri()));
|
||||
|
||||
clientService.publishDiagnostics(params.getTextDocument().getUri(), allDiagnostics);
|
||||
} catch (Exception f) {
|
||||
logService.log("[didSave] Error trying to get Inlay-Hints and Diagnostics for Client: " + f.getMessage(), MessageType.Error);
|
||||
|
||||
for (StackTraceElement elem : f.getStackTrace()) {
|
||||
logService.log(elem.toString());
|
||||
}
|
||||
clientService.showMessage(MessageType.Error, f.getMessage() == null ? "null" : f.getMessage());
|
||||
cacheService.updateGlobalMaps(new ArrayList<>(), new ArrayList<>(), params.getTextDocument().getUri());
|
||||
}
|
||||
tempFile2.delete();
|
||||
} catch (Exception e) {
|
||||
logService.log("[didSave] Error trying to get Inlay-Hints and Diagnostics for Client: " + e.getMessage(), MessageType.Error);
|
||||
|
@@ -42,6 +42,11 @@ public class PlaceholderPoint {
|
||||
return point.getStartIndex() + extraOffset;
|
||||
}
|
||||
|
||||
|
||||
public PlaceholderType getKind() {
|
||||
return kind;
|
||||
}
|
||||
|
||||
public boolean equals(Object obj) {
|
||||
return this == obj;
|
||||
/*
|
||||
|
@@ -13,7 +13,6 @@ public class PlaceholderVariable {
|
||||
ResultPair<?, ?> resultPair;
|
||||
|
||||
|
||||
|
||||
public PlaceholderVariable(PlaceholderPoint point, Set<PlaceholderPoint> additionalPoints, ResultPair<?, ?> resultPair) {
|
||||
this.point = point;
|
||||
inserts = additionalPoints;
|
||||
@@ -26,7 +25,10 @@ public class PlaceholderVariable {
|
||||
|
||||
List<PlaceholderPoint> insertsSorted = new ArrayList<>();
|
||||
insertsSorted.add(point);
|
||||
|
||||
if (!point.getInsertString().contains("void")) {
|
||||
insertsSorted.addAll(inserts);
|
||||
}
|
||||
Collections.sort(insertsSorted, new PlaceholderPoint.TypeInsertPointPositionComparator().reversed());
|
||||
|
||||
for (PlaceholderPoint insertPoint : insertsSorted) {
|
||||
@@ -40,7 +42,8 @@ public class PlaceholderVariable {
|
||||
return point.getInsertString();
|
||||
}
|
||||
|
||||
public void reducePackage(){point.setInsertString(point.getInsertString().replaceAll("java\\.lang\\.", "").replaceAll("java\\.util\\.", ""));
|
||||
public void reducePackage() {
|
||||
point.setInsertString(point.getInsertString().replaceAll("java\\.lang\\.", "").replaceAll("java\\.util\\.", ""));
|
||||
}
|
||||
|
||||
public ResultPair<?, ?> getResultPair() {
|
||||
|
@@ -55,6 +55,10 @@ The Language Server in itself can be used for any Client. The Clients task is to
|
||||
|
||||

|
||||
|
||||
## Additional Information
|
||||
|
||||
- Uses the [LSP-Interface](https://gitea.hb.dhbw-stuttgart.de/JavaTX/JavaCompilerCore/src/branch/LSP-Interface) Branch of the Java-TX Compiler Repository
|
||||
|
||||
## Update JavaTX Compiler Dependency as Maven Package
|
||||
If you make changes in the Compiler Interface, you have to change the jar and therefore the Dependency in the Java TX Language Server
|
||||
You can follow this steps:
|
||||
|
Reference in New Issue
Block a user