mirror of
https://github.com/processing/processing4.git
synced 2026-02-03 05:39:18 +01:00
Synchronize access to ASTGenerator
We might want to remove this later
This commit is contained in:
@@ -31,6 +31,7 @@ import processing.app.ui.Toolkit;
|
||||
import processing.mode.java.debug.LineBreakpoint;
|
||||
import processing.mode.java.debug.LineHighlight;
|
||||
import processing.mode.java.debug.LineID;
|
||||
import processing.mode.java.pdex.ASTGenerator;
|
||||
import processing.mode.java.pdex.ErrorCheckerService;
|
||||
import processing.mode.java.pdex.LineMarker;
|
||||
import processing.mode.java.pdex.ErrorMessageSimplifier;
|
||||
@@ -2674,14 +2675,20 @@ public class JavaEditor extends Editor {
|
||||
/** Handle refactor operation */
|
||||
private void handleRefactor() {
|
||||
Messages.log("Caret at:" + textarea.getLineText(textarea.getCaretLine()));
|
||||
errorCheckerService.getASTGenerator().handleRefactor();
|
||||
ASTGenerator astGenerator = errorCheckerService.getASTGenerator();
|
||||
synchronized (astGenerator) {
|
||||
astGenerator.handleRefactor();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** Handle show usage operation */
|
||||
private void handleShowUsage() {
|
||||
Messages.log("Caret at:" + textarea.getLineText(textarea.getCaretLine()));
|
||||
errorCheckerService.getASTGenerator().handleShowUsage();
|
||||
ASTGenerator astGenerator = errorCheckerService.getASTGenerator();
|
||||
synchronized (astGenerator) {
|
||||
astGenerator.handleShowUsage();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -390,7 +390,10 @@ public class ASTNodeWrapper {
|
||||
// Instead of converting pde into java, how can I simply extract the same source
|
||||
// from the java code? Think. TODO
|
||||
String sourceAlt = new String(source);
|
||||
String sourceJava = ecs.astGenerator.getJavaSourceCodeLine(lineNumber);
|
||||
String sourceJava;
|
||||
synchronized (ecs.astGenerator) {
|
||||
sourceJava = ecs.astGenerator.getJavaSourceCodeLine(lineNumber);
|
||||
}
|
||||
TreeMap<Integer, Integer> offsetmap = new TreeMap<Integer, Integer>();
|
||||
|
||||
if(sourceJava.trim().startsWith("public") && !source.startsWith("public")){
|
||||
|
||||
@@ -129,8 +129,11 @@ public class CompletionPanel {
|
||||
scrollPane.setViewportView(completionList = createSuggestionList(position, items));
|
||||
popupMenu.add(scrollPane, BorderLayout.CENTER);
|
||||
popupMenu.setPopupSize(calcWidth(), calcHeight(items.getSize())); //TODO: Eradicate this evil
|
||||
editor.getErrorChecker().getASTGenerator().updateJavaDoc(completionList.getSelectedValue());
|
||||
textarea.requestFocusInWindow();
|
||||
ASTGenerator astGenerator = editor.getErrorChecker().getASTGenerator();
|
||||
synchronized (astGenerator) {
|
||||
astGenerator.updateJavaDoc(completionList.getSelectedValue());
|
||||
}
|
||||
popupMenu.show(textarea, location.x, textarea.getBaseline(0, 0) + location.y);
|
||||
//log("Suggestion shown: " + System.currentTimeMillis());
|
||||
}
|
||||
@@ -506,7 +509,10 @@ public class CompletionPanel {
|
||||
.getVerticalScrollBar()
|
||||
.getValue()
|
||||
- step);
|
||||
editor.getErrorChecker().getASTGenerator().updateJavaDoc(completionList.getSelectedValue());
|
||||
ASTGenerator astGenerator = editor.getErrorChecker().getASTGenerator();
|
||||
synchronized (astGenerator) {
|
||||
astGenerator.updateJavaDoc(completionList.getSelectedValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -523,7 +529,10 @@ public class CompletionPanel {
|
||||
int index = Math.min(completionList.getSelectedIndex() + 1,
|
||||
completionList.getModel().getSize() - 1);
|
||||
selectIndex(index);
|
||||
editor.getErrorChecker().getASTGenerator().updateJavaDoc(completionList.getSelectedValue());
|
||||
ASTGenerator astGenerator = editor.getErrorChecker().getASTGenerator();
|
||||
synchronized (astGenerator) {
|
||||
astGenerator.updateJavaDoc(completionList.getSelectedValue());
|
||||
}
|
||||
int step = scrollPane.getVerticalScrollBar().getMaximum() / completionList.getModel().getSize();
|
||||
scrollPane.getVerticalScrollBar().setValue(scrollPane.getVerticalScrollBar().getValue() + step);
|
||||
}
|
||||
|
||||
@@ -316,7 +316,9 @@ public class ErrorCheckerService implements Runnable {
|
||||
// This is when the loaded sketch already has syntax errors.
|
||||
// Completion wouldn't be complete, but it'd be still something
|
||||
// better than nothing
|
||||
astGenerator.buildAST(cu);
|
||||
synchronized (astGenerator) {
|
||||
astGenerator.buildAST(cu);
|
||||
}
|
||||
handleErrorCheckingToggle();
|
||||
while (!stopThread.get()) {
|
||||
try {
|
||||
@@ -349,7 +351,9 @@ public class ErrorCheckerService implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
astGenerator.disposeAllWindows();
|
||||
synchronized (astGenerator) {
|
||||
astGenerator.disposeAllWindows();
|
||||
}
|
||||
compilationChecker = null;
|
||||
checkerClass = null;
|
||||
classLoader = null;
|
||||
@@ -503,7 +507,9 @@ public class ErrorCheckerService implements Runnable {
|
||||
// log(editor.getSketch().getName() + "2 MCO " + mainClassOffset);
|
||||
}
|
||||
|
||||
astGenerator.buildAST(cu);
|
||||
synchronized (astGenerator) {
|
||||
astGenerator.buildAST(cu);
|
||||
}
|
||||
if (!JavaMode.errorCheckEnabled) {
|
||||
problemsList.clear();
|
||||
Messages.log("Error Check disabled, so not updating UI.");
|
||||
@@ -897,7 +903,9 @@ public class ErrorCheckerService implements Runnable {
|
||||
}
|
||||
new Thread(new Runnable() {
|
||||
public void run() {
|
||||
astGenerator.loadJars(); // update jar file for completion lookup
|
||||
synchronized (astGenerator) {
|
||||
astGenerator.loadJars(); // update jar file for completion lookup
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
@@ -956,7 +964,10 @@ public class ErrorCheckerService implements Runnable {
|
||||
String[] args = p.getIProblem().getArguments();
|
||||
if (args.length > 0) {
|
||||
String missingClass = args[0];
|
||||
String[] si = astGenerator.getSuggestImports(missingClass);
|
||||
String[] si;
|
||||
synchronized (astGenerator) {
|
||||
si = astGenerator.getSuggestImports(missingClass);
|
||||
}
|
||||
if (si != null && si.length > 0) {
|
||||
p.setImportSuggestions(si);
|
||||
// errorData[index][0] = "<html>" + p.getMessage() +
|
||||
|
||||
@@ -368,7 +368,10 @@ public class JavaTextArea extends JEditTextArea {
|
||||
return null;
|
||||
}
|
||||
Messages.log("Mouse click, word: " + word.trim());
|
||||
editor.getErrorChecker().getASTGenerator().setLastClickedWord(line, word, xLS);
|
||||
ASTGenerator astGenerator = editor.getErrorChecker().getASTGenerator();
|
||||
synchronized (astGenerator) {
|
||||
astGenerator.setLastClickedWord(line, word, xLS);
|
||||
}
|
||||
return word.trim();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,7 +207,10 @@ public class JavaTextAreaPainter extends TextAreaPainter
|
||||
return;
|
||||
|
||||
Messages.log(getJavaEditor().getErrorChecker().mainClassOffset + line + "|" + line + "| offset " + xLS + word + " <= \n");
|
||||
getJavaEditor().getErrorChecker().getASTGenerator().scrollToDeclaration(line, word, xLS);
|
||||
ASTGenerator astGenerator = getJavaEditor().getErrorChecker().getASTGenerator();
|
||||
synchronized (astGenerator) {
|
||||
astGenerator.scrollToDeclaration(line, word, xLS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -515,12 +518,14 @@ public class JavaTextAreaPainter extends TextAreaPainter
|
||||
return super.getToolTipText(event);
|
||||
}
|
||||
ASTGenerator ast = getJavaEditor().getErrorChecker().getASTGenerator();
|
||||
String tooltipText = ast.getLabelForASTNode(line, word, xLS);
|
||||
synchronized (ast) {
|
||||
String tooltipText = ast.getLabelForASTNode(line, word, xLS);
|
||||
|
||||
// log(errorCheckerService.mainClassOffset + " MCO "
|
||||
// + "|" + line + "| offset " + xLS + word + " <= offf: "+off+ "\n");
|
||||
if (tooltipText != null) {
|
||||
return tooltipText;
|
||||
// log(errorCheckerService.mainClassOffset + " MCO "
|
||||
// + "|" + line + "| offset " + xLS + word + " <= offf: "+off+ "\n");
|
||||
if (tooltipText != null) {
|
||||
return tooltipText;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user