mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fix for 208685.
This commit is contained in:
parent
8463aa5adf
commit
39dac301aa
3 changed files with 49 additions and 19 deletions
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* IBM Corporation - initial API and implementation
|
* IBM Corporation - initial API and implementation
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core;
|
package org.eclipse.cdt.core;
|
||||||
|
|
||||||
|
@ -14,6 +15,7 @@ import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
|
@ -42,8 +44,8 @@ public class ErrorParserManager extends OutputStream {
|
||||||
|
|
||||||
private IProject fProject;
|
private IProject fProject;
|
||||||
private IMarkerGenerator fMarkerGenerator;
|
private IMarkerGenerator fMarkerGenerator;
|
||||||
private Map fFilesInProject;
|
// Maps a file name without directory to a IFile object or a list of a IFile objects.
|
||||||
private List fNameConflicts;
|
private Map fFilesInProject; // Files or lists of files keyed by the file name
|
||||||
|
|
||||||
private Map fErrorParsers;
|
private Map fErrorParsers;
|
||||||
private ArrayList fErrors;
|
private ArrayList fErrors;
|
||||||
|
@ -88,7 +90,6 @@ public class ErrorParserManager extends OutputStream {
|
||||||
|
|
||||||
private void initErrorParserManager(IPath workingDirectory) {
|
private void initErrorParserManager(IPath workingDirectory) {
|
||||||
fFilesInProject = new HashMap();
|
fFilesInProject = new HashMap();
|
||||||
fNameConflicts = new ArrayList();
|
|
||||||
fDirectoryStack = new Vector();
|
fDirectoryStack = new Vector();
|
||||||
fErrors = new ArrayList();
|
fErrors = new ArrayList();
|
||||||
|
|
||||||
|
@ -98,9 +99,18 @@ public class ErrorParserManager extends OutputStream {
|
||||||
|
|
||||||
for (int i = 0; i < collectedFiles.size(); i++) {
|
for (int i = 0; i < collectedFiles.size(); i++) {
|
||||||
IFile file = (IFile) collectedFiles.get(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) {
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -168,7 +178,7 @@ public class ErrorParserManager extends OutputStream {
|
||||||
protected void collectFiles(IProject parent, final List result) {
|
protected void collectFiles(IProject parent, final List result) {
|
||||||
try {
|
try {
|
||||||
parent.accept(new IResourceProxyVisitor() {
|
parent.accept(new IResourceProxyVisitor() {
|
||||||
public boolean visit(IResourceProxy proxy) throws CoreException {
|
public boolean visit(IResourceProxy proxy) {
|
||||||
if (proxy.getType() == IResource.FILE) {
|
if (proxy.getType() == IResource.FILE) {
|
||||||
result.add(proxy.requestResource());
|
result.add(proxy.requestResource());
|
||||||
return false;
|
return false;
|
||||||
|
@ -233,11 +243,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) {
|
public IFile findFileName(String fileName) {
|
||||||
IPath path = new Path(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) {
|
protected IFile findFileInWorkspace(IPath path) {
|
||||||
|
@ -263,11 +297,12 @@ 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) {
|
public boolean isConflictingName(String fileName) {
|
||||||
IPath path = new Path(fileName);
|
IPath path = new Path(fileName);
|
||||||
return fNameConflicts.contains(path.lastSegment());
|
Object obj = fFilesInProject.get(path.lastSegment());
|
||||||
|
return obj != null && !(obj instanceof IFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -347,7 +382,6 @@ public class ErrorParserManager extends OutputStream {
|
||||||
hasErrors = true;
|
hasErrors = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called by the error parsers. Return the previous line, save in the working buffer.
|
* Called by the error parsers. Return the previous line, save in the working buffer.
|
||||||
*/
|
*/
|
||||||
|
@ -357,7 +391,7 @@ public class ErrorParserManager extends OutputStream {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Method setOutputStream.
|
* Method setOutputStream.
|
||||||
* @param cos
|
* @param os
|
||||||
*/
|
*/
|
||||||
public void setOutputStream(OutputStream os) {
|
public void setOutputStream(OutputStream os) {
|
||||||
outputStream = os;
|
outputStream = os;
|
||||||
|
|
|
@ -131,7 +131,7 @@ public class ErrorPattern {
|
||||||
IResource file = null;
|
IResource file = null;
|
||||||
if (fileName != null) {
|
if (fileName != null) {
|
||||||
file = eoParser.findFileName(fileName);
|
file = eoParser.findFileName(fileName);
|
||||||
if (file == null || eoParser.isConflictingName(fileName)) {
|
if (file == null) {
|
||||||
file = eoParser.findFilePath(fileName);
|
file = eoParser.findFilePath(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,11 +50,7 @@ public class GASErrorParser implements IErrorParser {
|
||||||
file = eoParser.findFileName(fileName);
|
file = eoParser.findFileName(fileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
boolean isConflicting = false;
|
if (file == null) {
|
||||||
if (file != null) {
|
|
||||||
isConflicting = eoParser.isConflictingName(fileName);
|
|
||||||
file = null;
|
|
||||||
} else {
|
|
||||||
file = eoParser.findFileName(fileName);
|
file = eoParser.findFileName(fileName);
|
||||||
}
|
}
|
||||||
if (file == null) {
|
if (file == null) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue