mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
Simple PDE test working again.
This commit is contained in:
@@ -147,6 +147,7 @@ public class PdeTextAreaPainter extends TextAreaPainter {
|
||||
protected void paintErrorLine(Graphics gfx, int line, int x) {
|
||||
List<Problem> problems = getEditor().findProblems(line);
|
||||
for (Problem problem : problems) {
|
||||
System.out.println("here");
|
||||
int lineOffsetStart = textArea.getLineStartOffset(line);
|
||||
int lineOffsetStop = textArea.getLineStopOffset(line);
|
||||
|
||||
@@ -326,7 +327,7 @@ public class PdeTextAreaPainter extends TextAreaPainter {
|
||||
public String getToolTipText(MouseEvent event) {
|
||||
fontMetrics = getFontMetrics();
|
||||
int line = event.getY() / fontMetrics.getHeight() + textArea.getFirstLine();
|
||||
if (line >= 0 || line < textArea.getLineCount()) {getPreprocessIssues
|
||||
if (line >= 0 || line < textArea.getLineCount()) {
|
||||
List<Problem> problems = getEditor().findProblems(line);
|
||||
for (Problem problem : problems) {
|
||||
int lineStart = textArea.getLineStartOffset(line);
|
||||
@@ -338,8 +339,6 @@ public class PdeTextAreaPainter extends TextAreaPainter {
|
||||
int startOffset = Math.max(errorStart, lineStart) - lineStart;
|
||||
int stopOffset = Math.min(errorEnd, lineEnd) - lineStart;
|
||||
|
||||
System.out.println(lineStart + "\t" + lineEnd + "\t" + errorStart + "\t" + errorEnd + "\t" + startOffset + "\t" + stopOffset);
|
||||
|
||||
int x = event.getX();
|
||||
|
||||
if (x >= textArea.offsetToX(line, startOffset) &&
|
||||
|
||||
@@ -2630,10 +2630,11 @@ public abstract class Editor extends JFrame implements RunnerListener {
|
||||
.filter(p -> p.getTabIndex() == currentTab)
|
||||
.filter(p -> {
|
||||
int pStartLine = p.getLineNumber();
|
||||
int lineOffset = textarea.getLineOfOffset(pStartLine);
|
||||
int lineOffset = textarea.getLineStartOffset(pStartLine);
|
||||
int pEndOffset = lineOffset + p.getStopOffset();
|
||||
int pEndLine = textarea.getLineOfOffset(pEndOffset);
|
||||
|
||||
System.out.println(line + "\t" + pStartLine + "\t" + pEndLine);
|
||||
return line >= pStartLine && line <= pEndLine;
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user