1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Bug 248149.

This commit is contained in:
Sergey Prigogin 2008-09-22 16:24:55 +00:00
parent 0ecc8782a4
commit e593e311fa

View file

@ -31,7 +31,6 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceProxy; import org.eclipse.core.resources.IResourceProxy;
import org.eclipse.core.resources.IResourceProxyVisitor; import org.eclipse.core.resources.IResourceProxyVisitor;
import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
@ -234,7 +233,7 @@ public class ErrorParserManager extends OutputStream {
} }
if (obj instanceof IFile) { if (obj instanceof IFile) {
IFile file = (IFile) obj; IFile file = (IFile) obj;
if (isPossibleMatch(path, file.getLocation())) { if (isPossibleMatch(path, file)) {
return file; return file;
} }
return null; return null;
@ -243,7 +242,7 @@ public class ErrorParserManager extends OutputStream {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
Collection<IFile> files = (Collection<IFile>) obj; Collection<IFile> files = (Collection<IFile>) obj;
for (IFile file : files) { for (IFile file : files) {
if (isPossibleMatch(path, file.getLocation())) { if (isPossibleMatch(path, file)) {
if (matchingFile != null) { if (matchingFile != null) {
return null; // Ambiguous match 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 * Checks if a file system path {@code location} may point to a workspace {@code resource}.
* file as an absolute file system path {@code absoluteLocation}.
* @param location an absolute or relative file system path. * @param location an absolute or relative file system path.
* @param absoluteLocation an absolute file system path. * @param resource a workspace resource.
* @return {@code true} if * @return {@code true} if {@code location} may point to {@code resource}.
*/ */
private boolean isPossibleMatch(IPath location, IPath absoluteLocation) { private static boolean isPossibleMatch(IPath location, IResource resource) {
Assert.isLegal(absoluteLocation.isAbsolute()); IPath resourceLocation = resource.getLocation();
if (resourceLocation == null) {
return false;
}
if (location.isAbsolute()) { if (location.isAbsolute()) {
return location.equals(absoluteLocation); return location.equals(resourceLocation);
} else { } else {
int prefixLen = absoluteLocation.segmentCount() - location.segmentCount(); int prefixLen = resourceLocation.segmentCount() - location.segmentCount();
return prefixLen >= 0 && absoluteLocation.removeFirstSegments(prefixLen).equals(location); return prefixLen >= 0 && resourceLocation.removeFirstSegments(prefixLen).equals(location);
} }
} }