Skip to content

Commit fd0b1c3

Browse files
committed
language-server: add comments about real-time problems
1 parent aed0eb2 commit fd0b1c3

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

language-server/src/main/java/com/as3mxml/vscode/utils/RealTimeProblemsChecker.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ public synchronized void setFileSpecification(IFileSpecification newFileSpec) {
7171
public synchronized void setCompilationUnit(ICompilationUnit compilationUnit, IFileSpecification fileSpec,
7272
ActionScriptProjectData projectData) {
7373
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.
7476
updateNow();
7577
pendingProjectData = projectData;
7678
pendingCompilationUnit = compilationUnit;
@@ -83,6 +85,9 @@ public synchronized void setCompilationUnit(ICompilationUnit compilationUnit, IF
8385
pendingProjectData = null;
8486
pendingCompilationUnit = null;
8587
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.
8691
syntaxTreeRequest = compilationUnit.getSyntaxTreeRequest();
8792
fileScopeRequest = compilationUnit.getFileScopeRequest();
8893
outgoingDepsRequest = compilationUnit.getOutgoingDependenciesRequest();
@@ -116,6 +121,8 @@ public synchronized void updateNow() {
116121
abcBytesRequest = compilationUnit.getABCBytesRequest();
117122
}
118123
try {
124+
// force all requests to finish immediately because we can no longer
125+
// wait for the background thread and need the results now.
119126
syntaxTreeRequest.get();
120127
fileScopeRequest.get();
121128
outgoingDepsRequest.get();
@@ -173,6 +180,10 @@ private synchronized void checkForProblems() {
173180
if (abcBytesRequest == null) {
174181
abcBytesRequest = compilationUnit.getABCBytesRequest();
175182
}
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.
176187
if (syntaxTreeRequest.isDone() && fileScopeRequest.isDone() && outgoingDepsRequest.isDone()
177188
&& abcBytesRequest.isDone()) {
178189
publishDiagnostics();

0 commit comments

Comments
 (0)