1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

bug 359140: Allow ErrorParserManager create workspace level markers

This commit is contained in:
Andrew Gvozdev 2011-09-27 16:41:31 -04:00
parent fe0611ef33
commit a4d4dec51f
3 changed files with 37 additions and 10 deletions

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008, 2010 QNX Software Systems and others.
* Copyright (c) 2008, 2011 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@ -30,6 +30,7 @@ import org.eclipse.cdt.core.model.ICProject;
import org.eclipse.cdt.core.testplugin.CProjectHelper;
import org.eclipse.cdt.core.testplugin.CTestPlugin;
import org.eclipse.core.internal.registry.ExtensionRegistry;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceDescription;
@ -305,4 +306,24 @@ public class ErrorParserManagerTest extends TestCase {
assertEquals(" la la 99 ",end);
}
public static class TestParser4 implements IErrorParser {
public boolean processLine(String line, ErrorParserManager eoParser) {
ProblemMarkerInfo problemMarkerInfo = new ProblemMarkerInfo(null, 0, "Workspace level marker", IMarker.SEVERITY_INFO, null);
eoParser.addProblemMarker(problemMarkerInfo);
return true;
}
}
public void testWorkspaceLevelError() throws IOException {
String id = addErrorParserExtension("test4", TestParser4.class);
epManager = new ErrorParserManager(null, markerGenerator, new String[] { id });
StringBuffer buf = new StringBuffer("errorT: ");
output(buf.toString()+"\n");
end();
assertEquals(1, errorList.size());
ProblemMarkerInfo problemMarkerInfo = errorList.get(0);
assertEquals("Workspace level marker", problemMarkerInfo.description);
assertTrue(problemMarkerInfo.file instanceof IWorkspaceRoot);
}
}

View file

@ -118,7 +118,7 @@ public class ErrorParserManager extends OutputStream {
* @param parsersIDs - array of error parsers' IDs.
*/
public ErrorParserManager(IProject project, IMarkerGenerator markerGenerator, String[] parsersIDs) {
this(project, project.getLocationURI(), markerGenerator, parsersIDs);
this(project, (URI)null, markerGenerator, parsersIDs);
}
/**
@ -154,8 +154,10 @@ public class ErrorParserManager extends OutputStream {
if (baseDirectoryURI != null)
fBaseDirectoryURI = baseDirectoryURI;
else
else if (project != null)
fBaseDirectoryURI = project.getLocationURI();
else
fBaseDirectoryURI = org.eclipse.core.filesystem.URIUtil.toURI(System.getProperty("user.dir")); // CWD //$NON-NLS-1$
}
private void enableErrorParsers(String[] parsersIDs) {
@ -420,12 +422,15 @@ outer:
// Try to find best match considering known partial path
if (file==null) {
path = path.setDevice(null);
IProject[] prjs = new IProject[] { fProject };
IFile[] files = ResourceLookup.findFilesByName(path, prjs, false);
if (files.length == 0)
files = ResourceLookup.findFilesByName(path, prjs, /* ignoreCase */ true);
if (files.length == 0) {
prjs = ResourcesPlugin.getWorkspace().getRoot().getProjects();
IFile[] files = null;
if (fProject != null) {
IProject[] prjs = new IProject[] { fProject };
files = ResourceLookup.findFilesByName(path, prjs, false);
if (files.length == 0)
files = ResourceLookup.findFilesByName(path, prjs, /* ignoreCase */ true);
}
if (files == null || files.length == 0) {
IProject[] prjs = ResourcesPlugin.getWorkspace().getRoot().getProjects();
files = ResourceLookup.findFilesByName(path, prjs, false);
if (files.length == 0)
files = ResourceLookup.findFilesByName(path, prjs, /* ignoreCase */ true);

View file

@ -19,6 +19,7 @@ import java.util.Map;
import org.eclipse.cdt.core.resources.ACBuilder;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
/**
@ -52,7 +53,7 @@ public class ProblemMarkerInfo {
* @param variableName - the name of the variable involved in the error if any.
*/
public ProblemMarkerInfo(IResource file, int lineNumber, String description, int severity, String variableName) {
this.file = file;
this.file = (file != null) ? file : ResourcesPlugin.getWorkspace().getRoot();
this.lineNumber = lineNumber;
this.description = description;
this.severity = severity;