From 5b93048496f9491d9848c7a4dd76e648dae73f32 Mon Sep 17 00:00:00 2001 From: Markus Schorn Date: Mon, 4 Jul 2011 16:35:49 +0200 Subject: [PATCH] Bug 351029: NPE resolving binding in copied AST. --- .../core/dom/parser/cpp/semantics/CPPVisitor.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java index 0715609e8ba..67d41b61c07 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/CPPVisitor.java @@ -1065,9 +1065,12 @@ public class CPPVisitor extends ASTQueries { for (; i < names.length; i++) { if (names[i] == name) break; } + final IASTTranslationUnit tu = parent.getTranslationUnit(); if (i == 0) { if (qname.isFullyQualified()) { - return parent.getTranslationUnit().getScope(); + if (tu == null) + return null; + return tu.getScope(); } if (qname.getParent() instanceof ICPPASTFieldReference) { name= qname; @@ -1091,8 +1094,8 @@ public class CPPVisitor extends ASTQueries { boolean done= true; IScope scope= null; if (binding instanceof ICPPClassType) { - if (binding instanceof IIndexBinding) { - binding= (((CPPASTTranslationUnit) parent.getTranslationUnit())).mapToAST((ICPPClassType) binding); + if (binding instanceof IIndexBinding && tu != null) { + binding= (((CPPASTTranslationUnit) tu)).mapToAST((ICPPClassType) binding); } scope= ((ICPPClassType) binding).getCompositeScope(); } else if (binding instanceof ICPPNamespace) {