mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-11 02:05:39 +02:00
Fix for NPE by Andrey Eremchenko.
This commit is contained in:
parent
127db8e30b
commit
615cf0372b
1 changed files with 6 additions and 4 deletions
|
@ -284,7 +284,7 @@ public abstract class PDOMSearchQuery implements ISearchQuery {
|
||||||
names.addAll(Arrays.asList(ast.getDeclarationsInAST(binding)));
|
names.addAll(Arrays.asList(ast.getDeclarationsInAST(binding)));
|
||||||
names.addAll(Arrays.asList(ast.getDefinitionsInAST(binding)));
|
names.addAll(Arrays.asList(ast.getDefinitionsInAST(binding)));
|
||||||
names.addAll(Arrays.asList(ast.getReferences(binding)));
|
names.addAll(Arrays.asList(ast.getReferences(binding)));
|
||||||
// collect local matches from AST
|
// Collect local matches from AST
|
||||||
IIndexFileLocation fileLocation = null;
|
IIndexFileLocation fileLocation = null;
|
||||||
Set<Match> localMatches = new HashSet<Match>();
|
Set<Match> localMatches = new HashSet<Match>();
|
||||||
for (IASTName name : names) {
|
for (IASTName name : names) {
|
||||||
|
@ -301,7 +301,9 @@ public abstract class PDOMSearchQuery implements ISearchQuery {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// search for dirty editor
|
if (localMatches.isEmpty())
|
||||||
|
return;
|
||||||
|
// Search for dirty editor
|
||||||
ITextEditor dirtyTextEditor = null;
|
ITextEditor dirtyTextEditor = null;
|
||||||
String fullPath = ast.getFilePath();
|
String fullPath = ast.getFilePath();
|
||||||
for (IEditorPart editorPart : CUIPlugin.getDirtyEditors()) {
|
for (IEditorPart editorPart : CUIPlugin.getDirtyEditors()) {
|
||||||
|
@ -318,7 +320,7 @@ public abstract class PDOMSearchQuery implements ISearchQuery {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// create line search elements
|
// Create line search elements
|
||||||
Match[] matchesArray = localMatches.toArray(new Match[localMatches.size()]);
|
Match[] matchesArray = localMatches.toArray(new Match[localMatches.size()]);
|
||||||
LineSearchElement[] lineElements;
|
LineSearchElement[] lineElements;
|
||||||
if (dirtyTextEditor != null) {
|
if (dirtyTextEditor != null) {
|
||||||
|
@ -328,7 +330,7 @@ public abstract class PDOMSearchQuery implements ISearchQuery {
|
||||||
} else {
|
} else {
|
||||||
lineElements = LineSearchElement.createElements(fileLocation, matchesArray);
|
lineElements = LineSearchElement.createElements(fileLocation, matchesArray);
|
||||||
}
|
}
|
||||||
// create real PDOMSearchMatch with corresponding line elements
|
// Create real PDOMSearchMatch with corresponding line elements
|
||||||
for (LineSearchElement searchElement : lineElements) {
|
for (LineSearchElement searchElement : lineElements) {
|
||||||
for (Match lineMatch : searchElement.getMatches()) {
|
for (Match lineMatch : searchElement.getMatches()) {
|
||||||
int offset = lineMatch.getOffset();
|
int offset = lineMatch.getOffset();
|
||||||
|
|
Loading…
Add table
Reference in a new issue