Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergey Prigogin2007-12-08 12:58:48 -0500
committerSergey Prigogin2007-12-08 12:58:48 -0500
commitd1ced6a47ba57c47b00aaeb117e84e4010851c2b (patch)
treedb6467157ab5e4529e43091f3e362233dbc253dd
parentc194265e35e9b98cbe34839a5fb99530100c1fbe (diff)
downloadorg.eclipse.cdt-d1ced6a47ba57c47b00aaeb117e84e4010851c2b.tar.gz
org.eclipse.cdt-d1ced6a47ba57c47b00aaeb117e84e4010851c2b.tar.xz
org.eclipse.cdt-d1ced6a47ba57c47b00aaeb117e84e4010851c2b.zip
Fix for 208685.
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/core/ErrorParserManager.java58
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/ErrorPattern.java2
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/GASErrorParser.java6
3 files changed, 48 insertions, 18 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 7a4a324107..ad171feb8d 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
@@ -14,6 +14,7 @@ import java.io.File;
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
@@ -42,8 +43,8 @@ public class ErrorParserManager extends OutputStream {
private IProject fProject;
private IMarkerGenerator fMarkerGenerator;
- private Map fFilesInProject;
- private List fNameConflicts;
+ // Maps a file name without directory to a IFile object or a list of a IFile objects.
+ private Map fFilesInProject; // Files or lists of files keyed by the file name
private Map fErrorParsers;
private ArrayList fErrors;
@@ -88,7 +89,6 @@ public class ErrorParserManager extends OutputStream {
private void initErrorParserManager(IPath workingDirectory) {
fFilesInProject = new HashMap();
- fNameConflicts = new ArrayList();
fDirectoryStack = new Vector();
fErrors = new ArrayList();
@@ -98,9 +98,18 @@ public class ErrorParserManager extends OutputStream {
for (int i = 0; i < collectedFiles.size(); i++) {
IFile file = (IFile) collectedFiles.get(i);
- Object existing = fFilesInProject.put(file.getName(), file);
+ String filename = file.getName();
+ Object existing = fFilesInProject.put(filename, file);
if (existing != null) {
- fNameConflicts.add(file.getName());
+ Collection files;
+ if (existing instanceof IFile) {
+ files = new ArrayList();
+ files.add(existing);
+ } else {
+ files = (Collection) existing;
+ }
+ files.add(file);
+ fFilesInProject.put(filename, files);
}
}
}
@@ -233,11 +242,35 @@ public class ErrorParserManager extends OutputStream {
}
/**
- * Called by the error parsers.
+ * Returns the project file with the given name if that file can be uniquely identified.
+ * Otherwise returns <code>null</code>.
*/
public IFile findFileName(String fileName) {
IPath path = new Path(fileName);
- return (IFile) fFilesInProject.get(path.lastSegment());
+ Object obj = fFilesInProject.get(path.lastSegment());
+ if (obj == null || obj instanceof IFile) {
+ return (IFile) obj;
+ }
+ Collection files = (Collection) obj;
+ IFile matchingFile = null;
+ for (Iterator it = files.iterator(); it.hasNext();) {
+ IFile file = (IFile) it.next();
+ IPath location = file.getLocation();
+ boolean match = false;
+ if (path.isAbsolute()) {
+ match = path.equals(location);
+ } else {
+ int prefixLen = location.segmentCount() - path.segmentCount();
+ match = prefixLen >= 0 && location.removeFirstSegments(prefixLen).equals(path);
+ }
+ if (match) {
+ if (matchingFile != null) {
+ return null; // Ambiguous match
+ }
+ matchingFile = file;
+ }
+ }
+ return matchingFile;
}
protected IFile findFileInWorkspace(IPath path) {
@@ -263,12 +296,13 @@ public class ErrorParserManager extends OutputStream {
}
/**
- * Called by the error parsers.
+ * Returns <code>true</code> if the project contains more than one file with the given name.
*/
- public boolean isConflictingName(String fileName) {
- IPath path = new Path(fileName);
- return fNameConflicts.contains(path.lastSegment());
- }
+// public boolean isConflictingName(String fileName) {
+// IPath path = new Path(fileName);
+// Object obj = fFilesInProject.get(path.lastSegment());
+// return obj != null && !(obj instanceof IFile);
+// }
/**
* Called by the error parsers.
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/ErrorPattern.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/ErrorPattern.java
index 5608bc5ae8..59f6c7f298 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/ErrorPattern.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/ErrorPattern.java
@@ -131,7 +131,7 @@ public class ErrorPattern {
IResource file = null;
if (fileName != null) {
file = eoParser.findFileName(fileName);
- if (file == null || eoParser.isConflictingName(fileName)) {
+ if (file == null) {
file = eoParser.findFilePath(fileName);
}
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/GASErrorParser.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/GASErrorParser.java
index c2ac13d593..f93d8d4bb4 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/GASErrorParser.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/errorparsers/GASErrorParser.java
@@ -50,11 +50,7 @@ public class GASErrorParser implements IErrorParser {
file = eoParser.findFileName(fileName);
}
}
- boolean isConflicting = false;
- if (file != null) {
- isConflicting = eoParser.isConflictingName(fileName);
- file = null;
- } else {
+ if (file == null) {
file = eoParser.findFileName(fileName);
}
if (file == null) {

Back to the top