From 2c8724af33ed987c19bb5b55a8a7232b5bfa2f9f Mon Sep 17 00:00:00 2001 From: James Blackburn Date: Thu, 4 Jun 2009 19:43:53 +0000 Subject: [PATCH] Bug 279155 Tweak JavaDoc on #findFileName --- .../eclipse/cdt/core/ErrorParserManager.java | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 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 5b32993e1c3..01c8fdc05a4 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 @@ -326,18 +326,27 @@ public class ErrorParserManager extends OutputStream { } /** - * Returns the file with the given name if that file can be uniquely identified. + * Returns the file with the given (partial) location if that file can be uniquely identified. * Otherwise returns {@code null}. + *

+ * The passed in String 'partialLoc' is treated as a partial filesystem location for the + * resource. Resolution is attempted with the following precedence:
+ * If partialLoc is an absolute fs location:
+ * - Resolve it to an IFile in the Project
+ * - Resolve it to an IFile in the Workspace
+ * If partialLoc is a relative path:
+ * - Resolve it relative to the Current Working Directory
+ * - Resolve just the segments provided
* - * @param fileName - file name could be plain file name, absolute path or partial path + * @param partialLoc - file name could be plain file name, absolute path or partial path * @return - file in the workspace or {@code null}. */ - public IFile findFileName(String fileName) { - if (fileName.equals(cachedFileName) && cachedWorkingDirectory != null && + public IFile findFileName(String partialLoc) { + if (partialLoc.equals(cachedFileName) && cachedWorkingDirectory != null && org.eclipse.core.filesystem.URIUtil.equals(getWorkingDirectoryURI(), cachedWorkingDirectory)) return cachedFile; - IPath path = new Path(fileName); + IPath path = new Path(partialLoc); // Try to find exact match. If path is not absolute - searching in working directory. IFile file = findFileInWorkspace(path); @@ -360,10 +369,10 @@ public class ErrorParserManager extends OutputStream { // Could be cygwin path if (file==null && isCygwin && path.isAbsolute()) { - file = findCygwinFile(fileName); + file = findCygwinFile(partialLoc); } - cachedFileName = fileName; + cachedFileName = partialLoc; cachedWorkingDirectory = getWorkingDirectoryURI(); cachedFile = file; return file;