mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-04 06:45:43 +02:00
Fixed an NPE when resolving prefix on a name that isn't properly hooked up in the AST. This usually occurs when a backtrack happens and the AST branch is cut off.
This commit is contained in:
parent
c946e6f846
commit
363f066567
2 changed files with 5 additions and 3 deletions
|
@ -30,10 +30,9 @@ public class CPPASTNode extends ASTNode implements IASTNode {
|
||||||
public IASTTranslationUnit getTranslationUnit() {
|
public IASTTranslationUnit getTranslationUnit() {
|
||||||
if( this instanceof IASTTranslationUnit ) return (IASTTranslationUnit) this;
|
if( this instanceof IASTTranslationUnit ) return (IASTTranslationUnit) this;
|
||||||
IASTNode node = getParent();
|
IASTNode node = getParent();
|
||||||
while( ! (node instanceof IASTTranslationUnit ))
|
while(node != null && !(node instanceof IASTTranslationUnit))
|
||||||
{
|
|
||||||
node = node.getParent();
|
node = node.getParent();
|
||||||
}
|
|
||||||
return (IASTTranslationUnit) node;
|
return (IASTTranslationUnit) node;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -52,6 +52,9 @@ public class DOMCompletionContributor implements ICompletionContributor {
|
||||||
// Find all bindings
|
// Find all bindings
|
||||||
List allBindings = new ArrayList();
|
List allBindings = new ArrayList();
|
||||||
for (int i = 0; i < names.length; ++i) {
|
for (int i = 0; i < names.length; ++i) {
|
||||||
|
if (names[i].getTranslationUnit() == null)
|
||||||
|
// The node isn't properly hooked up, must have backtracked out of this node
|
||||||
|
continue;
|
||||||
IBinding[] bindings = names[i].resolvePrefix();
|
IBinding[] bindings = names[i].resolvePrefix();
|
||||||
if (bindings != null)
|
if (bindings != null)
|
||||||
for (int j = 0; j < bindings.length; ++j) {
|
for (int j = 0; j < bindings.length; ++j) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue