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

[279740] API scrub

This commit is contained in:
Alena Laskavaia 2010-03-08 19:51:33 +00:00
parent b99ecd97c7
commit c8dd92b392
61 changed files with 656 additions and 417 deletions

View file

@ -20,9 +20,15 @@
<arguments> <arguments>
</arguments> </arguments>
</buildCommand> </buildCommand>
<buildCommand>
<name>org.eclipse.pde.api.tools.apiAnalysisBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec> </buildSpec>
<natures> <natures>
<nature>org.eclipse.pde.PluginNature</nature> <nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature> <nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.pde.api.tools.apiAnalysisNature</nature>
</natures> </natures>
</projectDescription> </projectDescription>

View file

@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
Bundle-Name: Checkers Ui Bundle-Name: Checkers Ui
Bundle-SymbolicName: org.eclipse.cdt.codan.checkers.ui;singleton:=true Bundle-SymbolicName: org.eclipse.cdt.codan.checkers.ui;singleton:=true
Bundle-Version: 1.0.0 Bundle-Version: 1.0.0
Bundle-Activator: org.eclipse.cdt.codan.checkers.ui.CheckersUiActivator Bundle-Activator: org.eclipse.cdt.codan.internal.checkers.ui.CheckersUiActivator
Require-Bundle: org.eclipse.ui, Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime, org.eclipse.core.runtime,
org.eclipse.ui.ide;bundle-version="3.5.0", org.eclipse.ui.ide;bundle-version="3.5.0",

View file

@ -3,7 +3,3 @@ output.. = bin/
bin.includes = META-INF/,\ bin.includes = META-INF/,\
.,\ .,\
plugin.xml plugin.xml
src.includes = src/,\
plugin.xml,\
build.properties,\
META-INF/

View file

@ -1,4 +1,4 @@
package org.eclipse.cdt.codan.checkers.ui; package org.eclipse.cdt.codan.internal.checkers.ui;
import org.eclipse.ui.plugin.AbstractUIPlugin; import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext; import org.osgi.framework.BundleContext;

View file

@ -20,9 +20,15 @@
<arguments> <arguments>
</arguments> </arguments>
</buildCommand> </buildCommand>
<buildCommand>
<name>org.eclipse.pde.api.tools.apiAnalysisBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec> </buildSpec>
<natures> <natures>
<nature>org.eclipse.pde.PluginNature</nature> <nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature> <nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.pde.api.tools.apiAnalysisNature</nature>
</natures> </natures>
</projectDescription> </projectDescription>

View file

@ -3,7 +3,3 @@ output.. = bin/
bin.includes = META-INF/,\ bin.includes = META-INF/,\
.,\ .,\
plugin.xml plugin.xml
src.includes = src/,\
plugin.xml,\
META-INF/,\
build.properties

View file

@ -3,74 +3,74 @@
<plugin> <plugin>
<extension <extension
point="org.eclipse.cdt.codan.core.checkers" point="org.eclipse.cdt.codan.core.checkers"
id="org.eclipse.cdt.codan.core.checkers.sample"> id="org.eclipse.cdt.codan.core.examples.checkers">
<checker <checker
class="org.eclipse.cdt.codan.internal.checkers.sample.AssignmentInConditionChecker" class="org.eclipse.cdt.codan.examples.checkers.AssignmentInConditionChecker"
id="org.eclipse.cdt.codan.checkers.sample.AssignmentInConditionChecker" id="org.eclipse.cdt.codan.examples.checkers.AssignmentInConditionChecker"
name="Assignment in condition"> name="Assignment in condition">
<problem <problem
defaultSeverity="Warning" defaultSeverity="Warning"
id="org.eclipse.cdt.codan.checkers.sample.AssignmentInConditionProblem" id="org.eclipse.cdt.codan.examples.checkers.AssignmentInConditionProblem"
name="Assignment in condition"> name="Assignment in condition">
</problem> </problem>
</checker> </checker>
<checker <checker
class="org.eclipse.cdt.codan.internal.checkers.sample.StatementHasNoEffectChecker" class="org.eclipse.cdt.codan.examples.checkers.StatementHasNoEffectChecker"
id="org.eclipse.cdt.codan.checkers.sample.StatementHasNoEffectChecker" id="org.eclipse.cdt.codan.examples.checkers.StatementHasNoEffectChecker"
name="StatementHasNoEffectChecker"> name="StatementHasNoEffectChecker">
<problem <problem
category="org.eclipse.cdt.codan.core.categories.ProgrammingProblems" category="org.eclipse.cdt.codan.core.categories.ProgrammingProblems"
defaultSeverity="Warning" defaultSeverity="Warning"
id="org.eclipse.cdt.codan.checkers.sample.StatementHasNoEffectProblem" id="org.eclipse.cdt.codan.examples.checkers.StatementHasNoEffectProblem"
name="Statement has no effect"> name="Statement has no effect">
</problem> </problem>
</checker> </checker>
<checker <checker
class="org.eclipse.cdt.codan.internal.checkers.sample.NonVirtualDestructor" class="org.eclipse.cdt.codan.examples.checkers.NonVirtualDestructor"
id="org.eclipse.cdt.codan.checkers.sample.NonVirtualDescructor" id="org.eclipse.cdt.codan.examples.checkers.NonVirtualDescructor"
name="NonVirtualDescructorChecker"> name="NonVirtualDescructorChecker">
<problem <problem
category="org.eclipse.cdt.codan.core.categories.ProgrammingProblems" category="org.eclipse.cdt.codan.core.categories.ProgrammingProblems"
defaultSeverity="Warning" defaultSeverity="Warning"
id="org.eclipse.cdt.codan.checkers.sample.NonVirtualDestructorProblem" id="org.eclipse.cdt.codan.examples.checkers.NonVirtualDestructorProblem"
name="Class has a virtual method and non-virtual destructor"> name="Class has a virtual method and non-virtual destructor">
</problem> </problem>
</checker> </checker>
<checker <checker
class="org.eclipse.cdt.codan.internal.checkers.sample.CatchUsesReference" class="org.eclipse.cdt.codan.examples.checkers.CatchUsesReference"
id="org.eclipse.cdt.codan.checkers.sample.CatchUsesReference" id="org.eclipse.cdt.codan.examples.checkers.CatchUsesReference"
name="CatchUsesReferenceChecker"> name="CatchUsesReferenceChecker">
<problem <problem
category="org.eclipse.cdt.codan.core.categories.ProgrammingProblems" category="org.eclipse.cdt.codan.core.categories.ProgrammingProblems"
defaultSeverity="Warning" defaultSeverity="Warning"
id="org.eclipse.cdt.codan.checkers.sample.CatchUsesReference" id="org.eclipse.cdt.codan.examples.checkers.CatchUsesReference"
name="Catch uses reference to exception"> name="Catch uses reference to exception">
</problem> </problem>
</checker> </checker>
<checker <checker
class="org.eclipse.cdt.codan.internal.checkers.sample.SuggestedParenthesisChecker" class="org.eclipse.cdt.codan.examples.checkers.SuggestedParenthesisChecker"
id="org.eclipse.cdt.codan.checkers.sample.SuggestedParenthesisChecker" id="org.eclipse.cdt.codan.examples.checkers.SuggestedParenthesisChecker"
name="SuggestedParenthesisChecker"> name="SuggestedParenthesisChecker">
<problem <problem
category="org.eclipse.cdt.codan.core.categories.ProgrammingProblems" category="org.eclipse.cdt.codan.core.categories.ProgrammingProblems"
defaultSeverity="Warning" defaultSeverity="Warning"
id="org.eclipse.cdt.codan.checkers.sample.SuggestedParenthesisProblem" id="org.eclipse.cdt.codan.examples.checkers.SuggestedParenthesisProblem"
name="Suggested parenthesis around expression"> name="Suggested parenthesis around expression">
</problem> </problem>
</checker> </checker>
<checker <checker
class="org.eclipse.cdt.codan.internal.checkers.sample.NamingConventionFunctionChecker" class="org.eclipse.cdt.codan.examples.checkers.NamingConventionFunctionChecker"
id="org.eclipse.cdt.codan.checkers.sample.NamingConventionFunctionChecker" id="org.eclipse.cdt.codan.examples.checkers.NamingConventionFunctionChecker"
name="NamingConventionFunctionChecker"> name="NamingConventionFunctionChecker">
<problem <problem
category="org.eclipse.cdt.codan.core.categories.CodeStyle" category="org.eclipse.cdt.codan.core.categories.CodeStyle"
defaultSeverity="Warning" defaultSeverity="Warning"
id="org.eclipse.cdt.codan.checkers.sample.NamingConventionFunctionProblem" id="org.eclipse.cdt.codan.examples.checkers.NamingConventionFunctionProblem"
name="Name convention for function"> name="Name convention for function">
</problem> </problem>
</checker> </checker>

View file

