Skip to content

Commit

Permalink
language-server: more calls to completePendingRequests() to avoid nul…
Browse files Browse the repository at this point in the history
…l reference exceptions
  • Loading branch information
joshtynjala committed Aug 7, 2018
1 parent 3b30bfb commit e5071cc
Showing 1 changed file with 72 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -383,10 +383,9 @@ public CompletableFuture<Either<List<CompletionItem>, 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);
Expand Down Expand Up @@ -448,6 +447,12 @@ public CompletableFuture<Hover> 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)
{
Expand Down Expand Up @@ -483,10 +488,9 @@ public CompletableFuture<SignatureHelp> 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;
Expand Down Expand Up @@ -634,6 +638,12 @@ public CompletableFuture<List<? extends Location>> 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)
{
Expand Down Expand Up @@ -664,6 +674,12 @@ public CompletableFuture<List<? extends Location>> 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)
{
Expand Down Expand Up @@ -693,6 +709,12 @@ public CompletableFuture<List<? extends Location>> 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)
{
Expand All @@ -719,6 +741,12 @@ public CompletableFuture<List<? extends Location>> 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)
{
Expand Down Expand Up @@ -751,6 +779,11 @@ public CompletableFuture<List<? extends DocumentHighlight>> documentHighlight(Te
*/
public CompletableFuture<List<? extends SymbolInformation>> 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<String> qualifiedNames = new HashSet<>();
List<SymbolInformation> result = new ArrayList<>();
String query = params.getQuery();
Expand Down Expand Up @@ -854,6 +887,12 @@ public CompletableFuture<List<? extends SymbolInformation>> 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)
{
Expand Down Expand Up @@ -887,7 +926,11 @@ public CompletableFuture<List<? extends Command>> codeAction(CodeActionParams pa
List<? extends Diagnostic> 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());
}
Expand All @@ -897,6 +940,12 @@ public CompletableFuture<List<? extends Command>> 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))
{
Expand Down Expand Up @@ -1232,6 +1281,15 @@ public CompletableFuture<WorkspaceEdit> 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)
{
Expand All @@ -1256,6 +1314,11 @@ public CompletableFuture<WorkspaceEdit> rename(RenameParams params)
*/
public CompletableFuture<Object> 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:
Expand Down

0 comments on commit e5071cc

Please sign in to comment.