|
Lines 14-19
Link Here
|
| 14 |
import java.io.IOException; |
14 |
import java.io.IOException; |
| 15 |
import java.io.OutputStream; |
15 |
import java.io.OutputStream; |
| 16 |
import java.util.ArrayList; |
16 |
import java.util.ArrayList; |
|
|
17 |
import java.util.Collection; |
| 17 |
import java.util.HashMap; |
18 |
import java.util.HashMap; |
| 18 |
import java.util.Iterator; |
19 |
import java.util.Iterator; |
| 19 |
import java.util.LinkedHashMap; |
20 |
import java.util.LinkedHashMap; |
|
Lines 42-49
Link Here
|
| 42 |
|
43 |
|
| 43 |
private IProject fProject; |
44 |
private IProject fProject; |
| 44 |
private IMarkerGenerator fMarkerGenerator; |
45 |
private IMarkerGenerator fMarkerGenerator; |
| 45 |
private Map fFilesInProject; |
46 |
// Maps a file name without directory to a IFile object or a list of a IFile objects. |
| 46 |
private List fNameConflicts; |
47 |
private Map fFilesInProject; // Files or lists of files keyed by the file name |
| 47 |
|
48 |
|
| 48 |
private Map fErrorParsers; |
49 |
private Map fErrorParsers; |
| 49 |
private ArrayList fErrors; |
50 |
private ArrayList fErrors; |
|
Lines 88-94
Link Here
|
| 88 |
|
89 |
|
| 89 |
private void initErrorParserManager(IPath workingDirectory) { |
90 |
private void initErrorParserManager(IPath workingDirectory) { |
| 90 |
fFilesInProject = new HashMap(); |
91 |
fFilesInProject = new HashMap(); |
| 91 |
fNameConflicts = new ArrayList(); |
|
|
| 92 |
fDirectoryStack = new Vector(); |
92 |
fDirectoryStack = new Vector(); |
| 93 |
fErrors = new ArrayList(); |
93 |
fErrors = new ArrayList(); |
| 94 |
|
94 |
|
|
Lines 98-106
Link Here
|
| 98 |
|
98 |
|
| 99 |
for (int i = 0; i < collectedFiles.size(); i++) { |
99 |
for (int i = 0; i < collectedFiles.size(); i++) { |
| 100 |
IFile file = (IFile) collectedFiles.get(i); |
100 |
IFile file = (IFile) collectedFiles.get(i); |
| 101 |
Object existing = fFilesInProject.put(file.getName(), file); |
101 |
String filename = file.getName(); |
|
|
102 |
Object existing = fFilesInProject.put(filename, file); |
| 102 |
if (existing != null) { |
103 |
if (existing != null) { |
| 103 |
fNameConflicts.add(file.getName()); |
104 |
Collection files; |
|
|
105 |
if (existing instanceof IFile) { |
| 106 |
files = new ArrayList(); |
| 107 |
files.add(existing); |
| 108 |
} else { |
| 109 |
files = (Collection) existing; |
| 110 |
} |
| 111 |
files.add(file); |
| 112 |
fFilesInProject.put(filename, files); |
| 104 |
} |
113 |
} |
| 105 |
} |
114 |
} |
| 106 |
} |
115 |
} |
|
Lines 233-243
Link Here
|
| 233 |
} |
242 |
} |
| 234 |
|
243 |
|
| 235 |
/** |
244 |
/** |
| 236 |
* Called by the error parsers. |
245 |
* Returns the project file with the given name if that file can be uniquely identified. |
|
|
246 |
* Otherwise returns <code>null</code>. |
| 237 |
*/ |
247 |
*/ |
| 238 |
public IFile findFileName(String fileName) { |
248 |
public IFile findFileName(String fileName) { |
| 239 |
IPath path = new Path(fileName); |
249 |
IPath path = new Path(fileName); |
| 240 |
return (IFile) fFilesInProject.get(path.lastSegment()); |
250 |
Object obj = fFilesInProject.get(path.lastSegment()); |
|
|
251 |
if (obj == null || obj instanceof IFile) { |
| 252 |
return (IFile) obj; |
| 253 |
} |
| 254 |
Collection files = (Collection) obj; |
| 255 |
IFile matchingFile = null; |
| 256 |
for (Iterator it = files.iterator(); it.hasNext();) { |
| 257 |
IFile file = (IFile) it.next(); |
| 258 |
IPath location = file.getLocation(); |
| 259 |
boolean match = false; |
| 260 |
if (path.isAbsolute()) { |
| 261 |
match = path.equals(location); |
| 262 |
} else { |
| 263 |
int prefixLen = location.segmentCount() - path.segmentCount(); |
| 264 |
match = prefixLen >= 0 && location.removeFirstSegments(prefixLen).equals(path); |
| 265 |
} |
| 266 |
if (match) { |
| 267 |
if (matchingFile != null) { |
| 268 |
return null; // Ambiguous match |
| 269 |
} |
| 270 |
matchingFile = file; |
| 271 |
} |
| 272 |
} |
| 273 |
return matchingFile; |
| 241 |
} |
274 |
} |
| 242 |
|
275 |
|
| 243 |
protected IFile findFileInWorkspace(IPath path) { |
276 |
protected IFile findFileInWorkspace(IPath path) { |
|
Lines 263-274
Link Here
|
| 263 |
} |
296 |
} |
| 264 |
|
297 |
|
| 265 |
/** |
298 |
/** |
| 266 |
* Called by the error parsers. |
299 |
* Returns <code>true</code> if the project contains more than one file with the given name. |
| 267 |
*/ |
300 |
*/ |
| 268 |
public boolean isConflictingName(String fileName) { |
301 |
// public boolean isConflictingName(String fileName) { |
| 269 |
IPath path = new Path(fileName); |
302 |
// IPath path = new Path(fileName); |
| 270 |
return fNameConflicts.contains(path.lastSegment()); |
303 |
// Object obj = fFilesInProject.get(path.lastSegment()); |
| 271 |
} |
304 |
// return obj != null && !(obj instanceof IFile); |
|
|
305 |
// } |
| 272 |
|
306 |
|
| 273 |
/** |
307 |
/** |
| 274 |
* Called by the error parsers. |
308 |
* Called by the error parsers. |