Compare commits
5 Commits
29f0e6a05a
...
main
Author | SHA1 | Date | |
---|---|---|---|
|
254edf25af | ||
|
fc628f7547 | ||
|
33d5fbb01d | ||
|
6332daf2ad | ||
|
01616ee985 |
Binary file not shown.
@@ -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.
|
@@ -3,7 +3,7 @@
|
|||||||
"name": "java-tx-language-extension",
|
"name": "java-tx-language-extension",
|
||||||
"displayName": "Java-TX Language Extension",
|
"displayName": "Java-TX Language Extension",
|
||||||
"description": "The Language Extension for Java-TX with Typehints and Syntax Checks",
|
"description": "The Language Extension for Java-TX with Typehints and Syntax Checks",
|
||||||
"version": "0.0.7",
|
"version": "0.0.9",
|
||||||
"engines": {
|
"engines": {
|
||||||
"vscode": "^1.94.0"
|
"vscode": "^1.94.0"
|
||||||
},
|
},
|
||||||
|
@@ -26,7 +26,7 @@ function createClient(context: vscode.ExtensionContext): LanguageClient {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const clientOptions: LanguageClientOptions = {
|
const clientOptions: LanguageClientOptions = {
|
||||||
documentSelector: [{ scheme: 'file', language: 'java' }],
|
documentSelector: [{ scheme: 'file', pattern: '**/*.jav' }],
|
||||||
synchronize: {
|
synchronize: {
|
||||||
fileEvents: vscode.workspace.createFileSystemWatcher('**/*.jav')
|
fileEvents: vscode.workspace.createFileSystemWatcher('**/*.jav')
|
||||||
},
|
},
|
||||||
|
Binary file not shown.
@@ -13,6 +13,8 @@ import org.eclipse.lsp4j.*;
|
|||||||
import java.io.BufferedWriter;
|
import java.io.BufferedWriter;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileWriter;
|
import java.io.FileWriter;
|
||||||
|
import java.net.URI;
|
||||||
|
import java.nio.file.Path;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.concurrent.atomic.AtomicReference;
|
import java.util.concurrent.atomic.AtomicReference;
|
||||||
@@ -93,7 +95,7 @@ public class ChangeHandler {
|
|||||||
logService.log("Type is here: " + type);
|
logService.log("Type is here: " + type);
|
||||||
for (LSPVariable variable : cacheService.getVariables()) {
|
for (LSPVariable variable : cacheService.getVariables()) {
|
||||||
for (Type variableType : variable.getPossibleTypes()) {
|
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(" ", ""));
|
shouldCalculate = shouldCalculate || type.replaceAll(" ", "").contains(variableType.getType().replaceAll(" ", ""));
|
||||||
if (shouldCalculate) {
|
if (shouldCalculate) {
|
||||||
break;
|
break;
|
||||||
@@ -154,28 +156,37 @@ public class ChangeHandler {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
try {
|
try {
|
||||||
File tempDir2 = new File(System.getProperty("java.io.tmpdir"));
|
File tempDir2 = Path.of(new URI(params.getTextDocument().getUri())).getParent().toFile();
|
||||||
File tempFile2 = File.createTempFile("newText", ".tmp", tempDir2);
|
File tempFile2 = File.createTempFile("jtx_temp", ".tmp", tempDir2);
|
||||||
FileWriter fileWriter = new FileWriter(tempFile2, true);
|
FileWriter fileWriter = new FileWriter(tempFile2, true);
|
||||||
BufferedWriter bw = new BufferedWriter(fileWriter);
|
BufferedWriter bw = new BufferedWriter(fileWriter);
|
||||||
bw.write(input);
|
bw.write(input);
|
||||||
bw.close();
|
bw.close();
|
||||||
|
|
||||||
ArrayList<LSPVariable> variables = typeResolver.infereInput(tempFile2.toURI().toString(), input, false);
|
try {
|
||||||
cacheService.setVariables(variables);
|
ArrayList<LSPVariable> variables = typeResolver.infereInput(tempFile2.toURI().toString(), input, true);
|
||||||
|
cacheService.setVariables(variables);
|
||||||
|
|
||||||
DiagnosticsAndTypehints diagnosticsAndTypehints = conversionHelper.variablesToDiagnosticsAndTypehintsWithInput(variables, input);
|
DiagnosticsAndTypehints diagnosticsAndTypehints = conversionHelper.variablesToDiagnosticsAndTypehintsWithInput(variables, input);
|
||||||
|
|
||||||
List<InlayHint> typeHint = diagnosticsAndTypehints.getInlayHints();
|
List<InlayHint> typeHint = diagnosticsAndTypehints.getInlayHints();
|
||||||
List<Diagnostic> diagnostics = diagnosticsAndTypehints.getDiagnostics();
|
List<Diagnostic> diagnostics = diagnosticsAndTypehints.getDiagnostics();
|
||||||
|
|
||||||
cacheService.updateGlobalMaps(diagnostics, typeHint, params.getTextDocument().getUri());
|
cacheService.updateGlobalMaps(diagnostics, typeHint, params.getTextDocument().getUri());
|
||||||
|
|
||||||
List<Diagnostic> allDiagnostics = new ArrayList<>(diagnostics);
|
List<Diagnostic> allDiagnostics = new ArrayList<>(diagnostics);
|
||||||
allDiagnostics.addAll(parserService.getDiagnosticsOfErrors(input, params.getTextDocument().getUri()));
|
allDiagnostics.addAll(parserService.getDiagnosticsOfErrors(input, params.getTextDocument().getUri()));
|
||||||
|
|
||||||
clientService.publishDiagnostics(params.getTextDocument().getUri(), allDiagnostics);
|
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();
|
tempFile2.delete();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
logService.log("[didSave] Error trying to get Inlay-Hints and Diagnostics for Client: " + e.getMessage(), MessageType.Error);
|
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;
|
return point.getStartIndex() + extraOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public PlaceholderType getKind() {
|
||||||
|
return kind;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
return this == obj;
|
return this == obj;
|
||||||
/*
|
/*
|
||||||
|
@@ -13,7 +13,6 @@ public class PlaceholderVariable {
|
|||||||
ResultPair<?, ?> resultPair;
|
ResultPair<?, ?> resultPair;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public PlaceholderVariable(PlaceholderPoint point, Set<PlaceholderPoint> additionalPoints, ResultPair<?, ?> resultPair) {
|
public PlaceholderVariable(PlaceholderPoint point, Set<PlaceholderPoint> additionalPoints, ResultPair<?, ?> resultPair) {
|
||||||
this.point = point;
|
this.point = point;
|
||||||
inserts = additionalPoints;
|
inserts = additionalPoints;
|
||||||
@@ -26,7 +25,10 @@ public class PlaceholderVariable {
|
|||||||
|
|
||||||
List<PlaceholderPoint> insertsSorted = new ArrayList<>();
|
List<PlaceholderPoint> insertsSorted = new ArrayList<>();
|
||||||
insertsSorted.add(point);
|
insertsSorted.add(point);
|
||||||
insertsSorted.addAll(inserts);
|
|
||||||
|
if (!point.getInsertString().contains("void")) {
|
||||||
|
insertsSorted.addAll(inserts);
|
||||||
|
}
|
||||||
Collections.sort(insertsSorted, new PlaceholderPoint.TypeInsertPointPositionComparator().reversed());
|
Collections.sort(insertsSorted, new PlaceholderPoint.TypeInsertPointPositionComparator().reversed());
|
||||||
|
|
||||||
for (PlaceholderPoint insertPoint : insertsSorted) {
|
for (PlaceholderPoint insertPoint : insertsSorted) {
|
||||||
@@ -40,7 +42,8 @@ public class PlaceholderVariable {
|
|||||||
return point.getInsertString();
|
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() {
|
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
|
## 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
|
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:
|
You can follow this steps:
|
||||||
|
Reference in New Issue
Block a user