mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 06:02:11 +02:00
- added headless launch support (application), based on patch of Francois Rigault
This commit is contained in:
parent
a774350786
commit
e93f96dd51
5 changed files with 125 additions and 6 deletions
|
@ -1,4 +1,4 @@
|
|||
#Tue Jun 02 17:09:29 EDT 2009
|
||||
#Mon Aug 10 14:23:53 EDT 2009
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
|
||||
|
|
|
@ -53,5 +53,20 @@
|
|||
|
||||
</category>
|
||||
</extension>
|
||||
|
||||
<extension
|
||||
id="application"
|
||||
point="org.eclipse.core.runtime.applications">
|
||||
<application
|
||||
cardinality="singleton-global"
|
||||
thread="main"
|
||||
visible="true">
|
||||
<run
|
||||
class="org.eclipse.cdt.codan.core.CodanApplication">
|
||||
</run>
|
||||
</application>
|
||||
</extension>
|
||||
|
||||
|
||||
|
||||
</plugin>
|
||||
|
|
|
@ -0,0 +1,95 @@
|
|||
package org.eclipse.cdt.codan.core;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.eclipse.cdt.codan.core.builder.CodanBuilder;
|
||||
import org.eclipse.cdt.codan.core.model.CodanProblemReporter;
|
||||
import org.eclipse.cdt.codan.core.model.CodanRuntime;
|
||||
import org.eclipse.core.resources.IFile;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||
import org.eclipse.core.resources.ResourcesPlugin;
|
||||
import org.eclipse.equinox.app.IApplication;
|
||||
import org.eclipse.equinox.app.IApplicationContext;
|
||||
|
||||
public class CodanApplication implements IApplication {
|
||||
private Collection<String> projects = new ArrayList<String>();
|
||||
private boolean verbose = false;
|
||||
private boolean all = false;
|
||||
|
||||
public Object start(IApplicationContext context) throws Exception {
|
||||
String[] args = (String[]) context.getArguments().get(
|
||||
"application.args");
|
||||
if (args == null || args.length == 0) {
|
||||
help();
|
||||
return EXIT_OK;
|
||||
}
|
||||
extractArguments(args);
|
||||
CodanBuilder codanBuilder = new CodanBuilder();
|
||||
CodanRuntime runtime = CodanRuntime.getInstance();
|
||||
runtime.setProblemReporter(new CodanProblemReporter() {
|
||||
@Override
|
||||
public void reportProblem(String id, IFile file, int lineNumber,
|
||||
String message) {
|
||||
System.out.println(file.getLocation() + ":" + lineNumber + ": "
|
||||
+ message);
|
||||
}
|
||||
});
|
||||
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
|
||||
if (all) {
|
||||
log("Launching analysis on workspace");
|
||||
root.accept(codanBuilder.new CodanResourceVisitor());
|
||||
} else {
|
||||
for (String project : projects) {
|
||||
log("Launching analysis on project " + project);
|
||||
IProject wProject = root.getProject(project);
|
||||
if (!wProject.exists()) {
|
||||
System.err.println("Error: project " + project
|
||||
+ " does not exist");
|
||||
continue;
|
||||
}
|
||||
wProject.accept(codanBuilder.new CodanResourceVisitor());
|
||||
}
|
||||
}
|
||||
return EXIT_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string
|
||||
*/
|
||||
private void log(String string) {
|
||||
if (verbose)
|
||||
System.err.println(string);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param args
|
||||
*/
|
||||
private void extractArguments(String[] args) {
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
String string = args[i];
|
||||
if (string.equals("-verbose")) {
|
||||
verbose = true;
|
||||
} else if (string.equals("-all")) {
|
||||
all = true;
|
||||
} else {
|
||||
projects.add(string);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private void help() {
|
||||
System.out.println("Usage: [options] <project1> <project2> ...");
|
||||
System.out.println("Options:");
|
||||
System.out.println(" -all - run on all projects in workspace");
|
||||
System.out.println(" -verbose - print extra build information");
|
||||
}
|
||||
|
||||
public void stop() {
|
||||
// nothing
|
||||
}
|
||||
}
|
|
@ -34,13 +34,17 @@ public class CodanProblemReporter {
|
|||
return; // skip
|
||||
int severity = problem.getSeverity().intValue();
|
||||
// Do not put in duplicates
|
||||
IMarker[] cur = file.findMarkers(GENERIC_CODE_ANALYSIS_MARKER_TYPE, false, IResource.DEPTH_ZERO);
|
||||
IMarker[] cur = file.findMarkers(GENERIC_CODE_ANALYSIS_MARKER_TYPE,
|
||||
false, IResource.DEPTH_ZERO);
|
||||
if (cur != null) {
|
||||
for (IMarker element : cur) {
|
||||
int line = ((Integer) element.getAttribute(IMarker.LINE_NUMBER)).intValue();
|
||||
if (line==lineNumber) {
|
||||
String mesg = (String) element.getAttribute(IMarker.MESSAGE);
|
||||
int sev = ((Integer) element.getAttribute(IMarker.SEVERITY)).intValue();
|
||||
int line = ((Integer) element
|
||||
.getAttribute(IMarker.LINE_NUMBER)).intValue();
|
||||
if (line == lineNumber) {
|
||||
String mesg = (String) element
|
||||
.getAttribute(IMarker.MESSAGE);
|
||||
int sev = ((Integer) element
|
||||
.getAttribute(IMarker.SEVERITY)).intValue();
|
||||
if (sev == severity && mesg.equals(message))
|
||||
return;
|
||||
}
|
||||
|
@ -64,6 +68,7 @@ public class CodanProblemReporter {
|
|||
file.deleteMarkers(GENERIC_CODE_ANALYSIS_MARKER_TYPE, false,
|
||||
IResource.DEPTH_ZERO);
|
||||
} catch (CoreException ce) {
|
||||
ce.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,10 @@ public class CodanRuntime {
|
|||
return problemReporter;
|
||||
}
|
||||
|
||||
public void setProblemReporter(CodanProblemReporter reporter) {
|
||||
problemReporter = reporter;
|
||||
}
|
||||
|
||||
public static CodanRuntime getInstance() {
|
||||
return instance;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue