@@ -71,6 +71,8 @@ public synchronized void setFileSpecification(IFileSpecification newFileSpec) {
71
71
public synchronized void setCompilationUnit (ICompilationUnit compilationUnit , IFileSpecification fileSpec ,
72
72
ActionScriptProjectData projectData ) {
73
73
if (this .compilationUnit != null && this .compilationUnit != compilationUnit ) {
74
+ // if the compilation unit has changing, let's report the previous
75
+ // one's problems quickly and move on to the new one.
74
76
updateNow ();
75
77
pendingProjectData = projectData ;
76
78
pendingCompilationUnit = compilationUnit ;
@@ -83,6 +85,9 @@ public synchronized void setCompilationUnit(ICompilationUnit compilationUnit, IF
83
85
pendingProjectData = null ;
84
86
pendingCompilationUnit = null ;
85
87
pendingFileSpec = null ;
88
+ // make these requests, but allow the compiler to handle things in a
89
+ // background thread for now. we can force it to complete synchronously
90
+ // later, if we need to.
86
91
syntaxTreeRequest = compilationUnit .getSyntaxTreeRequest ();
87
92
fileScopeRequest = compilationUnit .getFileScopeRequest ();
88
93
outgoingDepsRequest = compilationUnit .getOutgoingDependenciesRequest ();
@@ -116,6 +121,8 @@ public synchronized void updateNow() {
116
121
abcBytesRequest = compilationUnit .getABCBytesRequest ();
117
122
}
118
123
try {
124
+ // force all requests to finish immediately because we can no longer
125
+ // wait for the background thread and need the results now.
119
126
syntaxTreeRequest .get ();
120
127
fileScopeRequest .get ();
121
128
outgoingDepsRequest .get ();
@@ -173,6 +180,10 @@ private synchronized void checkForProblems() {
173
180
if (abcBytesRequest == null ) {
174
181
abcBytesRequest = compilationUnit .getABCBytesRequest ();
175
182
}
183
+ // wait until all requests are done before publishing diagnostics.
184
+ // they will either finish in the compiler's background thread, or they
185
+ // will be forced to complete synchronously in the updateNow() method
186
+ // in this class.
176
187
if (syntaxTreeRequest .isDone () && fileScopeRequest .isDone () && outgoingDepsRequest .isDone ()
177
188
&& abcBytesRequest .isDone ()) {
178
189
publishDiagnostics ();
0 commit comments