Skip to main content
summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorSergey Prigogin2009-01-25 21:04:46 +0000
committerSergey Prigogin2009-01-25 21:04:46 +0000
commit8cfeac4de4424b6eb4b8a70430b03f488454fe26 (patch)
tree913384ece29899e389623c4a930ca2fb20b88f99 /core
parentf98c292b8d2bdebb7da3855ba0951d3ae4b8b03a (diff)
downloadorg.eclipse.cdt-8cfeac4de4424b6eb4b8a70430b03f488454fe26.tar.gz
org.eclipse.cdt-8cfeac4de4424b6eb4b8a70430b03f488454fe26.tar.xz
org.eclipse.cdt-8cfeac4de4424b6eb4b8a70430b03f488454fe26.zip
NPE protection.
Diffstat (limited to 'core')
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMMacro.java8
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMMacroReferenceName.java9
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/PDOMName.java9
3 files changed, 17 insertions, 9 deletions
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 189f426b14d..8ba0ac0575d 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. The latter also
@@ -273,14 +274,15 @@ public class PDOMMacro implements IIndexMacro, IIndexFragmentBinding, IASTFileLo
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 026ec8978d0..157bced2667 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.
@@ -165,14 +167,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 adf1247d9d0..cf9beaef08a 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.internal.core.index.IIndexFragment;
@@ -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;
/**
* @author Doug Schaefer
@@ -267,14 +269,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);
}

Back to the top