mirror of
https://github.com/processing/processing4.git
synced 2026-02-13 10:30:44 +01:00
more synchronization
This commit is contained in:
@@ -126,6 +126,19 @@ x Working for local code
|
||||
* Labels for predefined class objects
|
||||
* Chaining support for labels
|
||||
|
||||
Synchronization
|
||||
===============
|
||||
|
||||
Gotta do it carefully between main thread, ECS Thread, and SwingWorker threads
|
||||
Fields that are concurrently accessed:
|
||||
|
||||
ECS members:
|
||||
ArrayList<Problem> problems - updated in ECS, accessed by ErrorBar.update()
|
||||
ArrayList<URL> classpathJars - updated in ECS, accessed by ASTGenerator.loadJars()
|
||||
hasErrors, syntaxErrors - Atomic Boolean
|
||||
CompilationUnit cu - updated in ECS, accessed a zillion times in ASTGenerator :'(
|
||||
|
||||
|
||||
General Stuff
|
||||
=============
|
||||
|
||||
|
||||
@@ -174,21 +174,22 @@ public class ErrorBar extends JPanel {
|
||||
// Each problem.getSourceLine() will have an extra line added
|
||||
// because of
|
||||
// class declaration in the beginning as well as default imports
|
||||
for (Problem problem : problems) {
|
||||
if (problem.getTabIndex() == currentTab) {
|
||||
// Ratio of error line to total lines
|
||||
float y = (problem.getLineNumber() - errorCheckerService.defaultImportsOffset)
|
||||
/ ((float) totalLines);
|
||||
// Ratio multiplied by height of the error bar
|
||||
y *= fheight - 15; // -15 is just a vertical offset
|
||||
errorPoints
|
||||
.add(new ErrorMarker(problem, (int) y,
|
||||
problem.isError() ? ErrorMarker.Error
|
||||
: ErrorMarker.Warning));
|
||||
// System.out.println("Y: " + y);
|
||||
synchronized (problems) {
|
||||
for (Problem problem : problems) {
|
||||
if (problem.getTabIndex() == currentTab) {
|
||||
// Ratio of error line to total lines
|
||||
float y = (problem.getLineNumber() - errorCheckerService.defaultImportsOffset)
|
||||
/ ((float) totalLines);
|
||||
// Ratio multiplied by height of the error bar
|
||||
y *= fheight - 15; // -15 is just a vertical offset
|
||||
errorPoints
|
||||
.add(new ErrorMarker(problem, (int) y,
|
||||
problem.isError() ? ErrorMarker.Error
|
||||
: ErrorMarker.Warning));
|
||||
// System.out.println("Y: " + y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -510,51 +510,52 @@ public class ErrorCheckerService implements Runnable{
|
||||
if (errorList == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
problems = new DefaultProblem[errorList.length];
|
||||
|
||||
for (int i = 0; i < errorList.length; i++) {
|
||||
|
||||
// for (int j = 0; j < errorList[i].length; j++)
|
||||
// System.out.print(errorList[i][j] + ", ");
|
||||
|
||||
problems[i] = new DefaultProblem((char[]) errorList[i][0],
|
||||
(String) errorList[i][1],
|
||||
((Integer) errorList[i][2]).intValue(),
|
||||
(String[]) errorList[i][3],
|
||||
((Integer) errorList[i][4]).intValue(),
|
||||
((Integer) errorList[i][5]).intValue(),
|
||||
((Integer) errorList[i][6]).intValue(),
|
||||
((Integer) errorList[i][7]).intValue(), 0);
|
||||
|
||||
// System.out
|
||||
// .println("ECS: " + problems[i].getMessage() + ","
|
||||
// + problems[i].isError() + ","
|
||||
// + problems[i].isWarning());
|
||||
|
||||
IProblem problem = problems[i];
|
||||
// log(problem.getMessage());
|
||||
// for (String j : problem.getArguments()) {
|
||||
// log("arg " + j);
|
||||
// }
|
||||
int a[] = calculateTabIndexAndLineNumber(problem);
|
||||
Problem p = new Problem(problem, a[0], a[1]);
|
||||
if ((Boolean) errorList[i][8]) {
|
||||
p.setType(Problem.ERROR);
|
||||
containsErrors.set(true); // set flag
|
||||
|
||||
synchronized (problemsList) {
|
||||
problems = new DefaultProblem[errorList.length];
|
||||
|
||||
for (int i = 0; i < errorList.length; i++) {
|
||||
|
||||
// for (int j = 0; j < errorList[i].length; j++)
|
||||
// System.out.print(errorList[i][j] + ", ");
|
||||
|
||||
problems[i] = new DefaultProblem((char[]) errorList[i][0],
|
||||
(String) errorList[i][1],
|
||||
((Integer) errorList[i][2]).intValue(),
|
||||
(String[]) errorList[i][3],
|
||||
((Integer) errorList[i][4]).intValue(),
|
||||
((Integer) errorList[i][5]).intValue(),
|
||||
((Integer) errorList[i][6]).intValue(),
|
||||
((Integer) errorList[i][7]).intValue(), 0);
|
||||
|
||||
// System.out
|
||||
// .println("ECS: " + problems[i].getMessage() + ","
|
||||
// + problems[i].isError() + ","
|
||||
// + problems[i].isWarning());
|
||||
|
||||
IProblem problem = problems[i];
|
||||
// log(problem.getMessage());
|
||||
// for (String j : problem.getArguments()) {
|
||||
// log("arg " + j);
|
||||
// }
|
||||
int a[] = calculateTabIndexAndLineNumber(problem);
|
||||
Problem p = new Problem(problem, a[0], a[1]);
|
||||
if ((Boolean) errorList[i][8]) {
|
||||
p.setType(Problem.ERROR);
|
||||
containsErrors.set(true); // set flag
|
||||
}
|
||||
|
||||
if ((Boolean) errorList[i][9]) {
|
||||
p.setType(Problem.WARNING);
|
||||
}
|
||||
|
||||
// If warnings are disabled, skip 'em
|
||||
if (p.isWarning() && !warningsEnabled) {
|
||||
continue;
|
||||
}
|
||||
problemsList.add(p);
|
||||
}
|
||||
|
||||
if ((Boolean) errorList[i][9]) {
|
||||
p.setType(Problem.WARNING);
|
||||
}
|
||||
|
||||
// If warnings are disabled, skip 'em
|
||||
if (p.isWarning() && !warningsEnabled) {
|
||||
continue;
|
||||
}
|
||||
problemsList.add(p);
|
||||
}
|
||||
|
||||
} catch (ClassNotFoundException e) {
|
||||
System.err.println("Compiltation Checker files couldn't be found! "
|
||||
+ e + " compileCheck() problem.");
|
||||
@@ -717,7 +718,7 @@ public class ErrorCheckerService implements Runnable{
|
||||
/**
|
||||
* Enable/Disable warnings from being shown
|
||||
*/
|
||||
public boolean warningsEnabled = true;
|
||||
volatile public boolean warningsEnabled = true;
|
||||
|
||||
/**
|
||||
* Sets compiler options for JDT Compiler
|
||||
@@ -747,7 +748,7 @@ public class ErrorCheckerService implements Runnable{
|
||||
/**
|
||||
* Updates the error table in the Error Window.
|
||||
*/
|
||||
synchronized public void updateErrorTable() {
|
||||
public void updateErrorTable() {
|
||||
|
||||
try {
|
||||
String[][] errorData = new String[problemsList.size()][3];
|
||||
|
||||
@@ -46,7 +46,7 @@ public class ExperimentalMode extends JavaMode {
|
||||
public static final boolean VERBOSE_LOGGING = true;
|
||||
//public static final boolean VERBOSE_LOGGING = false;
|
||||
public static final int LOG_SIZE = 512 * 1024; // max log file size (in bytes)
|
||||
public static boolean DEBUG = !true;
|
||||
public static boolean DEBUG = true;
|
||||
|
||||
public ExperimentalMode(Base base, File folder) {
|
||||
super(base, folder);
|
||||
|
||||
Reference in New Issue
Block a user