1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00
This commit is contained in:
Alena Laskavaia 2010-06-02 01:08:25 +00:00
parent fb8475e290
commit b16ac6b603
4 changed files with 38 additions and 39 deletions

View file

@ -37,6 +37,9 @@ import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.Platform;
import org.osgi.service.prefs.Preferences; import org.osgi.service.prefs.Preferences;
/**
* Implementation of checker registry interface
*/
public class CheckersRegistry implements Iterable<IChecker>, ICheckersRegistry { public class CheckersRegistry implements Iterable<IChecker>, ICheckersRegistry {
private static final String NAME_ATTR = "name"; //$NON-NLS-1$ private static final String NAME_ATTR = "name"; //$NON-NLS-1$
private static final String ID_ATTR = "id"; //$NON-NLS-1$ private static final String ID_ATTR = "id"; //$NON-NLS-1$

View file

@ -16,7 +16,6 @@ import org.eclipse.equinox.app.IApplicationContext;
import org.eclipse.osgi.util.NLS; import org.eclipse.osgi.util.NLS;
/** /**
*
* Application to support headless build * Application to support headless build
* *
* @noextend This class is not intended to be extended by clients. * @noextend This class is not intended to be extended by clients.

View file

@ -30,11 +30,17 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.SubProgressMonitor; import org.eclipse.core.runtime.SubProgressMonitor;
/**
* Implementation of {@link ICodanBuilder}
*/
public class CodanBuilder extends IncrementalProjectBuilder implements public class CodanBuilder extends IncrementalProjectBuilder implements
ICodanBuilder { ICodanBuilder {
/**
* codan builder id
*/
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 { private class CodanDeltaVisitor implements IResourceDeltaVisitor {
private IProgressMonitor monitor; private IProgressMonitor monitor;
/** /**
@ -47,17 +53,17 @@ public class CodanBuilder extends IncrementalProjectBuilder implements
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, monitor); 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, monitor); processResource(resource, monitor);
break; break;
} }
// return true to continue visiting children. // return true to continue visiting children.
return true; return true;
@ -106,8 +112,8 @@ public class CodanBuilder extends IncrementalProjectBuilder implements
} }
int tick = 1000; int tick = 1000;
// System.err.println("processing " + resource); // System.err.println("processing " + resource);
monitor.beginTask(Messages.CodanBuilder_Code_Analysis_On + resource, checkers + memsize monitor.beginTask(Messages.CodanBuilder_Code_Analysis_On + resource,
* tick); checkers + memsize * tick);
try { try {
IProblemReporter problemReporter = CodanRuntime.getInstance() IProblemReporter problemReporter = CodanRuntime.getInstance()
.getProblemReporter(); .getProblemReporter();
@ -172,6 +178,13 @@ public class CodanBuilder extends IncrementalProjectBuilder implements
delta.accept(new CodanDeltaVisitor(monitor)); delta.accept(new CodanDeltaVisitor(monitor));
} }
/**
* Run all checkers that support "check as you type" mode
*
* @param model - model of given resource such as ast
* @param resource - resource to process
* @param monitor - progress monitor
*/
public void runInEditor(Object model, IResource resource, public void runInEditor(Object model, IResource resource,
IProgressMonitor monitor) { IProgressMonitor monitor) {
if (model == null) if (model == null)

View file

@ -16,6 +16,9 @@ import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IProjectNature; import org.eclipse.core.resources.IProjectNature;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
/**
* Code Analysis Nature for builder
*/
public class CodeAnlysisNature implements IProjectNature { public class CodeAnlysisNature implements IProjectNature {
/** /**
* ID of this project nature * ID of this project nature
@ -23,16 +26,13 @@ public class CodeAnlysisNature implements IProjectNature {
public static final String NATURE_ID = "org.eclipse.cdt.codan.core.codanNature"; //$NON-NLS-1$ public static final String NATURE_ID = "org.eclipse.cdt.codan.core.codanNature"; //$NON-NLS-1$
private IProject project; private IProject project;
/*
* (non-Javadoc)
*
* @see org.eclipse.core.resources.IProjectNature#configure()
*/
public void configure() throws CoreException { public void configure() throws CoreException {
IProjectDescription desc = project.getDescription(); IProjectDescription desc = project.getDescription();
ICommand[] commands = desc.getBuildSpec(); ICommand[] commands = desc.getBuildSpec();
for (int i = 0; i < commands.length; ++i) { for (int i = 0; i < commands.length; ++i) {
if (commands[i].getBuilderName().equals(CodanBuilder.BUILDER_ID)) { return; } if (commands[i].getBuilderName().equals(CodanBuilder.BUILDER_ID)) {
return;
}
} }
ICommand[] newCommands = new ICommand[commands.length + 1]; ICommand[] newCommands = new ICommand[commands.length + 1];
System.arraycopy(commands, 0, newCommands, 0, commands.length); System.arraycopy(commands, 0, newCommands, 0, commands.length);
@ -43,11 +43,6 @@ public class CodeAnlysisNature implements IProjectNature {
project.setDescription(desc, null); project.setDescription(desc, null);
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.core.resources.IProjectNature#deconfigure()
*/
public void deconfigure() throws CoreException { public void deconfigure() throws CoreException {
IProjectDescription description = getProject().getDescription(); IProjectDescription description = getProject().getDescription();
ICommand[] commands = description.getBuildSpec(); ICommand[] commands = description.getBuildSpec();
@ -55,7 +50,8 @@ public class CodeAnlysisNature implements IProjectNature {
if (commands[i].getBuilderName().equals(CodanBuilder.BUILDER_ID)) { if (commands[i].getBuilderName().equals(CodanBuilder.BUILDER_ID)) {
ICommand[] newCommands = new ICommand[commands.length - 1]; ICommand[] newCommands = new ICommand[commands.length - 1];
System.arraycopy(commands, 0, newCommands, 0, i); System.arraycopy(commands, 0, newCommands, 0, i);
System.arraycopy(commands, i + 1, newCommands, i, commands.length - i - 1); System.arraycopy(commands, i + 1, newCommands, i,
commands.length - i - 1);
description.setBuildSpec(newCommands); description.setBuildSpec(newCommands);
project.setDescription(description, null); project.setDescription(description, null);
return; return;
@ -63,22 +59,10 @@ public class CodeAnlysisNature implements IProjectNature {
} }
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.core.resources.IProjectNature#getProject()
*/
public IProject getProject() { public IProject getProject() {
return project; return project;
} }
/*
* (non-Javadoc)
*
* @see
* org.eclipse.core.resources.IProjectNature#setProject(org.eclipse.core
* .resources.IProject)
*/
public void setProject(IProject project) { public void setProject(IProject project) {
this.project = project; this.project = project;
} }