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.PluginNatureorg.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.PluginNatureorg.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.PluginNatureorg.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