From ef33d0d2999f0df9e3beafe1a4ed3a9afe0a1747 Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Fri, 8 May 2015 14:40:30 -0700 Subject: [PATCH] Fixed an NPE. Change-Id: If2455671e50e99a662d469febc8e5babf7fc24e3 --- .../ui/editor/OverrideIndicatorManager.java | 44 ++++++++++--------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OverrideIndicatorManager.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OverrideIndicatorManager.java index 8777b7b55a1..1b2e30b8d60 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OverrideIndicatorManager.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/editor/OverrideIndicatorManager.java @@ -29,6 +29,7 @@ import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTDeclarator; import org.eclipse.cdt.core.dom.ast.IASTFileLocation; +import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTNode; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; import org.eclipse.cdt.core.dom.ast.IBinding; @@ -125,30 +126,33 @@ public class OverrideIndicatorManager implements ICReconcilingListener { return PROCESS_CONTINUE; } IASTDeclarator decl = ASTQueries.findInnermostDeclarator(declarator); - IBinding binding = decl.getName().resolveBinding(); - if (binding instanceof ICPPMethod) { - ICPPMethod method = (ICPPMethod) binding; - try { - ICPPMethod overriddenMethod = testForOverride(method, declarator); - if (overriddenMethod != null) { - try { - ICElementHandle baseDeclaration = IndexUI.findAnyDeclaration(index, null, overriddenMethod); - if (baseDeclaration == null) { - ICElementHandle[] allDefinitions = IndexUI.findAllDefinitions(index, overriddenMethod); - if (allDefinitions.length > 0) { - baseDeclaration = allDefinitions[0]; + IASTName name = decl.getName(); + if (name != null) { + IBinding binding = name.resolveBinding(); + if (binding instanceof ICPPMethod) { + ICPPMethod method = (ICPPMethod) binding; + try { + ICPPMethod overriddenMethod = testForOverride(method, declarator); + if (overriddenMethod != null) { + try { + ICElementHandle baseDeclaration = IndexUI.findAnyDeclaration(index, null, overriddenMethod); + if (baseDeclaration == null) { + ICElementHandle[] allDefinitions = IndexUI.findAllDefinitions(index, overriddenMethod); + if (allDefinitions.length > 0) { + baseDeclaration = allDefinitions[0]; + } } + + OverrideIndicator indicator = new OverrideIndicator(annotationKind, annotationMessage, baseDeclaration); + + IASTFileLocation fileLocation = declarator.getFileLocation(); + Position position = new Position(fileLocation.getNodeOffset(), fileLocation.getNodeLength()); + annotationMap.put(indicator, position); + } catch (CoreException e) { } - - OverrideIndicator indicator = new OverrideIndicator(annotationKind, annotationMessage, baseDeclaration); - - IASTFileLocation fileLocation = declarator.getFileLocation(); - Position position = new Position(fileLocation.getNodeOffset(), fileLocation.getNodeLength()); - annotationMap.put(indicator, position); - } catch (CoreException e) { } + } catch (DOMException e) { } - } catch (DOMException e) { } } return PROCESS_CONTINUE;