From bebd18a5b299d8ba3aa5e04b6f148065ba904a64 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 476f3a42bff..2599107a734 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) {