@ -8,7 +8,7 @@
* Contributors: * Contributors:
* Alena Laskavaia - initial API and implementation * Alena Laskavaia - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.codan.internal.checkers.sample; package org.eclipse.cdt.codan.examples.checkers;
import org.eclipse.cdt.codan.core.model.AbstractIndexAstChecker; import org.eclipse.cdt.codan.core.model.AbstractIndexAstChecker;
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty; import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
@ -20,7 +20,7 @@ import org.eclipse.cdt.core.dom.ast.IASTIfStatement;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
public class AssignmentInConditionChecker extends AbstractIndexAstChecker { public class AssignmentInConditionChecker extends AbstractIndexAstChecker {
private static final String ER_ID = "org.eclipse.cdt.codan.internal.checkers.sample.AssignmentInConditionProblem"; private static final String ER_ID = "org.eclipse.cdt.codan.examples.checkers.AssignmentInConditionProblem";
public void processAst(IASTTranslationUnit ast) { public void processAst(IASTTranslationUnit ast) {
// traverse the ast using the visitor pattern. // traverse the ast using the visitor pattern.

View file

@ -9,7 +9,7 @@
* Alena Laskavaia - initial API and implementation * Alena Laskavaia - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.codan.internal.checkers.sample; package org.eclipse.cdt.codan.examples.checkers;
import org.eclipse.cdt.codan.core.model.AbstractIndexAstChecker; import org.eclipse.cdt.codan.core.model.AbstractIndexAstChecker;
import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.ASTVisitor;
@ -28,7 +28,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTryBlockStatement;
* *
*/ */
public class CatchUsesReference extends AbstractIndexAstChecker { public class CatchUsesReference extends AbstractIndexAstChecker {
private static final String ER_ID = "org.eclipse.cdt.codan.internal.checkers.sample.CatchUsesReference"; private static final String ER_ID = "org.eclipse.cdt.codan.examples.checkers.CatchUsesReference";
public void processAst(IASTTranslationUnit ast) { public void processAst(IASTTranslationUnit ast) {
// traverse the ast using the visitor pattern. // traverse the ast using the visitor pattern.

View file

@ -8,7 +8,7 @@
* Contributors: * Contributors:
* Alena Laskavaia - initial API and implementation * Alena Laskavaia - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.codan.internal.checkers.sample; package org.eclipse.cdt.codan.examples.checkers;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.eclipse.cdt.codan.core.model.AbstractCIndexChecker; import org.eclipse.cdt.codan.core.model.AbstractCIndexChecker;
@ -27,8 +27,8 @@ import org.eclipse.core.runtime.CoreException;
*/ */
public class NamingConventionFunctionChecker extends AbstractCIndexChecker public class NamingConventionFunctionChecker extends AbstractCIndexChecker
implements ICheckerWithParameters { implements ICheckerWithParameters {
public static final String PARAM_KEY = "pattern"; public static final String PARAM_KEY = "pattern"; //$NON-NLS-1$
private static final String ER_ID = "org.eclipse.cdt.codan.internal.checkers.sample.NamingConventionFunctionProblem"; private static final String ER_ID = "org.eclipse.cdt.codan.examples.checkers.NamingConventionFunctionProblem"; //$NON-NLS-1$
/* /*
* (non-Javadoc) * (non-Javadoc)

View file

@ -8,7 +8,7 @@
* Contributors: * Contributors:
* Alena Laskavaia - initial API and implementation * Alena Laskavaia - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.codan.internal.checkers.sample; package org.eclipse.cdt.codan.examples.checkers;
import java.text.MessageFormat; import java.text.MessageFormat;
@ -33,7 +33,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding;
* *
*/ */
public class NonVirtualDestructor extends AbstractIndexAstChecker { public class NonVirtualDestructor extends AbstractIndexAstChecker {
private static final String ER_ID = "org.eclipse.cdt.codan.internal.checkers.sample.NonVirtualDestructorProblem"; private static final String ER_ID = "org.eclipse.cdt.codan.examples.checkers.NonVirtualDestructorProblem";
public void processAst(IASTTranslationUnit ast) { public void processAst(IASTTranslationUnit ast) {
// traverse the ast using the visitor pattern. // traverse the ast using the visitor pattern.

View file

@ -8,7 +8,7 @@
* Contributors: * Contributors:
* Alena Laskavaia - initial API and implementation * Alena Laskavaia - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.codan.internal.checkers.sample; package org.eclipse.cdt.codan.examples.checkers;
import org.eclipse.cdt.codan.core.model.AbstractIndexAstChecker; import org.eclipse.cdt.codan.core.model.AbstractIndexAstChecker;
import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.ASTVisitor;
@ -36,7 +36,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTBinaryExpression;
* *
*/ */
public class StatementHasNoEffectChecker extends AbstractIndexAstChecker { public class StatementHasNoEffectChecker extends AbstractIndexAstChecker {
private static final String ER_ID = "org.eclipse.cdt.codan.internal.checkers.sample.StatementHasNoEffectProblem"; private static final String ER_ID = "org.eclipse.cdt.codan.examples.checkers.StatementHasNoEffectProblem";
public void processAst(IASTTranslationUnit ast) { public void processAst(IASTTranslationUnit ast) {
// traverse the ast using the visitor pattern. // traverse the ast using the visitor pattern.

View file

@ -8,7 +8,7 @@
* Contributors: * Contributors:
* Alena Laskavaia - initial API and implementation * Alena Laskavaia - initial API and implementation
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.codan.internal.checkers.sample; package org.eclipse.cdt.codan.examples.checkers;
import org.eclipse.cdt.codan.core.model.AbstractIndexAstChecker; import org.eclipse.cdt.codan.core.model.AbstractIndexAstChecker;
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty; import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
@ -29,7 +29,7 @@ import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
* *
*/ */
public class SuggestedParenthesisChecker extends AbstractIndexAstChecker { public class SuggestedParenthesisChecker extends AbstractIndexAstChecker {
private static final String ER_ID = "org.eclipse.cdt.codan.internal.checkers.sample.SuggestedParenthesisProblem"; private static final String ER_ID = "org.eclipse.cdt.codan.examples.checkers.SuggestedParenthesisProblem";
public void processAst(IASTTranslationUnit ast) { public void processAst(IASTTranslationUnit ast) {
// traverse the ast using the visitor pattern. // traverse the ast using the visitor pattern.

View file

@ -3,3 +3,4 @@ output.. = bin/
bin.includes = META-INF/,\ bin.includes = META-INF/,\
.,\ .,\
src/org/eclipse/cdt/codan/core/checkers/ src/org/eclipse/cdt/codan/core/checkers/
jre.compilation.profile = J2SE-1.5

View file

@ -20,9 +20,15 @@
<arguments> <arguments>
</arguments> </arguments>
</buildCommand> </buildCommand>
<buildCommand>
<name>org.eclipse.pde.api.tools.apiAnalysisBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec> </buildSpec>
<natures> <natures>
<nature>org.eclipse.pde.PluginNature</nature> <nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature> <nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.pde.api.tools.apiAnalysisNature</nature>
</natures> </natures>
</projectDescription> </projectDescription>

View file

@ -4,8 +4,4 @@ bin.includes = META-INF/,\
.,\ .,\
plugin.xml,\ plugin.xml,\
schema/ schema/
src.includes = src/,\ src.includes = schema/
schema/,\
plugin.xml,\
build.properties,\
META-INF/

View file

@ -65,7 +65,7 @@
thread="main" thread="main"
visible="true"> visible="true">
<run <run
class="org.eclipse.cdt.codan.core.CodanApplication"> class="org.eclipse.cdt.codan.internal.core.CodanApplication">
</run> </run>
</application> </application>
</extension> </extension>

View file

@ -13,7 +13,7 @@ import org.osgi.framework.BundleContext;
*/ */
public class CodanCorePlugin extends Plugin { public class CodanCorePlugin extends Plugin {
// The plug-in ID // The plug-in ID
public static final String PLUGIN_ID = "org.eclipse.cdt.codan.core"; public static final String PLUGIN_ID = "org.eclipse.cdt.codan.core"; //$NON-NLS-1$
public static final String NATURE_ID = CodeAnlysisNature.NATURE_ID; public static final String NATURE_ID = CodeAnlysisNature.NATURE_ID;
// The shared instance // The shared instance
private static CodanCorePlugin plugin; private static CodanCorePlugin plugin;
@ -34,6 +34,7 @@ public class CodanCorePlugin extends Plugin {
* @see * @see
* org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext) * org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext)
*/ */
@Override
public void start(BundleContext context) throws Exception { public void start(BundleContext context) throws Exception {
super.start(context); super.start(context);
plugin = this; plugin = this;
@ -45,6 +46,7 @@ public class CodanCorePlugin extends Plugin {
* @see * @see
* org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext) * org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext)
*/ */
@Override
public void stop(BundleContext context) throws Exception { public void stop(BundleContext context) throws Exception {
plugin = null; plugin = null;
super.stop(context); super.stop(context);

View file

@ -13,42 +13,94 @@ package org.eclipse.cdt.codan.core;
import org.eclipse.cdt.codan.core.model.ICheckersRegistry; import org.eclipse.cdt.codan.core.model.ICheckersRegistry;
import org.eclipse.cdt.codan.core.model.ICodanAstReconciler; import org.eclipse.cdt.codan.core.model.ICodanAstReconciler;
import org.eclipse.cdt.codan.core.model.ICodanBuilder; import org.eclipse.cdt.codan.core.model.ICodanBuilder;
import org.eclipse.cdt.codan.core.model.IProblemLocationFactory;
import org.eclipse.cdt.codan.core.model.IProblemReporter; import org.eclipse.cdt.codan.core.model.IProblemReporter;
import org.eclipse.cdt.codan.internal.core.CheckersRegisry; import org.eclipse.cdt.codan.internal.core.CheckersRegisry;
import org.eclipse.cdt.codan.internal.core.CodanBuilder; import org.eclipse.cdt.codan.internal.core.CodanBuilder;
import org.eclipse.cdt.codan.internal.core.model.CodanMarkerProblemReporter; import org.eclipse.cdt.codan.internal.core.model.CodanMarkerProblemReporter;
import org.eclipse.cdt.codan.internal.core.model.ProblemLocationFactory;
/** /**
* Runtime singleton class to get access to Codan framework parts * Runtime singleton class to get access to Codan framework parts
* *
* Clients may extend this class to override default framework parts.
*/ */
public class CodanRuntime { public class CodanRuntime {
private static CodanRuntime instance = new CodanRuntime(); private static CodanRuntime instance = new CodanRuntime();
private IProblemReporter problemReporter = new CodanMarkerProblemReporter(); private IProblemReporter problemReporter = new CodanMarkerProblemReporter();
private CodanBuilder builder = new CodanBuilder(); private CodanBuilder builder = new CodanBuilder();
private CheckersRegisry checkers = CheckersRegisry.getInstance(); private CheckersRegisry checkers = CheckersRegisry.getInstance();
private IProblemLocationFactory locFactory = new ProblemLocationFactory();
/**
* CodanRuntime - only can be called by subclasses to override default constructor
*/
protected CodanRuntime() {
// nothing here
}
/**
* Get runtime problem reporter. Default reported generated problem markers.
* @return
*/
public IProblemReporter getProblemReporter() { public IProblemReporter getProblemReporter() {
return problemReporter; return problemReporter;
} }
/**
* Set different problem reporter.
* @param reporter
*/
public void setProblemReporter(IProblemReporter reporter) { public void setProblemReporter(IProblemReporter reporter) {
problemReporter = reporter; problemReporter = reporter;
} }
/**
* Get instance of of Codan Runtime
* @return
*/
public static CodanRuntime getInstance() { public static CodanRuntime getInstance() {
return instance; return instance;
} }
/**
* Get builder. Builder can used to run code analysis on given resource using API.
* @return
*/
public ICodanBuilder getBuilder() { public ICodanBuilder getBuilder() {
return builder; return builder;
} }
/**
* Get quick builder. Can be used to run code analysis on given ast.
* @return
*/
public ICodanAstReconciler getAstQuickBuilder() { public ICodanAstReconciler getAstQuickBuilder() {
return builder; return builder;
} }
/**
* Get checkers registry.
* @return
*/
public ICheckersRegistry getChechersRegistry() { public ICheckersRegistry getChechersRegistry() {
return checkers; return checkers;
} }
/**
* Get problem location factory.
* @return
*/
public IProblemLocationFactory getProblemLocationFactory() {
return locFactory;
}
/**
* Set another problem location factory - only need if default is not sufficient, i.e
* IProblemLocation is implemented differently
* @param factory
*/
public void setProblemLocationFactory(IProblemLocationFactory factory) {
locFactory = factory;
}
} }

View file

@ -14,7 +14,7 @@ package org.eclipse.cdt.codan.core;
* Constant definitions for plug-in preferences * Constant definitions for plug-in preferences
*/ */
public class PreferenceConstants { public class PreferenceConstants {
public static final String P_RUN_ON_BUILD = "booleanPreference"; public static final String P_RUN_ON_BUILD = "booleanPreference"; //$NON-NLS-1$
public static final String P_PROBLEMS = "problems"; public static final String P_PROBLEMS = "problems"; //$NON-NLS-1$
public static final String P_USE_PARENT = "useParentScope"; public static final String P_USE_PARENT = "useParentScope"; //$NON-NLS-1$
} }

View file

@ -21,11 +21,11 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
/** /**
* Checker that works with C-Index of a file (but not AST) * Implementation of IChecker that works with C-Index of a file (but not AST)
* *
* Clients may extend this class.
*/ */
public abstract class AbstractCIndexChecker extends AbstractChecker implements public abstract class AbstractCIndexChecker extends AbstractChecker implements ICIndexChecker {
ICIndexChecker {
private IFile file; private IFile file;
protected IIndex index; protected IIndex index;
@ -36,11 +36,8 @@ public abstract class AbstractCIndexChecker extends AbstractChecker implements
void processFile(IFile file) throws CoreException, InterruptedException { void processFile(IFile file) throws CoreException, InterruptedException {
// create translation unit and access index // create translation unit and access index
ICElement model = CoreModel.getDefault().create(file); ICElement model = CoreModel.getDefault().create(file);
if (!(model instanceof ITranslationUnit)) if (!(model instanceof ITranslationUnit)) return; // not a C/C++ file
return;
ITranslationUnit tu = (ITranslationUnit) model; ITranslationUnit tu = (ITranslationUnit) model;
if (tu == null)
return; // not a C/C++ file
index = CCorePlugin.getIndexManager().getIndex(tu.getCProject()); index = CCorePlugin.getIndexManager().getIndex(tu.getCProject());
// lock the index for read access // lock the index for read access
index.acquireReadLock(); index.acquireReadLock();

View file

@ -15,6 +15,12 @@ import org.eclipse.cdt.codan.internal.core.CheckersRegisry;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
/**
* Convenience implementation of IChecker interface.
* Has a default implementation for common methods.
*
* Clients may extend this class.
*/
public abstract class AbstractChecker implements IChecker { public abstract class AbstractChecker implements IChecker {
protected String name; protected String name;
@ -44,15 +50,18 @@ public abstract class AbstractChecker implements IChecker {
* internationalization) * internationalization)
*/ */
public void reportProblem(String id, IFile file, int lineNumber, String arg) { public void reportProblem(String id, IFile file, int lineNumber, String arg) {
getProblemReporter().reportProblem(id, getProblemReporter().reportProblem(id, createProblemLocation(file, lineNumber), arg);
new ProblemLocation(file, lineNumber), arg);
} }
/**
* Finds an instance of problem by given id, in user profile registered for specific file
* @param id - problem id
* @param file - file in scope
* @return problem instance
*/
public IProblem getProblemById(String id, IFile file) { public IProblem getProblemById(String id, IFile file) {
IProblem problem = CheckersRegisry.getInstance().getResourceProfile( IProblem problem = CheckersRegisry.getInstance().getResourceProfile(file).findProblem(id);
file).findProblem(id); if (problem == null) throw new IllegalArgumentException("Id is not registered"); //$NON-NLS-1$
if (problem == null)
throw new IllegalArgumentException("Id is not registered");
return problem; return problem;
} }
@ -68,8 +77,7 @@ public abstract class AbstractChecker implements IChecker {
* - line * - line
*/ */
public void reportProblem(String id, IFile file, int lineNumber) { public void reportProblem(String id, IFile file, int lineNumber) {
getProblemReporter().reportProblem(id, getProblemReporter().reportProblem(id, createProblemLocation(file, lineNumber), new Object[] {});
new ProblemLocation(file, lineNumber), new Object[] {});
} }
/** /**
@ -79,6 +87,35 @@ public abstract class AbstractChecker implements IChecker {
return CodanRuntime.getInstance().getProblemReporter(); return CodanRuntime.getInstance().getProblemReporter();
} }
/**
* Convenience method to return codan runtime
* @return
*/
protected CodanRuntime getRuntime() {
return CodanRuntime.getInstance();
}
/**
* Convenience method to create and return instance of IProblemLocation
* @param file - file where problem is found
* @param line - line number 1-relative
* @return instance of IProblemLocation
*/
protected IProblemLocation createProblemLocation(IFile file, int line) {
return getRuntime().getProblemLocationFactory().createProblemLocation(file, line);
}
/**
* Convenience method to create and return instance of IProblemLocation
* @param file - file where problem is found
* @param startChar - start char of the problem in the file, is zero-relative
* @param endChar - end char of the problem in the file, is zero-relative and exclusive.
* @return instance of IProblemLocation
*/
protected IProblemLocation createProblemLocation(IFile file, int startChar, int endChar) {
return getRuntime().getProblemLocationFactory().createProblemLocation(file, startChar, endChar);
}
public boolean runInEditor() { public boolean runInEditor() {
return false; return false;
} }

View file

@ -27,11 +27,11 @@ import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Path;
/** /**
* @author Alena * Convenience implementation of checker that work on index based ast of a c/c++ program.
* *
* Clients may extend this class.
*/ */
public abstract class AbstractIndexAstChecker extends AbstractChecker implements public abstract class AbstractIndexAstChecker extends AbstractChecker implements ICAstChecker {
ICAstChecker {
private IFile file; private IFile file;
protected IFile getFile() { protected IFile getFile() {
@ -41,18 +41,14 @@ public abstract class AbstractIndexAstChecker extends AbstractChecker implements
void processFile(IFile file) throws CoreException, InterruptedException { void processFile(IFile file) throws CoreException, InterruptedException {
// create translation unit and access index // create translation unit and access index
ICElement model = CoreModel.getDefault().create(file); ICElement model = CoreModel.getDefault().create(file);
if (!(model instanceof ITranslationUnit)) if (!(model instanceof ITranslationUnit)) return; // not a C/C++ file
return;
ITranslationUnit tu = (ITranslationUnit) model; ITranslationUnit tu = (ITranslationUnit) model;
if (tu == null)
return; // not a C/C++ file
IIndex index = CCorePlugin.getIndexManager().getIndex(tu.getCProject()); IIndex index = CCorePlugin.getIndexManager().getIndex(tu.getCProject());
// lock the index for read access // lock the index for read access
index.acquireReadLock(); index.acquireReadLock();
try { try {
// create index based ast // create index based ast
IASTTranslationUnit ast = tu.getAST(index, IASTTranslationUnit ast = tu.getAST(index, ITranslationUnit.AST_SKIP_INDEXED_HEADERS);
ITranslationUnit.AST_SKIP_INDEXED_HEADERS);
// traverse the ast using the visitor pattern. // traverse the ast using the visitor pattern.
this.file = file; this.file = file;
processAst(ast); processAst(ast);
@ -80,19 +76,16 @@ public abstract class AbstractIndexAstChecker extends AbstractChecker implements
public void reportProblem(String id, IASTNode astNode, String message) { public void reportProblem(String id, IASTNode astNode, String message) {
IASTFileLocation astLocation = astNode.getFileLocation(); IASTFileLocation astLocation = astNode.getFileLocation();
IPath location = new Path(astLocation.getFileName()); IPath location = new Path(astLocation.getFileName());
IFile astFile = ResourcesPlugin.getWorkspace().getRoot() IFile astFile = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(location);
.getFileForLocation(location);
if (astFile == null) { if (astFile == null) {
astFile = file; astFile = file;
} }
ProblemLocation loc; IProblemLocation loc;
if (astLocation.getStartingLineNumber() == astLocation if (astLocation.getStartingLineNumber() == astLocation.getEndingLineNumber()) loc = getRuntime()
.getEndingLineNumber()) .getProblemLocationFactory().createProblemLocation(astFile, astLocation.getNodeOffset(),
loc = new ProblemLocation(astFile, astLocation.getNodeOffset(), astLocation.getNodeOffset() + astLocation.getNodeLength());
astLocation.getNodeOffset() + astLocation.getNodeLength()); else loc = getRuntime().getProblemLocationFactory().createProblemLocation(astFile,
else astLocation.getStartingLineNumber());
loc = new ProblemLocation(astFile, astLocation
.getStartingLineNumber());
getProblemReporter().reportProblem(id, loc, message); getProblemReporter().reportProblem(id, loc, message);
} }

View file

@ -12,9 +12,17 @@ package org.eclipse.cdt.codan.core.model;
import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IMarker;
/**
*
* Represents Severity of the codan problem. It is directly mapped to markers severity,
* therefore not intended to be extended.
*
* @noextend This class is not intended to be extended by clients.
* @noinstantiate This class is not intended to be instantiated by clients.
*
*/
public enum CodanSeverity { public enum CodanSeverity {
Info(IMarker.SEVERITY_INFO), Warning(IMarker.SEVERITY_WARNING), Error( Info(IMarker.SEVERITY_INFO), Warning(IMarker.SEVERITY_WARNING), Error(IMarker.SEVERITY_ERROR);
IMarker.SEVERITY_ERROR);
private int value; private int value;
private CodanSeverity(int value) { private CodanSeverity(int value) {
@ -26,7 +34,7 @@ public enum CodanSeverity {
} }
/** /**
* @return * @return array of string value for all severities
*/ */
public static String[] stringValues() { public static String[] stringValues() {
CodanSeverity[] values = values(); CodanSeverity[] values = values();

View file

@ -13,9 +13,16 @@ package org.eclipse.cdt.codan.core.model;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
/** /**
* @author Alena * Checker that can/want to process C/C++ AST (Abstract Syntax Tree) of a program
* Default implementation {@link AbstractIndexAstChecker}
* *
* Clients may implement and extend this interface.
*/ */
public interface ICAstChecker extends IChecker { public interface ICAstChecker extends IChecker {
/**
* Run this checker on a given ast.
* Ast locks would be obtained by the framework before calling this method.
* @param ast
*/
void processAst(IASTTranslationUnit ast); void processAst(IASTTranslationUnit ast);
} }

View file

@ -13,9 +13,15 @@ package org.eclipse.cdt.codan.core.model;
import org.eclipse.cdt.core.model.ITranslationUnit; import org.eclipse.cdt.core.model.ITranslationUnit;
/** /**
* @author Alena * Extension of IChecker that works with C-Index of a file (but not AST)
* Default implementation {@link AbstractCIndexChecker}
* *
* Client may implement this interface.
*/ */
public interface ICIndexChecker extends IChecker { public interface ICIndexChecker extends IChecker {
/**
* Run checker on translation unit
* @param unit - translation unit
*/
void processUnit(ITranslationUnit unit); void processUnit(ITranslationUnit unit);
} }

View file

@ -14,6 +14,8 @@ import org.eclipse.core.resources.IResource;
/** /**
* Interface that checker must implement. CDT Checker must be able to process a resource. * Interface that checker must implement. CDT Checker must be able to process a resource.
*
* Clients may implement and extend this interface.
*/ */
public interface IChecker { public interface IChecker {
/** /**
@ -26,7 +28,7 @@ public interface IChecker {
/** /**
* Implement this method to trim down type of resource you are interested in, * Implement this method to trim down type of resource you are interested in,
* usually it will be c/c++ files only * usually it will be c/c++ files only
* @param resource * @param resource - resource to run on
* @return * @return
*/ */
boolean enabledInContext(IResource resource); boolean enabledInContext(IResource resource);

View file

@ -11,9 +11,15 @@
package org.eclipse.cdt.codan.core.model; package org.eclipse.cdt.codan.core.model;
/** /**
* @author Alena * Interface for checker with parameters, if checker implements this
* interface method would be called on initialization so checker has
* a chance to set default values for its parameters
* *
*/ */
public interface ICheckerWithParameters { public interface ICheckerWithParameters {
/**
* Implement this method to set default parameters for checkers with parameters.
* @param problem - instance of problem working copy
*/
void initParameters(IProblemWorkingCopy problem); void initParameters(IProblemWorkingCopy problem);
} }

View file

@ -15,52 +15,82 @@ import java.util.Iterator;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
/** /**
* @author Alena * This interface an API to add/remove checker and problems programmatically,
* get problem profiles and change problem default settings
* *
*/ */
public interface ICheckersRegistry { public interface ICheckersRegistry extends Iterable<IChecker> {
/**
* Iterator for registered checkers
* @return
*/
public abstract Iterator<IChecker> iterator(); public abstract Iterator<IChecker> iterator();
/**
* Add another checker
* @param checker
*/
public abstract void addChecker(IChecker checker); public abstract void addChecker(IChecker checker);
public abstract void addProblem(IProblem p, String category); /**
* Add problem p with default category by category id into default profile, category must exists in default profile
* @param p - problem
* @param categoryId - category id
*/
public abstract void addProblem(IProblem p, String categoryId);
public abstract void addCategory(IProblemCategory p, String category); /**
* Add subcategory with id categoryId into parent category,
* if parent does not exist in default, profile - if not will be added to the root
* @param category - new category
* @param parentCategoryId - parent category id
*/
public abstract void addCategory(IProblemCategory category, String parentCategoryId);
/**
* Add problem reference to a checker, i.e. claim that checker can produce this problem.
* If checker does not claim any problems it cannot be enabled.
* @param c - checker
* @param p - problem
*/
public abstract void addRefProblem(IChecker c, IProblem p); public abstract 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 * @return
*/ */
public abstract IProblemProfile getDefaultProfile(); public abstract IProblemProfile getDefaultProfile();
/** /**
* @return * Get workspace profile. User can change setting for workspace profile.
* @return profile
*/ */
public abstract IProblemProfile getWorkspaceProfile(); public abstract IProblemProfile getWorkspaceProfile();
/** /**
* @param element * Get resource profile. For example given directory can have different profile
* @return * than parent project.
*
* @param element - resource
* @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
* specified for given element it will search for parent resource and so on).
* @param element * @param element
* @return * @return
*/ */
public abstract IProblemProfile getResourceProfileWorkingCopy( public abstract IProblemProfile getResourceProfileWorkingCopy(IResource element);
IResource element);
/** /**
* Set profile for resource. This method is called by UI, and should not be * Set profile for resource.
* called by clients directly * @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, public abstract void updateProfile(IResource resource, IProblemProfile profile);
IProblemProfile profile);
} }

View file

@ -14,9 +14,17 @@ import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
/** /**
* @author Alena * Allows to run all checkers that can run on ast via editing using API
*
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
* *
*/ */
public interface ICodanAstReconciler { public interface ICodanAstReconciler {
/**
* Run code analysis on ast
* @param ast - ast to be reconciled
* @param monitor - progress monitor
*/
public void reconcileAst(IASTTranslationUnit ast, IProgressMonitor monitor); public void reconcileAst(IASTTranslationUnit ast, IProgressMonitor monitor);
} }

View file

@ -14,9 +14,19 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IProgressMonitor;
/** /**
* @author Alena * Interface for "Codan Builder". Clients can cann processResource method to
* traverse the resource tree, calling all the checker (this interface allows
* to call framework without using UI). You can obtain instance of this
* class as CodanRuntime.getInstance().getBuilder()
* *
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
*/ */
public interface ICodanBuilder { public interface ICodanBuilder {
/**
* Run code analysis on given resource
* @param resource - resource to process
* @param monitor - progress monitor
*/
public void processResource(IResource resource, IProgressMonitor monitor); public void processResource(IResource resource, IProgressMonitor monitor);
} }

View file

@ -10,9 +10,14 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.codan.core.model; package org.eclipse.cdt.codan.core.model;
/** /**
* Interface representing code analysis problem * Interface representing code analysis problem type. For example "Null Pointer Dereference"
* is a problem. It has user visible Name and Message (translatable), as well as some other
* parameters, changeable by user such as enablement, severity and so on. Same problem
* cannot have two severities determined by runtime. If it is the case - two Problem should
* be created (i.e. one for error and one for warning).
*
* Clients may implement and extend this interface.
* *
*/ */
public interface IProblem extends IProblemElement { public interface IProblem extends IProblemElement {
@ -53,8 +58,9 @@ public interface IProblem extends IProblemElement {
public Object getParameter(Object key); public Object getParameter(Object key);
/** /**
* Get root paramterInfo - contains description of types of all the * Get parameter info root - contains description of types of all the
* parameters or null if not defined * parameters or null if not defined (used by ui to generate user controls
* for changing parameters)
* *
* @return * @return
*/ */

View file

@ -11,8 +11,9 @@
package org.eclipse.cdt.codan.core.model; package org.eclipse.cdt.codan.core.model;
/** /**
* Problem category * Problem category.
* *
* Clients may extend and implement this interface.
*/ */
public interface IProblemCategory extends IProblemElement { public interface IProblemCategory extends IProblemElement {
/** /**
@ -32,17 +33,4 @@ public interface IProblemCategory extends IProblemElement {
*/ */
IProblemElement[] getChildren(); IProblemElement[] getChildren();
/**
* Find problem by id within children recursively
* @param id
* @return
*/
IProblem findProblem(String id);
/**
* Find category by id within children recursively
* @param id
* @return
*/
IProblemCategory findCategory(String id);
} }

View file

@ -11,9 +11,17 @@
package org.eclipse.cdt.codan.core.model; package org.eclipse.cdt.codan.core.model;
/** /**
* Problem category or problem * Problem category {@link IProblemCategory} or problem {@link IProblem}
* *
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
*/ */
public interface IProblemElement extends Cloneable { public interface IProblemElement extends Cloneable {
/**
* clone method should be implemented to support problem cloning
* @see {@link Object#clone}
* @return new object which is copy of this one
* @throws CloneNotSupportedException - it is declared with this exception but it should NOT throw it
*/
Object clone() throws CloneNotSupportedException; Object clone() throws CloneNotSupportedException;
} }

View file

@ -16,6 +16,8 @@ import org.eclipse.core.resources.IFile;
* Interface to describe problem location. Usually contains file and linenumber, * Interface to describe problem location. Usually contains file and linenumber,
* also supports character positions for sophisticated errors. * also supports character positions for sophisticated errors.
* *
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
*/ */
public interface IProblemLocation { public interface IProblemLocation {
/** /**

View file

@ -0,0 +1,39 @@
/*******************************************************************************
* Copyright (c) 2009 Alena Laskavaia
* 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Alena Laskavaia - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.codan.core.model;
import org.eclipse.core.resources.IFile;
/**
* Factory interface that allows to create problem locations.
*
* Clients may implement and extend this interface.
*/
public interface IProblemLocationFactory {
/**
* Create and return instance of IProblemLocation
* @param file - file where problem is found
* @param line - line number where problem is found, starts with 1
* @return instance of IProblemLocation
*/
public IProblemLocation createProblemLocation(IFile file, int line);
/**
* Create and return instance of IProblemLocation
* @param file - file where problem is found
* @param startChar - start char of the problem in the file, is zero-relative
* @param endChar - end char of the problem in the file, is zero-relative and exclusive.
* @return instance of IProblemLocation
*/
public IProblemLocation createProblemLocation(IFile file, int startChar, int endChar);
}

View file

@ -11,15 +11,15 @@
package org.eclipse.cdt.codan.core.model; package org.eclipse.cdt.codan.core.model;
/** /**
* Problem parameter usually key=value settings that allow to alter checker * Problem parameter usually key=value settings that allows to alter checker
* behaviour for given problem. For example if checker finds violation of naming * behaviour for given problem. For example if checker finds violation of naming
* conventions for function, parameter would be the pattern of allowed names. * conventions for function, parameter would be the pattern of allowed names.
* ProblemParameterInfo represent parameter meta-info for the ui. * ProblemParameterInfo represent parameter meta-info for the ui.
* If more that one parameter required ParameterInfo should describe hash or array of parameters. * If more that one parameter required ParameterInfo should describe hash or array of parameters.
* This is only needed for auto-generated ui for parameter editing. For complex case custom ui control should be used * This is only needed for auto-generated ui for parameter editing. For complex case custom ui control should be used
* *
* @author Alena * @noextend This interface is not intended to be extended by clients.
* * @noimplement This interface is not intended to be implemented by clients.
*/ */
public interface IProblemParameterInfo { public interface IProblemParameterInfo {
String getKey(); String getKey();
@ -42,13 +42,14 @@ public interface IProblemParameterInfo {
String getUiInfo(); String getUiInfo();
/** /**
* User visible label for the control in UI * User visible label for the parameter control in UI
* @return the label
*/ */
String getLabel(); String getLabel();
/** /**
* Available if type is list or hash. Returns value of subparamer with the * Available if type is list or hash. Returns value of subparamer with the
* name of key. For the "list" key must be "#". * name of key. For the "list" type key is the number (index).
* *
* @param key * @param key
* - name of the subparameter. * - name of the subparameter.

View file

@ -11,15 +11,21 @@
package org.eclipse.cdt.codan.core.model; package org.eclipse.cdt.codan.core.model;
/** /**
* Problem Profile contains tree of categories and problems. For user profile is quick way * Problem Profile contains tree of categories and problems. For the user
* to switch between problems sets depends on task he is doing (i.e. find real bugs, vs doing code style report) * the profile is quick way to switch between problem sets depending on the
* User can set different profiles in different projects. * task he is doing (i.e. find real bugs, vs doing code style report)
* Profiles can have different categories and different problems set, problems with the same id * User can set different profiles for different projects.
* can have different severities/enablement in different profiles. To obtain * Profiles can have different categories and different problem sets,
* profile use class {@link CheckersRegisry#getResourceProfile, * problems with the same id can have different severities/enablement in different profiles.
* Category tree can have few reference to a same problem, but only instance of Problem
* with the same id can exist in the same profile (i.e. two category can have same problem listed in both,
* but they both should point to the same problem instance).
*
* To obtain read-only profile use method {@link CheckersRegisry#getResourceProfile,
* CheckersRegisry#getDefaultProfile() or CheckersRegisry#getWorkspaceProfile()} * CheckersRegisry#getDefaultProfile() or CheckersRegisry#getWorkspaceProfile()}
* .
* *
* @noextend This interface is not intended to be extended by clients.
* @noimplement This interface is not intended to be implemented by clients.
*/ */
public interface IProblemProfile extends IProblemElement { public interface IProblemProfile extends IProblemElement {
/** /**
@ -28,7 +34,7 @@ public interface IProblemProfile extends IProblemElement {
IProblemCategory getRoot(); IProblemCategory getRoot();
/** /**
* Find and return problem by id * Find and return problem by id if it contained in this profile
* *
* @param id * @param id
* - problem id * - problem id
@ -37,7 +43,7 @@ public interface IProblemProfile extends IProblemElement {
IProblem findProblem(String id); IProblem findProblem(String id);
/** /**
* Find and return category by id * Find and return category by id if it is contained in this profile
* *
* @param id * @param id
* - category id * - category id
@ -46,7 +52,7 @@ public interface IProblemProfile extends IProblemElement {
IProblemCategory findCategory(String id); IProblemCategory findCategory(String id);
/** /**
* Get all defined problems * Get all problems defined in this profile (if problem duplicated in a category tree, it returns only one instance of each)
* *
* @return array of problems defined in profile * @return array of problems defined in profile
*/ */

View file

@ -10,20 +10,20 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.codan.core.model; package org.eclipse.cdt.codan.core.model;
/** /**
* IProblemReporter - interface to report problems * IProblemReporter - interface to report problems
* *
* Clients may implement and extend this interface
*/ */
public interface IProblemReporter { public interface IProblemReporter {
public static final String GENERIC_CODE_ANALYSIS_MARKER_TYPE = "org.eclipse.cdt.codan.core.codanProblem"; public static final String GENERIC_CODE_ANALYSIS_MARKER_TYPE = "org.eclipse.cdt.codan.core.codanProblem"; //$NON-NLS-1$
/** /**
* Report a problem with "problemId" id on location determined by "loc", * Report a problem with "problemId" id on the location determined by "loc",
* using problem specific error message customised by args. * using problem specific error message customized by args.
* @param problemId - id of the problem registers with checker * @param problemId - id of the problem registered with a checker
* @param loc - location object * @param loc - location object
* @param args - custom args, can be null, in this case default message is reported * @param args - custom arguments, can be null, in this case default message is reported
*/ */
public void reportProblem(String problemId, IProblemLocation loc, public void reportProblem(String problemId, IProblemLocation loc, Object... args);
Object ... args);
} }

View file

@ -10,22 +10,43 @@
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.codan.core.model; package org.eclipse.cdt.codan.core.model;
/** /**
* Modifiable problem * Modifiable problem
* @author Alena
* *
* Clients may extend and implement this interface
*/ */
public interface IProblemWorkingCopy extends IProblem { public interface IProblemWorkingCopy extends IProblem {
/**
* Set severity for this this problem instance. Severity can only be changed in profile
* not by checker when printing problems.
* @param sev - codan severity
*/
void setSeverity(CodanSeverity sev); void setSeverity(CodanSeverity sev);
void setEnabled(boolean checked); /**
* Set checker enablement.
* @param enabled - true if problem is enabled in profile
*/
void setEnabled(boolean enabled);
void setMessagePattern(String message); /**
* Set default message pattern. UI would call this method if user does not like default
* settings, checker should not use method, default message pattern should be set in
* checker extension
* @param messagePattern - java style message patter i.e. "Variable {0} is never used"
*/
void setMessagePattern(String messagePattern);
/**
* Set value for the checker parameter, checker may set value during initialization only
* @param key - key of the parameter
* @param value - parameter value
*/
public void setParameter(Object key, Object value); public void setParameter(Object key, Object value);
public IProblemCategory getCategory(); /**
* Set parameter info object for the given problem, see {@link IProblemParameterInfo}
* @param info
*/
public void setParameterInfo(IProblemParameterInfo info); public void setParameterInfo(IProblemParameterInfo info);
} }

View file

@ -13,36 +13,25 @@ package org.eclipse.cdt.codan.core.model;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
/** /**
* Implementation of IProblemLocation * Abstract Implementation of IProblemLocation
* *
* Clients may extend this class.
*/ */
public class ProblemLocation implements IProblemLocation { public abstract class ProblemLocation implements IProblemLocation {
protected IFile file; protected IFile file;
protected int line; protected int line;
protected int posStart; protected int posStart;
protected int posEnd; protected int posEnd;
protected Object extra; protected Object extra;
/** protected ProblemLocation(IFile file, int line) {
* @param file
* @param line
* @param lineEnd
* @param posStart
* @param posEnd
*/
public ProblemLocation(IFile file, int line) {
this.file = file; this.file = file;
this.line = line; this.line = line;
this.posStart = -1; this.posStart = -1;
this.posEnd = -1; this.posEnd = -1;
} }
/** protected ProblemLocation(IFile file, int startChar, int endChar) {
* @param file
* @param startingLineNumber
* @param endingLineNumber
*/
public ProblemLocation(IFile file, int startChar, int endChar) {
this.file = file; this.file = file;
this.line = -1; this.line = -1;
this.posStart = startChar; this.posStart = startChar;

View file

@ -38,11 +38,13 @@ import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.preferences.IEclipsePreferences; import org.eclipse.core.runtime.preferences.IEclipsePreferences;
public class CheckersRegisry implements Iterable<IChecker>, ICheckersRegistry { public class CheckersRegisry implements Iterable<IChecker>, ICheckersRegistry {
private static final String EXTENSION_POINT_NAME = "checkers"; private static final String NAME_ATTR = "name"; //$NON-NLS-1$
private static final String CHECKER_ELEMENT = "checker"; private static final String ID_ATTR = "id"; //$NON-NLS-1$
private static final String PROBLEM_ELEMENT = "problem"; private static final String EXTENSION_POINT_NAME = "checkers"; //$NON-NLS-1$
private static final String CATEGORY_ELEMENT = "category"; private static final String CHECKER_ELEMENT = "checker"; //$NON-NLS-1$
private static final Object DEFAULT = "DEFAULT"; private static final String PROBLEM_ELEMENT = "problem"; //$NON-NLS-1$
private static final String CATEGORY_ELEMENT = "category"; //$NON-NLS-1$
private static final Object DEFAULT = "DEFAULT"; //$NON-NLS-1$
private Collection<IChecker> checkers = new ArrayList<IChecker>(); private Collection<IChecker> checkers = new ArrayList<IChecker>();
private static CheckersRegisry instance; private static CheckersRegisry instance;
private HashMap<Object, IProblemProfile> profiles = new HashMap<Object, IProblemProfile>(); private HashMap<Object, IProblemProfile> profiles = new HashMap<Object, IProblemProfile>();
@ -55,10 +57,9 @@ public class CheckersRegisry implements Iterable<IChecker>, ICheckersRegistry {
} }
private void readCheckersRegistry() { private void readCheckersRegistry() {
IExtensionPoint ep = Platform.getExtensionRegistry().getExtensionPoint( IExtensionPoint ep = Platform.getExtensionRegistry().getExtensionPoint(CodanCorePlugin.PLUGIN_ID,
CodanCorePlugin.PLUGIN_ID, EXTENSION_POINT_NAME); EXTENSION_POINT_NAME);
if (ep == null) if (ep == null) return;
return;
IConfigurationElement[] elements = ep.getConfigurationElements(); IConfigurationElement[] elements = ep.getConfigurationElements();
// process categories // process categories
for (int i = 0; i < elements.length; i++) { for (int i = 0; i < elements.length; i++) {
@ -76,16 +77,14 @@ public class CheckersRegisry implements Iterable<IChecker>, ICheckersRegistry {
processChecker(configurationElement); processChecker(configurationElement);
} }
// init parameters for checkers with parameters // init parameters for checkers with parameters
for (Iterator iterator = problemList.keySet().iterator(); iterator for (Iterator<IChecker> iterator = problemList.keySet().iterator(); iterator.hasNext();) {
.hasNext();) { IChecker c = iterator.next();
IChecker c = (IChecker) iterator.next();
if (c instanceof ICheckerWithParameters) { if (c instanceof ICheckerWithParameters) {
Collection<IProblem> list = problemList.get(c); Collection<IProblem> list = problemList.get(c);
for (Iterator iterator2 = list.iterator(); iterator2.hasNext();) { for (Iterator<IProblem> iterator2 = list.iterator(); iterator2.hasNext();) {
IProblem p = (IProblem) iterator2.next(); IProblem p = iterator2.next();
if (p instanceof IProblemWorkingCopy) { if (p instanceof IProblemWorkingCopy) {
((ICheckerWithParameters) c) ((ICheckerWithParameters) c).initParameters((IProblemWorkingCopy) p);
.initParameters((IProblemWorkingCopy) p);
} }
} }
} }
@ -97,15 +96,12 @@ public class CheckersRegisry implements Iterable<IChecker>, ICheckersRegistry {
*/ */
private void processCategories(IConfigurationElement configurationElement) { private void processCategories(IConfigurationElement configurationElement) {
if (configurationElement.getName().equals(CATEGORY_ELEMENT)) { if (configurationElement.getName().equals(CATEGORY_ELEMENT)) {
String id = getAtt(configurationElement, "id"); String id = getAtt(configurationElement, ID_ATTR);
if (id == null) if (id == null) return;
return; String name = getAtt(configurationElement, NAME_ATTR);
String name = getAtt(configurationElement, "name"); if (name == null) return;
if (name == null)
return;
CodanProblemCategory cat = new CodanProblemCategory(id, name); CodanProblemCategory cat = new CodanProblemCategory(id, name);
String category = getAtt(configurationElement, "parentCategory", String category = getAtt(configurationElement, "parentCategory", false); //$NON-NLS-1$
false);
addCategory(cat, category); addCategory(cat, category);
} }
} }
@ -116,27 +112,22 @@ public class CheckersRegisry implements Iterable<IChecker>, ICheckersRegistry {
private void processChecker(IConfigurationElement configurationElement) { private void processChecker(IConfigurationElement configurationElement) {
try { try {
if (configurationElement.getName().equals(CHECKER_ELEMENT)) { if (configurationElement.getName().equals(CHECKER_ELEMENT)) {
String id = getAtt(configurationElement, "id"); String id = getAtt(configurationElement, ID_ATTR);
if (id == null) if (id == null) return;
return; String name = getAtt(configurationElement, NAME_ATTR, false);
String name = getAtt(configurationElement, "name", false); if (name == null) name = id;
if (name == null)
name = id;
IChecker checkerObj = null; IChecker checkerObj = null;
try { try {
Object checker = configurationElement Object checker = configurationElement.createExecutableExtension("class"); //$NON-NLS-1$
.createExecutableExtension("class");
checkerObj = (IChecker) checker; checkerObj = (IChecker) checker;
addChecker(checkerObj); addChecker(checkerObj);
} catch (CoreException e) { } catch (CoreException e) {
CodanCorePlugin.log(e); CodanCorePlugin.log(e);
return; return;
} }
IConfigurationElement[] children1 = configurationElement IConfigurationElement[] children1 = configurationElement.getChildren("problemRef"); //$NON-NLS-1$
.getChildren("problemRef");
boolean hasRef = false; boolean hasRef = false;
IConfigurationElement[] children2 = configurationElement IConfigurationElement[] children2 = configurationElement.getChildren(PROBLEM_ELEMENT);
.getChildren(PROBLEM_ELEMENT);
if (children2 != null) { if (children2 != null) {
for (IConfigurationElement ref : children2) { for (IConfigurationElement ref : children2) {
IProblem p = processProblem(ref); IProblem p = processProblem(ref);
@ -147,8 +138,7 @@ public class CheckersRegisry implements Iterable<IChecker>, ICheckersRegistry {
if (children1 != null) { if (children1 != null) {
for (IConfigurationElement ref : children1) { for (IConfigurationElement ref : children1) {
hasRef = true; hasRef = true;
IProblem p = getDefaultProfile().findProblem( IProblem p = getDefaultProfile().findProblem(ref.getAttribute("refId")); //$NON-NLS-1$
ref.getAttribute("refId"));
addRefProblem(checkerObj, p); addRefProblem(checkerObj, p);
} }
} }
@ -167,39 +157,30 @@ public class CheckersRegisry implements Iterable<IChecker>, ICheckersRegistry {
* @param configurationElement * @param configurationElement
* @return * @return
*/ */
private CodanProblem processProblem( private CodanProblem processProblem(IConfigurationElement configurationElement) {
IConfigurationElement configurationElement) {
if (configurationElement.getName().equals(PROBLEM_ELEMENT)) { if (configurationElement.getName().equals(PROBLEM_ELEMENT)) {
String id = getAtt(configurationElement, "id"); String id = getAtt(configurationElement, ID_ATTR);
if (id == null) if (id == null) return null;
return null; String name = getAtt(configurationElement, NAME_ATTR);
String name = getAtt(configurationElement, "name"); if (name == null) name = id;
if (name == null)
name = id;
CodanProblem p = new CodanProblem(id, name); CodanProblem p = new CodanProblem(id, name);
String category = getAtt(configurationElement, "category", false); String category = getAtt(configurationElement, "category", false); //$NON-NLS-1$
if (category == null) if (category == null) category = "org.eclipse.cdt.codan.core.categories.ProgrammingProblems"; //$NON-NLS-1$
category = "org.eclipse.cdt.codan.core.categories.ProgrammingProblems";
addProblem(p, category); addProblem(p, category);
return p; return p;
} }
return null; return null;
} }
private static String getAtt(IConfigurationElement configurationElement, private static String getAtt(IConfigurationElement configurationElement, String name) {
String name) {
return getAtt(configurationElement, name, true); return getAtt(configurationElement, name, true);
} }
private static String getAtt(IConfigurationElement configurationElement, private static String getAtt(IConfigurationElement configurationElement, String name, boolean req) {
String name, boolean req) {
String elementValue = configurationElement.getAttribute(name); String elementValue = configurationElement.getAttribute(name);
if (elementValue == null && req) if (elementValue == null && req)
CodanCorePlugin.log("Extension " CodanCorePlugin.log("Extension " + configurationElement.getDeclaringExtension().getUniqueIdentifier() //$NON-NLS-1$
+ configurationElement.getDeclaringExtension() + " missing required attribute: " + configurationElement.getName() + "." + name); //$NON-NLS-1$ //$NON-NLS-2$
.getUniqueIdentifier()
+ " missing required attribute: "
+ configurationElement.getName() + "." + name);
return elementValue; return elementValue;
} }
@ -213,8 +194,7 @@ public class CheckersRegisry implements Iterable<IChecker>, ICheckersRegistry {
} }
public static CheckersRegisry getInstance() { public static CheckersRegisry getInstance() {
if (instance == null) if (instance == null) return new CheckersRegisry();
new CheckersRegisry();
return instance; return instance;
} }
@ -238,8 +218,7 @@ public class CheckersRegisry implements Iterable<IChecker>, ICheckersRegistry {
*/ */
public void addProblem(IProblem p, String category) { public void addProblem(IProblem p, String category) {
IProblemCategory cat = getDefaultProfile().findCategory(category); IProblemCategory cat = getDefaultProfile().findCategory(category);
if (cat == null) if (cat == null) cat = getDefaultProfile().getRoot();
cat = getDefaultProfile().getRoot();
((ProblemProfile) getDefaultProfile()).addProblem(p, cat); ((ProblemProfile) getDefaultProfile()).addProblem(p, cat);
} }
@ -252,8 +231,7 @@ public class CheckersRegisry implements Iterable<IChecker>, ICheckersRegistry {
*/ */
public void addCategory(IProblemCategory p, String category) { public void addCategory(IProblemCategory p, String category) {
IProblemCategory cat = getDefaultProfile().findCategory(category); IProblemCategory cat = getDefaultProfile().findCategory(category);
if (cat == null) if (cat == null) cat = getDefaultProfile().getRoot();
cat = getDefaultProfile().getRoot();
((ProblemProfile) getDefaultProfile()).addCategory(p, cat); ((ProblemProfile) getDefaultProfile()).addCategory(p, cat);
} }
@ -310,15 +288,17 @@ public class CheckersRegisry implements Iterable<IChecker>, ICheckersRegistry {
} catch (CloneNotSupportedException e) { } catch (CloneNotSupportedException e) {
wp = getDefaultProfile(); wp = getDefaultProfile();
} }
profiles.put(ResourcesPlugin.getWorkspace(), wp);
} }
return wp; return wp;
} }
public void updateProfile(IResource element, IProblemProfile profile) { public void updateProfile(IResource element, IProblemProfile profile) {
if (profile == null) // updating profile can invalidate all cached profiles
profiles.remove(element); IProblemProfile defaultProfile = getDefaultProfile();
else profiles.clear();
profiles.put(element, profile); profiles.put(DEFAULT, defaultProfile);
if (profile != null && element != null) profiles.put(element, profile);
} }
/* /*
@ -335,17 +315,13 @@ public class CheckersRegisry implements Iterable<IChecker>, ICheckersRegistry {
try { try {
prof = (IProblemProfile) getWorkspaceProfile().clone(); prof = (IProblemProfile) getWorkspaceProfile().clone();
// load default values // load default values
CodanPreferencesLoader loader = new CodanPreferencesLoader( CodanPreferencesLoader loader = new CodanPreferencesLoader(prof);
prof); IEclipsePreferences node = new ProjectScope((IProject) element).getNode(CodanCorePlugin.PLUGIN_ID);
IEclipsePreferences node = new ProjectScope( boolean useWorkspace = node.getBoolean(PreferenceConstants.P_USE_PARENT, false);
(IProject) element)
.getNode(CodanCorePlugin.PLUGIN_ID);
boolean useWorkspace = node.getBoolean(
PreferenceConstants.P_USE_PARENT, false);
if (!useWorkspace) { if (!useWorkspace) {
loader.load(node); loader.load(node);
} }
updateProfile(element, prof); profiles.put(element, prof);
} catch (CloneNotSupportedException e) { } catch (CloneNotSupportedException e) {
// cant // cant
} }
@ -366,20 +342,13 @@ public class CheckersRegisry implements Iterable<IChecker>, ICheckersRegistry {
* getResourceProfileWorkingCopy(org.eclipse.core.resources.IResource) * getResourceProfileWorkingCopy(org.eclipse.core.resources.IResource)
*/ */
public IProblemProfile getResourceProfileWorkingCopy(IResource element) { public IProblemProfile getResourceProfileWorkingCopy(IResource element) {
if (element instanceof IProject) {
try { try {
IProblemProfile prof = (IProblemProfile) getWorkspaceProfile() IProblemProfile prof = (IProblemProfile) getResourceProfile(element).clone();
.clone(); return prof;
// load default values } catch (CloneNotSupportedException e) {
CodanPreferencesLoader loader = new CodanPreferencesLoader(prof); // cant
IEclipsePreferences node = new ProjectScope((IProject) element) return null;
.getNode(CodanCorePlugin.PLUGIN_ID);
loader.load(node);
return prof;
} catch (CloneNotSupportedException e) {
// cant
}
} }
return null;
} }
} }

View file

@ -1,9 +1,9 @@
package org.eclipse.cdt.codan.core; package org.eclipse.cdt.codan.internal.core;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import org.eclipse.cdt.codan.internal.core.CodanBuilder; import org.eclipse.cdt.codan.core.CodanRuntime;
import org.eclipse.cdt.codan.internal.core.model.CodanMarkerProblemReporter; import org.eclipse.cdt.codan.internal.core.model.CodanMarkerProblemReporter;
import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProject;
@ -12,14 +12,20 @@ import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.equinox.app.IApplication; import org.eclipse.equinox.app.IApplication;
import org.eclipse.equinox.app.IApplicationContext; import org.eclipse.equinox.app.IApplicationContext;
/**
*
* Application to support headless build
*
* @noextend This class is not intended to be extended by clients.
* @noinstantiate This class is not intended to be instantiated by clients.
*/
public class CodanApplication implements IApplication { public class CodanApplication implements IApplication {
private Collection<String> projects = new ArrayList<String>(); private Collection<String> projects = new ArrayList<String>();
private boolean verbose = false; private boolean verbose = false;
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( String[] args = (String[]) context.getArguments().get("application.args"); //$NON-NLS-1$
"application.args");
if (args == null || args.length == 0) { if (args == null || args.length == 0) {
help(); help();
return EXIT_OK; return EXIT_OK;
@ -29,10 +35,9 @@ 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, public void reportProblem(String id, int severity, IFile file, int lineNumber, int startChar, int endChar,
int lineNumber, int startChar, int endChar, String message) { String message) {
System.out.println(file.getLocation() + ":" + lineNumber + ": " System.out.println(file.getLocation() + ":" + lineNumber + ": " + message);
+ message);
} }
}); });
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
@ -44,8 +49,7 @@ public class CodanApplication implements IApplication {
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 System.err.println("Error: project " + project + " does not exist");
+ " does not exist");
continue; continue;
} }
wProject.accept(codanBuilder.new CodanResourceVisitor()); wProject.accept(codanBuilder.new CodanResourceVisitor());
@ -58,8 +62,7 @@ public class CodanApplication implements IApplication {
* @param string * @param string
*/ */
private void log(String string) { private void log(String string) {
if (verbose) if (verbose) System.err.println(string);
System.err.println(string);
} }
/** /**

View file

@ -41,9 +41,8 @@ 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.NullProgressMonitor;
public class CodanBuilder extends IncrementalProjectBuilder implements public class CodanBuilder extends IncrementalProjectBuilder implements ICodanBuilder, ICodanAstReconciler {
ICodanBuilder, ICodanAstReconciler { 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";
public class CodanDeltaVisitor implements IResourceDeltaVisitor { public class CodanDeltaVisitor implements IResourceDeltaVisitor {
/* /*
@ -63,17 +62,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, new NullProgressMonitor()); processResource(resource, new NullProgressMonitor());
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, new NullProgressMonitor());
break; break;
} }
// return true to continue visiting children. // return true to continue visiting children.
return true; return true;
@ -82,8 +81,7 @@ public class CodanBuilder extends IncrementalProjectBuilder implements
public class CodanResourceVisitor implements IResourceVisitor { public class CodanResourceVisitor implements IResourceVisitor {
public boolean visit(IResource resource) { public boolean visit(IResource resource) {
if (!(resource instanceof IProject)) if (!(resource instanceof IProject)) processResource(resource, new NullProgressMonitor());
processResource(resource, new NullProgressMonitor());
// return true to continue visiting children. // return true to continue visiting children.
return true; return true;
} }
@ -95,8 +93,9 @@ public class CodanBuilder extends IncrementalProjectBuilder implements
* @see org.eclipse.core.internal.events.InternalBuilder#build(int, * @see org.eclipse.core.internal.events.InternalBuilder#build(int,
* java.util.Map, org.eclipse.core.runtime.IProgressMonitor) * java.util.Map, org.eclipse.core.runtime.IProgressMonitor)
*/ */
protected IProject[] build(int kind, Map args, IProgressMonitor monitor) @SuppressWarnings("rawtypes")
throws CoreException { @Override
protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException {
if (kind == FULL_BUILD) { if (kind == FULL_BUILD) {
fullBuild(monitor); fullBuild(monitor);
} else { } else {
@ -115,21 +114,16 @@ public class CodanBuilder extends IncrementalProjectBuilder implements
// CodanCorePlugin.PLUGIN_ID, "problems", "", null); // CodanCorePlugin.PLUGIN_ID, "problems", "", null);
// System.err.println("set = " + string); // System.err.println("set = " + string);
// delete general markers // delete general markers
IProblemReporter problemReporter = CodanRuntime.getInstance() IProblemReporter problemReporter = CodanRuntime.getInstance().getProblemReporter();
.getProblemReporter();
if (problemReporter instanceof CodanMarkerProblemReporter) { if (problemReporter instanceof CodanMarkerProblemReporter) {
((CodanMarkerProblemReporter) problemReporter) ((CodanMarkerProblemReporter) problemReporter).deleteMarkers(resource);
.deleteMarkers(resource);
} }
for (IChecker checker : CheckersRegisry.getInstance()) { for (IChecker checker : CheckersRegisry.getInstance()) {
try { try {
boolean run = false; boolean run = false;
if (checker.enabledInContext(resource)) if (checker.enabledInContext(resource)) run = true;
run = true; if (areProblemsForCheckerEnabled(checker, resource)) run = true;
if (areProblemsForCheckerEnabled(checker, resource)) if (run) checker.processResource(resource);
run = true;
if (run)
checker.processResource(resource);
} catch (Throwable e) { } catch (Throwable e) {
CodanCorePlugin.log(e); CodanCorePlugin.log(e);
} }
@ -144,8 +138,7 @@ public class CodanBuilder extends IncrementalProjectBuilder implements
} }
public void reconcileAst(IASTTranslationUnit ast, IProgressMonitor monitor) { public void reconcileAst(IASTTranslationUnit ast, IProgressMonitor monitor) {
if (ast == null) if (ast == null) return;
return;
String filePath = ast.getFilePath(); String filePath = ast.getFilePath();
IWorkspace workspace = ResourcesPlugin.getWorkspace(); IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceRoot root = workspace.getRoot(); IWorkspaceRoot root = workspace.getRoot();
@ -154,24 +147,20 @@ public class CodanBuilder extends IncrementalProjectBuilder implements
resources = root.findFilesForLocationURI(uri); resources = root.findFilesForLocationURI(uri);
if (resources != null && resources.length > 0) { if (resources != null && resources.length > 0) {
IFile resource = resources[0]; IFile resource = resources[0];
IProblemReporter problemReporter = CodanRuntime.getInstance() IProblemReporter problemReporter = CodanRuntime.getInstance().getProblemReporter();
.getProblemReporter();
// TODO: this is wrong - should not delete all markers - // TODO: this is wrong - should not delete all markers -
// only those that contributed by the checker that we run now // only those that contributed by the checker that we run now
if (problemReporter instanceof CodanMarkerProblemReporter) { if (problemReporter instanceof CodanMarkerProblemReporter) {
((CodanMarkerProblemReporter) problemReporter) ((CodanMarkerProblemReporter) problemReporter).deleteMarkers(resource);
.deleteMarkers(resource);
} }
for (IChecker checker : CheckersRegisry.getInstance()) { for (IChecker checker : CheckersRegisry.getInstance()) {
try { try {
boolean run = false; boolean run = false;
if (checker.enabledInContext(resource)) if (checker.enabledInContext(resource)) run = true;
run = true;
if (areProblemsForCheckerEnabled(checker, resource)) { if (areProblemsForCheckerEnabled(checker, resource)) {
run = true; run = true;
} }
if (run && checker instanceof ICAstChecker if (run && checker instanceof ICAstChecker && checker.runInEditor())
&& checker.runInEditor())
((ICAstChecker) checker).processAst(ast); ((ICAstChecker) checker).processAst(ast);
} catch (Throwable e) { } catch (Throwable e) {
CodanCorePlugin.log(e); CodanCorePlugin.log(e);
@ -185,35 +174,28 @@ public class CodanBuilder extends IncrementalProjectBuilder implements
* @param resource * @param resource
* @return * @return
*/ */
private boolean areProblemsForCheckerEnabled(IChecker checker, private boolean areProblemsForCheckerEnabled(IChecker checker, IResource resource) {
IResource resource) { IProblemProfile resourceProfile = CheckersRegisry.getInstance().getResourceProfile(resource);
IProblemProfile resourceProfile = CheckersRegisry.getInstance() Collection<IProblem> refProblems = CheckersRegisry.getInstance().getRefProblems(checker);
.getResourceProfile(resource); for (Iterator<IProblem> iterator = refProblems.iterator(); iterator.hasNext();) {
Collection<IProblem> refProblems = CheckersRegisry.getInstance() IProblem p = iterator.next();
.getRefProblems(checker);
for (Iterator iterator = refProblems.iterator(); iterator.hasNext();) {
IProblem p = (IProblem) iterator.next();
// we need to check problem enablement in particular profile // we need to check problem enablement in particular profile
IProblem problem = resourceProfile.findProblem(p.getId()); IProblem problem = resourceProfile.findProblem(p.getId());
if (problem == null) if (problem == null) throw new IllegalArgumentException("Id is not registered"); //$NON-NLS-1$
throw new IllegalArgumentException("Id is not registered"); if (problem.isEnabled()) return true;
if (problem.isEnabled())
return true;
} }
// no problem is enabled for this checker, skip the checker // no problem is enabled for this checker, skip the checker
return false; return false;
} }
protected void fullBuild(final IProgressMonitor monitor) protected void fullBuild(final IProgressMonitor monitor) throws CoreException {
throws CoreException {
try { try {
getProject().accept(new CodanResourceVisitor()); getProject().accept(new CodanResourceVisitor());
} catch (CoreException e) { } 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());
} }

View file

@ -54,11 +54,10 @@ public class CodanPreferencesLoader {
*/ */
public void setProperty(String id, String s) { public void setProperty(String id, String s) {
IProblem prob = baseModel.findProblem(id); IProblem prob = baseModel.findProblem(id);
if (!(prob instanceof CodanProblem)) if (!(prob instanceof CodanProblem)) return;
return;
String sevs = s; String sevs = s;
boolean enabled = true; boolean enabled = true;
if (sevs.startsWith("-")) { if (sevs.startsWith("-")) { //$NON-NLS-1$
sevs = sevs.substring(1); sevs = sevs.substring(1);
enabled = false; enabled = false;
} }
@ -95,8 +94,7 @@ public class CodanPreferencesLoader {
*/ */
public String getProperty(String id) { public String getProperty(String id) {
IProblem prob = baseModel.findProblem(id); IProblem prob = baseModel.findProblem(id);
if (!(prob instanceof CodanProblem)) if (!(prob instanceof CodanProblem)) return null;
return null;
String enabled = prob.isEnabled() ? "" : "-"; String enabled = prob.isEnabled() ? "" : "-";
String severity = prob.getSeverity().toString(); String severity = prob.getSeverity().toString();
String res = enabled + severity; String res = enabled + severity;

View file

@ -20,7 +20,7 @@ public class CodeAnlysisNature implements IProjectNature {
/** /**
* ID of this project nature * ID of this project nature
*/ */
public static final String NATURE_ID = "org.eclipse.cdt.codan.core.codanNature"; public static final String NATURE_ID = "org.eclipse.cdt.codan.core.codanNature"; //$NON-NLS-1$
private IProject project; private IProject project;
/* /*
@ -32,9 +32,7 @@ public class CodeAnlysisNature implements IProjectNature {
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)) { if (commands[i].getBuilderName().equals(CodanBuilder.BUILDER_ID)) { return; }
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);
@ -57,8 +55,7 @@ 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, System.arraycopy(commands, i + 1, newCommands, i, commands.length - i - 1);
commands.length - i - 1);
description.setBuildSpec(newCommands); description.setBuildSpec(newCommands);
project.setDescription(description, null); project.setDescription(description, null);
return; return;

View file

@ -24,7 +24,6 @@ import org.eclipse.core.runtime.CoreException;
public class CodanMarkerProblemReporter implements IProblemReporter { public class CodanMarkerProblemReporter implements IProblemReporter {
/* /*
* (non-Javadoc) * (non-Javadoc)
* *
@ -36,27 +35,20 @@ public class CodanMarkerProblemReporter implements IProblemReporter {
public void reportProblem(String id, IProblemLocation loc, Object... args) { public void reportProblem(String id, IProblemLocation loc, Object... args) {
IFile file = loc.getFile(); IFile file = loc.getFile();
int lineNumber = loc.getLineNumber(); int lineNumber = loc.getLineNumber();
if (file == null) if (file == null) throw new NullPointerException("file"); //$NON-NLS-1$
throw new NullPointerException("file"); if (id == null) throw new NullPointerException("id"); //$NON-NLS-1$
if (id == null) IProblem problem = CheckersRegisry.getInstance().getResourceProfile(file).findProblem(id);
throw new NullPointerException("id"); if (problem == null) throw new IllegalArgumentException("Id is not registered"); //$NON-NLS-1$
IProblem problem = CheckersRegisry.getInstance().getResourceProfile( if (problem.isEnabled() == false) return; // skip
file).findProblem(id);
if (problem == null)
throw new IllegalArgumentException("Id is not registered");
if (problem.isEnabled() == false)
return; // skip
int severity = problem.getSeverity().intValue(); int severity = problem.getSeverity().intValue();
String messagePattern = problem.getMessagePattern(); String messagePattern = problem.getMessagePattern();
String message = id; String message = id;
if (messagePattern == null) { if (messagePattern == null) {
if (args != null && args.length > 0 && args[0] instanceof String) if (args != null && args.length > 0 && args[0] instanceof String) message = (String) args[0];
message = (String) args[0];
} else { } else {
MessageFormat.format(messagePattern, args); MessageFormat.format(messagePattern, args);
} }
reportProblem(id, severity, file, lineNumber, loc.getStartingChar(), reportProblem(id, severity, file, lineNumber, loc.getStartingChar(), loc.getEndingChar(), message);
loc.getEndingChar(), message);
} }
/* /*
@ -66,28 +58,22 @@ public class CodanMarkerProblemReporter implements IProblemReporter {
* org.eclipse.cdt.codan.core.model.IProblemReporter#reportProblem(java. * org.eclipse.cdt.codan.core.model.IProblemReporter#reportProblem(java.
* lang.String, org.eclipse.core.resources.IFile, int, java.lang.String) * lang.String, org.eclipse.core.resources.IFile, int, java.lang.String)
*/ */
public void reportProblem(String id, int severity, IFile file, public void reportProblem(String id, int severity, IFile file, int lineNumber, int startChar, int endChar,
int lineNumber, int startChar, int endChar, String message) { String message) {
try { try {
// Do not put in duplicates // Do not put in duplicates
IMarker[] cur = file.findMarkers(GENERIC_CODE_ANALYSIS_MARKER_TYPE, IMarker[] cur = file.findMarkers(GENERIC_CODE_ANALYSIS_MARKER_TYPE, false, IResource.DEPTH_ZERO);
false, IResource.DEPTH_ZERO);
if (cur != null) { if (cur != null) {
for (IMarker element : cur) { for (IMarker element : cur) {
int line = ((Integer) element int line = ((Integer) element.getAttribute(IMarker.LINE_NUMBER)).intValue();
.getAttribute(IMarker.LINE_NUMBER)).intValue();
if (line == lineNumber) { if (line == lineNumber) {
String mesg = (String) element String mesg = (String) element.getAttribute(IMarker.MESSAGE);
.getAttribute(IMarker.MESSAGE); int sev = ((Integer) element.getAttribute(IMarker.SEVERITY)).intValue();
int sev = ((Integer) element if (sev == severity && mesg.equals(message)) return;
.getAttribute(IMarker.SEVERITY)).intValue();
if (sev == severity && mesg.equals(message))
return;
} }
} }
} }
IMarker marker = file IMarker marker = file.createMarker(GENERIC_CODE_ANALYSIS_MARKER_TYPE);
.createMarker(GENERIC_CODE_ANALYSIS_MARKER_TYPE);
marker.setAttribute(IMarker.MESSAGE, message); marker.setAttribute(IMarker.MESSAGE, message);
marker.setAttribute(IMarker.SEVERITY, severity); marker.setAttribute(IMarker.SEVERITY, severity);
marker.setAttribute(IMarker.LINE_NUMBER, lineNumber); marker.setAttribute(IMarker.LINE_NUMBER, lineNumber);
@ -101,8 +87,7 @@ public class CodanMarkerProblemReporter implements IProblemReporter {
public void deleteMarkers(IResource file) { public void deleteMarkers(IResource file) {
try { try {
file.deleteMarkers(GENERIC_CODE_ANALYSIS_MARKER_TYPE, false, file.deleteMarkers(GENERIC_CODE_ANALYSIS_MARKER_TYPE, false, IResource.DEPTH_ZERO);
IResource.DEPTH_ZERO);
} catch (CoreException ce) { } catch (CoreException ce) {
ce.printStackTrace(); ce.printStackTrace();
} }
@ -111,8 +96,7 @@ public class CodanMarkerProblemReporter implements IProblemReporter {
public void deleteAllMarkers() { public void deleteAllMarkers() {
try { try {
// TODO delete contributed markers too // TODO delete contributed markers too
ResourcesPlugin.getWorkspace().getRoot().deleteMarkers( ResourcesPlugin.getWorkspace().getRoot().deleteMarkers(GENERIC_CODE_ANALYSIS_MARKER_TYPE, false,
GENERIC_CODE_ANALYSIS_MARKER_TYPE, false,
IResource.DEPTH_INFINITE); IResource.DEPTH_INFINITE);
} catch (CoreException e) { } catch (CoreException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block

View file

@ -11,6 +11,7 @@
package org.eclipse.cdt.codan.internal.core.model; package org.eclipse.cdt.codan.internal.core.model;
import java.util.HashMap; import java.util.HashMap;
import org.eclipse.cdt.codan.core.model.CodanSeverity; import org.eclipse.cdt.codan.core.model.CodanSeverity;
import org.eclipse.cdt.codan.core.model.IProblemCategory; import org.eclipse.cdt.codan.core.model.IProblemCategory;
import org.eclipse.cdt.codan.core.model.IProblemParameterInfo; import org.eclipse.cdt.codan.core.model.IProblemParameterInfo;
@ -24,6 +25,7 @@ public class CodanProblem implements IProblemWorkingCopy {
private boolean enabled = true; private boolean enabled = true;
private HashMap<Object, Object> parameters = new HashMap<Object, Object>(0); private HashMap<Object, Object> parameters = new HashMap<Object, Object>(0);
private IProblemParameterInfo parameterInfo; private IProblemParameterInfo parameterInfo;
private boolean frozen;
public CodanSeverity getSeverity() { public CodanSeverity getSeverity() {
return severity; return severity;
@ -32,6 +34,7 @@ public class CodanProblem implements IProblemWorkingCopy {
public CodanProblem(String problemId, String name) { public CodanProblem(String problemId, String name) {
this.id = problemId; this.id = problemId;
this.name = name; this.name = name;
this.frozen = false;
} }
public String getName() { public String getName() {
@ -57,8 +60,7 @@ public class CodanProblem implements IProblemWorkingCopy {
} }
public void setSeverity(CodanSeverity sev) { public void setSeverity(CodanSeverity sev) {
if (sev == null) if (sev == null) throw new NullPointerException();
throw new NullPointerException();
this.severity = sev; this.severity = sev;
} }
@ -101,11 +103,20 @@ public class CodanProblem implements IProblemWorkingCopy {
return message; return message;
} }
protected void freeze() {
frozen = true;
}
/** /**
* @param message * @param message
* the message to set * the message to set
*/ */
public void setMessagePattern(String message) { public void setMessagePattern(String message) {
checkSet();
this.message = message; this.message = message;
} }
protected void checkSet() {
if (frozen) throw new IllegalStateException("Object is unmodifieble"); //$NON-NLS-1$
}
} }

View file

@ -41,40 +41,36 @@ public class CodanProblemCategory implements IProblemCategory, Cloneable {
} }
public IProblemElement[] getChildren() { public IProblemElement[] getChildren() {
return (IProblemElement[]) list.toArray(new IProblemElement[list.size()]); return list.toArray(new IProblemElement[list.size()]);
} }
public void addChild(IProblemElement p) { public void addChild(IProblemElement p) {
list.add(p); list.add(p);
} }
public IProblem findProblem(String id) { public static IProblem findProblem(IProblemCategory c, String id) {
Object[] children = this.getChildren(); Object[] children = c.getChildren();
for (Object object : children) { for (Object object : children) {
if (object instanceof IProblemCategory) { if (object instanceof IProblemCategory) {
IProblemCategory cat = (IProblemCategory) object; IProblemCategory cat = (IProblemCategory) object;
IProblem found = cat.findProblem(id); IProblem found = findProblem(cat, id);
if (found != null) if (found != null) return found;
return found;
} else if (object instanceof IProblem) { } else if (object instanceof IProblem) {
IProblem p = (IProblem) object; IProblem p = (IProblem) object;
if (p.getId().equals(id)) if (p.getId().equals(id)) return p;
return p;
} }
} }
return null; return null;
} }
public IProblemCategory findCategory(String id) { public static IProblemCategory findCategory(IProblemCategory cat, String id) {
if (getId().equals(id)) if (cat.getId().equals(id)) return cat;
return this; Object[] children = cat.getChildren();
Object[] children = getChildren();
for (Object object : children) { for (Object object : children) {
if (object instanceof IProblemCategory) { if (object instanceof IProblemCategory) {
IProblemCategory cat = (IProblemCategory) object; IProblemCategory cat2 = (IProblemCategory) object;
IProblemCategory found = cat.findCategory(id); IProblemCategory found = findCategory(cat2, id);
if (found != null) if (found != null) return found;
return found;
} }
} }
return null; return null;
@ -90,8 +86,7 @@ public class CodanProblemCategory implements IProblemCategory, Cloneable {
try { try {
CodanProblemCategory clone = (CodanProblemCategory) super.clone(); CodanProblemCategory clone = (CodanProblemCategory) super.clone();
clone.list = new ArrayList<IProblemElement>(); clone.list = new ArrayList<IProblemElement>();
for (Iterator<IProblemElement> iterator = this.list.iterator(); iterator for (Iterator<IProblemElement> iterator = this.list.iterator(); iterator.hasNext();) {
.hasNext();) {
IProblemElement child = iterator.next(); IProblemElement child = iterator.next();
clone.list.add((IProblemElement) child.clone()); clone.list.add((IProblemElement) child.clone());
} }

View file

@ -0,0 +1,30 @@
/*******************************************************************************
* Copyright (c) 2009 Alena Laskavaia
* 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Alena Laskavaia - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.codan.internal.core.model;
import org.eclipse.cdt.codan.core.model.ProblemLocation;
import org.eclipse.core.resources.IFile;
/**
* Codan Problem Location, so far same as abstract class
*
*/
public class CodanProblemLocation extends ProblemLocation {
public CodanProblemLocation(IFile file, int startChar, int endChar) {
super(file, startChar, endChar);
}
protected CodanProblemLocation(IFile file, int line) {
super(file, line);
}
}

View file

@ -0,0 +1,35 @@
/*******************************************************************************
* Copyright (c) 2009 Alena Laskavaia
* 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
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Alena Laskavaia - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.codan.internal.core.model;
import org.eclipse.cdt.codan.core.model.IProblemLocation;
import org.eclipse.cdt.codan.core.model.IProblemLocationFactory;
import org.eclipse.core.resources.IFile;
/**
* Factory class that allows to create problem locations
*
*/
public class ProblemLocationFactory implements IProblemLocationFactory {
/* (non-Javadoc)
* @see org.eclipse.cdt.codan.core.model.IProblemLocationFactory#createProblemLocation(org.eclipse.core.resources.IFile, int)
*/
public IProblemLocation createProblemLocation(IFile file, int line) {
return new CodanProblemLocation(file, line);
}
/* (non-Javadoc)
* @see org.eclipse.cdt.codan.core.model.IProblemLocationFactory#createProblemLocation(org.eclipse.core.resources.IFile, int, int)
*/
public IProblemLocation createProblemLocation(IFile file, int startChar, int endChar) {
return new CodanProblemLocation(file, startChar, endChar);
}
}

View file

@ -22,8 +22,7 @@ import org.eclipse.cdt.codan.core.model.IProblemProfile;
* *
*/ */
public class ProblemProfile implements IProblemProfile, Cloneable { public class ProblemProfile implements IProblemProfile, Cloneable {
private IProblemCategory rootCategory = new CodanProblemCategory("root", private IProblemCategory rootCategory = new CodanProblemCategory("root", "root"); //$NON-NLS-1$ //$NON-NLS-2$
"root");
/* /*
* (non-Javadoc) * (non-Javadoc)
@ -33,7 +32,7 @@ public class ProblemProfile implements IProblemProfile, Cloneable {
* .String) * .String)
*/ */
public IProblem findProblem(String id) { public IProblem findProblem(String id) {
return getRoot().findProblem(id); return CodanProblemCategory.findProblem(getRoot(), id);
} }
/* /*
@ -51,8 +50,7 @@ public class ProblemProfile implements IProblemProfile, Cloneable {
* @param root * @param root
* @param problems * @param problems
*/ */
protected void collectProblems(IProblemCategory parent, protected void collectProblems(IProblemCategory parent, Collection<IProblem> problems) {
Collection<IProblem> problems) {
Object[] children = parent.getChildren(); Object[] children = parent.getChildren();
for (Object object : children) { for (Object object : children) {
if (object instanceof IProblemCategory) { if (object instanceof IProblemCategory) {
@ -69,13 +67,12 @@ public class ProblemProfile implements IProblemProfile, Cloneable {
} }
public void addProblem(IProblem p, IProblemCategory cat) { public void addProblem(IProblem p, IProblemCategory cat) {
if (cat == null) if (cat == null) cat = getRoot();
cat = getRoot();
((CodanProblemCategory) cat).addChild(p); ((CodanProblemCategory) cat).addChild(p);
} }
public IProblemCategory findCategory(String id) { public IProblemCategory findCategory(String id) {
return getRoot().findCategory(id); return CodanProblemCategory.findCategory(getRoot(), id);
} }
/* /*
@ -87,8 +84,7 @@ public class ProblemProfile implements IProblemProfile, Cloneable {
public Object clone() { public Object clone() {
try { try {
ProblemProfile clone = (ProblemProfile) super.clone(); ProblemProfile clone = (ProblemProfile) super.clone();
clone.rootCategory = (IProblemCategory) ((CodanProblemCategory) this.rootCategory) clone.rootCategory = (IProblemCategory) ((CodanProblemCategory) this.rootCategory).clone();
.clone();
return clone; return clone;
} catch (CloneNotSupportedException e) { } catch (CloneNotSupportedException e) {
return this; return this;

View file

@ -20,9 +20,15 @@
<arguments> <arguments>
</arguments> </arguments>
</buildCommand> </buildCommand>
<buildCommand>
<name>org.eclipse.pde.api.tools.apiAnalysisBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec> </buildSpec>
<natures> <natures>
<nature>org.eclipse.pde.PluginNature</nature> <nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature> <nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.pde.api.tools.apiAnalysisNature</nature>
</natures> </natures>
</projectDescription> </projectDescription>

View file

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<component id="org.eclipse.cdt.codan.ui" version="2">
<resource path="src/org/eclipse/cdt/codan/internal/ui/preferences/CodanPreferencePage.java" type="org.eclipse.cdt.codan.internal.ui.preferences.CodanPreferencePage">
<filter id="640712815">
<message_arguments>
<message_argument value="ICheckersRegistry"/>
<message_argument value="CodanPreferencePage"/>
<message_argument value="updateProfile(IResource, IProblemProfile)"/>
</message_arguments>
</filter>
</resource>
</component>

View file

@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
Bundle-Name: Code Analyzers Framework Bundle-Name: Code Analyzers Framework
Bundle-SymbolicName: org.eclipse.cdt.codan.ui; singleton:=true Bundle-SymbolicName: org.eclipse.cdt.codan.ui; singleton:=true
Bundle-Version: 1.0.0 Bundle-Version: 1.0.0
Bundle-Activator: org.eclipse.cdt.codan.ui.CodanUIActivator Bundle-Activator: org.eclipse.cdt.codan.internal.ui.CodanUIActivator
Bundle-Vendor: Eclipse Bundle-Vendor: Eclipse
Require-Bundle: org.eclipse.ui, Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime, org.eclipse.core.runtime,

View file

@ -3,7 +3,3 @@ output.. = bin/
bin.includes = plugin.xml,\ bin.includes = plugin.xml,\
META-INF/,\ META-INF/,\
. .
src.includes = src/,\
plugin.xml,\
build.properties,\
META-INF/

View file

@ -40,7 +40,7 @@ public class CodanCReconciler implements ICReconcilingListener {
* *
*/ */
private void initialize() { private void initialize() {
// TODO Auto-generated method stub // nothing?
} }
/* /*
@ -51,7 +51,7 @@ public class CodanCReconciler implements ICReconcilingListener {
* () * ()
*/ */
public void aboutToBeReconciled() { public void aboutToBeReconciled() {
// TODO Auto-generated method stub // nothing
} }
/* /*

View file

@ -1,4 +1,4 @@
package org.eclipse.cdt.codan.ui; package org.eclipse.cdt.codan.internal.ui;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.Status;

View file

@ -21,7 +21,7 @@ public class BuildPropertyPage extends FieldEditorPreferencePage implements
* *
*/ */
public BuildPropertyPage() { public BuildPropertyPage() {
setPreferenceStore(org.eclipse.cdt.codan.ui.CodanUIActivator.getDefault() setPreferenceStore(org.eclipse.cdt.codan.internal.ui.CodanUIActivator.getDefault()
.getPreferenceStore()); .getPreferenceStore());
} }

View file

@ -71,7 +71,7 @@ public class CodanPreferencePage extends FieldEditorOverlayPage implements
protected String getPageId() { protected String getPageId() {
return "org.eclipse.cdt.codan.internal.ui.preferences.CodanPreferencePage"; return "org.eclipse.cdt.codan.internal.ui.preferences.CodanPreferencePage"; //$NON-NLS-1$
} }
/** /**
@ -153,7 +153,7 @@ public class CodanPreferencePage extends FieldEditorOverlayPage implements
*/ */
@Override @Override
public boolean performOk() { public boolean performOk() {
if (isPropertyPage()) //if (isPropertyPage())
getRegistry().updateProfile((IResource) getElement(), null); getRegistry().updateProfile((IResource) getElement(), null);
return super.performOk(); return super.performOk();
} }

View file

@ -25,7 +25,7 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer {
* @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences() * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
*/ */
public void initializeDefaultPreferences() { public void initializeDefaultPreferences() {
IPreferenceStore store = org.eclipse.cdt.codan.ui.CodanUIActivator IPreferenceStore store = org.eclipse.cdt.codan.internal.ui.CodanUIActivator
.getDefault().getPreferenceStore(); .getDefault().getPreferenceStore();
store.setDefault(PreferenceConstants.P_RUN_ON_BUILD, false); store.setDefault(PreferenceConstants.P_RUN_ON_BUILD, false);
} }