mirror of
https://github.com/processing/processing4.git
synced 2026-01-28 10:51:07 +01:00
Clean up for #752.
This commit is contained in:
@@ -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, this);
|
||||
preprocService = new PreprocService(this.jmode, this.sketch);
|
||||
|
||||
// long t5 = System.currentTimeMillis();
|
||||
|
||||
|
||||
@@ -93,8 +93,6 @@ 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
|
||||
@@ -114,21 +112,6 @@ 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.
|
||||
*/
|
||||
@@ -431,15 +414,9 @@ public class PreprocService {
|
||||
final int endNumLines = numLines;
|
||||
|
||||
if (preprocessorResult.getPreprocessIssues().size() > 0) {
|
||||
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);
|
||||
}
|
||||
preprocessorResult.getPreprocessIssues().stream()
|
||||
.map((x) -> ProblemFactory.build(x, tabLineStarts))
|
||||
.forEach(result.otherProblems::add);
|
||||
|
||||
result.hasSyntaxErrors = true;
|
||||
}
|
||||
|
||||
@@ -14,49 +14,6 @@ import processing.mode.java.preproc.PdePreprocessIssue;
|
||||
*/
|
||||
public class ProblemFactory {
|
||||
|
||||
/**
|
||||
* Create a new {Problem}.
|
||||
*
|
||||
* @param pdePreprocessIssue The preprocess issue found.
|
||||
* @param tabStarts The list of line numbers on which each tab starts.
|
||||
* @param editor The editor in which errors will appear.
|
||||
* @return Newly created problem.
|
||||
*/
|
||||
public static Problem build(PdePreprocessIssue pdePreprocessIssue, List<Integer> tabStarts,
|
||||
int numLines, Editor editor) {
|
||||
|
||||
int line = pdePreprocessIssue.getLine();
|
||||
|
||||
// Sometimes errors are reported one line past end of sketch. Fix that.
|
||||
if (line >= numLines) {
|
||||
line = numLines - 1;
|
||||
}
|
||||
|
||||
// Get local area
|
||||
TabLine tabLine = getTab(tabStarts, line);
|
||||
|
||||
int tab = tabLine.getTab();
|
||||
int localLine = tabLine.getLineInTab(); // Problems emitted in 0 index
|
||||
|
||||
// Generate syntax problem
|
||||
String message = pdePreprocessIssue.getMsg();
|
||||
|
||||
int lineStart = editor.getLineStartOffset(localLine);
|
||||
int lineStop = editor.getLineStopOffset(localLine) - 1;
|
||||
|
||||
if (lineStart == lineStop) {
|
||||
lineStop++;
|
||||
}
|
||||
|
||||
return new SyntaxProblem(
|
||||
tab,
|
||||
localLine,
|
||||
message,
|
||||
0,
|
||||
lineStop - lineStart
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {Problem}.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user