mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-19 23:15:24 +02:00
- optimized building
This commit is contained in:
parent
e750d3bff2
commit
404c5aba3c
6 changed files with 185 additions and 127 deletions
|
@ -45,7 +45,7 @@ public class CxxModelsCache {
|
||||||
if (!(celement instanceof ITranslationUnit))
|
if (!(celement instanceof ITranslationUnit))
|
||||||
return null; // not a C/C++ file
|
return null; // not a C/C++ file
|
||||||
this.file = file;
|
this.file = file;
|
||||||
System.err.println("Making ast for "+file);
|
//System.err.println("Making ast for "+file);
|
||||||
tu = (ITranslationUnit) celement;
|
tu = (ITranslationUnit) celement;
|
||||||
index = CCorePlugin.getIndexManager().getIndex(tu.getCProject());
|
index = CCorePlugin.getIndexManager().getIndex(tu.getCProject());
|
||||||
// lock the index for read access
|
// lock the index for read access
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.codan.core.model;
|
package org.eclipse.cdt.codan.core.model;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
|
@ -25,75 +26,106 @@ import org.eclipse.core.resources.IResource;
|
||||||
public interface ICheckersRegistry extends Iterable<IChecker> {
|
public interface ICheckersRegistry extends Iterable<IChecker> {
|
||||||
/**
|
/**
|
||||||
* Iterator for registered checkers
|
* Iterator for registered checkers
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public abstract Iterator<IChecker> iterator();
|
public abstract Iterator<IChecker> iterator();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add another checker
|
* Add another checker
|
||||||
|
*
|
||||||
* @param checker
|
* @param checker
|
||||||
*/
|
*/
|
||||||
public abstract void addChecker(IChecker checker);
|
public abstract void addChecker(IChecker checker);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add problem p with default category by category id into default profile, category must exists in default profile
|
* Add problem p with default category by category id into default profile,
|
||||||
* @param p - problem
|
* category must exists in default profile
|
||||||
* @param categoryId - category id
|
*
|
||||||
|
* @param p
|
||||||
|
* - problem
|
||||||
|
* @param categoryId
|
||||||
|
* - category id
|
||||||
*/
|
*/
|
||||||
public abstract void addProblem(IProblem p, String categoryId);
|
public abstract void addProblem(IProblem p, String categoryId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add subcategory with id categoryId into parent category,
|
* Add subcategory with id categoryId into parent category, if parent does
|
||||||
* if parent does not exist in default, profile - if not will be added to the root
|
* not exist in default, profile - if not will be added to the root
|
||||||
* @param category - new category
|
*
|
||||||
* @param parentCategoryId - parent category id
|
* @param category
|
||||||
|
* - new category
|
||||||
|
* @param parentCategoryId
|
||||||
|
* - parent category id
|
||||||
*/
|
*/
|
||||||
public abstract void addCategory(IProblemCategory category, String parentCategoryId);
|
public abstract void addCategory(IProblemCategory category,
|
||||||
|
String parentCategoryId);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add problem reference to a checker, i.e. claim that checker can produce this problem.
|
* Add problem reference to a checker, i.e. claim that checker can produce
|
||||||
* If checker does not claim any problems it cannot be enabled.
|
* this problem. If checker does not claim any problems it cannot be
|
||||||
* @param c - checker
|
* enabled.
|
||||||
* @param p - problem
|
*
|
||||||
|
* @param c
|
||||||
|
* - checker
|
||||||
|
* @param p
|
||||||
|
* - problem
|
||||||
*/
|
*/
|
||||||
public abstract void addRefProblem(IChecker c, IProblem p);
|
public void addRefProblem(IChecker c, IProblem p);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get default profile, default profile is kind of "Installation Default". Always the same, comes from default in checker extensions
|
* Return collection of problem that this checker can produce
|
||||||
|
*
|
||||||
|
* @param checker
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Collection<IProblem> getRefProblems(IChecker checker);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get default profile, default profile is kind of "Installation Default".
|
||||||
|
* Always the same, comes from default in checker extensions
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public abstract IProblemProfile getDefaultProfile();
|
public abstract IProblemProfile getDefaultProfile();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get workspace profile. User can change setting for workspace profile.
|
* Get workspace profile. User can change setting for workspace profile.
|
||||||
|
*
|
||||||
* @return profile
|
* @return profile
|
||||||
*/
|
*/
|
||||||
public abstract IProblemProfile getWorkspaceProfile();
|
public abstract IProblemProfile getWorkspaceProfile();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get resource profile. For example given directory can have different profile
|
* Get resource profile. For example given directory can have different
|
||||||
* than parent project.
|
* profile than parent project.
|
||||||
*
|
*
|
||||||
* @param element - resource
|
* @param element
|
||||||
|
* - resource
|
||||||
* @return profile
|
* @return profile
|
||||||
*/
|
*/
|
||||||
public abstract IProblemProfile getResourceProfile(IResource element);
|
public abstract IProblemProfile getResourceProfile(IResource element);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns profile working copy for given resource element. (If profile is not
|
* Returns profile working copy for given resource element. (If profile is
|
||||||
* specified for given element it will search for parent resource and so on).
|
* not specified for given element it will search for parent resource and so
|
||||||
|
* on).
|
||||||
|
*
|
||||||
* @param element
|
* @param element
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public abstract IProblemProfile getResourceProfileWorkingCopy(IResource element);
|
public abstract IProblemProfile getResourceProfileWorkingCopy(
|
||||||
|
IResource element);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set profile for resource.
|
* Set profile for resource.
|
||||||
|
*
|
||||||
* @noreference This method is not intended to be referenced by clients.
|
* @noreference This method is not intended to be referenced by clients.
|
||||||
* @param resource
|
* @param resource
|
||||||
* - resource
|
* - resource
|
||||||
* @param profile
|
* @param profile
|
||||||
* - problems profile
|
* - problems profile
|
||||||
*/
|
*/
|
||||||
public abstract void updateProfile(IResource resource, IProblemProfile profile);
|
public abstract void updateProfile(IResource resource,
|
||||||
|
IProblemProfile profile);
|
||||||
}
|
}
|
|
@ -14,6 +14,7 @@ import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
|
||||||
import org.eclipse.cdt.codan.core.CodanCorePlugin;
|
import org.eclipse.cdt.codan.core.CodanCorePlugin;
|
||||||
import org.eclipse.cdt.codan.core.PreferenceConstants;
|
import org.eclipse.cdt.codan.core.PreferenceConstants;
|
||||||
import org.eclipse.cdt.codan.core.model.CodanSeverity;
|
import org.eclipse.cdt.codan.core.model.CodanSeverity;
|
||||||
|
@ -420,4 +421,11 @@ public class CheckersRegisry implements Iterable<IChecker>, ICheckersRegistry {
|
||||||
// no problem is enabled for this checker, skip the checker
|
// no problem is enabled for this checker, skip the checker
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public int getCheckersSize() {
|
||||||
|
return checkers.size();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import org.eclipse.core.resources.IFile;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IWorkspaceRoot;
|
import org.eclipse.core.resources.IWorkspaceRoot;
|
||||||
import org.eclipse.core.resources.ResourcesPlugin;
|
import org.eclipse.core.resources.ResourcesPlugin;
|
||||||
|
import org.eclipse.core.runtime.NullProgressMonitor;
|
||||||
import org.eclipse.equinox.app.IApplication;
|
import org.eclipse.equinox.app.IApplication;
|
||||||
import org.eclipse.equinox.app.IApplicationContext;
|
import org.eclipse.equinox.app.IApplicationContext;
|
||||||
|
|
||||||
|
@ -25,7 +26,8 @@ public class CodanApplication implements IApplication {
|
||||||
private boolean all = false;
|
private boolean all = false;
|
||||||
|
|
||||||
public Object start(IApplicationContext context) throws Exception {
|
public Object start(IApplicationContext context) throws Exception {
|
||||||
String[] args = (String[]) context.getArguments().get("application.args"); //$NON-NLS-1$
|
String[] args = (String[]) context.getArguments().get(
|
||||||
|
"application.args"); //$NON-NLS-1$
|
||||||
if (args == null || args.length == 0) {
|
if (args == null || args.length == 0) {
|
||||||
help();
|
help();
|
||||||
return EXIT_OK;
|
return EXIT_OK;
|
||||||
|
@ -35,24 +37,27 @@ public class CodanApplication implements IApplication {
|
||||||
CodanRuntime runtime = CodanRuntime.getInstance();
|
CodanRuntime runtime = CodanRuntime.getInstance();
|
||||||
runtime.setProblemReporter(new CodanMarkerProblemReporter() {
|
runtime.setProblemReporter(new CodanMarkerProblemReporter() {
|
||||||
@Override
|
@Override
|
||||||
public void reportProblem(String id, int severity, IFile file, int lineNumber, int startChar, int endChar,
|
public void reportProblem(String id, int severity, IFile file,
|
||||||
String message) {
|
int lineNumber, int startChar, int endChar, String message) {
|
||||||
System.out.println(file.getLocation() + ":" + lineNumber + ": " + message);
|
System.out.println(file.getLocation() + ":" + lineNumber + ": "
|
||||||
|
+ message);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
|
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
|
||||||
if (all) {
|
if (all) {
|
||||||
log("Launching analysis on workspace");
|
log("Launching analysis on workspace");
|
||||||
root.accept(codanBuilder.new CodanResourceVisitor());
|
codanBuilder.processResource(root, new NullProgressMonitor());
|
||||||
} else {
|
} else {
|
||||||
for (String project : projects) {
|
for (String project : projects) {
|
||||||
log("Launching analysis on project " + project);
|
log("Launching analysis on project " + project);
|
||||||
IProject wProject = root.getProject(project);
|
IProject wProject = root.getProject(project);
|
||||||
if (!wProject.exists()) {
|
if (!wProject.exists()) {
|
||||||
System.err.println("Error: project " + project + " does not exist");
|
System.err.println("Error: project " + project
|
||||||
|
+ " does not exist");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
wProject.accept(codanBuilder.new CodanResourceVisitor());
|
codanBuilder.processResource(wProject,
|
||||||
|
new NullProgressMonitor());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return EXIT_OK;
|
return EXIT_OK;
|
||||||
|
@ -62,7 +67,8 @@ public class CodanApplication implements IApplication {
|
||||||
* @param string
|
* @param string
|
||||||
*/
|
*/
|
||||||
private void log(String string) {
|
private void log(String string) {
|
||||||
if (verbose) System.err.println(string);
|
if (verbose)
|
||||||
|
System.err.println(string);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -19,49 +19,43 @@ import org.eclipse.cdt.codan.core.model.ICodanBuilder;
|
||||||
import org.eclipse.cdt.codan.core.model.IProblemReporter;
|
import org.eclipse.cdt.codan.core.model.IProblemReporter;
|
||||||
import org.eclipse.cdt.codan.core.model.IProblemReporterPersistent;
|
import org.eclipse.cdt.codan.core.model.IProblemReporterPersistent;
|
||||||
import org.eclipse.cdt.codan.core.model.IRunnableInEditorChecker;
|
import org.eclipse.cdt.codan.core.model.IRunnableInEditorChecker;
|
||||||
import org.eclipse.cdt.codan.internal.core.model.CodanMarkerProblemReporter;
|
import org.eclipse.core.resources.IContainer;
|
||||||
import org.eclipse.core.resources.IProject;
|
import org.eclipse.core.resources.IProject;
|
||||||
import org.eclipse.core.resources.IResource;
|
import org.eclipse.core.resources.IResource;
|
||||||
import org.eclipse.core.resources.IResourceDelta;
|
import org.eclipse.core.resources.IResourceDelta;
|
||||||
import org.eclipse.core.resources.IResourceDeltaVisitor;
|
import org.eclipse.core.resources.IResourceDeltaVisitor;
|
||||||
import org.eclipse.core.resources.IResourceVisitor;
|
|
||||||
import org.eclipse.core.resources.IncrementalProjectBuilder;
|
import org.eclipse.core.resources.IncrementalProjectBuilder;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IProgressMonitor;
|
import org.eclipse.core.runtime.IProgressMonitor;
|
||||||
import org.eclipse.core.runtime.NullProgressMonitor;
|
import org.eclipse.core.runtime.SubProgressMonitor;
|
||||||
|
|
||||||
public class CodanBuilder extends IncrementalProjectBuilder implements
|
public class CodanBuilder extends IncrementalProjectBuilder implements
|
||||||
ICodanBuilder {
|
ICodanBuilder {
|
||||||
public static final String BUILDER_ID = "org.eclipse.cdt.codan.core.codanBuilder"; //$NON-NLS-1$
|
public static final String BUILDER_ID = "org.eclipse.cdt.codan.core.codanBuilder"; //$NON-NLS-1$
|
||||||
|
|
||||||
public class CodanDeltaVisitor implements IResourceDeltaVisitor {
|
public class CodanDeltaVisitor implements IResourceDeltaVisitor {
|
||||||
/*
|
private IProgressMonitor monitor;
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
/**
|
||||||
* @see
|
* @param monitor
|
||||||
* org.eclipse.core.resources.IResourceDeltaVisitor#visit(org.eclipse
|
|
||||||
* .core.resources.IResourceDelta)
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see
|
|
||||||
* org.eclipse.cdt.codan.internal.core.ICodanBuilder#visit(org.eclipse
|
|
||||||
* .core.resources.IResourceDelta)
|
|
||||||
*/
|
*/
|
||||||
|
public CodanDeltaVisitor(IProgressMonitor monitor) {
|
||||||
|
this.monitor = monitor;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean visit(IResourceDelta delta) throws CoreException {
|
public boolean visit(IResourceDelta delta) throws CoreException {
|
||||||
IResource resource = delta.getResource();
|
IResource resource = delta.getResource();
|
||||||
switch (delta.getKind()) {
|
switch (delta.getKind()) {
|
||||||
case IResourceDelta.ADDED:
|
case IResourceDelta.ADDED:
|
||||||
// handle added resource
|
// handle added resource
|
||||||
processResource(resource, new NullProgressMonitor());
|
processResource(resource, monitor);
|
||||||
break;
|
break;
|
||||||
case IResourceDelta.REMOVED:
|
case IResourceDelta.REMOVED:
|
||||||
// handle removed resource
|
// handle removed resource
|
||||||
break;
|
break;
|
||||||
case IResourceDelta.CHANGED:
|
case IResourceDelta.CHANGED:
|
||||||
// handle changed resource
|
// handle changed resource
|
||||||
processResource(resource, new NullProgressMonitor());
|
processResource(resource, monitor);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// return true to continue visiting children.
|
// return true to continue visiting children.
|
||||||
|
@ -69,15 +63,6 @@ public class CodanBuilder extends IncrementalProjectBuilder implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class CodanResourceVisitor implements IResourceVisitor {
|
|
||||||
public boolean visit(IResource resource) {
|
|
||||||
if (!(resource instanceof IProject))
|
|
||||||
processResource(resource, new NullProgressMonitor());
|
|
||||||
// return true to continue visiting children.
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* (non-Javadoc)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
|
@ -102,89 +87,94 @@ public class CodanBuilder extends IncrementalProjectBuilder implements
|
||||||
}
|
}
|
||||||
|
|
||||||
public void processResource(IResource resource, IProgressMonitor monitor) {
|
public void processResource(IResource resource, IProgressMonitor monitor) {
|
||||||
// String string = Platform.getPreferencesService().getString(
|
processResource(resource, monitor, null, false);
|
||||||
// CodanCorePlugin.PLUGIN_ID, "problems", "", null);
|
}
|
||||||
// System.err.println("set = " + string);
|
|
||||||
// delete general markers
|
protected void processResource(IResource resource,
|
||||||
IProblemReporter problemReporter = CodanRuntime.getInstance()
|
IProgressMonitor monitor, Object model, boolean inEditor) {
|
||||||
.getProblemReporter();
|
|
||||||
if (problemReporter instanceof CodanMarkerProblemReporter) {
|
|
||||||
((CodanMarkerProblemReporter) problemReporter)
|
|
||||||
.deleteProblems(resource);
|
|
||||||
}
|
|
||||||
CheckersRegisry chegistry = CheckersRegisry.getInstance();
|
CheckersRegisry chegistry = CheckersRegisry.getInstance();
|
||||||
for (IChecker checker : chegistry) {
|
int checkers = chegistry.getCheckersSize();
|
||||||
|
int memsize = 0;
|
||||||
|
if (resource instanceof IContainer) {
|
||||||
try {
|
try {
|
||||||
if (monitor.isCanceled())
|
IResource[] members = ((IContainer) resource).members();
|
||||||
return;
|
memsize = members.length;
|
||||||
if (chegistry.isCheckerEnabled(checker, resource)
|
|
||||||
&& checker.enabledInContext(resource)) {
|
|
||||||
checker.processResource(resource);
|
|
||||||
}
|
|
||||||
} catch (Throwable e) {
|
|
||||||
CodanCorePlugin.log(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (resource instanceof IProject) {
|
|
||||||
try {
|
|
||||||
resource.accept(getResourceVisitor());
|
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
CodanCorePlugin.log(e);
|
CodanCorePlugin.log(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
int tick = 1000;
|
||||||
|
// System.err.println("processing " + resource);
|
||||||
|
monitor.beginTask("Code analysis on " + resource, checkers + memsize
|
||||||
|
* tick);
|
||||||
|
try {
|
||||||
|
IProblemReporter problemReporter = CodanRuntime.getInstance()
|
||||||
|
.getProblemReporter();
|
||||||
|
for (IChecker checker : chegistry) {
|
||||||
|
try {
|
||||||
|
if (monitor.isCanceled())
|
||||||
|
return;
|
||||||
|
if (checker.enabledInContext(resource)) {
|
||||||
|
// delete markers if checker can possibly run on this
|
||||||
|
// resource
|
||||||
|
// this way if checker is not enabled markers would be
|
||||||
|
// deleted too
|
||||||
|
if (problemReporter instanceof IProblemReporterPersistent) {
|
||||||
|
// delete general markers
|
||||||
|
((IProblemReporterPersistent) problemReporter)
|
||||||
|
.deleteProblems(resource, checker);
|
||||||
|
}
|
||||||
|
if (chegistry.isCheckerEnabled(checker, resource)) {
|
||||||
|
if (inEditor) {
|
||||||
|
if (checker.runInEditor()
|
||||||
|
&& checker instanceof IRunnableInEditorChecker) {
|
||||||
|
((IRunnableInEditorChecker) checker)
|
||||||
|
.processModel(model);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
checker.processResource(resource);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
monitor.worked(1);
|
||||||
|
} catch (Throwable e) {
|
||||||
|
CodanCorePlugin.log(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (resource instanceof IContainer) {
|
||||||
|
try {
|
||||||
|
IResource[] members = ((IContainer) resource).members();
|
||||||
|
for (int i = 0; i < members.length; i++) {
|
||||||
|
if (monitor.isCanceled())
|
||||||
|
return;
|
||||||
|
IResource member = members[i];
|
||||||
|
processResource(member, new SubProgressMonitor(monitor,
|
||||||
|
tick));
|
||||||
|
}
|
||||||
|
} catch (CoreException e) {
|
||||||
|
CodanCorePlugin.log(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
monitor.done();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void fullBuild(final IProgressMonitor monitor)
|
protected void fullBuild(final IProgressMonitor monitor)
|
||||||
throws CoreException {
|
throws CoreException {
|
||||||
try {
|
processResource(getProject(), monitor);
|
||||||
getProject().accept(new CodanResourceVisitor());
|
|
||||||
} catch (CoreException e) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void incrementalBuild(IResourceDelta delta,
|
protected void incrementalBuild(IResourceDelta delta,
|
||||||
IProgressMonitor monitor) throws CoreException {
|
IProgressMonitor monitor) throws CoreException {
|
||||||
// the visitor does the work.
|
// the visitor does the work.
|
||||||
delta.accept(new CodanDeltaVisitor());
|
delta.accept(new CodanDeltaVisitor(monitor));
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* (non-Javadoc)
|
|
||||||
*
|
|
||||||
* @see org.eclipse.cdt.codan.core.model.ICodanBuilder#getResourceVisitor()
|
|
||||||
*/
|
|
||||||
public CodanResourceVisitor getResourceVisitor() {
|
|
||||||
return new CodanResourceVisitor();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void runInEditor(Object model, IResource resource,
|
public void runInEditor(Object model, IResource resource,
|
||||||
IProgressMonitor monitor) {
|
IProgressMonitor monitor) {
|
||||||
if (model == null)
|
if (model == null)
|
||||||
return;
|
return;
|
||||||
IProblemReporter problemReporter = CodanRuntime.getInstance()
|
processResource(resource, monitor, model, true);
|
||||||
.getProblemReporter();
|
|
||||||
// TODO: this is wrong - should not delete all markers -
|
|
||||||
// only those that contributed by the checker that we run now
|
|
||||||
if (problemReporter instanceof IProblemReporterPersistent) {
|
|
||||||
((IProblemReporterPersistent) problemReporter)
|
|
||||||
.deleteProblems(resource);
|
|
||||||
}
|
|
||||||
CheckersRegisry chegistry = CheckersRegisry.getInstance();
|
|
||||||
for (IChecker checker : chegistry) {
|
|
||||||
try {
|
|
||||||
boolean run = false;
|
|
||||||
if (checker.enabledInContext(resource)
|
|
||||||
&& chegistry.isCheckerEnabled(checker, resource)) {
|
|
||||||
run = true;
|
|
||||||
}
|
|
||||||
if (run && checker.runInEditor()
|
|
||||||
&& checker instanceof IRunnableInEditorChecker)
|
|
||||||
((IRunnableInEditorChecker) checker).processModel(model);
|
|
||||||
if (monitor.isCanceled())
|
|
||||||
break;
|
|
||||||
} catch (Throwable e) {
|
|
||||||
CodanCorePlugin.log(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,8 +11,13 @@
|
||||||
package org.eclipse.cdt.codan.internal.core.model;
|
package org.eclipse.cdt.codan.internal.core.model;
|
||||||
|
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
import org.eclipse.cdt.codan.core.CodanCorePlugin;
|
||||||
|
import org.eclipse.cdt.codan.core.CodanRuntime;
|
||||||
import org.eclipse.cdt.codan.core.model.IChecker;
|
import org.eclipse.cdt.codan.core.model.IChecker;
|
||||||
|
import org.eclipse.cdt.codan.core.model.ICheckersRegistry;
|
||||||
import org.eclipse.cdt.codan.core.model.IProblem;
|
import org.eclipse.cdt.codan.core.model.IProblem;
|
||||||
import org.eclipse.cdt.codan.core.model.IProblemLocation;
|
import org.eclipse.cdt.codan.core.model.IProblemLocation;
|
||||||
import org.eclipse.cdt.codan.core.model.IProblemReporterPersistent;
|
import org.eclipse.cdt.codan.core.model.IProblemReporterPersistent;
|
||||||
|
@ -101,7 +106,7 @@ public class CodanMarkerProblemReporter implements IProblemReporterPersistent {
|
||||||
|
|
||||||
public void deleteProblems(IResource file) {
|
public void deleteProblems(IResource file) {
|
||||||
try {
|
try {
|
||||||
file.deleteMarkers(GENERIC_CODE_ANALYSIS_MARKER_TYPE, false,
|
file.deleteMarkers(GENERIC_CODE_ANALYSIS_MARKER_TYPE, true,
|
||||||
IResource.DEPTH_ZERO);
|
IResource.DEPTH_ZERO);
|
||||||
} catch (CoreException ce) {
|
} catch (CoreException ce) {
|
||||||
ce.printStackTrace();
|
ce.printStackTrace();
|
||||||
|
@ -110,13 +115,11 @@ public class CodanMarkerProblemReporter implements IProblemReporterPersistent {
|
||||||
|
|
||||||
public void deleteAllProblems() {
|
public void deleteAllProblems() {
|
||||||
try {
|
try {
|
||||||
// TODO delete contributed markers too
|
|
||||||
ResourcesPlugin.getWorkspace().getRoot().deleteMarkers(
|
ResourcesPlugin.getWorkspace().getRoot().deleteMarkers(
|
||||||
GENERIC_CODE_ANALYSIS_MARKER_TYPE, false,
|
GENERIC_CODE_ANALYSIS_MARKER_TYPE, true,
|
||||||
IResource.DEPTH_INFINITE);
|
IResource.DEPTH_INFINITE);
|
||||||
} catch (CoreException e) {
|
} catch (CoreException e) {
|
||||||
// TODO Auto-generated catch block
|
CodanCorePlugin.log(e);
|
||||||
e.printStackTrace();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,6 +132,25 @@ public class CodanMarkerProblemReporter implements IProblemReporterPersistent {
|
||||||
* org.eclipse.cdt.codan.core.model.IChecker)
|
* org.eclipse.cdt.codan.core.model.IChecker)
|
||||||
*/
|
*/
|
||||||
public void deleteProblems(IResource file, IChecker checker) {
|
public void deleteProblems(IResource file, IChecker checker) {
|
||||||
deleteProblems(file);
|
try {
|
||||||
|
IMarker[] markers = file.findMarkers(
|
||||||
|
GENERIC_CODE_ANALYSIS_MARKER_TYPE, true,
|
||||||
|
IResource.DEPTH_INFINITE);
|
||||||
|
ICheckersRegistry reg = CodanRuntime.getInstance()
|
||||||
|
.getChechersRegistry();
|
||||||
|
for (int i = 0; i < markers.length; i++) {
|
||||||
|
IMarker m = markers[i];
|
||||||
|
String id = m.getAttribute(IMarker.PROBLEM, ""); //$NON-NLS-1$
|
||||||
|
Collection<IProblem> problems = reg.getRefProblems(checker);
|
||||||
|
for (Iterator<IProblem> iterator = problems.iterator(); iterator
|
||||||
|
.hasNext();) {
|
||||||
|
IProblem iProblem = iterator.next();
|
||||||
|
if (iProblem.getId().equals(id))
|
||||||
|
m.delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (CoreException e) {
|
||||||
|
CodanCorePlugin.log(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue