1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-25 01:45:33 +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:
Doug Schaefer 2005-04-01 20:12:41 +00:00
parent c946e6f846
commit 363f066567
2 changed files with 5 additions and 3 deletions

View file

@ -30,10 +30,9 @@ public class CPPASTNode extends ASTNode implements IASTNode {
public IASTTranslationUnit getTranslationUnit() {
if( this instanceof IASTTranslationUnit ) return (IASTTranslationUnit) this;
IASTNode node = getParent();
while( ! (node instanceof IASTTranslationUnit ))
{
while(node != null && !(node instanceof IASTTranslationUnit))
node = node.getParent();
}
return (IASTTranslationUnit) node;
}

View file

@ -52,6 +52,9 @@ public class DOMCompletionContributor implements ICompletionContributor {
// Find all bindings
List allBindings = new ArrayList();
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();
if (bindings != null)
for (int j = 0; j < bindings.length; ++j) {