From e593e311fa42c5d2c6a39ef014de247230d6eb2a Mon Sep 17 00:00:00 2001 From: Sergey Prigogin Date: Mon, 22 Sep 2008 16:24:55 +0000 Subject: [PATCH] Bug 248149. --- .../eclipse/cdt/core/ErrorParserManager.java | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ErrorParserManager.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ErrorParserManager.java index ea3419f6d33..11da9ca89fd 100644 --- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ErrorParserManager.java +++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ErrorParserManager.java @@ -31,7 +31,6 @@ import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResourceProxy; import org.eclipse.core.resources.IResourceProxyVisitor; import org.eclipse.core.resources.IWorkspaceRoot; -import org.eclipse.core.runtime.Assert; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; @@ -234,7 +233,7 @@ public class ErrorParserManager extends OutputStream { } if (obj instanceof IFile) { IFile file = (IFile) obj; - if (isPossibleMatch(path, file.getLocation())) { + if (isPossibleMatch(path, file)) { return file; } return null; @@ -243,7 +242,7 @@ public class ErrorParserManager extends OutputStream { @SuppressWarnings("unchecked") Collection files = (Collection) obj; for (IFile file : files) { - if (isPossibleMatch(path, file.getLocation())) { + if (isPossibleMatch(path, file)) { if (matchingFile != null) { return null; // Ambiguous match } @@ -254,19 +253,21 @@ public class ErrorParserManager extends OutputStream { } /** - * Checks if a file system path {@code location} may point to the same - * file as an absolute file system path {@code absoluteLocation}. + * Checks if a file system path {@code location} may point to a workspace {@code resource}. * @param location an absolute or relative file system path. - * @param absoluteLocation an absolute file system path. - * @return {@code true} if + * @param resource a workspace resource. + * @return {@code true} if {@code location} may point to {@code resource}. */ - private boolean isPossibleMatch(IPath location, IPath absoluteLocation) { - Assert.isLegal(absoluteLocation.isAbsolute()); + private static boolean isPossibleMatch(IPath location, IResource resource) { + IPath resourceLocation = resource.getLocation(); + if (resourceLocation == null) { + return false; + } if (location.isAbsolute()) { - return location.equals(absoluteLocation); + return location.equals(resourceLocation); } else { - int prefixLen = absoluteLocation.segmentCount() - location.segmentCount(); - return prefixLen >= 0 && absoluteLocation.removeFirstSegments(prefixLen).equals(location); + int prefixLen = resourceLocation.segmentCount() - location.segmentCount(); + return prefixLen >= 0 && resourceLocation.removeFirstSegments(prefixLen).equals(location); } }