1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-04 06:45:43 +02:00

2004-11-14 Alain Magloire

Fix for PR 77546.
	Make the error parser manager faster by
	using IResourceProxyVisitor to get the files.
	Use eoParser.findFileName() faster.
	* src/org/eclipse/cdt/core/ErrorParserManager.java
	* src/org/eclipse/cdt/core/internal/errorparsers/GASErrorParser.java
	* src/org/eclipse/cdt/core/internal/errorparsers/GCCErrorParser.java
	* src/org/eclipse/cdt/core/internal/errorparsers/GLDErrorarser.java
This commit is contained in:
Alain Magloire 2004-11-15 03:41:14 +00:00
parent 40c7fa80a3
commit 757c7b4860
5 changed files with 97 additions and 36 deletions

View file

@ -1,3 +1,13 @@
2004-11-14 Alain Magloire
Fix for PR 77546.
Make the error parser manager faster by
using IResourceProxyVisitor to get the files.
Use eoParser.findFileName() faster.
* src/org/eclipse/cdt/core/ErrorParserManager.java
* src/org/eclipse/cdt/core/internal/errorparsers/GASErrorParser.java
* src/org/eclipse/cdt/core/internal/errorparsers/GCCErrorParser.java
* src/org/eclipse/cdt/core/internal/errorparsers/GLDErrorarser.java
2004-11-11 Alain Magloire
PR 78573, patch from Brad Jarvinen
* src/org/eclipse/cdt/internal/errorparser/VCErroParser.java

View file

@ -17,10 +17,11 @@ import java.util.Map;
import java.util.Vector;
import org.eclipse.cdt.core.resources.ACBuilder;
import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IResourceProxy;
import org.eclipse.core.resources.IResourceProxyVisitor;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
@ -83,19 +84,15 @@ public class ErrorParserManager extends OutputStream {
fDirectoryStack = new Vector();
fErrors = new ArrayList();
// prepare file lists
fFilesInProject.clear();
fNameConflicts.clear();
List collectedFiles = new ArrayList();
fBaseDirectory = (workingDirectory == null || workingDirectory.isEmpty()) ? fProject.getLocation() : workingDirectory;
collectFiles(fProject, collectedFiles);
for (int i = 0; i < collectedFiles.size(); i++) {
IFile curr = (IFile) collectedFiles.get(i);
Object existing = fFilesInProject.put(curr.getName(), curr);
IFile file = (IFile) collectedFiles.get(i);
Object existing = fFilesInProject.put(file.getName(), file);
if (existing != null) {
fNameConflicts.add(curr.getName());
fNameConflicts.add(file.getName());
}
}
}
@ -156,17 +153,17 @@ public class ErrorParserManager extends OutputStream {
}
}
protected void collectFiles(IContainer parent, List result) {
protected void collectFiles(IProject parent, final List result) {
try {
IResource[] resources = parent.members();
for (int i = 0; i < resources.length; i++) {
IResource resource = resources[i];
if (resource instanceof IFile) {
result.add(resource);
} else if (resource instanceof IContainer) {
collectFiles((IContainer) resource, result);
parent.accept(new IResourceProxyVisitor() {
public boolean visit(IResourceProxy proxy) throws CoreException {
if (proxy.getType() == IResource.FILE) {
result.add(proxy.requestResource());
return false;
}
return true;
}
}
}, IResource.NONE);
} catch (CoreException e) {
CCorePlugin.log(e.getStatus());
}

View file

@ -41,11 +41,18 @@ public class GASErrorParser implements IErrorParser {
desc = line.substring(secondColon + 2);
}
}
file = eoParser.findFilePath(fileName);
file = eoParser.findFileName(fileName);
}
}
boolean isConflicting = false;
if (file != null) {
isConflicting = eoParser.isConflictingName(fileName);
file = null;
} else {
file = eoParser.findFileName(fileName);
}
if (file == null) {
desc = fileName + " " + desc; //$NON-NLS-1$
desc = fileName + ":" + desc; //$NON-NLS-1$
}
eoParser.generateMarker(file, num, desc, severity, null);
}

