1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

Bug 264704 Error parsing: if failing to resolve absolute IPath, search all workspace projects for IPath.

This commit is contained in:
James Blackburn 2009-06-03 19:49:56 +00:00
parent c6f7acc9b2
commit 08b56873fd
2 changed files with 27 additions and 1 deletions

View file

@ -1239,4 +1239,23 @@ public class ErrorParserFileMatchingTest extends TestCase {
}
}
/**
* Checks if a file from error output can be found.
*
* @throws Exception...
*/
public void testMappedRemoteAbsolutePath_Bug264704() throws Exception {
ResourceHelper.createFolder(fProject, "Folder");
ResourceHelper.createFolder(fProject, "Folder/AbsoluteRemoteFolder");
IFile file = ResourceHelper.createFile(fProject, "Folder/AbsoluteRemoteFolder/testMappedRemoteAbsolutePath.h");
parseOutput("/AbsoluteRemoteFolder/testMappedRemoteAbsolutePath.h:1:error");
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
assertEquals("L/FindMatchingFilesTest/Folder/AbsoluteRemoteFolder/testMappedRemoteAbsolutePath.h",problemMarkerInfo.file.toString());
assertEquals(1,problemMarkerInfo.lineNumber);
assertEquals("error",problemMarkerInfo.description);
}
}

View file

@ -31,6 +31,7 @@ import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceProxy;
import org.eclipse.core.resources.IResourceProxyVisitor;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
@ -342,11 +343,17 @@ public class ErrorParserManager extends OutputStream {
IFile file = findFileInWorkspace(path);
// Try to find best match considering known partial path
if (file==null && !path.isAbsolute()) {
if (file==null) {
IProject[] prjs = new IProject[] { fProject };
IFile[] files = ResourceLookup.findFilesByName(path, prjs, false);
if (files.length == 0)
files = ResourceLookup.findFilesByName(path, prjs, /* ignoreCase */ true);
if (files.length == 0) {
prjs = ResourcesPlugin.getWorkspace().getRoot().getProjects();
files = ResourceLookup.findFilesByName(path, prjs, false);
if (files.length == 0)
files = ResourceLookup.findFilesByName(path, prjs, /* ignoreCase */ true);
}
if (files.length == 1)
file = files[0];
}