diff --git a/codan/org.eclipse.cdt.codan.checkers.ui/.project b/codan/org.eclipse.cdt.codan.checkers.ui/.project index 4c298688616..047b3a35ca3 100644 --- a/codan/org.eclipse.cdt.codan.checkers.ui/.project +++ b/codan/org.eclipse.cdt.codan.checkers.ui/.project @@ -20,9 +20,15 @@ + + org.eclipse.pde.api.tools.apiAnalysisBuilder + + + org.eclipse.pde.PluginNature org.eclipse.jdt.core.javanature + org.eclipse.pde.api.tools.apiAnalysisNature diff --git a/codan/org.eclipse.cdt.codan.checkers.ui/META-INF/MANIFEST.MF b/codan/org.eclipse.cdt.codan.checkers.ui/META-INF/MANIFEST.MF index faffd30dfcf..c469bb971e5 100644 --- a/codan/org.eclipse.cdt.codan.checkers.ui/META-INF/MANIFEST.MF +++ b/codan/org.eclipse.cdt.codan.checkers.ui/META-INF/MANIFEST.MF @@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: Checkers Ui Bundle-SymbolicName: org.eclipse.cdt.codan.checkers.ui;singleton:=true 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, org.eclipse.core.runtime, org.eclipse.ui.ide;bundle-version="3.5.0", diff --git a/codan/org.eclipse.cdt.codan.checkers.ui/build.properties b/codan/org.eclipse.cdt.codan.checkers.ui/build.properties index ae09d1e02ec..e9863e281ea 100644 --- a/codan/org.eclipse.cdt.codan.checkers.ui/build.properties +++ b/codan/org.eclipse.cdt.codan.checkers.ui/build.properties @@ -3,7 +3,3 @@ output.. = bin/ bin.includes = META-INF/,\ .,\ plugin.xml -src.includes = src/,\ - plugin.xml,\ - build.properties,\ - META-INF/ diff --git a/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/CheckersUiActivator.java b/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/CheckersUiActivator.java similarity index 95% rename from codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/CheckersUiActivator.java rename to codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/CheckersUiActivator.java index 16356844b98..3c03dcebff1 100644 --- a/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/checkers/ui/CheckersUiActivator.java +++ b/codan/org.eclipse.cdt.codan.checkers.ui/src/org/eclipse/cdt/codan/internal/checkers/ui/CheckersUiActivator.java @@ -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.osgi.framework.BundleContext; diff --git a/codan/org.eclipse.cdt.codan.checkers/.project b/codan/org.eclipse.cdt.codan.checkers/.project index 6b76138faa3..c99d7bb6a5a 100644 --- a/codan/org.eclipse.cdt.codan.checkers/.project +++ b/codan/org.eclipse.cdt.codan.checkers/.project @@ -20,9 +20,15 @@ + + org.eclipse.pde.api.tools.apiAnalysisBuilder + + + org.eclipse.pde.PluginNature org.eclipse.jdt.core.javanature + org.eclipse.pde.api.tools.apiAnalysisNature diff --git a/codan/org.eclipse.cdt.codan.checkers/build.properties b/codan/org.eclipse.cdt.codan.checkers/build.properties index d7742bd8a06..e9863e281ea 100644 --- a/codan/org.eclipse.cdt.codan.checkers/build.properties +++ b/codan/org.eclipse.cdt.codan.checkers/build.properties @@ -3,7 +3,3 @@ output.. = bin/ bin.includes = META-INF/,\ .,\ plugin.xml -src.includes = src/,\ - plugin.xml,\ - META-INF/,\ - build.properties diff --git a/codan/org.eclipse.cdt.codan.checkers/plugin.xml b/codan/org.eclipse.cdt.codan.checkers/plugin.xml index a61f946f23d..dd237f3dfaa 100644 --- a/codan/org.eclipse.cdt.codan.checkers/plugin.xml +++ b/codan/org.eclipse.cdt.codan.checkers/plugin.xml @@ -3,74 +3,74 @@ + id="org.eclipse.cdt.codan.core.examples.checkers"> diff --git a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/sample/AssignmentInConditionChecker.java b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/examples/checkers/AssignmentInConditionChecker.java similarity index 92% rename from codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/sample/AssignmentInConditionChecker.java rename to codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/examples/checkers/AssignmentInConditionChecker.java index 0c74ab4dda0..d6881b045e0 100644 --- a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/sample/AssignmentInConditionChecker.java +++ b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/examples/checkers/AssignmentInConditionChecker.java @@ -8,7 +8,7 @@ * Contributors: * 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.core.dom.ast.ASTNodeProperty; @@ -20,7 +20,7 @@ import org.eclipse.cdt.core.dom.ast.IASTIfStatement; import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; 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) { // traverse the ast using the visitor pattern. diff --git a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/sample/CatchUsesReference.java b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/examples/checkers/CatchUsesReference.java similarity index 94% rename from codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/sample/CatchUsesReference.java rename to codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/examples/checkers/CatchUsesReference.java index 44c2063fa61..40a6a7b515e 100644 --- a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/sample/CatchUsesReference.java +++ b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/examples/checkers/CatchUsesReference.java @@ -9,7 +9,7 @@ * 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.core.dom.ast.ASTVisitor; @@ -28,7 +28,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTryBlockStatement; * */ 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) { // traverse the ast using the visitor pattern. diff --git a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/sample/NamingConventionFunctionChecker.java b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/examples/checkers/NamingConventionFunctionChecker.java similarity index 92% rename from codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/sample/NamingConventionFunctionChecker.java rename to codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/examples/checkers/NamingConventionFunctionChecker.java index 960dbef8ed6..23c54fded2f 100644 --- a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/sample/NamingConventionFunctionChecker.java +++ b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/examples/checkers/NamingConventionFunctionChecker.java @@ -8,7 +8,7 @@ * Contributors: * 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 org.eclipse.cdt.codan.core.model.AbstractCIndexChecker; @@ -27,8 +27,8 @@ import org.eclipse.core.runtime.CoreException; */ public class NamingConventionFunctionChecker extends AbstractCIndexChecker implements ICheckerWithParameters { - public static final String PARAM_KEY = "pattern"; - private static final String ER_ID = "org.eclipse.cdt.codan.internal.checkers.sample.NamingConventionFunctionProblem"; + public static final String PARAM_KEY = "pattern"; //$NON-NLS-1$ + private static final String ER_ID = "org.eclipse.cdt.codan.examples.checkers.NamingConventionFunctionProblem"; //$NON-NLS-1$ /* * (non-Javadoc) diff --git a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/sample/NonVirtualDestructor.java b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/examples/checkers/NonVirtualDestructor.java similarity index 97% rename from codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/sample/NonVirtualDestructor.java rename to codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/examples/checkers/NonVirtualDestructor.java index 90c9202bff3..9a85168eb1e 100644 --- a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/sample/NonVirtualDestructor.java +++ b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/examples/checkers/NonVirtualDestructor.java @@ -8,7 +8,7 @@ * Contributors: * 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; @@ -33,7 +33,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalBinding; * */ 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) { // traverse the ast using the visitor pattern. diff --git a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/sample/StatementHasNoEffectChecker.java b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/examples/checkers/StatementHasNoEffectChecker.java similarity index 95% rename from codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/sample/StatementHasNoEffectChecker.java rename to codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/examples/checkers/StatementHasNoEffectChecker.java index a9e3083b94e..46e1647aea6 100644 --- a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/sample/StatementHasNoEffectChecker.java +++ b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/examples/checkers/StatementHasNoEffectChecker.java @@ -8,7 +8,7 @@ * Contributors: * 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.core.dom.ast.ASTVisitor; @@ -36,7 +36,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTBinaryExpression; * */ 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) { // traverse the ast using the visitor pattern. diff --git a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/sample/SuggestedParenthesisChecker.java b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/examples/checkers/SuggestedParenthesisChecker.java similarity index 96% rename from codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/sample/SuggestedParenthesisChecker.java rename to codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/examples/checkers/SuggestedParenthesisChecker.java index c292533aa9b..b35ea559d00 100644 --- a/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/internal/checkers/sample/SuggestedParenthesisChecker.java +++ b/codan/org.eclipse.cdt.codan.checkers/src/org/eclipse/cdt/codan/examples/checkers/SuggestedParenthesisChecker.java @@ -8,7 +8,7 @@ * Contributors: * 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.core.dom.ast.ASTNodeProperty; @@ -29,7 +29,7 @@ import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression; * */ 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) { // traverse the ast using the visitor pattern. diff --git a/codan/org.eclipse.cdt.codan.core.test/build.properties b/codan/org.eclipse.cdt.codan.core.test/build.properties index 5c6aea6a46c..5facb59686f 100644 --- a/codan/org.eclipse.cdt.codan.core.test/build.properties +++ b/codan/org.eclipse.cdt.codan.core.test/build.properties @@ -3,3 +3,4 @@ output.. = bin/ bin.includes = META-INF/,\ .,\ src/org/eclipse/cdt/codan/core/checkers/ +jre.compilation.profile = J2SE-1.5 diff --git a/codan/org.eclipse.cdt.codan.core/.project b/codan/org.eclipse.cdt.codan.core/.project index 8ba33e61574..4edd707def7 100644 --- a/codan/org.eclipse.cdt.codan.core/.project +++ b/codan/org.eclipse.cdt.codan.core/.project @@ -20,9 +20,15 @@ + + org.eclipse.pde.api.tools.apiAnalysisBuilder + + + org.eclipse.pde.PluginNature org.eclipse.jdt.core.javanature + org.eclipse.pde.api.tools.apiAnalysisNature diff --git a/codan/org.eclipse.cdt.codan.core/build.properties b/codan/org.eclipse.cdt.codan.core/build.properties index 66e6d075b74..5952bfea885 100644 --- a/codan/org.eclipse.cdt.codan.core/build.properties +++ b/codan/org.eclipse.cdt.codan.core/build.properties @@ -4,8 +4,4 @@ bin.includes = META-INF/,\ .,\ plugin.xml,\ schema/ -src.includes = src/,\ - schema/,\ - plugin.xml,\ - build.properties,\ - META-INF/ +src.includes = schema/ diff --git a/codan/org.eclipse.cdt.codan.core/plugin.xml b/codan/org.eclipse.cdt.codan.core/plugin.xml index 0f7ecd33ea6..02ef64d2eb2 100644 --- a/codan/org.eclipse.cdt.codan.core/plugin.xml +++ b/codan/org.eclipse.cdt.codan.core/plugin.xml @@ -65,7 +65,7 @@ thread="main" visible="true"> + class="org.eclipse.cdt.codan.internal.core.CodanApplication"> diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/CodanCorePlugin.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/CodanCorePlugin.java index d60262b419b..49f1bd7ad2e 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/CodanCorePlugin.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/CodanCorePlugin.java @@ -13,7 +13,7 @@ import org.osgi.framework.BundleContext; */ public class CodanCorePlugin extends Plugin { // 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; // The shared instance private static CodanCorePlugin plugin; @@ -34,6 +34,7 @@ public class CodanCorePlugin extends Plugin { * @see * org.eclipse.core.runtime.Plugins#start(org.osgi.framework.BundleContext) */ + @Override public void start(BundleContext context) throws Exception { super.start(context); plugin = this; @@ -45,6 +46,7 @@ public class CodanCorePlugin extends Plugin { * @see * org.eclipse.core.runtime.Plugin#stop(org.osgi.framework.BundleContext) */ + @Override public void stop(BundleContext context) throws Exception { plugin = null; super.stop(context); diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/CodanRuntime.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/CodanRuntime.java index 16375cfe7d2..84e562be5cc 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/CodanRuntime.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/CodanRuntime.java @@ -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.ICodanAstReconciler; 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.internal.core.CheckersRegisry; 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.ProblemLocationFactory; /** * Runtime singleton class to get access to Codan framework parts * + * Clients may extend this class to override default framework parts. */ public class CodanRuntime { private static CodanRuntime instance = new CodanRuntime(); private IProblemReporter problemReporter = new CodanMarkerProblemReporter(); private CodanBuilder builder = new CodanBuilder(); 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() { return problemReporter; } + /** + * Set different problem reporter. + * @param reporter + */ public void setProblemReporter(IProblemReporter reporter) { problemReporter = reporter; } + /** + * Get instance of of Codan Runtime + * @return + */ public static CodanRuntime getInstance() { return instance; } + /** + * Get builder. Builder can used to run code analysis on given resource using API. + * @return + */ public ICodanBuilder getBuilder() { return builder; } + /** + * Get quick builder. Can be used to run code analysis on given ast. + * @return + */ public ICodanAstReconciler getAstQuickBuilder() { return builder; } + /** + * Get checkers registry. + * @return + */ public ICheckersRegistry getChechersRegistry() { 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; + } } diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/PreferenceConstants.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/PreferenceConstants.java index a4a13741a67..a8bb0bc3b61 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/PreferenceConstants.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/PreferenceConstants.java @@ -14,7 +14,7 @@ package org.eclipse.cdt.codan.core; * Constant definitions for plug-in preferences */ public class PreferenceConstants { - public static final String P_RUN_ON_BUILD = "booleanPreference"; - public static final String P_PROBLEMS = "problems"; - public static final String P_USE_PARENT = "useParentScope"; + public static final String P_RUN_ON_BUILD = "booleanPreference"; //$NON-NLS-1$ + public static final String P_PROBLEMS = "problems"; //$NON-NLS-1$ + public static final String P_USE_PARENT = "useParentScope"; //$NON-NLS-1$ } diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractCIndexChecker.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractCIndexChecker.java index 44051b74522..fba9a0e093a 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractCIndexChecker.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractCIndexChecker.java @@ -21,11 +21,11 @@ import org.eclipse.core.resources.IResource; 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 - ICIndexChecker { +public abstract class AbstractCIndexChecker extends AbstractChecker implements ICIndexChecker { private IFile file; protected IIndex index; @@ -36,11 +36,8 @@ public abstract class AbstractCIndexChecker extends AbstractChecker implements void processFile(IFile file) throws CoreException, InterruptedException { // create translation unit and access index ICElement model = CoreModel.getDefault().create(file); - if (!(model instanceof ITranslationUnit)) - return; + if (!(model instanceof ITranslationUnit)) return; // not a C/C++ file ITranslationUnit tu = (ITranslationUnit) model; - if (tu == null) - return; // not a C/C++ file index = CCorePlugin.getIndexManager().getIndex(tu.getCProject()); // lock the index for read access index.acquireReadLock(); diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractChecker.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractChecker.java index 2c031149149..b0c882f2d34 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractChecker.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractChecker.java @@ -15,6 +15,12 @@ import org.eclipse.cdt.codan.internal.core.CheckersRegisry; import org.eclipse.core.resources.IFile; 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 { protected String name; @@ -44,15 +50,18 @@ public abstract class AbstractChecker implements IChecker { * internationalization) */ public void reportProblem(String id, IFile file, int lineNumber, String arg) { - getProblemReporter().reportProblem(id, - new ProblemLocation(file, lineNumber), arg); + getProblemReporter().reportProblem(id, createProblemLocation(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) { - IProblem problem = CheckersRegisry.getInstance().getResourceProfile( - file).findProblem(id); - if (problem == null) - throw new IllegalArgumentException("Id is not registered"); + IProblem problem = CheckersRegisry.getInstance().getResourceProfile(file).findProblem(id); + if (problem == null) throw new IllegalArgumentException("Id is not registered"); //$NON-NLS-1$ return problem; } @@ -68,8 +77,7 @@ public abstract class AbstractChecker implements IChecker { * - line */ public void reportProblem(String id, IFile file, int lineNumber) { - getProblemReporter().reportProblem(id, - new ProblemLocation(file, lineNumber), new Object[] {}); + getProblemReporter().reportProblem(id, createProblemLocation(file, lineNumber), new Object[] {}); } /** @@ -79,6 +87,35 @@ public abstract class AbstractChecker implements IChecker { 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() { return false; } diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractIndexAstChecker.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractIndexAstChecker.java index d805f2fbefd..660c019c9fe 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractIndexAstChecker.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractIndexAstChecker.java @@ -27,11 +27,11 @@ import org.eclipse.core.runtime.IPath; 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 - ICAstChecker { +public abstract class AbstractIndexAstChecker extends AbstractChecker implements ICAstChecker { private IFile file; protected IFile getFile() { @@ -41,18 +41,14 @@ public abstract class AbstractIndexAstChecker extends AbstractChecker implements void processFile(IFile file) throws CoreException, InterruptedException { // create translation unit and access index ICElement model = CoreModel.getDefault().create(file); - if (!(model instanceof ITranslationUnit)) - return; + if (!(model instanceof ITranslationUnit)) return; // not a C/C++ file ITranslationUnit tu = (ITranslationUnit) model; - if (tu == null) - return; // not a C/C++ file IIndex index = CCorePlugin.getIndexManager().getIndex(tu.getCProject()); // lock the index for read access index.acquireReadLock(); try { // create index based ast - IASTTranslationUnit ast = tu.getAST(index, - ITranslationUnit.AST_SKIP_INDEXED_HEADERS); + IASTTranslationUnit ast = tu.getAST(index, ITranslationUnit.AST_SKIP_INDEXED_HEADERS); // traverse the ast using the visitor pattern. this.file = file; processAst(ast); @@ -80,19 +76,16 @@ public abstract class AbstractIndexAstChecker extends AbstractChecker implements public void reportProblem(String id, IASTNode astNode, String message) { IASTFileLocation astLocation = astNode.getFileLocation(); IPath location = new Path(astLocation.getFileName()); - IFile astFile = ResourcesPlugin.getWorkspace().getRoot() - .getFileForLocation(location); + IFile astFile = ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(location); if (astFile == null) { astFile = file; } - ProblemLocation loc; - if (astLocation.getStartingLineNumber() == astLocation - .getEndingLineNumber()) - loc = new ProblemLocation(astFile, astLocation.getNodeOffset(), - astLocation.getNodeOffset() + astLocation.getNodeLength()); - else - loc = new ProblemLocation(astFile, astLocation - .getStartingLineNumber()); + IProblemLocation loc; + if (astLocation.getStartingLineNumber() == astLocation.getEndingLineNumber()) loc = getRuntime() + .getProblemLocationFactory().createProblemLocation(astFile, astLocation.getNodeOffset(), + astLocation.getNodeOffset() + astLocation.getNodeLength()); + else loc = getRuntime().getProblemLocationFactory().createProblemLocation(astFile, + astLocation.getStartingLineNumber()); getProblemReporter().reportProblem(id, loc, message); } diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CodanSeverity.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CodanSeverity.java index acfa4d1c67e..2655b02cced 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CodanSeverity.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CodanSeverity.java @@ -12,9 +12,17 @@ package org.eclipse.cdt.codan.core.model; 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 { - Info(IMarker.SEVERITY_INFO), Warning(IMarker.SEVERITY_WARNING), Error( - IMarker.SEVERITY_ERROR); + Info(IMarker.SEVERITY_INFO), Warning(IMarker.SEVERITY_WARNING), Error(IMarker.SEVERITY_ERROR); private 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() { CodanSeverity[] values = values(); diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICAstChecker.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICAstChecker.java index 461c0fa6f6c..961ea5b8b6d 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICAstChecker.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICAstChecker.java @@ -13,9 +13,16 @@ package org.eclipse.cdt.codan.core.model; 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 { + /** + * 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); } diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICIndexChecker.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICIndexChecker.java index 54cf6e5948b..98e7cd56751 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICIndexChecker.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICIndexChecker.java @@ -13,9 +13,15 @@ package org.eclipse.cdt.codan.core.model; 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 { + /** + * Run checker on translation unit + * @param unit - translation unit + */ void processUnit(ITranslationUnit unit); } diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IChecker.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IChecker.java index 60f7cb2b99e..0e36c5dbd25 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IChecker.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IChecker.java @@ -14,6 +14,8 @@ import org.eclipse.core.resources.IResource; /** * Interface that checker must implement. CDT Checker must be able to process a resource. + * + * Clients may implement and extend this interface. */ public interface IChecker { /** @@ -26,7 +28,7 @@ public interface IChecker { /** * Implement this method to trim down type of resource you are interested in, * usually it will be c/c++ files only - * @param resource + * @param resource - resource to run on * @return */ boolean enabledInContext(IResource resource); diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICheckerWithParameters.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICheckerWithParameters.java index 070da1e082a..2225a6a60c9 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICheckerWithParameters.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICheckerWithParameters.java @@ -11,9 +11,15 @@ 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 { + /** + * Implement this method to set default parameters for checkers with parameters. + * @param problem - instance of problem working copy + */ void initParameters(IProblemWorkingCopy problem); } diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICheckersRegistry.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICheckersRegistry.java index 052d868059d..94037a83e6d 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICheckersRegistry.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICheckersRegistry.java @@ -15,52 +15,82 @@ import java.util.Iterator; 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 { + /** + * Iterator for registered checkers + * @return + */ public abstract Iterator iterator(); + /** + * Add another checker + * @param 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); /** + * Get default profile, default profile is kind of "Installation Default". Always the same, comes from default in checker extensions * @return */ public abstract IProblemProfile getDefaultProfile(); /** - * @return + * Get workspace profile. User can change setting for workspace profile. + * @return profile */ public abstract IProblemProfile getWorkspaceProfile(); /** - * @param element - * @return + * Get resource profile. For example given directory can have different profile + * than parent project. + * + * @param element - resource + * @return profile */ 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 * @return */ - public abstract IProblemProfile getResourceProfileWorkingCopy( - IResource element); + public abstract IProblemProfile getResourceProfileWorkingCopy(IResource element); /** - * Set profile for resource. This method is called by UI, and should not be - * called by clients directly - * + * Set profile for resource. + * @noreference This method is not intended to be referenced by clients. * @param resource * - resource * @param profile * - problems profile */ - public abstract void updateProfile(IResource resource, - IProblemProfile profile); + public abstract void updateProfile(IResource resource, IProblemProfile profile); } \ No newline at end of file diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICodanAstReconciler.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICodanAstReconciler.java index 17bc8f70180..1920180e39e 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICodanAstReconciler.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICodanAstReconciler.java @@ -14,9 +14,17 @@ import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit; 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 { + /** + * Run code analysis on ast + * @param ast - ast to be reconciled + * @param monitor - progress monitor + */ public void reconcileAst(IASTTranslationUnit ast, IProgressMonitor monitor); } \ No newline at end of file diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICodanBuilder.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICodanBuilder.java index ce1f66872c1..597c29211c4 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICodanBuilder.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICodanBuilder.java @@ -14,9 +14,19 @@ import org.eclipse.core.resources.IResource; 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 { + /** + * Run code analysis on given resource + * @param resource - resource to process + * @param monitor - progress monitor + */ public void processResource(IResource resource, IProgressMonitor monitor); } \ No newline at end of file diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblem.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblem.java index f59d825666a..e1fa9ea81ab 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblem.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblem.java @@ -10,9 +10,14 @@ *******************************************************************************/ 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 { @@ -53,8 +58,9 @@ public interface IProblem extends IProblemElement { public Object getParameter(Object key); /** - * Get root paramterInfo - contains description of types of all the - * parameters or null if not defined + * Get parameter info root - contains description of types of all the + * parameters or null if not defined (used by ui to generate user controls + * for changing parameters) * * @return */ diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemCategory.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemCategory.java index cd3de3a9645..72a1e65d70d 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemCategory.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemCategory.java @@ -11,8 +11,9 @@ package org.eclipse.cdt.codan.core.model; /** - * Problem category - * + * Problem category. + * + * Clients may extend and implement this interface. */ public interface IProblemCategory extends IProblemElement { /** @@ -32,17 +33,4 @@ public interface IProblemCategory extends IProblemElement { */ 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); } diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemElement.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemElement.java index 318f304da0e..71489ef5008 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemElement.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemElement.java @@ -11,9 +11,17 @@ 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 { + /** + * 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; } diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemLocation.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemLocation.java index f5e4f23f275..12949abdec2 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemLocation.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemLocation.java @@ -16,6 +16,8 @@ import org.eclipse.core.resources.IFile; * Interface to describe problem location. Usually contains file and linenumber, * 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 { /** diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemLocationFactory.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemLocationFactory.java new file mode 100644 index 00000000000..a74305d572a --- /dev/null +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemLocationFactory.java @@ -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); + +} \ No newline at end of file diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemParameterInfo.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemParameterInfo.java index d704984bb46..86d670ccf88 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemParameterInfo.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemParameterInfo.java @@ -11,15 +11,15 @@ 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 * conventions for function, parameter would be the pattern of allowed names. * ProblemParameterInfo represent parameter meta-info for the ui. * 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 * - * @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 { String getKey(); @@ -42,13 +42,14 @@ public interface IProblemParameterInfo { String getUiInfo(); /** - * User visible label for the control in UI + * User visible label for the parameter control in UI + * @return the label */ String getLabel(); /** * 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 * - name of the subparameter. diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemProfile.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemProfile.java index 896eb101e7b..e73ee57b9be 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemProfile.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemProfile.java @@ -11,15 +11,21 @@ package org.eclipse.cdt.codan.core.model; /** - * Problem Profile contains tree of categories and problems. For user profile is quick way - * to switch between problems sets depends on task he is doing (i.e. find real bugs, vs doing code style report) - * User can set different profiles in different projects. - * Profiles can have different categories and different problems set, problems with the same id - * can have different severities/enablement in different profiles. To obtain - * profile use class {@link CheckersRegisry#getResourceProfile, + * Problem Profile contains tree of categories and problems. For the user + * the profile is quick way to switch between problem sets depending on the + * task he is doing (i.e. find real bugs, vs doing code style report) + * User can set different profiles for different projects. + * Profiles can have different categories and different problem sets, + * 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()} - * . * + * @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 { /** @@ -28,7 +34,7 @@ public interface IProblemProfile extends IProblemElement { IProblemCategory getRoot(); /** - * Find and return problem by id + * Find and return problem by id if it contained in this profile * * @param id * - problem id @@ -37,7 +43,7 @@ public interface IProblemProfile extends IProblemElement { 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 * - category id @@ -46,7 +52,7 @@ public interface IProblemProfile extends IProblemElement { 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 */ diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemReporter.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemReporter.java index 059f15519b0..f9ac4026603 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemReporter.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemReporter.java @@ -10,20 +10,20 @@ *******************************************************************************/ package org.eclipse.cdt.codan.core.model; - /** * IProblemReporter - interface to report problems - * + * + * Clients may implement and extend this interface */ 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", - * using problem specific error message customised by args. - * @param problemId - id of the problem registers with checker + * Report a problem with "problemId" id on the location determined by "loc", + * using problem specific error message customized by args. + * @param problemId - id of the problem registered with a checker * @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, - Object ... args); + public void reportProblem(String problemId, IProblemLocation loc, Object... args); } \ No newline at end of file diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemWorkingCopy.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemWorkingCopy.java index 716a7cc9da2..17b0341975d 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemWorkingCopy.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemWorkingCopy.java @@ -10,22 +10,43 @@ *******************************************************************************/ package org.eclipse.cdt.codan.core.model; - /** * Modifiable problem - * @author Alena * + * Clients may extend and implement this interface */ 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 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 IProblemCategory getCategory(); - + /** + * Set parameter info object for the given problem, see {@link IProblemParameterInfo} + * @param info + */ public void setParameterInfo(IProblemParameterInfo info); } diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ProblemLocation.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ProblemLocation.java index ced12f0259a..e4b15573bf0 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ProblemLocation.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ProblemLocation.java @@ -13,36 +13,25 @@ package org.eclipse.cdt.codan.core.model; 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 int line; protected int posStart; protected int posEnd; protected Object extra; - /** - * @param file - * @param line - * @param lineEnd - * @param posStart - * @param posEnd - */ - public ProblemLocation(IFile file, int line) { + protected ProblemLocation(IFile file, int line) { this.file = file; this.line = line; this.posStart = -1; this.posEnd = -1; } - /** - * @param file - * @param startingLineNumber - * @param endingLineNumber - */ - public ProblemLocation(IFile file, int startChar, int endChar) { + protected ProblemLocation(IFile file, int startChar, int endChar) { this.file = file; this.line = -1; this.posStart = startChar; diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CheckersRegisry.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CheckersRegisry.java index a6eecb58e0b..623de899ab0 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CheckersRegisry.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CheckersRegisry.java @@ -38,11 +38,13 @@ import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.preferences.IEclipsePreferences; public class CheckersRegisry implements Iterable, ICheckersRegistry { - private static final String EXTENSION_POINT_NAME = "checkers"; - private static final String CHECKER_ELEMENT = "checker"; - private static final String PROBLEM_ELEMENT = "problem"; - private static final String CATEGORY_ELEMENT = "category"; - private static final Object DEFAULT = "DEFAULT"; + private static final String NAME_ATTR = "name"; //$NON-NLS-1$ + private static final String ID_ATTR = "id"; //$NON-NLS-1$ + private static final String EXTENSION_POINT_NAME = "checkers"; //$NON-NLS-1$ + private static final String CHECKER_ELEMENT = "checker"; //$NON-NLS-1$ + 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 checkers = new ArrayList(); private static CheckersRegisry instance; private HashMap profiles = new HashMap(); @@ -55,10 +57,9 @@ public class CheckersRegisry implements Iterable, ICheckersRegistry { } private void readCheckersRegistry() { - IExtensionPoint ep = Platform.getExtensionRegistry().getExtensionPoint( - CodanCorePlugin.PLUGIN_ID, EXTENSION_POINT_NAME); - if (ep == null) - return; + IExtensionPoint ep = Platform.getExtensionRegistry().getExtensionPoint(CodanCorePlugin.PLUGIN_ID, + EXTENSION_POINT_NAME); + if (ep == null) return; IConfigurationElement[] elements = ep.getConfigurationElements(); // process categories for (int i = 0; i < elements.length; i++) { @@ -76,16 +77,14 @@ public class CheckersRegisry implements Iterable, ICheckersRegistry { processChecker(configurationElement); } // init parameters for checkers with parameters - for (Iterator iterator = problemList.keySet().iterator(); iterator - .hasNext();) { - IChecker c = (IChecker) iterator.next(); + for (Iterator iterator = problemList.keySet().iterator(); iterator.hasNext();) { + IChecker c = iterator.next(); if (c instanceof ICheckerWithParameters) { Collection list = problemList.get(c); - for (Iterator iterator2 = list.iterator(); iterator2.hasNext();) { - IProblem p = (IProblem) iterator2.next(); + for (Iterator iterator2 = list.iterator(); iterator2.hasNext();) { + IProblem p = iterator2.next(); if (p instanceof IProblemWorkingCopy) { - ((ICheckerWithParameters) c) - .initParameters((IProblemWorkingCopy) p); + ((ICheckerWithParameters) c).initParameters((IProblemWorkingCopy) p); } } } @@ -97,15 +96,12 @@ public class CheckersRegisry implements Iterable, ICheckersRegistry { */ private void processCategories(IConfigurationElement configurationElement) { if (configurationElement.getName().equals(CATEGORY_ELEMENT)) { - String id = getAtt(configurationElement, "id"); - if (id == null) - return; - String name = getAtt(configurationElement, "name"); - if (name == null) - return; + String id = getAtt(configurationElement, ID_ATTR); + if (id == null) return; + String name = getAtt(configurationElement, NAME_ATTR); + if (name == null) return; CodanProblemCategory cat = new CodanProblemCategory(id, name); - String category = getAtt(configurationElement, "parentCategory", - false); + String category = getAtt(configurationElement, "parentCategory", false); //$NON-NLS-1$ addCategory(cat, category); } } @@ -116,27 +112,22 @@ public class CheckersRegisry implements Iterable, ICheckersRegistry { private void processChecker(IConfigurationElement configurationElement) { try { if (configurationElement.getName().equals(CHECKER_ELEMENT)) { - String id = getAtt(configurationElement, "id"); - if (id == null) - return; - String name = getAtt(configurationElement, "name", false); - if (name == null) - name = id; + String id = getAtt(configurationElement, ID_ATTR); + if (id == null) return; + String name = getAtt(configurationElement, NAME_ATTR, false); + if (name == null) name = id; IChecker checkerObj = null; try { - Object checker = configurationElement - .createExecutableExtension("class"); + Object checker = configurationElement.createExecutableExtension("class"); //$NON-NLS-1$ checkerObj = (IChecker) checker; addChecker(checkerObj); } catch (CoreException e) { CodanCorePlugin.log(e); return; } - IConfigurationElement[] children1 = configurationElement - .getChildren("problemRef"); + IConfigurationElement[] children1 = configurationElement.getChildren("problemRef"); //$NON-NLS-1$ boolean hasRef = false; - IConfigurationElement[] children2 = configurationElement - .getChildren(PROBLEM_ELEMENT); + IConfigurationElement[] children2 = configurationElement.getChildren(PROBLEM_ELEMENT); if (children2 != null) { for (IConfigurationElement ref : children2) { IProblem p = processProblem(ref); @@ -147,8 +138,7 @@ public class CheckersRegisry implements Iterable, ICheckersRegistry { if (children1 != null) { for (IConfigurationElement ref : children1) { hasRef = true; - IProblem p = getDefaultProfile().findProblem( - ref.getAttribute("refId")); + IProblem p = getDefaultProfile().findProblem(ref.getAttribute("refId")); //$NON-NLS-1$ addRefProblem(checkerObj, p); } } @@ -167,39 +157,30 @@ public class CheckersRegisry implements Iterable, ICheckersRegistry { * @param configurationElement * @return */ - private CodanProblem processProblem( - IConfigurationElement configurationElement) { + private CodanProblem processProblem(IConfigurationElement configurationElement) { if (configurationElement.getName().equals(PROBLEM_ELEMENT)) { - String id = getAtt(configurationElement, "id"); - if (id == null) - return null; - String name = getAtt(configurationElement, "name"); - if (name == null) - name = id; + String id = getAtt(configurationElement, ID_ATTR); + if (id == null) return null; + String name = getAtt(configurationElement, NAME_ATTR); + if (name == null) name = id; CodanProblem p = new CodanProblem(id, name); - String category = getAtt(configurationElement, "category", false); - if (category == null) - category = "org.eclipse.cdt.codan.core.categories.ProgrammingProblems"; + String category = getAtt(configurationElement, "category", false); //$NON-NLS-1$ + if (category == null) category = "org.eclipse.cdt.codan.core.categories.ProgrammingProblems"; //$NON-NLS-1$ addProblem(p, category); return p; } return null; } - private static String getAtt(IConfigurationElement configurationElement, - String name) { + private static String getAtt(IConfigurationElement configurationElement, String name) { return getAtt(configurationElement, name, true); } - private static String getAtt(IConfigurationElement configurationElement, - String name, boolean req) { + private static String getAtt(IConfigurationElement configurationElement, String name, boolean req) { String elementValue = configurationElement.getAttribute(name); if (elementValue == null && req) - CodanCorePlugin.log("Extension " - + configurationElement.getDeclaringExtension() - .getUniqueIdentifier() - + " missing required attribute: " - + configurationElement.getName() + "." + name); + CodanCorePlugin.log("Extension " + configurationElement.getDeclaringExtension().getUniqueIdentifier() //$NON-NLS-1$ + + " missing required attribute: " + configurationElement.getName() + "." + name); //$NON-NLS-1$ //$NON-NLS-2$ return elementValue; } @@ -213,8 +194,7 @@ public class CheckersRegisry implements Iterable, ICheckersRegistry { } public static CheckersRegisry getInstance() { - if (instance == null) - new CheckersRegisry(); + if (instance == null) return new CheckersRegisry(); return instance; } @@ -238,8 +218,7 @@ public class CheckersRegisry implements Iterable, ICheckersRegistry { */ public void addProblem(IProblem p, String category) { IProblemCategory cat = getDefaultProfile().findCategory(category); - if (cat == null) - cat = getDefaultProfile().getRoot(); + if (cat == null) cat = getDefaultProfile().getRoot(); ((ProblemProfile) getDefaultProfile()).addProblem(p, cat); } @@ -252,8 +231,7 @@ public class CheckersRegisry implements Iterable, ICheckersRegistry { */ public void addCategory(IProblemCategory p, String category) { IProblemCategory cat = getDefaultProfile().findCategory(category); - if (cat == null) - cat = getDefaultProfile().getRoot(); + if (cat == null) cat = getDefaultProfile().getRoot(); ((ProblemProfile) getDefaultProfile()).addCategory(p, cat); } @@ -310,15 +288,17 @@ public class CheckersRegisry implements Iterable, ICheckersRegistry { } catch (CloneNotSupportedException e) { wp = getDefaultProfile(); } + profiles.put(ResourcesPlugin.getWorkspace(), wp); } return wp; } public void updateProfile(IResource element, IProblemProfile profile) { - if (profile == null) - profiles.remove(element); - else - profiles.put(element, profile); + // updating profile can invalidate all cached profiles + IProblemProfile defaultProfile = getDefaultProfile(); + profiles.clear(); + profiles.put(DEFAULT, defaultProfile); + if (profile != null && element != null) profiles.put(element, profile); } /* @@ -335,17 +315,13 @@ public class CheckersRegisry implements Iterable, ICheckersRegistry { try { prof = (IProblemProfile) getWorkspaceProfile().clone(); // load default values - CodanPreferencesLoader loader = new CodanPreferencesLoader( - prof); - IEclipsePreferences node = new ProjectScope( - (IProject) element) - .getNode(CodanCorePlugin.PLUGIN_ID); - boolean useWorkspace = node.getBoolean( - PreferenceConstants.P_USE_PARENT, false); + CodanPreferencesLoader loader = new CodanPreferencesLoader(prof); + IEclipsePreferences node = new ProjectScope((IProject) element).getNode(CodanCorePlugin.PLUGIN_ID); + boolean useWorkspace = node.getBoolean(PreferenceConstants.P_USE_PARENT, false); if (!useWorkspace) { loader.load(node); } - updateProfile(element, prof); + profiles.put(element, prof); } catch (CloneNotSupportedException e) { // cant } @@ -366,20 +342,13 @@ public class CheckersRegisry implements Iterable, ICheckersRegistry { * getResourceProfileWorkingCopy(org.eclipse.core.resources.IResource) */ public IProblemProfile getResourceProfileWorkingCopy(IResource element) { - if (element instanceof IProject) { - try { - IProblemProfile prof = (IProblemProfile) getWorkspaceProfile() - .clone(); - // load default values - CodanPreferencesLoader loader = new CodanPreferencesLoader(prof); - IEclipsePreferences node = new ProjectScope((IProject) element) - .getNode(CodanCorePlugin.PLUGIN_ID); - loader.load(node); - return prof; - } catch (CloneNotSupportedException e) { - // cant - } + + try { + IProblemProfile prof = (IProblemProfile) getResourceProfile(element).clone(); + return prof; + } catch (CloneNotSupportedException e) { + // cant + return null; } - return null; } } diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/CodanApplication.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodanApplication.java similarity index 79% rename from codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/CodanApplication.java rename to codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodanApplication.java index e0287b10621..b258c149c92 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/CodanApplication.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodanApplication.java @@ -1,9 +1,9 @@ -package org.eclipse.cdt.codan.core; +package org.eclipse.cdt.codan.internal.core; import java.util.ArrayList; 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.core.resources.IFile; 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.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 { private Collection projects = new ArrayList(); private boolean verbose = false; private boolean all = false; public Object start(IApplicationContext context) throws Exception { - String[] args = (String[]) context.getArguments().get( - "application.args"); + String[] args = (String[]) context.getArguments().get("application.args"); //$NON-NLS-1$ if (args == null || args.length == 0) { help(); return EXIT_OK; @@ -29,10 +35,9 @@ public class CodanApplication implements IApplication { CodanRuntime runtime = CodanRuntime.getInstance(); runtime.setProblemReporter(new CodanMarkerProblemReporter() { @Override - public void reportProblem(String id, int severity, IFile file, - int lineNumber, int startChar, int endChar, String message) { - System.out.println(file.getLocation() + ":" + lineNumber + ": " - + message); + public void reportProblem(String id, int severity, IFile file, int lineNumber, int startChar, int endChar, + String message) { + System.out.println(file.getLocation() + ":" + lineNumber + ": " + message); } }); IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); @@ -44,8 +49,7 @@ public class CodanApplication implements IApplication { log("Launching analysis on project " + project); IProject wProject = root.getProject(project); if (!wProject.exists()) { - System.err.println("Error: project " + project - + " does not exist"); + System.err.println("Error: project " + project + " does not exist"); continue; } wProject.accept(codanBuilder.new CodanResourceVisitor()); @@ -58,8 +62,7 @@ public class CodanApplication implements IApplication { * @param string */ private void log(String string) { - if (verbose) - System.err.println(string); + if (verbose) System.err.println(string); } /** diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodanBuilder.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodanBuilder.java index 56916b857dc..086d7255631 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodanBuilder.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodanBuilder.java @@ -41,9 +41,8 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor; -public class CodanBuilder extends IncrementalProjectBuilder implements - ICodanBuilder, ICodanAstReconciler { - public static final String BUILDER_ID = "org.eclipse.cdt.codan.core.codanBuilder"; +public class CodanBuilder extends IncrementalProjectBuilder implements ICodanBuilder, ICodanAstReconciler { + public static final String BUILDER_ID = "org.eclipse.cdt.codan.core.codanBuilder"; //$NON-NLS-1$ public class CodanDeltaVisitor implements IResourceDeltaVisitor { /* @@ -63,17 +62,17 @@ public class CodanBuilder extends IncrementalProjectBuilder implements public boolean visit(IResourceDelta delta) throws CoreException { IResource resource = delta.getResource(); switch (delta.getKind()) { - case IResourceDelta.ADDED: - // handle added resource - processResource(resource, new NullProgressMonitor()); - break; - case IResourceDelta.REMOVED: - // handle removed resource - break; - case IResourceDelta.CHANGED: - // handle changed resource - processResource(resource, new NullProgressMonitor()); - break; + case IResourceDelta.ADDED: + // handle added resource + processResource(resource, new NullProgressMonitor()); + break; + case IResourceDelta.REMOVED: + // handle removed resource + break; + case IResourceDelta.CHANGED: + // handle changed resource + processResource(resource, new NullProgressMonitor()); + break; } // return true to continue visiting children. return true; @@ -82,8 +81,7 @@ public class CodanBuilder extends IncrementalProjectBuilder implements public class CodanResourceVisitor implements IResourceVisitor { public boolean visit(IResource resource) { - if (!(resource instanceof IProject)) - processResource(resource, new NullProgressMonitor()); + if (!(resource instanceof IProject)) processResource(resource, new NullProgressMonitor()); // return true to continue visiting children. return true; } @@ -95,8 +93,9 @@ public class CodanBuilder extends IncrementalProjectBuilder implements * @see org.eclipse.core.internal.events.InternalBuilder#build(int, * java.util.Map, org.eclipse.core.runtime.IProgressMonitor) */ - protected IProject[] build(int kind, Map args, IProgressMonitor monitor) - throws CoreException { + @SuppressWarnings("rawtypes") + @Override + protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException { if (kind == FULL_BUILD) { fullBuild(monitor); } else { @@ -115,21 +114,16 @@ public class CodanBuilder extends IncrementalProjectBuilder implements // CodanCorePlugin.PLUGIN_ID, "problems", "", null); // System.err.println("set = " + string); // delete general markers - IProblemReporter problemReporter = CodanRuntime.getInstance() - .getProblemReporter(); + IProblemReporter problemReporter = CodanRuntime.getInstance().getProblemReporter(); if (problemReporter instanceof CodanMarkerProblemReporter) { - ((CodanMarkerProblemReporter) problemReporter) - .deleteMarkers(resource); + ((CodanMarkerProblemReporter) problemReporter).deleteMarkers(resource); } for (IChecker checker : CheckersRegisry.getInstance()) { try { boolean run = false; - if (checker.enabledInContext(resource)) - run = true; - if (areProblemsForCheckerEnabled(checker, resource)) - run = true; - if (run) - checker.processResource(resource); + if (checker.enabledInContext(resource)) run = true; + if (areProblemsForCheckerEnabled(checker, resource)) run = true; + if (run) checker.processResource(resource); } catch (Throwable e) { CodanCorePlugin.log(e); } @@ -144,8 +138,7 @@ public class CodanBuilder extends IncrementalProjectBuilder implements } public void reconcileAst(IASTTranslationUnit ast, IProgressMonitor monitor) { - if (ast == null) - return; + if (ast == null) return; String filePath = ast.getFilePath(); IWorkspace workspace = ResourcesPlugin.getWorkspace(); IWorkspaceRoot root = workspace.getRoot(); @@ -154,24 +147,20 @@ public class CodanBuilder extends IncrementalProjectBuilder implements resources = root.findFilesForLocationURI(uri); if (resources != null && resources.length > 0) { IFile resource = resources[0]; - IProblemReporter problemReporter = CodanRuntime.getInstance() - .getProblemReporter(); + IProblemReporter problemReporter = CodanRuntime.getInstance().getProblemReporter(); // TODO: this is wrong - should not delete all markers - // only those that contributed by the checker that we run now if (problemReporter instanceof CodanMarkerProblemReporter) { - ((CodanMarkerProblemReporter) problemReporter) - .deleteMarkers(resource); + ((CodanMarkerProblemReporter) problemReporter).deleteMarkers(resource); } for (IChecker checker : CheckersRegisry.getInstance()) { try { boolean run = false; - if (checker.enabledInContext(resource)) - run = true; + if (checker.enabledInContext(resource)) run = true; if (areProblemsForCheckerEnabled(checker, resource)) { run = true; } - if (run && checker instanceof ICAstChecker - && checker.runInEditor()) + if (run && checker instanceof ICAstChecker && checker.runInEditor()) ((ICAstChecker) checker).processAst(ast); } catch (Throwable e) { CodanCorePlugin.log(e); @@ -185,35 +174,28 @@ public class CodanBuilder extends IncrementalProjectBuilder implements * @param resource * @return */ - private boolean areProblemsForCheckerEnabled(IChecker checker, - IResource resource) { - IProblemProfile resourceProfile = CheckersRegisry.getInstance() - .getResourceProfile(resource); - Collection refProblems = CheckersRegisry.getInstance() - .getRefProblems(checker); - for (Iterator iterator = refProblems.iterator(); iterator.hasNext();) { - IProblem p = (IProblem) iterator.next(); + private boolean areProblemsForCheckerEnabled(IChecker checker, IResource resource) { + IProblemProfile resourceProfile = CheckersRegisry.getInstance().getResourceProfile(resource); + Collection refProblems = CheckersRegisry.getInstance().getRefProblems(checker); + for (Iterator iterator = refProblems.iterator(); iterator.hasNext();) { + IProblem p = iterator.next(); // we need to check problem enablement in particular profile IProblem problem = resourceProfile.findProblem(p.getId()); - if (problem == null) - throw new IllegalArgumentException("Id is not registered"); - if (problem.isEnabled()) - return true; + if (problem == null) throw new IllegalArgumentException("Id is not registered"); //$NON-NLS-1$ + if (problem.isEnabled()) return true; } // no problem is enabled for this checker, skip the checker return false; } - protected void fullBuild(final IProgressMonitor monitor) - throws CoreException { + protected void fullBuild(final IProgressMonitor monitor) throws CoreException { try { getProject().accept(new CodanResourceVisitor()); } catch (CoreException e) { } } - protected void incrementalBuild(IResourceDelta delta, - IProgressMonitor monitor) throws CoreException { + protected void incrementalBuild(IResourceDelta delta, IProgressMonitor monitor) throws CoreException { // the visitor does the work. delta.accept(new CodanDeltaVisitor()); } diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodanPreferencesLoader.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodanPreferencesLoader.java index bafff9a23cb..0bc26158933 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodanPreferencesLoader.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodanPreferencesLoader.java @@ -54,11 +54,10 @@ public class CodanPreferencesLoader { */ public void setProperty(String id, String s) { IProblem prob = baseModel.findProblem(id); - if (!(prob instanceof CodanProblem)) - return; + if (!(prob instanceof CodanProblem)) return; String sevs = s; boolean enabled = true; - if (sevs.startsWith("-")) { + if (sevs.startsWith("-")) { //$NON-NLS-1$ sevs = sevs.substring(1); enabled = false; } @@ -95,8 +94,7 @@ public class CodanPreferencesLoader { */ public String getProperty(String id) { IProblem prob = baseModel.findProblem(id); - if (!(prob instanceof CodanProblem)) - return null; + if (!(prob instanceof CodanProblem)) return null; String enabled = prob.isEnabled() ? "" : "-"; String severity = prob.getSeverity().toString(); String res = enabled + severity; diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodeAnlysisNature.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodeAnlysisNature.java index 5157e163eb5..214d760a5a1 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodeAnlysisNature.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/CodeAnlysisNature.java @@ -20,7 +20,7 @@ public class CodeAnlysisNature implements IProjectNature { /** * 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; /* @@ -32,9 +32,7 @@ public class CodeAnlysisNature implements IProjectNature { IProjectDescription desc = project.getDescription(); ICommand[] commands = desc.getBuildSpec(); for (int i = 0; i < commands.length; ++i) { - if (commands[i].getBuilderName().equals(CodanBuilder.BUILDER_ID)) { - return; - } + if (commands[i].getBuilderName().equals(CodanBuilder.BUILDER_ID)) { return; } } ICommand[] newCommands = new ICommand[commands.length + 1]; 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)) { ICommand[] newCommands = new ICommand[commands.length - 1]; System.arraycopy(commands, 0, newCommands, 0, i); - System.arraycopy(commands, i + 1, newCommands, i, - commands.length - i - 1); + System.arraycopy(commands, i + 1, newCommands, i, commands.length - i - 1); description.setBuildSpec(newCommands); project.setDescription(description, null); return; diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CodanMarkerProblemReporter.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CodanMarkerProblemReporter.java index a4599c59b45..cfc74222ed7 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CodanMarkerProblemReporter.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CodanMarkerProblemReporter.java @@ -24,7 +24,6 @@ import org.eclipse.core.runtime.CoreException; public class CodanMarkerProblemReporter implements IProblemReporter { - /* * (non-Javadoc) * @@ -36,27 +35,20 @@ public class CodanMarkerProblemReporter implements IProblemReporter { public void reportProblem(String id, IProblemLocation loc, Object... args) { IFile file = loc.getFile(); int lineNumber = loc.getLineNumber(); - if (file == null) - throw new NullPointerException("file"); - if (id == null) - throw new NullPointerException("id"); - IProblem problem = CheckersRegisry.getInstance().getResourceProfile( - file).findProblem(id); - if (problem == null) - throw new IllegalArgumentException("Id is not registered"); - if (problem.isEnabled() == false) - return; // skip + if (file == null) throw new NullPointerException("file"); //$NON-NLS-1$ + if (id == null) throw new NullPointerException("id"); //$NON-NLS-1$ + IProblem problem = CheckersRegisry.getInstance().getResourceProfile(file).findProblem(id); + if (problem == null) throw new IllegalArgumentException("Id is not registered"); //$NON-NLS-1$ + if (problem.isEnabled() == false) return; // skip int severity = problem.getSeverity().intValue(); String messagePattern = problem.getMessagePattern(); String message = id; if (messagePattern == null) { - if (args != null && args.length > 0 && args[0] instanceof String) - message = (String) args[0]; + if (args != null && args.length > 0 && args[0] instanceof String) message = (String) args[0]; } else { MessageFormat.format(messagePattern, args); } - reportProblem(id, severity, file, lineNumber, loc.getStartingChar(), - loc.getEndingChar(), message); + reportProblem(id, severity, file, lineNumber, loc.getStartingChar(), loc.getEndingChar(), message); } /* @@ -66,28 +58,22 @@ public class CodanMarkerProblemReporter implements IProblemReporter { * org.eclipse.cdt.codan.core.model.IProblemReporter#reportProblem(java. * lang.String, org.eclipse.core.resources.IFile, int, java.lang.String) */ - public void reportProblem(String id, int severity, IFile file, - int lineNumber, int startChar, int endChar, String message) { + public void reportProblem(String id, int severity, IFile file, int lineNumber, int startChar, int endChar, + String message) { try { // Do not put in duplicates - IMarker[] cur = file.findMarkers(GENERIC_CODE_ANALYSIS_MARKER_TYPE, - false, IResource.DEPTH_ZERO); + IMarker[] cur = file.findMarkers(GENERIC_CODE_ANALYSIS_MARKER_TYPE, false, IResource.DEPTH_ZERO); if (cur != null) { for (IMarker element : cur) { - int line = ((Integer) element - .getAttribute(IMarker.LINE_NUMBER)).intValue(); + int line = ((Integer) element.getAttribute(IMarker.LINE_NUMBER)).intValue(); if (line == lineNumber) { - String mesg = (String) element - .getAttribute(IMarker.MESSAGE); - int sev = ((Integer) element - .getAttribute(IMarker.SEVERITY)).intValue(); - if (sev == severity && mesg.equals(message)) - return; + String mesg = (String) element.getAttribute(IMarker.MESSAGE); + int sev = ((Integer) element.getAttribute(IMarker.SEVERITY)).intValue(); + if (sev == severity && mesg.equals(message)) return; } } } - IMarker marker = file - .createMarker(GENERIC_CODE_ANALYSIS_MARKER_TYPE); + IMarker marker = file.createMarker(GENERIC_CODE_ANALYSIS_MARKER_TYPE); marker.setAttribute(IMarker.MESSAGE, message); marker.setAttribute(IMarker.SEVERITY, severity); marker.setAttribute(IMarker.LINE_NUMBER, lineNumber); @@ -101,8 +87,7 @@ public class CodanMarkerProblemReporter implements IProblemReporter { public void deleteMarkers(IResource file) { try { - file.deleteMarkers(GENERIC_CODE_ANALYSIS_MARKER_TYPE, false, - IResource.DEPTH_ZERO); + file.deleteMarkers(GENERIC_CODE_ANALYSIS_MARKER_TYPE, false, IResource.DEPTH_ZERO); } catch (CoreException ce) { ce.printStackTrace(); } @@ -111,8 +96,7 @@ public class CodanMarkerProblemReporter implements IProblemReporter { public void deleteAllMarkers() { try { // TODO delete contributed markers too - ResourcesPlugin.getWorkspace().getRoot().deleteMarkers( - GENERIC_CODE_ANALYSIS_MARKER_TYPE, false, + ResourcesPlugin.getWorkspace().getRoot().deleteMarkers(GENERIC_CODE_ANALYSIS_MARKER_TYPE, false, IResource.DEPTH_INFINITE); } catch (CoreException e) { // TODO Auto-generated catch block diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CodanProblem.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CodanProblem.java index 8c29ef51d91..c43346600ae 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CodanProblem.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CodanProblem.java @@ -11,6 +11,7 @@ package org.eclipse.cdt.codan.internal.core.model; import java.util.HashMap; + import org.eclipse.cdt.codan.core.model.CodanSeverity; import org.eclipse.cdt.codan.core.model.IProblemCategory; import org.eclipse.cdt.codan.core.model.IProblemParameterInfo; @@ -24,6 +25,7 @@ public class CodanProblem implements IProblemWorkingCopy { private boolean enabled = true; private HashMap parameters = new HashMap(0); private IProblemParameterInfo parameterInfo; + private boolean frozen; public CodanSeverity getSeverity() { return severity; @@ -32,6 +34,7 @@ public class CodanProblem implements IProblemWorkingCopy { public CodanProblem(String problemId, String name) { this.id = problemId; this.name = name; + this.frozen = false; } public String getName() { @@ -57,8 +60,7 @@ public class CodanProblem implements IProblemWorkingCopy { } public void setSeverity(CodanSeverity sev) { - if (sev == null) - throw new NullPointerException(); + if (sev == null) throw new NullPointerException(); this.severity = sev; } @@ -101,11 +103,20 @@ public class CodanProblem implements IProblemWorkingCopy { return message; } + protected void freeze() { + frozen = true; + } + /** * @param message * the message to set */ public void setMessagePattern(String message) { + checkSet(); this.message = message; } + + protected void checkSet() { + if (frozen) throw new IllegalStateException("Object is unmodifieble"); //$NON-NLS-1$ + } } diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CodanProblemCategory.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CodanProblemCategory.java index fc6348034e1..07c8ef10069 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CodanProblemCategory.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CodanProblemCategory.java @@ -41,40 +41,36 @@ public class CodanProblemCategory implements IProblemCategory, Cloneable { } public IProblemElement[] getChildren() { - return (IProblemElement[]) list.toArray(new IProblemElement[list.size()]); + return list.toArray(new IProblemElement[list.size()]); } public void addChild(IProblemElement p) { list.add(p); } - public IProblem findProblem(String id) { - Object[] children = this.getChildren(); + public static IProblem findProblem(IProblemCategory c, String id) { + Object[] children = c.getChildren(); for (Object object : children) { if (object instanceof IProblemCategory) { IProblemCategory cat = (IProblemCategory) object; - IProblem found = cat.findProblem(id); - if (found != null) - return found; + IProblem found = findProblem(cat, id); + if (found != null) return found; } else if (object instanceof IProblem) { IProblem p = (IProblem) object; - if (p.getId().equals(id)) - return p; + if (p.getId().equals(id)) return p; } } return null; } - public IProblemCategory findCategory(String id) { - if (getId().equals(id)) - return this; - Object[] children = getChildren(); + public static IProblemCategory findCategory(IProblemCategory cat, String id) { + if (cat.getId().equals(id)) return cat; + Object[] children = cat.getChildren(); for (Object object : children) { if (object instanceof IProblemCategory) { - IProblemCategory cat = (IProblemCategory) object; - IProblemCategory found = cat.findCategory(id); - if (found != null) - return found; + IProblemCategory cat2 = (IProblemCategory) object; + IProblemCategory found = findCategory(cat2, id); + if (found != null) return found; } } return null; @@ -90,8 +86,7 @@ public class CodanProblemCategory implements IProblemCategory, Cloneable { try { CodanProblemCategory clone = (CodanProblemCategory) super.clone(); clone.list = new ArrayList(); - for (Iterator iterator = this.list.iterator(); iterator - .hasNext();) { + for (Iterator iterator = this.list.iterator(); iterator.hasNext();) { IProblemElement child = iterator.next(); clone.list.add((IProblemElement) child.clone()); } diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CodanProblemLocation.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CodanProblemLocation.java new file mode 100644 index 00000000000..56c32827815 --- /dev/null +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/CodanProblemLocation.java @@ -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); + } + +} diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/ProblemLocationFactory.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/ProblemLocationFactory.java new file mode 100644 index 00000000000..fe7c198dadf --- /dev/null +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/ProblemLocationFactory.java @@ -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); + } +} diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/ProblemProfile.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/ProblemProfile.java index d2330f194f0..ffa5c335dfd 100644 --- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/ProblemProfile.java +++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/internal/core/model/ProblemProfile.java @@ -22,8 +22,7 @@ import org.eclipse.cdt.codan.core.model.IProblemProfile; * */ public class ProblemProfile implements IProblemProfile, Cloneable { - private IProblemCategory rootCategory = new CodanProblemCategory("root", - "root"); + private IProblemCategory rootCategory = new CodanProblemCategory("root", "root"); //$NON-NLS-1$ //$NON-NLS-2$ /* * (non-Javadoc) @@ -33,7 +32,7 @@ public class ProblemProfile implements IProblemProfile, Cloneable { * .String) */ 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 problems */ - protected void collectProblems(IProblemCategory parent, - Collection problems) { + protected void collectProblems(IProblemCategory parent, Collection problems) { Object[] children = parent.getChildren(); for (Object object : children) { if (object instanceof IProblemCategory) { @@ -69,13 +67,12 @@ public class ProblemProfile implements IProblemProfile, Cloneable { } public void addProblem(IProblem p, IProblemCategory cat) { - if (cat == null) - cat = getRoot(); + if (cat == null) cat = getRoot(); ((CodanProblemCategory) cat).addChild(p); } 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() { try { ProblemProfile clone = (ProblemProfile) super.clone(); - clone.rootCategory = (IProblemCategory) ((CodanProblemCategory) this.rootCategory) - .clone(); + clone.rootCategory = (IProblemCategory) ((CodanProblemCategory) this.rootCategory).clone(); return clone; } catch (CloneNotSupportedException e) { return this; diff --git a/codan/org.eclipse.cdt.codan.ui/.project b/codan/org.eclipse.cdt.codan.ui/.project index 1a97756c65e..f51fbc8bb12 100644 --- a/codan/org.eclipse.cdt.codan.ui/.project +++ b/codan/org.eclipse.cdt.codan.ui/.project @@ -20,9 +20,15 @@ + + org.eclipse.pde.api.tools.apiAnalysisBuilder + + + org.eclipse.pde.PluginNature org.eclipse.jdt.core.javanature + org.eclipse.pde.api.tools.apiAnalysisNature diff --git a/codan/org.eclipse.cdt.codan.ui/.settings/.api_filters b/codan/org.eclipse.cdt.codan.ui/.settings/.api_filters new file mode 100644 index 00000000000..2d910f457e7 --- /dev/null +++ b/codan/org.eclipse.cdt.codan.ui/.settings/.api_filters @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/codan/org.eclipse.cdt.codan.ui/META-INF/MANIFEST.MF b/codan/org.eclipse.cdt.codan.ui/META-INF/MANIFEST.MF index 3fd988f418e..340c6c679fd 100644 --- a/codan/org.eclipse.cdt.codan.ui/META-INF/MANIFEST.MF +++ b/codan/org.eclipse.cdt.codan.ui/META-INF/MANIFEST.MF @@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2 Bundle-Name: Code Analyzers Framework Bundle-SymbolicName: org.eclipse.cdt.codan.ui; singleton:=true 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 Require-Bundle: org.eclipse.ui, org.eclipse.core.runtime, diff --git a/codan/org.eclipse.cdt.codan.ui/build.properties b/codan/org.eclipse.cdt.codan.ui/build.properties index ccce0d1190a..2b0d95b6b02 100644 --- a/codan/org.eclipse.cdt.codan.ui/build.properties +++ b/codan/org.eclipse.cdt.codan.ui/build.properties @@ -3,7 +3,3 @@ output.. = bin/ bin.includes = plugin.xml,\ META-INF/,\ . -src.includes = src/,\ - plugin.xml,\ - build.properties,\ - META-INF/ diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CodanCReconciler.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CodanCReconciler.java index 90a4a9c7085..a7893f7bb68 100644 --- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CodanCReconciler.java +++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CodanCReconciler.java @@ -40,7 +40,7 @@ public class CodanCReconciler implements ICReconcilingListener { * */ private void initialize() { - // TODO Auto-generated method stub + // nothing? } /* @@ -51,7 +51,7 @@ public class CodanCReconciler implements ICReconcilingListener { * () */ public void aboutToBeReconciled() { - // TODO Auto-generated method stub + // nothing } /* diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/CodanUIActivator.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CodanUIActivator.java similarity index 98% rename from codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/CodanUIActivator.java rename to codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CodanUIActivator.java index 8c81586195d..e59880165b9 100644 --- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/ui/CodanUIActivator.java +++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/CodanUIActivator.java @@ -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.Status; diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/BuildPropertyPage.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/BuildPropertyPage.java index 968d9cb4691..31e90295204 100644 --- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/BuildPropertyPage.java +++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/BuildPropertyPage.java @@ -21,7 +21,7 @@ public class BuildPropertyPage extends FieldEditorPreferencePage implements * */ public BuildPropertyPage() { - setPreferenceStore(org.eclipse.cdt.codan.ui.CodanUIActivator.getDefault() + setPreferenceStore(org.eclipse.cdt.codan.internal.ui.CodanUIActivator.getDefault() .getPreferenceStore()); } diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/CodanPreferencePage.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/CodanPreferencePage.java index 97996078a14..5f6d2b23a8b 100644 --- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/CodanPreferencePage.java +++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/CodanPreferencePage.java @@ -71,7 +71,7 @@ public class CodanPreferencePage extends FieldEditorOverlayPage implements 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 public boolean performOk() { - if (isPropertyPage()) + //if (isPropertyPage()) getRegistry().updateProfile((IResource) getElement(), null); return super.performOk(); } diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/PreferenceInitializer.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/PreferenceInitializer.java index fdd7447c045..8994b27b264 100644 --- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/PreferenceInitializer.java +++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/preferences/PreferenceInitializer.java @@ -25,7 +25,7 @@ public class PreferenceInitializer extends AbstractPreferenceInitializer { * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences() */ public void initializeDefaultPreferences() { - IPreferenceStore store = org.eclipse.cdt.codan.ui.CodanUIActivator + IPreferenceStore store = org.eclipse.cdt.codan.internal.ui.CodanUIActivator .getDefault().getPreferenceStore(); store.setDefault(PreferenceConstants.P_RUN_ON_BUILD, false); }