View file

@ -9,6 +9,8 @@ import org.eclipse.cdt.core.ErrorParserManager;
import org.eclipse.cdt.core.IErrorParser;
import org.eclipse.cdt.core.IMarkerGenerator;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
public class GCCErrorParser implements IErrorParser {
@ -211,16 +213,39 @@ public class GCCErrorParser implements IErrorParser {
}
}
IFile file = eoParser.findFilePath(fileName);
if (file == null) {
// Parse the entire project.
file = eoParser.findFileName(fileName);
if (file != null) {
// If there is a conflict set the error on the project.
if (eoParser.isConflictingName(fileName)) {
desc = "*" + desc; //$NON-NLS-1$
file = null;
// The pattern is to generall we have to guard:
// Before making this pattern a marker we do one more check
// The fileName that we extract __must__ look like a valid file name.
// We been having to much bad hits with patterns like
// /bin/sh ../libtool --mode=link gcc -version-info 0:1:0 foo.lo var.lo
// Things like libtool that will fool the parser because of "0:1:0"
if (!Path.EMPTY.isValidPath(fileName)) {
return false;
}
IFile file = eoParser.findFileName(fileName);
if (file != null) {
if (eoParser.isConflictingName(fileName)) {
desc = "[Conflicting names: " + fileName + " ] " + desc; //$NON-NLS-1$ //$NON-NLS-2$
file = null;
}
} else {
file = eoParser.findFilePath(fileName);
if (file == null) {
// one last try before bailing out we may be in a wrong
// directory. This will happen, for example in the Makefile:
// all: foo.c
// cd src3; gcc -c bar/foo.c
// the user do a cd(1).
IPath path = new Path(fileName);
if (path.segmentCount() > 1) {
String name = path.lastSegment();
file = eoParser.findFileName(fileName);
if (file != null) {
if (eoParser.isConflictingName(fileName)) {
desc = "[Conflicting names: " + name + " ] " + desc; //$NON-NLS-1$ //$NON-NLS-2$
file = null;
}
}
}
}
}

View file

@ -9,6 +9,7 @@ import org.eclipse.cdt.core.ErrorParserManager;
import org.eclipse.cdt.core.IErrorParser;
import org.eclipse.cdt.core.IMarkerGenerator;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.Path;
public class GLDErrorParser implements IErrorParser {
@ -38,11 +39,25 @@ public class GLDErrorParser implements IErrorParser {
previous = previous.substring(colon + 1);
}
// The pattern is to generall we have to guard:
// Before making this pattern a marker we do one more check
// The fileName that we extract __must__ look like a valid file name.
// We been having to much bad hits with patterns like
// /bin/sh ../libtool --mode=link gcc -version-info 0:1:0 foo.lo var.lo
// Things like libtool that will fool the parser because of "0:1:0"
if (!Path.EMPTY.isValidPath(fileName)) {
return false;
}
desc = "*" + previous + " " + desc; //$NON-NLS-1$ //$NON-NLS-2$
// Since we do not have any way to know the name of the C file
// where the undefined reference is refering we set the error
// on the project.
IFile file = eoParser.findFilePath(fileName);
IFile file = eoParser.findFileName(fileName);
if (file != null) {
if (eoParser.isConflictingName(fileName)) {
file = null;
}
} else {
file = eoParser.findFilePath(fileName);
}
if (file == null) {
desc = fileName + " " + desc; //$NON-NLS-1$
}
@ -56,7 +71,14 @@ public class GLDErrorParser implements IErrorParser {
}
String fileName = line.substring(0, firstColon);
IFile file = eoParser.findFilePath(fileName);
IFile file = eoParser.findFileName(fileName);
if (file != null) {
if (eoParser.isConflictingName(fileName)) {
file = null;
}
} else {
file = eoParser.findFilePath(fileName);
}
if (file == null) {
desc = fileName + " " + desc; //$NON-NLS-1$
}