Simple PDE test working again.

This commit is contained in:
Sam Pottinger
2023-07-16 19:17:59 -07:00
parent d366df99cc
commit c2356b834d
4 changed files with 32 additions and 7 deletions
@@ -118,7 +118,7 @@ public class JavaEditor extends Editor {
// setting breakpoints will flag sketch as modified, so override this here
getSketch().setModified(false);
preprocService = new PreprocService(this.jmode, this.sketch);
preprocService = new PreprocService(this.jmode, this.sketch, this);
// long t5 = System.currentTimeMillis();
@@ -93,13 +93,15 @@ public class PreprocService {
private volatile boolean running;
private CompletableFuture<PreprocSketch> preprocessingTask = new CompletableFuture<>();
private JavaEditor editor;
private CompletableFuture<?> lastCallback =
new CompletableFuture<>() {{
complete(null); // initialization block
}};
/**
* Create a new preprocessing service to support an editor.
* Create a new preprocessing service to support the language server.
*/
public PreprocService(JavaMode javaMode, Sketch sketch) {
this.javaMode = javaMode;
@@ -112,6 +114,21 @@ public class PreprocService {
preprocessingThread.start();
}
/**
* Create a new preprocessing service to support an editor.
*/
public PreprocService(JavaMode javaMode, Sketch sketch, JavaEditor editor) {
this.javaMode = javaMode;
this.sketch = sketch;
this.editor = editor;
// Register listeners for first run
whenDone(this::fireListeners);
preprocessingThread = new Thread(this::mainLoop, "ECS");
preprocessingThread.start();
}
/**
* The "main loop" for the background thread that checks for code issues.
*/
@@ -411,10 +428,18 @@ public class PreprocService {
throw new RuntimeException("Unexpected sketch exception in preprocessing: " + e);
}
final int endNumLines = numLines;
if (preprocessorResult.getPreprocessIssues().size() > 0) {
preprocessorResult.getPreprocessIssues().stream()
if (editor == null) {
preprocessorResult.getPreprocessIssues().stream()
.map((x) -> ProblemFactory.build(x, tabLineStarts))
.forEach(result.otherProblems::add);
} else {
preprocessorResult.getPreprocessIssues().stream()
.map((x) -> ProblemFactory.build(x, tabLineStarts, endNumLines, editor))
.forEach(result.otherProblems::add);
}
result.hasSyntaxErrors = true;
}