diff --git a/language-server/src/main/java/com/as3mxml/vscode/ActionScriptTextDocumentService.java b/language-server/src/main/java/com/as3mxml/vscode/ActionScriptTextDocumentService.java index da09fe695..d769220cc 100644 --- a/language-server/src/main/java/com/as3mxml/vscode/ActionScriptTextDocumentService.java +++ b/language-server/src/main/java/com/as3mxml/vscode/ActionScriptTextDocumentService.java @@ -383,10 +383,9 @@ public CompletableFuture, CompletionList>> completio return CompletableFuture.completedFuture(Either.forRight(result)); } - //we need the compilation unit to be fully built or the completion - //result will be inaccurate - //additionally, there could be null reference exceptions caused by old - //scopes being referenced + //we need the compilation unit to be fully built or the result will be + //inaccurate. additionally, there could be null reference exceptions + //caused by old scopes being referenced realTimeProblemAnalyzer.completePendingRequests(); IMXMLTagData offsetTag = getOffsetMXMLTag(params); @@ -448,6 +447,12 @@ public CompletableFuture hover(TextDocumentPositionParams position) { return CompletableFuture.completedFuture(new Hover(Collections.emptyList(), null)); } + + //we need the compilation unit to be fully built or the result will be + //inaccurate. additionally, there could be null reference exceptions + //caused by old scopes being referenced + realTimeProblemAnalyzer.completePendingRequests(); + IMXMLTagData offsetTag = getOffsetMXMLTag(position); if (offsetTag != null) { @@ -483,10 +488,9 @@ public CompletableFuture signatureHelp(TextDocumentPositionParams return CompletableFuture.completedFuture(new SignatureHelp(Collections.emptyList(), -1, -1)); } - //we need the compilation unit to be fully built or the signature help - //result will be inaccurate - //additionally, there could be null reference exceptions caused by old - //scopes being referenced + //we need the compilation unit to be fully built or the result will be + //inaccurate. additionally, there could be null reference exceptions + //caused by old scopes being referenced realTimeProblemAnalyzer.completePendingRequests(); IASNode offsetNode = null; @@ -634,6 +638,12 @@ public CompletableFuture> definition(TextDocumentPositi { return CompletableFuture.completedFuture(Collections.emptyList()); } + + //we need the compilation unit to be fully built or the result will be + //inaccurate. additionally, there could be null reference exceptions + //caused by old scopes being referenced + realTimeProblemAnalyzer.completePendingRequests(); + IMXMLTagData offsetTag = getOffsetMXMLTag(position); if (offsetTag != null) { @@ -664,6 +674,12 @@ public CompletableFuture> typeDefinition(TextDocumentPo { return CompletableFuture.completedFuture(Collections.emptyList()); } + + //we need the compilation unit to be fully built or the result will be + //inaccurate. additionally, there could be null reference exceptions + //caused by old scopes being referenced + realTimeProblemAnalyzer.completePendingRequests(); + IMXMLTagData offsetTag = getOffsetMXMLTag(position); if (offsetTag != null) { @@ -693,6 +709,12 @@ public CompletableFuture> implementation(TextDocumentPo { return CompletableFuture.completedFuture(Collections.emptyList()); } + + //we need the compilation unit to be fully built or the result will be + //inaccurate. additionally, there could be null reference exceptions + //caused by old scopes being referenced + realTimeProblemAnalyzer.completePendingRequests(); + IMXMLTagData offsetTag = getOffsetMXMLTag(position); if (offsetTag != null) { @@ -719,6 +741,12 @@ public CompletableFuture> references(ReferenceParams pa { return CompletableFuture.completedFuture(Collections.emptyList()); } + + //we need the compilation unit to be fully built or the result will be + //inaccurate. additionally, there could be null reference exceptions + //caused by old scopes being referenced + realTimeProblemAnalyzer.completePendingRequests(); + IMXMLTagData offsetTag = getOffsetMXMLTag(params); if (offsetTag != null) { @@ -751,6 +779,11 @@ public CompletableFuture> documentHighlight(Te */ public CompletableFuture> workspaceSymbol(WorkspaceSymbolParams params) { + //we need the compilation unit to be fully built or the result will be + //inaccurate. additionally, there could be null reference exceptions + //caused by old scopes being referenced + realTimeProblemAnalyzer.completePendingRequests(); + Set qualifiedNames = new HashSet<>(); List result = new ArrayList<>(); String query = params.getQuery(); @@ -854,6 +887,12 @@ public CompletableFuture> documentSymbol(Docum { return CompletableFuture.completedFuture(Collections.emptyList()); } + + //we need the compilation unit to be fully built or the result will be + //inaccurate. additionally, there could be null reference exceptions + //caused by old scopes being referenced + realTimeProblemAnalyzer.completePendingRequests(); + ICompilationUnit unit = getCompilationUnit(path); if (unit == null) { @@ -887,7 +926,11 @@ public CompletableFuture> codeAction(CodeActionParams pa List diagnostics = params.getContext().getDiagnostics(); TextDocumentIdentifier textDocument = params.getTextDocument(); Path path = LanguageServerCompilerUtils.getPathFromLanguageServerURI(textDocument.getUri()); - if (path == null || !sourceByPath.containsKey(path)) + if (path == null) + { + return CompletableFuture.completedFuture(Collections.emptyList()); + } + if (!sourceByPath.containsKey(path)) { return CompletableFuture.completedFuture(Collections.emptyList()); } @@ -897,6 +940,12 @@ public CompletableFuture> codeAction(CodeActionParams pa //the path must be in the workspace or source-path return CompletableFuture.completedFuture(Collections.emptyList()); } + + //we need the compilation unit to be fully built or the result will be + //inaccurate. additionally, there could be null reference exceptions + //caused by old scopes being referenced + realTimeProblemAnalyzer.completePendingRequests(); + currentProject = getProject(folderData); if (currentProject == null || !SourcePathUtils.isInProjectSourcePath(path, currentProject)) { @@ -1232,6 +1281,15 @@ public CompletableFuture rename(RenameParams params) return CompletableFuture.completedFuture(new WorkspaceEdit(new HashMap<>())); } + //we need the compilation unit to be fully built or the result will be + //inaccurate. additionally, there could be null reference exceptions + //caused by old scopes being referenced + if (realTimeProblemAnalyzer.getCompilationUnit() != null) + { + System.err.println("rename: needs complete pending requests"); + } + //realTimeProblemAnalyzer.completePendingRequests(); + IMXMLTagData offsetTag = getOffsetMXMLTag(params.getTextDocument(), params.getPosition()); if (offsetTag != null) { @@ -1256,6 +1314,11 @@ public CompletableFuture rename(RenameParams params) */ public CompletableFuture executeCommand(ExecuteCommandParams params) { + //we need the compilation unit to be fully built or the result will be + //inaccurate. additionally, there could be null reference exceptions + //caused by old scopes being referenced + realTimeProblemAnalyzer.completePendingRequests(); + switch(params.getCommand()) { case ICommandConstants.ADD_IMPORT: