diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMMacro.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMMacro.java index 78df7d78504..16dd0a893ea 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMMacro.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMMacro.java @@ -37,6 +37,7 @@ import org.eclipse.cdt.internal.core.pdom.PDOM; import org.eclipse.cdt.internal.core.pdom.db.Database; import org.eclipse.cdt.internal.core.pdom.db.IString; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; /** * Represents macro definitions. They are stored with the file and with a PDOMMacroContainer. @@ -273,14 +274,15 @@ public class PDOMMacro implements IIndexMacro, IPDOMBinding, IASTFileLocation { public String getFileName() { try { - PDOMFile file = getFile(); + IIndexFile file = getFile(); if (file == null) { return null; } - // We need to spec. what this method can return to know + // We need to specify what this method can return to know // how to implement this. Existing implementations return // the absolute path, so here we attempt to do the same. - return IndexLocationFactory.getAbsolutePath(file.getLocation()).toOSString(); + IPath location = IndexLocationFactory.getAbsolutePath(file.getLocation()); + return location != null ? location.toOSString() : null; } catch (CoreException e) { CCorePlugin.log(e); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMMacroReferenceName.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMMacroReferenceName.java index 367bfcf0e1a..a0f4f0b1a8a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMMacroReferenceName.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMMacroReferenceName.java @@ -14,6 +14,7 @@ package org.eclipse.cdt.internal.core.pdom.dom; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.ast.IASTFileLocation; import org.eclipse.cdt.core.dom.ast.IASTName; +import org.eclipse.cdt.core.index.IIndexFile; import org.eclipse.cdt.core.index.IIndexName; import org.eclipse.cdt.core.index.IndexLocationFactory; import org.eclipse.cdt.core.parser.util.CharArrayUtils; @@ -23,6 +24,7 @@ import org.eclipse.cdt.internal.core.index.IIndexFragmentName; import org.eclipse.cdt.internal.core.pdom.PDOM; import org.eclipse.cdt.internal.core.pdom.db.Database; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; /** * Represents declarations, definitions and references to bindings, except for macros. @@ -174,14 +176,15 @@ public final class PDOMMacroReferenceName implements IIndexFragmentName, IASTFil public String getFileName() { try { - PDOMFile file = getFile(); + IIndexFile file = getFile(); if (file == null) { return null; } - // We need to spec. what this method can return to know + // We need to specify what this method can return to know // how to implement this. Existing implementations return // the absolute path, so here we attempt to do the same. - return IndexLocationFactory.getAbsolutePath(file.getLocation()).toOSString(); + IPath location = IndexLocationFactory.getAbsolutePath(file.getLocation()); + return location != null ? location.toOSString() : null; } catch (CoreException e) { CCorePlugin.log(e); } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMName.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMName.java index 88c3937d472..e61707a97a5 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMName.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMName.java @@ -16,6 +16,7 @@ import java.util.ArrayList; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.dom.ast.IASTFileLocation; import org.eclipse.cdt.core.dom.ast.IASTName; +import org.eclipse.cdt.core.index.IIndexFile; import org.eclipse.cdt.core.index.IIndexName; import org.eclipse.cdt.core.index.IndexLocationFactory; import org.eclipse.cdt.core.parser.util.CharArrayUtils; @@ -24,6 +25,7 @@ import org.eclipse.cdt.internal.core.index.IIndexFragmentName; import org.eclipse.cdt.internal.core.pdom.PDOM; import org.eclipse.cdt.internal.core.pdom.db.Database; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; /** * @author Doug Schaefer @@ -281,14 +283,15 @@ public final class PDOMName implements IIndexFragmentName, IASTFileLocation { public String getFileName() { try { - PDOMFile file = getFile(); + IIndexFile file = getFile(); if (file == null) { return null; } - // We need to spec. what this method can return to know + // We need to specify what this method can return to know // how to implement this. Existing implementations return // the absolute path, so here we attempt to do the same. - return IndexLocationFactory.getAbsolutePath(file.getLocation()).toOSString(); + IPath location = IndexLocationFactory.getAbsolutePath(file.getLocation()); + return location != null ? location.toOSString() : null; } catch (CoreException e) { CCorePlugin.log(e); }