From d4841209b5e16f429037fdb601c54554d3c21cb5 Mon Sep 17 00:00:00 2001 From: Nathan Ridge Date: Thu, 27 Apr 2017 21:27:42 -0400 Subject: [PATCH] Bug 515343 - NPE in NamespaceHelper.checkFileNameAndLocation() Change-Id: Id281e1cd8ec189e214dcfeffb6d238b66c87050e --- .../cdt/internal/ui/refactoring/utils/NamespaceHelper.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/NamespaceHelper.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/NamespaceHelper.java index a595ca8fbfb..c8db2fbf389 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/NamespaceHelper.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/refactoring/utils/NamespaceHelper.java @@ -18,6 +18,7 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier; +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.IASTNode.CopyStyle; @@ -79,7 +80,11 @@ public class NamespaceHelper { } private static boolean checkFileNameAndLocation(final IPath path, final int offset, IASTNode namespace) { - boolean fileNameOk = namespace.getFileLocation().getFileName().endsWith(path.toOSString()); + IASTFileLocation fileLoc = namespace.getFileLocation(); + if (fileLoc == null) { + return false; + } + boolean fileNameOk = fileLoc.getFileName().endsWith(path.toOSString()); if (!fileNameOk) { return false; }