Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] Fix for PR 45609

Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/ChangeLog,v
retrieving revision 1.171
diff -u -r1.171 ChangeLog
--- ChangeLog	27 Oct 2003 03:12:20 -0000	1.171
+++ ChangeLog	27 Oct 2003 17:47:00 -0000
@@ -1,3 +1,12 @@
+2003-10-27 Alain Magloire
+
+	Fix PR45609:
+	IWorkspaceRoot.getFileForLocation() does not work well when
+	the resource is linked, we should fall back to
+	IWorkspaceRoot.findFilesForLocation().
+
+	* src/org/eclipse/cdt/core/ErrorParserManager.java
+
 2003-10-23 Alain Magloire
 
 	Firing deltas on cpathentries modifications.
Index: src/org/eclipse/cdt/core/ErrorParserManager.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ErrorParserManager.java,v
retrieving revision 1.17
diff -u -r1.17 ErrorParserManager.java
--- src/org/eclipse/cdt/core/ErrorParserManager.java	24 Sep 2003 14:48:19 -0000	1.17
+++ src/org/eclipse/cdt/core/ErrorParserManager.java	27 Oct 2003 17:47:01 -0000
@@ -20,6 +20,7 @@
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.resources.IProject;
 import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRoot;
 import org.eclipse.core.runtime.CoreException;
 import org.eclipse.core.runtime.IPath;
 import org.eclipse.core.runtime.Path;
@@ -208,6 +209,28 @@
 		return (IFile) fFilesInProject.get(path.lastSegment());
 	}
 
+	protected IFile findFileInWorkspace(IPath path) {
+		IFile file = null;
+		if (path.isAbsolute()) {
+			IWorkspaceRoot root = fProject.getWorkspace().getRoot();
+			file =  root.getFileForLocation(path);
+			// It may be a link resource so we must check it also.
+			if (file == null) {
+				IFile[] files = root.findFilesForLocation(path);
+				for (int i = 0; i < files.length; i++) {
+					if (files[i].getProject().equals(fProject)) {
+						file = files[i];
+						break;
+					}
+				}
+			}
+
+		} else {
+			file = fProject.getFile(path);
+		}
+		return file;
+	}
+
 	/**
 	 * Called by the error parsers.
 	 */
@@ -235,9 +258,9 @@
 
 		IFile file = null;
 		// The workspace may throw an IllegalArgumentException
-		// Catch it and the parser will fallback to scan the entire project.
+		// Catch it and the parser should fallback to scan the entire project.
 		try {
-			file = (path.isAbsolute()) ? fProject.getWorkspace().getRoot().getFileForLocation(path) : fProject.getFile(path);
+			file = findFileInWorkspace(path);
 		} catch (Exception e) {
 		}
 
@@ -248,11 +271,9 @@
 			try {
 				String canon = f.getCanonicalPath();
 				path = new Path(canon);
-				file = (path.isAbsolute()) ? fProject.getWorkspace().getRoot().getFileForLocation(path) : fProject.getFile(path);
+				file = findFileInWorkspace(path);
 			} catch (IOException e1) {
 			}
-		} else {
-			return file;
 		}
 		return (file != null && file.exists()) ? file : null;
 	}



Back to the top