summaryrefslogtreecommitdiffstats
path: root/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model')
-rw-r--r--org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractChecker.java115
-rw-r--r--org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractCheckerWithProblemPreferences.java223
-rw-r--r--org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractIndexAstChecker.java103
-rw-r--r--org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractProblemLocation.java (renamed from org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ProblemLocation.java)45
-rw-r--r--org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CVS/Entries35
-rw-r--r--org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CVS/Tag1
-rw-r--r--org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CodanSeverity.java27
-rw-r--r--org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IChecker.java37
-rw-r--r--org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICheckerWithPreferences.java35
-rw-r--r--org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICheckersRegistry.java114
-rw-r--r--org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICodanBuilder.java15
-rw-r--r--org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblem.java64
-rw-r--r--org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemCategory.java33
-rw-r--r--org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemElement.java12
-rw-r--r--org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemLocation.java8
-rw-r--r--org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemLocationFactory.java67
-rw-r--r--org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemProfile.java42
-rw-r--r--org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemReporter.java34
-rw-r--r--org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemReporterPersistent.java45
-rw-r--r--org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemWorkingCopy.java73
-rw-r--r--org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IRunnableInEditorChecker.java29
-rw-r--r--org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/CVS/Entries13
-rw-r--r--org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/CVS/Repository1
-rw-r--r--org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/CVS/Root1
-rw-r--r--org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/CVS/Tag1
-rw-r--r--org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/IBasicBlock.java46
-rw-r--r--org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/IBranchNode.java38
-rw-r--r--org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/ICfgData.java32
-rw-r--r--org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/IConnectorNode.java25
-rw-r--r--org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/IControlFlowGraph.java69
-rw-r--r--org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/IDecisionNode.java29
-rw-r--r--org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/IExitNode.java25
-rw-r--r--org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/IJumpNode.java33
-rw-r--r--org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/INodeFactory.java54
-rw-r--r--org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/IPlainNode.java22
-rw-r--r--org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/ISingleIncoming.java (renamed from org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICodanAstReconciler.java)21
-rw-r--r--org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/ISingleOutgoing.java (renamed from org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICAstChecker.java)18
-rw-r--r--org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/IStartNode.java22
38 files changed, 1326 insertions, 281 deletions
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractChecker.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractChecker.java
index f1e5028..411ba67 100644
--- a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractChecker.java
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractChecker.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Alena Laskavaia
+ * Copyright (c) 2009, 2010 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
@@ -11,12 +11,21 @@
package org.eclipse.cdt.codan.core.model;
import org.eclipse.cdt.codan.core.CodanRuntime;
+import org.eclipse.cdt.codan.internal.core.CheckersRegistry;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
+/**
+ * Convenience implementation of IChecker interface. Has a default
+ * implementation for common methods.
+ *
+ */
public abstract class AbstractChecker implements IChecker {
protected String name;
+ /**
+ * Default constructor
+ */
public AbstractChecker() {
}
@@ -32,19 +41,38 @@ public abstract class AbstractChecker implements IChecker {
* Reports a simple problem for given file and line
*
* @param id
- * - problem id
+ * - problem id
* @param file
- * - file
+ * - file
* @param lineNumber
- * - line
- * @param arg
- * - problem argument, if problem does not define error message
- * it will be error message (not recommended because of
- * internationalization)
+ * - line
+ * @param args
+ * - problem arguments, if problem does not define error message
+ * it will be error message (not recommended because of
+ * internationalization)
*/
- public void reportProblem(String id, IFile file, int lineNumber, String arg) {
+ public void reportProblem(String id, IFile file, int lineNumber,
+ Object... args) {
getProblemReporter().reportProblem(id,
- new ProblemLocation(file, lineNumber), arg);
+ createProblemLocation(file, lineNumber), args);
+ }
+
+ /**
+ * 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, IResource file) {
+ IProblem problem = CheckersRegistry.getInstance()
+ .getResourceProfile(file).findProblem(id);
+ if (problem == null)
+ throw new IllegalArgumentException("Id is not registered"); //$NON-NLS-1$
+ return problem;
}
/**
@@ -52,15 +80,15 @@ public abstract class AbstractChecker implements IChecker {
* from problem definition
*
* @param id
- * - problem id
+ * - problem id
* @param file
- * - file
+ * - file
* @param lineNumber
- * - line
+ * - line
*/
public void reportProblem(String id, IFile file, int lineNumber) {
getProblemReporter().reportProblem(id,
- new ProblemLocation(file, lineNumber), new Object[] {});
+ createProblemLocation(file, lineNumber), new Object[] {});
}
/**
@@ -70,7 +98,64 @@ 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);
+ }
+
+ /**
+ * Defines if checker should be run as user type in C editor. Override this
+ * method is checker is too heavy for that (runs too long)
+ */
public boolean runInEditor() {
- return false;
+ return this instanceof IRunnableInEditorChecker;
+ }
+
+ /**
+ * report a problem
+ *
+ * @param problemId - id of a problem
+ * @param loc - problem location
+ * @param args - extra problem arguments
+ */
+ public void reportProblem(String problemId, IProblemLocation loc,
+ Object... args) {
+ getProblemReporter().reportProblem(problemId, loc, args);
}
}
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractCheckerWithProblemPreferences.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractCheckerWithProblemPreferences.java
new file mode 100644
index 0000000..b58156f
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractCheckerWithProblemPreferences.java
@@ -0,0 +1,223 @@
+/*******************************************************************************
+ * Copyright (c) 2009,2010 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 java.util.Collection;
+import java.util.Iterator;
+
+import org.eclipse.cdt.codan.core.param.AbstractProblemPreference;
+import org.eclipse.cdt.codan.core.param.BasicProblemPreference;
+import org.eclipse.cdt.codan.core.param.FileScopeProblemPreference;
+import org.eclipse.cdt.codan.core.param.IProblemPreference;
+import org.eclipse.cdt.codan.core.param.IProblemPreferenceDescriptor.PreferenceType;
+import org.eclipse.cdt.codan.core.param.ListProblemPreference;
+import org.eclipse.cdt.codan.core.param.MapProblemPreference;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IPath;
+
+/**
+ * AbstarctChecker that has extra methods to simplify adding problem
+ * preferences.
+ * Checker can produce several problems, but preferences are per problem.
+ * Sharing preferences between problems is not supported now.
+ */
+public abstract class AbstractCheckerWithProblemPreferences extends
+ AbstractChecker implements ICheckerWithPreferences {
+ /**
+ * Checker that actually has parameter must override this
+ */
+ public void initPreferences(IProblemWorkingCopy problem) {
+ // by default add file scope preference
+ addPreference(problem, new FileScopeProblemPreference(), null);
+ }
+
+ /**
+ * Scope preference - special preference that all file checkers should have,
+ * it allows user to include/exclude files for this specific problem.
+ *
+ * @param problem - problem for which scope preference is need
+ * @return scope problem preference, null if not defined
+ */
+ public FileScopeProblemPreference getScopePreference(IProblem problem) {
+ FileScopeProblemPreference scope = (FileScopeProblemPreference) getTopLevelPreferenceMap(
+ problem).getChildDescriptor(FileScopeProblemPreference.KEY);
+ return scope;
+ }
+
+ /**
+ * User can scope out some resources for this checker. Checker can use this
+ * call to test if it should run on this resource at all or not. Test should
+ * be done within processResource method not in enabledInContext.
+ * This test uses user "scope" preference for the all problems that this
+ * checker can produce.
+ *
+ * @param res - resource to test on
+ * @return true if checker should report problems, fails otherwise.
+ */
+ public boolean shouldProduceProblems(IResource res) {
+ Collection<IProblem> refProblems = getRuntime().getChechersRegistry()
+ .getRefProblems(this);
+ for (Iterator<IProblem> iterator = refProblems.iterator(); iterator
+ .hasNext();) {
+ IProblem checkerProblem = iterator.next();
+ if (shouldProduceProblem(
+ getProblemById(checkerProblem.getId(), res),
+ res.getLocation()))
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * User can scope out some resources for this checker. Checker can use this
+ * call to test if it should run on this resource at all or produce a
+ * specific problem on this resource. Test should
+ * be done within processResource method not in enabledInContext, or just
+ * before printing of a problem.
+ * This test uses user "scope" preference for the given problem. If scope is
+ * not defined preference it returns true.
+ *
+ * @param problem - problem to test for
+ * @param resource - resource to test on
+ *
+ * @return true if problem should be report for given resource, fails
+ * otherwise.
+ */
+ public boolean shouldProduceProblem(IProblem problem, IPath resource) {
+ FileScopeProblemPreference scope = getScopePreference(problem);
+ if (scope == null)
+ return true;
+ return scope.isInScope(resource);
+ }
+
+ @Override
+ public void reportProblem(String problemId, IProblemLocation loc,
+ Object... args) {
+ if (shouldProduceProblem(getProblemById(problemId, loc.getFile()), loc
+ .getFile().getLocation()))
+ super.reportProblem(problemId, loc, args);
+ }
+
+ /**
+ * Add a parameter
+ *
+ * @param problem
+ * - problem that has parameter
+ * @param key
+ * - parameter key
+ * @param label
+ * - parameter label - user visible
+ * @param defaultValue
+ * - parameter default value
+ * @return - parameter info object
+ */
+ public IProblemPreference addPreference(IProblemWorkingCopy problem,
+ String key, String label, Object defaultValue) {
+ MapProblemPreference map = getTopLevelPreferenceMap(problem);
+ BasicProblemPreference info = new BasicProblemPreference(key, label,
+ PreferenceType.typeOf(defaultValue));
+ map.addChildDescriptor(info);
+ setDefaultPreferenceValue(problem, key, defaultValue);
+ return info;
+ }
+
+ /**
+ * Add preference of type list of strings, list is empty by
+ * default
+ *
+ * @param problem
+ * - problem
+ * @param key
+ * - preference key
+ * @param label
+ * - preference label
+ * @param itemLabel
+ * @return preference instance of of the list, can be used to add default
+ * values or set different element type
+ *
+ */
+ public ListProblemPreference addListPreference(IProblemWorkingCopy problem,
+ String key, String label, String itemLabel) {
+ MapProblemPreference map = getTopLevelPreferenceMap(problem);
+ ListProblemPreference list = new ListProblemPreference(key, label);
+ list.setChildDescriptor(new BasicProblemPreference(
+ ListProblemPreference.COMMON_DESCRIPTOR_KEY, itemLabel,
+ PreferenceType.TYPE_STRING));
+ return (ListProblemPreference) map.addChildDescriptor(list);
+ }
+
+ /**
+ * Add preference for the given problem with default value
+ *
+ * @param problem
+ * @param pref - preference
+ * @param defaultValue - default value of the preference
+ * @return added preference
+ */
+ public IProblemPreference addPreference(IProblemWorkingCopy problem,
+ IProblemPreference pref, Object defaultValue) {
+ MapProblemPreference map = getTopLevelPreferenceMap(problem);
+ String key = pref.getKey();
+ pref = map.addChildDescriptor(pref);
+ setDefaultPreferenceValue(problem, key, defaultValue);
+ return pref;
+ }
+
+ /**
+ * Convenience method for setting default preference value for checker that
+ * uses "map" as top level problem preference.
+ *
+ * @param problem - problem for which to set default value for a prefence
+ * @param key - preference key
+ * @param defaultValue - value of preference to be set
+ */
+ protected void setDefaultPreferenceValue(IProblemWorkingCopy problem,
+ String key, Object defaultValue) {
+ MapProblemPreference map = getTopLevelPreferenceMap(problem);
+ if (map.getChildValue(key) == null)
+ map.setChildValue(key, defaultValue);
+ }
+
+ /**
+ * Return "map" problem preference for a give problem, if problem
+ * has preference different than a map, it will throw ClassCastException.
+ * If top level preference does not exist create a map preference with name
+ * "params"
+ * and return it.
+ *
+ * @param problem
+ * @return top level preference if it is a map
+ */
+ protected MapProblemPreference getTopLevelPreferenceMap(IProblem problem) {
+ MapProblemPreference map = (MapProblemPreference) problem
+ .getPreference();
+ if (map == null) {
+ map = new MapProblemPreference(AbstractProblemPreference.PARAM, ""); //$NON-NLS-1$
+ if (problem instanceof IProblemWorkingCopy) {
+ ((IProblemWorkingCopy) problem).setPreference(map);
+ }
+ }
+ return map;
+ }
+
+ /**
+ * Returns value of the preference for the key in the top level
+ * preference map for the given problem
+ *
+ * @param problem - problem for which to get the preference
+ * @param key - preference key
+ * @return value of the preference
+ */
+ public Object getPreference(IProblem problem, String key) {
+ return ((MapProblemPreference) problem.getPreference())
+ .getChildValue(key);
+ }
+}
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractIndexAstChecker.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractIndexAstChecker.java
deleted file mode 100644
index d805f2f..0000000
--- a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractIndexAstChecker.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*******************************************************************************
- * 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.cdt.codan.core.CodanCorePlugin;
-import org.eclipse.cdt.core.CCorePlugin;
-import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
-import org.eclipse.cdt.core.dom.ast.IASTNode;
-import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
-import org.eclipse.cdt.core.index.IIndex;
-import org.eclipse.cdt.core.model.CoreModel;
-import org.eclipse.cdt.core.model.ICElement;
-import org.eclipse.cdt.core.model.ITranslationUnit;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-
-/**
- * @author Alena
- *
- */
-public abstract class AbstractIndexAstChecker extends AbstractChecker implements
- ICAstChecker {
- private IFile file;
-
- protected IFile getFile() {
- return file;
- }
-
- void processFile(IFile file) throws CoreException, InterruptedException {
- // create translation unit and access index
- ICElement model = CoreModel.getDefault().create(file);
- if (!(model instanceof ITranslationUnit))
- return;
- 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);
- // traverse the ast using the visitor pattern.
- this.file = file;
- processAst(ast);
- } finally {
- this.file = null;
- index.releaseReadLock();
- }
- }
-
- public boolean processResource(IResource resource) {
- if (resource instanceof IFile) {
- IFile file = (IFile) resource;
- try {
- processFile(file);
- } catch (CoreException e) {
- CodanCorePlugin.log(e);
- } catch (InterruptedException e) {
- // ignore
- }
- return false;
- }
- return true;
- }
-
- 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);
- 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());
- getProblemReporter().reportProblem(id, loc, message);
- }
-
- @Override
- public boolean runInEditor() {
- return true;
- }
-}
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ProblemLocation.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractProblemLocation.java
index ced12f0..c2bcd2a 100644
--- a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ProblemLocation.java
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/AbstractProblemLocation.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Alena Laskavaia
+ * Copyright (c) 2009, 2010 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
@@ -13,36 +13,30 @@ 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.
+ * <p>
+ * <strong>EXPERIMENTAL</strong>. This class or interface has been added as
+ * part of a work in progress. There is no guarantee that this API will
+ * work or that it will remain the same.
+ * </p>
*/
-public class ProblemLocation implements IProblemLocation {
+public abstract class AbstractProblemLocation 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 AbstractProblemLocation(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 AbstractProblemLocation(IFile file, int startChar, int endChar) {
this.file = file;
this.line = -1;
this.posStart = startChar;
@@ -58,6 +52,11 @@ public class ProblemLocation implements IProblemLocation {
return extra;
}
+ /**
+ * Sets extra data for the problem location
+ *
+ * @param data
+ */
public void setData(Object data) {
this.extra = data;
}
@@ -71,19 +70,15 @@ public class ProblemLocation implements IProblemLocation {
return file;
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.cdt.codan.core.model.IProblemLocation#getLine()
+ /**
+ * Problem line number referenced in problem view in location field
*/
public int getLineNumber() {
return getStartingLineNumber();
}
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.cdt.codan.core.model.IProblemLocation#getStartLine()
+ /**
+ * @return line number where problem starts
*/
public int getStartingLineNumber() {
return line;
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CVS/Entries b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CVS/Entries
index 8635b9d..4315bc4 100644
--- a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CVS/Entries
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CVS/Entries
@@ -1,16 +1,19 @@
-/AbstractChecker.java/1.4/Sat Aug 22 21:31:29 2009//
-/AbstractIndexAstChecker.java/1.6/Wed Dec 16 21:48:48 2009//
-/CodanSeverity.java/1.2/Wed Apr 22 01:26:56 2009//
-/ICAstChecker.java/1.1/Thu Apr 9 12:46:50 2009//
-/IChecker.java/1.3/Wed Dec 16 21:48:48 2009//
-/ICheckersRegistry.java/1.1/Sat Aug 22 21:16:48 2009//
-/ICodanAstReconciler.java/1.1/Sat Aug 22 21:16:48 2009//
-/ICodanBuilder.java/1.1/Sat Aug 22 21:16:48 2009//
-/IProblem.java/1.4/Wed Dec 16 21:48:48 2009//
-/IProblemCategory.java/1.3/Wed Dec 16 21:48:48 2009//
-/IProblemElement.java/1.2/Wed Dec 16 21:48:48 2009//
-/IProblemLocation.java/1.1/Sat Aug 22 21:16:48 2009//
-/IProblemProfile.java/1.4/Wed Dec 16 21:48:48 2009//
-/IProblemReporter.java/1.2/Wed Dec 16 21:48:48 2009//
-/ProblemLocation.java/1.1/Sat Aug 22 21:16:48 2009//
-D
+/AbstractChecker.java/1.13/Sun Jun 27 01:30:41 2010//TCDT_7_0_0
+/AbstractCheckerWithProblemPreferences.java/1.5/Mon May 31 02:53:25 2010//TCDT_7_0_0
+/AbstractProblemLocation.java/1.3/Sun Jun 27 01:30:41 2010//TCDT_7_0_0
+/CodanSeverity.java/1.6/Sun Jun 27 01:30:41 2010//TCDT_7_0_0
+/IChecker.java/1.8/Sun Jun 27 01:30:41 2010//TCDT_7_0_0
+/ICheckerWithPreferences.java/1.3/Thu Jun 3 17:01:52 2010//TCDT_7_0_0
+/ICheckersRegistry.java/1.6/Sun Jun 27 01:30:41 2010//TCDT_7_0_0
+/ICodanBuilder.java/1.4/Sun Jun 27 01:30:41 2010//TCDT_7_0_0
+/IProblem.java/1.13/Sun Jun 27 01:30:41 2010//TCDT_7_0_0
+/IProblemCategory.java/1.7/Sun Jun 27 01:30:41 2010//TCDT_7_0_0
+/IProblemElement.java/1.4/Sun Jun 27 01:30:41 2010//TCDT_7_0_0
+/IProblemLocation.java/1.4/Sun Jun 27 01:30:41 2010//TCDT_7_0_0
+/IProblemLocationFactory.java/1.5/Sun Jun 27 01:30:41 2010//TCDT_7_0_0
+/IProblemProfile.java/1.8/Sun Jun 27 01:30:41 2010//TCDT_7_0_0
+/IProblemReporter.java/1.6/Sun Jun 27 01:30:41 2010//TCDT_7_0_0
+/IProblemReporterPersistent.java/1.3/Sun Jun 27 01:30:41 2010//TCDT_7_0_0
+/IProblemWorkingCopy.java/1.9/Sun Jun 27 01:30:41 2010//TCDT_7_0_0
+/IRunnableInEditorChecker.java/1.3/Sun Jun 27 01:30:41 2010//TCDT_7_0_0
+D/cfg////
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CVS/Tag b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CVS/Tag
new file mode 100644
index 0000000..49a449a
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CVS/Tag
@@ -0,0 +1 @@
+NCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CodanSeverity.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CodanSeverity.java
index acfa4d1..fb85718 100644
--- a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CodanSeverity.java
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CodanSeverity.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Alena Laskavaia
+ * Copyright (c) 2009, 2010 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
@@ -12,21 +12,40 @@ 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.
+ *
+ */
public enum CodanSeverity {
- Info(IMarker.SEVERITY_INFO), Warning(IMarker.SEVERITY_WARNING), Error(
- IMarker.SEVERITY_ERROR);
+ /**
+ * Info severity
+ */
+ Info(IMarker.SEVERITY_INFO),
+ /**
+ * Warning severity
+ */
+ Warning(IMarker.SEVERITY_WARNING),
+ /**
+ * Error severity
+ */
+ Error(IMarker.SEVERITY_ERROR);
private int value;
private CodanSeverity(int value) {
this.value = value;
}
+ /**
+ * @return int value of the severity
+ */
public int intValue() {
return value;
}
/**
- * @return
+ * @return array of string value for all severities
*/
public static String[] stringValues() {
CodanSeverity[] values = values();
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IChecker.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IChecker.java
index 60f7cb2..f00fea0 100644
--- a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IChecker.java
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IChecker.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Alena Laskavaia
+ * Copyright (c) 2009, 2010 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
@@ -13,27 +13,48 @@ package org.eclipse.cdt.codan.core.model;
import org.eclipse.core.resources.IResource;
/**
- * Interface that checker must implement. CDT Checker must be able to process a resource.
+ * Interface that checker must implement (through extending directly or
+ * indirectly {@link AbstractChecker}.
+ *
+ * <p>
+ * <strong>EXPERIMENTAL</strong>. This class or interface has been added as part
+ * of a work in progress. There is no guarantee that this API will work or that
+ * it will remain the same.
+ * </p>
+ *
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ * Extend {@link AbstractChecker} class instead.
*/
public interface IChecker {
/**
* Main method that checker should implement that actually detects errors
- * @param resource - resource to run on
- * @return true if need to traverse children
+ *
+ * @param resource
+ * - resource to run on
+ * @return true if framework should traverse children of the resource and
+ * run this checkers on them again
*/
boolean processResource(IResource resource);
/**
- * Implement this method to trim down type of resource you are interested in,
- * usually it will be c/c++ files only
+ * Implement this method to trim down type of resource you are interested
+ * in, usually it will be c/c++ files only. This method should be
+ * independent from current user preferences.
+ *
* @param resource
- * @return
+ * - resource to run on
+ * @return - true if checker should be run on this resource
*/
boolean enabledInContext(IResource resource);
/**
* Checker must implement this method to determine if it can run in editor
- * "as you type", checker must be really light weight to run in this mode
+ * "as you type". Checker must be really light weight to run in this mode.
+ * If it returns true, checker must also implement
+ * {@link IRunnableInEditorChecker}.
+ * Checker should return false if check is non-trivial and takes a long
+ * time.
*
* @return true if need to be run in editor as user types, and false
* otherwise
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICheckerWithPreferences.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICheckerWithPreferences.java
new file mode 100644
index 0000000..56619cb
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICheckerWithPreferences.java
@@ -0,0 +1,35 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 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;
+
+/**
+ * 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. It is recommended to use
+ * {@link AbstractCheckerWithProblemPreferences} insted of implementing it
+ * directly.<p>
+ * <strong>EXPERIMENTAL</strong>. This class or interface has been added as part
+ * of a work in progress. There is no guarantee that this API will work or that
+ * it will remain the same.
+ * </p>
+ *
+ * @noextend This interface is not intended to be extended by clients.
+ */
+public interface ICheckerWithPreferences {
+ /**
+ * Implement this method to set default parameters for checkers with
+ * parameters.
+ *
+ * @param problem
+ * - instance of problem working copy
+ */
+ void initPreferences(IProblemWorkingCopy problem);
+}
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICheckersRegistry.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICheckersRegistry.java
index 052d868..04189ae 100644
--- a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICheckersRegistry.java
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICheckersRegistry.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Alena Laskavaia
+ * Copyright (c) 2009, 2010 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
@@ -10,57 +10,125 @@
*******************************************************************************/
package org.eclipse.cdt.codan.core.model;
+import java.util.Collection;
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
+ *
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
*
*/
-public interface ICheckersRegistry {
- public abstract Iterator<IChecker> iterator();
+public interface ICheckersRegistry extends Iterable<IChecker> {
+ /**
+ * Iterator for registered checkers
+ *
+ * @return iterator for registered checkers
+ */
+ public Iterator<IChecker> iterator();
+
+ /**
+ * Add a checker
+ *
+ * @param checker instance
+ */
+ public void addChecker(IChecker checker);
- public abstract void addChecker(IChecker checker);
+ /**
+ * Add problem p into a category defined by a category id into default
+ * profile, category must exists in default profile
+ *
+ * @param p
+ * - problem
+ * @param categoryId
+ * - category id
+ */
+ public void addProblem(IProblem p, String categoryId);
- public abstract void addProblem(IProblem p, String category);
+ /**
+ * Add subcategory category into parent category with the id of
+ * parentCategoryId, if parent does not exist in the default profile or it
+ * is a null - it will be added to the root
+ *
+ * @param category
+ * - new category
+ * @param parentCategoryId
+ * - parent category id
+ */
+ public abstract void addCategory(IProblemCategory category,
+ String parentCategoryId);
- public abstract void addCategory(IProblemCategory p, String category);
+ /**
+ * 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 void addRefProblem(IChecker c, IProblem p);
- public abstract void addRefProblem(IChecker c, IProblem p);
+ /**
+ * Return collection of problem that this checker can produce
+ *
+ * @param checker
+ * @return collection of problems
+ */
+ public Collection<IProblem> getRefProblems(IChecker checker);
/**
- * @return
+ * Default profile is kind of "Installation Default".
+ * Always the same, comes from defaults in checker extensions or APIs added
+ *
+ * @return default profile
*/
- public abstract IProblemProfile getDefaultProfile();
+ public IProblemProfile getDefaultProfile();
/**
- * @return
+ * Get workspace profile. User can change setting for workspace profile.
+ *
+ * @return workspace profile
*/
- public abstract IProblemProfile getWorkspaceProfile();
+ public IProblemProfile getWorkspaceProfile();
/**
+ * Get resource profile. For example given project can have different
+ * profile than a workspace.
+ *
* @param element
- * @return
+ * - resource
+ * @return resource profile
*/
- public abstract IProblemProfile getResourceProfile(IResource element);
+ public 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). If you planning on editing it this method should be used instead of
+ * getResourceProfile. You have to save your changes after updating a
+ * working copy, using {@link #updateProfile(IResource, IProblemProfile)}
+ * method.
+ *
+ * @noreference This method is not intended to be referenced by clients.
* @param element
- * @return
+ * @return resource profile
*/
- public abstract IProblemProfile getResourceProfileWorkingCopy(
- IResource element);
+ public 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
+ * - resource
* @param profile
- * - problems profile
+ * - problems profile
*/
- public abstract void updateProfile(IResource resource,
- IProblemProfile profile);
+ public void updateProfile(IResource resource, IProblemProfile profile);
} \ No newline at end of file
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICodanBuilder.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICodanBuilder.java
index ce1f668..dcbe4c3 100644
--- a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICodanBuilder.java
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICodanBuilder.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Alena Laskavaia
+ * Copyright (c) 2009, 2010 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
@@ -14,9 +14,20 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IProgressMonitor;
/**
- * @author Alena
+ * Interface for "Codan Builder". Clients can call processResource method to
+ * traverse the resource tree. It will be calling all the checkers (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/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblem.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblem.java
index bbab313..d12806d 100644
--- a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblem.java
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblem.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Alena Laskavaia
+ * Copyright (c) 2009, 2010 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
@@ -10,56 +10,82 @@
*******************************************************************************/
package org.eclipse.cdt.codan.core.model;
-import java.util.Collection;
+import org.eclipse.cdt.codan.core.param.IProblemPreference;
/**
- * 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 Problems should be created
+ * (i.e. one for error and one for warning). All of problem attributes are
+ * defined in a checker extension point.
+ *
+ * <p>
+ * <strong>EXPERIMENTAL</strong>. This class or interface has been added as part
+ * of a work in progress. There is no guarantee that this API will work or that
+ * it will remain the same.
+ * </p>
+ *
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
*/
public interface IProblem extends IProblemElement {
/**
* Name of the problem - user visible "title", not the message
+ *
+ * @return title of the problem
*/
String getName();
/**
- * Unique problem id. Should be qualified by plugin name to maintain uniqueness.
- * @return
+ * Unique problem id. Should be qualified by plugin name to maintain
+ * uniqueness.
+ *
+ * @return unique problem id
*/
String getId();
/**
* Is enabled in current context (usually within profile)
+ *
* @return true if enabled
*/
boolean isEnabled();
/**
* Get current severity
+ *
* @return severity
*/
CodanSeverity getSeverity();
/**
* Message pattern, java patter like 'Variable {0} is never used here'
- * @return pattern
+ *
+ * @return pattern
*/
String getMessagePattern();
- void setSeverity(CodanSeverity sev);
-
- void setEnabled(boolean checked);
-
- void setMessagePattern(String message);
-
- public void setProperty(Object key, Object value);
+ /**
+ * Get root preference descriptor or null if not defined (used by ui to
+ * generate user controls for changing parameters)
+ *
+ * @return root preference or null
+ */
+ public IProblemPreference getPreference();
/**
- * Get custom property
- * @param property name
- * @return property object
+ * Get short description of a problem
+ *
+ * @return description
*/
- public Object getProperty(Object key);
+ public String getDescription();
- public Collection<Object> getPropertyKeys();
+ /**
+ * Return marker id for the problem
+ *
+ * @return marker id
+ */
+ public String getMarkerType();
}
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemCategory.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemCategory.java
index cd3de3a..adfc897 100644
--- a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemCategory.java
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemCategory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Alena Laskavaia
+ * Copyright (c) 2009, 2010 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
@@ -11,38 +11,35 @@
package org.eclipse.cdt.codan.core.model;
/**
- * Problem category
- *
+ * Problem category. Allows to group problems.
+ * <p>
+ * <strong>EXPERIMENTAL</strong>. This class or interface has been added as part
+ * of a work in progress. There is no guarantee that this API will work or that
+ * it will remain the same.
+ * </p>
+ *
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
*/
public interface IProblemCategory extends IProblemElement {
/**
* Category name
+ *
+ * @return category name
*/
String getName();
/**
* Unique category id
+ *
* @return id
*/
String getId();
/**
* Category children (other categories or problems)
- * @return
+ *
+ * @return children of the category
*/
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/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemElement.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemElement.java
index 318f304..3068aeb 100644
--- a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemElement.java
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemElement.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Alena Laskavaia
+ * Copyright (c) 2009, 2010 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
@@ -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/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemLocation.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemLocation.java
index f5e4f23..1ef8546 100644
--- a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemLocation.java
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemLocation.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Alena Laskavaia
+ * Copyright (c) 2009, 2010 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
@@ -10,19 +10,21 @@
*******************************************************************************/
package org.eclipse.cdt.codan.core.model;
-import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
/**
* 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 {
/**
*
* @return File for the problem - absolute full paths
*/
- IFile getFile();
+ IResource getFile();
/**
*
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemLocationFactory.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemLocationFactory.java
new file mode 100644
index 0000000..4710bb1
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemLocationFactory.java
@@ -0,0 +1,67 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 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.
+ * <p>
+ * <strong>EXPERIMENTAL</strong>. This class or interface has been added as part
+ * of a work in progress. There is no guarantee that this API will work or that
+ * it will remain the same.
+ * </p>
+ */
+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);
+
+ /**
+ * Create and return instance of IProblemLocation
+ *
+ * @param astFile - 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.
+ *
+ * @param line
+ * - start line number (for visualisation purposes)
+ * @return instance of IProblemLocation
+ */
+ public IProblemLocation createProblemLocation(IFile astFile,
+ int startChar, int endChar, int line);
+} \ No newline at end of file
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemProfile.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemProfile.java
index 896eb10..1a0d2df 100644
--- a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemProfile.java
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemProfile.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Alena Laskavaia
+ * Copyright (c) 2009, 2010 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
@@ -10,16 +10,29 @@
*******************************************************************************/
package org.eclipse.cdt.codan.core.model;
+import org.eclipse.cdt.codan.internal.core.CheckersRegistry;
+
/**
- * 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,
- * CheckersRegisry#getDefaultProfile() or CheckersRegisry#getWorkspaceProfile()}
- * .
+ * 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 CheckersRegistry#getResourceProfile},
+ * {@link CheckersRegistry#getDefaultProfile()} or
+ * {@link CheckersRegistry#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,25 +41,26 @@ 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
+ * - problem id
* @return problem instance
*/
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
+ * - category id
* @return category instance
*/
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/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemReporter.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemReporter.java
index 059f155..a928593 100644
--- a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemReporter.java
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemReporter.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009 Alena Laskavaia
+ * Copyright (c) 2009, 2010 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
@@ -10,20 +10,32 @@
*******************************************************************************/
package org.eclipse.cdt.codan.core.model;
-
/**
* IProblemReporter - interface to report problems
- *
+ *
+ * <p>
+ * <strong>EXPERIMENTAL</strong>. This class or interface has been added as
+ * part of a work in progress. There is no guarantee that this API will
+ * work or that it will remain the same.
+ * </p>
*/
public interface IProblemReporter {
- public static final String GENERIC_CODE_ANALYSIS_MARKER_TYPE = "org.eclipse.cdt.codan.core.codanProblem";
/**
- * 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
- * @param loc - location object
- * @param args - custom args, can be null, in this case default message is reported
+ * id of generic codan problem marker
+ */
+ 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 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, can be created using
+ * getRuntime().getProblemLocationFactory().createProblemLocation
+ * methods
+ * @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/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemReporterPersistent.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemReporterPersistent.java
new file mode 100644
index 0000000..88638d9
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemReporterPersistent.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 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.IResource;
+
+/**
+ * IProblemReporterPersistent - interface to report problems, which are
+ * persistent, ex. markers
+ *
+ * <p>
+ * <strong>EXPERIMENTAL</strong>. This class or interface has been added as part
+ * of a work in progress. There is no guarantee that this API will work or that
+ * it will remain the same.
+ * </p>
+ */
+public interface IProblemReporterPersistent extends IProblemReporter {
+ /**
+ * Delete all problems associated with resource created by given checker
+ *
+ * @param resource
+ * @param checker
+ */
+ public void deleteProblems(IResource resource, IChecker checker);
+
+ /**
+ * Delete all problems associated with resource
+ *
+ * @param resource
+ */
+ public void deleteProblems(IResource resource);
+
+ /**
+ * Delete all persisted problems
+ */
+ public void deleteAllProblems();
+} \ No newline at end of file
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemWorkingCopy.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemWorkingCopy.java
new file mode 100644
index 0000000..bb08f2e
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemWorkingCopy.java
@@ -0,0 +1,73 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 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.cdt.codan.core.param.IProblemPreference;
+
+/**
+ * Modifiable problem.
+ *
+ *
+ * <p>
+ * <strong>EXPERIMENTAL</strong>. This class or interface has been added as part
+ * of a work in progress. There is no guarantee that this API will work or that
+ * it will remain the same.
+ * </p>
+ *
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+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);
+
+ /**
+ * Set checker enablement.
+ *
+ * @param enabled
+ * - true if problem is enabled in profile
+ */
+ void setEnabled(boolean enabled);
+
+ /**
+ * 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, which would the default. User control this values
+ * through ui later.
+ *
+ * @param pref - preference to set
+ *
+ */
+ public void setPreference(IProblemPreference pref);
+
+ /**
+ * Set problem description
+ *
+ * @param desc
+ * - problem description - short version, but longer than name
+ */
+ public void setDescription(String desc);
+}
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IRunnableInEditorChecker.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IRunnableInEditorChecker.java
new file mode 100644
index 0000000..694aaf4
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IRunnableInEditorChecker.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 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;
+
+/**
+ * Interface for checkers that can be run when user is typing, checker has to be
+ * very quick to run in this mode
+ * <p>
+ * <strong>EXPERIMENTAL</strong>. This class or interface has been added as part
+ * of a work in progress. There is no guarantee that this API will work or that
+ * it will remain the same.
+ * </p>
+ *
+ * @noextend This interface is not intended to be extended by clients.
+ */
+public interface IRunnableInEditorChecker {
+ /**
+ * @param model
+ */
+ void processModel(Object model);
+}
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/CVS/Entries b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/CVS/Entries
new file mode 100644
index 0000000..60f510d
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/CVS/Entries
@@ -0,0 +1,13 @@
+/IBasicBlock.java/1.6/Thu Jun 3 17:01:53 2010//TCDT_7_0_0
+/IBranchNode.java/1.4/Thu Jun 3 17:01:53 2010//TCDT_7_0_0
+/ICfgData.java/1.2/Tue Jun 1 02:24:14 2010//TCDT_7_0_0
+/IConnectorNode.java/1.5/Thu Jun 3 17:01:53 2010//TCDT_7_0_0
+/IControlFlowGraph.java/1.5/Thu Jun 3 17:01:53 2010//TCDT_7_0_0
+/IDecisionNode.java/1.4/Thu Jun 3 17:01:53 2010//TCDT_7_0_0
+/IExitNode.java/1.4/Thu Jun 3 17:01:53 2010//TCDT_7_0_0
+/IJumpNode.java/1.5/Thu Jun 3 17:01:53 2010//TCDT_7_0_0
+/INodeFactory.java/1.4/Thu Jun 3 17:01:53 2010//TCDT_7_0_0
+/IPlainNode.java/1.4/Thu Jun 3 17:01:53 2010//TCDT_7_0_0
+/ISingleIncoming.java/1.4/Thu Jun 3 17:01:53 2010//TCDT_7_0_0
+/ISingleOutgoing.java/1.4/Thu Jun 3 17:01:53 2010//TCDT_7_0_0
+/IStartNode.java/1.3/Thu Jun 3 17:01:53 2010//TCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/CVS/Repository b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/CVS/Repository
new file mode 100644
index 0000000..52814e4
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/CVS/Repository
@@ -0,0 +1 @@
+org.eclipse.cdt/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/CVS/Root b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/CVS/Root
new file mode 100644
index 0000000..04efa23
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/CVS/Root
@@ -0,0 +1 @@
+:pserver:anonymous@dev.eclipse.org:/cvsroot/tools
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/CVS/Tag b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/CVS/Tag
new file mode 100644
index 0000000..49a449a
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/CVS/Tag
@@ -0,0 +1 @@
+NCDT_7_0_0
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/IBasicBlock.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/IBasicBlock.java
new file mode 100644
index 0000000..406ab84
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/IBasicBlock.java
@@ -0,0 +1,46 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Alena Laskavaia and others.
+ * 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.cfg;
+
+/**
+ * Control flow graph's basic block node - super interface of all nodes.
+ * It has set on incoming nodes and outgoing nodes.
+ * <p/>
+ *
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface IBasicBlock {
+ /**
+ * Incoming nodes - nodes that executed immediately before this one
+ *
+ * @return array of incoming nodes, empty array of none
+ */
+ IBasicBlock[] getIncomingNodes();
+
+ /**
+ * Outgoing nodes - where control would be passed. Can be more than one if
+ * node is condition.
+ *
+ * @return array of outgoing nodes, empty of none
+ */
+ IBasicBlock[] getOutgoingNodes();
+
+ /**
+ * @return size of array of incoming nodes
+ */
+ int getIncomingSize();
+
+ /**
+ * @return size of array of outgoing nodes
+ */
+ int getOutgoingSize();
+}
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/IBranchNode.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/IBranchNode.java
new file mode 100644
index 0000000..77e7fb3
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/IBranchNode.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 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.cfg;
+
+/**
+ * Node that represent empty operator with label, such as case branch or label
+ *
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface IBranchNode extends IBasicBlock, ISingleIncoming,
+ ISingleOutgoing {
+ /**
+ * Then branch of "if" statement
+ */
+ public static String THEN = "then"; //$NON-NLS-1$
+ /**
+ * Else branch of "if" statement
+ */
+ public static String ELSE = "else"; //$NON-NLS-1$
+ /**
+ * Default branch of "switch" statement
+ */
+ public static String DEFAULT = "default"; //$NON-NLS-1$
+
+ /**
+ * @return label of a branch
+ */
+ String getLabel();
+}
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/ICfgData.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/ICfgData.java
new file mode 100644
index 0000000..1e43450
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/ICfgData.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2009,2010 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.cfg;
+
+/**
+ * Interface to access data object that control flow graph block carries,
+ * usually it is an ast node.
+ *
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface ICfgData {
+ /**
+ * @return data object
+ */
+ public abstract Object getData();
+
+ /**
+ * Sets data object for the node
+ *
+ * @param data
+ */
+ public abstract void setData(Object data);
+} \ No newline at end of file
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/IConnectorNode.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/IConnectorNode.java
new file mode 100644
index 0000000..f58fdd1
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/IConnectorNode.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Alena Laskavaia and others.
+ * 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.cfg;
+
+/**
+ * Connector node has multiple incoming branches and single outgoing.
+ * Incoming nodes are usually instance of {@link IJumpNode}
+ *
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface IConnectorNode extends IBasicBlock, ISingleOutgoing {
+ /**
+ * @return true if one of the incoming arcs is backward arc
+ */
+ boolean hasBackwardIncoming();
+}
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/IControlFlowGraph.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/IControlFlowGraph.java
new file mode 100644
index 0000000..a8f9269
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/IControlFlowGraph.java
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 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.cfg;
+
+import java.util.Collection;
+import java.util.Iterator;
+
+/**
+ * Represents control flow graph (CFG) object.
+ * This is "normalized" control flow graph, with typed nodes:
+ * <br>
+ * <li> {@link IStartNode} - start node of the cfg (source)
+ * <li> {@link IExitNode} - exit node of the cfg (sink)
+ * <li> {@link IPlainNode} - has one incoming one outgoing
+ * <li> {@link IDecisionNode} - has one incoming and the only node that can have
+ * multiple outcoming
+ * arcs
+ * <li> {@link IConnectorNode} - the only node that can have multiple incoming
+ * arcs, and one outgoing
+ * <li> {@link IJumpNode} - has one incoming and one outgoing but represent
+ * change of control direction
+ * <li> {@link IBranchNode} - usually node where decision node connect to,
+ * labels represent a way where controls goes to
+ *
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface IControlFlowGraph {
+ /**
+ * @return start node of the graph. CFG only has one start node.
+ */
+ IStartNode getStartNode();
+
+ /**
+ * @return iterator over exit nodes of control flow graph. Exit nodes
+ * include return statement,
+ * and statements with throw and abort/exit functions.
+ */
+ Iterator<IExitNode> getExitNodeIterator();
+
+ /**
+ * @return size of exit nodes list
+ */
+ int getExitNodeSize();
+
+ /**
+ * @return list of roots of dead code sections, they don't have incoming
+ * arcs
+ */
+ Iterator<IBasicBlock> getUnconnectedNodeIterator();
+
+ /**
+ * @return size of unconnected nodes list
+ */
+ int getUnconnectedNodeSize();
+
+ /**
+ * @return collection of all nodes
+ */
+ Collection<IBasicBlock> getNodes();
+}
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/IDecisionNode.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/IDecisionNode.java
new file mode 100644
index 0000000..7f2f561
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/IDecisionNode.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Alena Laskavaia and others.
+ * 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.cfg;
+
+/**
+ *
+ * Interface for decision node. This node represent condition node in the graph,
+ * it has one incoming arc and many outgoing, each of outgoing node should be
+ * IBranchNode
+ *
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface IDecisionNode extends IBasicBlock, ISingleIncoming {
+ /**
+ * Node where branches of decision node merge
+ *
+ * @return the "merge" node
+ */
+ IConnectorNode getMergeNode();
+}
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/IExitNode.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/IExitNode.java
new file mode 100644
index 0000000..71d7e25
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/IExitNode.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 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.cfg;
+
+/**
+ * Exit node of the graph. Usually return from the function, can also be throw
+ * or abort, such at exit(0) call.
+ *
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface IExitNode extends IBasicBlock, ISingleIncoming {
+ /**
+ * @return reference to a start node a graph
+ */
+ IStartNode getStartNode();
+}
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/IJumpNode.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/IJumpNode.java
new file mode 100644
index 0000000..d2e298b
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/IJumpNode.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Alena Laskavaia and others.
+ * 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.cfg;
+
+/**
+ * Node that changes the control of the graph, i.e. passes control to non-next
+ * statement. Can be used to implement gotos, break, continue, end of branches.
+ * Outgoing node is always {@link IConnectorNode}
+ *
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface IJumpNode extends IBasicBlock, ISingleOutgoing {
+ /**
+ * @return true of outgoing arc is backward one, see definition of backward
+ * arc in a "network" graph
+ */
+ boolean isBackwardArc();
+
+ /**
+ * @return reference to a connector node to which this one "jumps" (same as
+ * outgoing node)
+ */
+ IConnectorNode getJumpNode();
+}
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/INodeFactory.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/INodeFactory.java
new file mode 100644
index 0000000..bd10ded
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/INodeFactory.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2010 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.cfg;
+
+/**
+ * Control Flow Graph Node factory
+ *
+ * @noextend This interface is not intended to be extended by clients.
+ */
+public interface INodeFactory {
+ /**
+ * @return new plain node
+ */
+ IPlainNode createPlainNode();
+
+ /**
+ * @return new jump node
+ */
+ IJumpNode createJumpNode();
+
+ /**
+ * @return new decision node
+ */
+ IDecisionNode createDecisionNode();
+
+ /**
+ * @return new connector node
+ */
+ IConnectorNode createConnectorNode();
+
+ /**
+ * @param label
+ * @return new branch node
+ */
+ IBranchNode createBranchNode(String label);
+
+ /**
+ * @return new start node
+ */
+ IStartNode createStartNode();
+
+ /**
+ * @return new exit node
+ */
+ IExitNode createExitNode();
+}
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/IPlainNode.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/IPlainNode.java
new file mode 100644
index 0000000..fac5599
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/IPlainNode.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Alena Laskavaia and others.
+ * 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.cfg;
+
+/**
+ * Has one incoming, one outgoing connection. Usually expression statement or
+ * declaration.
+ *
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface IPlainNode extends IBasicBlock, ISingleOutgoing,
+ ISingleIncoming {
+}
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICodanAstReconciler.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/ISingleIncoming.java
index 17bc8f7..2900ce8 100644
--- a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICodanAstReconciler.java
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/ISingleIncoming.java
@@ -1,22 +1,23 @@
/*******************************************************************************
- * Copyright (c) 2009 Alena Laskavaia
+ * Copyright (c) 2010 Alena Laskavaia and others.
* 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
+ * Alena Laskavaia - initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.codan.core.model;
-
-import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
-import org.eclipse.core.runtime.IProgressMonitor;
+package org.eclipse.cdt.codan.core.model.cfg;
/**
- * @author Alena
+ * Node with one incoming arc
*
+ * @noextend This interface is not intended to be extended by clients.
*/
-public interface ICodanAstReconciler {
- public void reconcileAst(IASTTranslationUnit ast, IProgressMonitor monitor);
-} \ No newline at end of file
+public interface ISingleIncoming {
+ /**
+ * @return single incoming node
+ */
+ IBasicBlock getIncoming();
+}
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICAstChecker.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/ISingleOutgoing.java
index 461c0fa..3427826 100644
--- a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ICAstChecker.java
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/ISingleOutgoing.java
@@ -1,21 +1,23 @@
/*******************************************************************************
- * Copyright (c) 2009 Alena Laskavaia
+ * Copyright (c) 2010 Alena Laskavaia and others.
* 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
+ * Alena Laskavaia - initial API and implementation
*******************************************************************************/
-package org.eclipse.cdt.codan.core.model;
-
-import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
+package org.eclipse.cdt.codan.core.model.cfg;
/**
- * @author Alena
+ * Node with one outgoing arc
*
+ * @noextend This interface is not intended to be extended by clients.
*/
-public interface ICAstChecker extends IChecker {
- void processAst(IASTTranslationUnit ast);
+public interface ISingleOutgoing {
+ /**
+ * @return outgoing node
+ */
+ IBasicBlock getOutgoing();
}
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/IStartNode.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/IStartNode.java
new file mode 100644
index 0000000..7c20c3e
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/cfg/IStartNode.java
@@ -0,0 +1,22 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Alena Laskavaia and others.
+ * 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.cfg;
+
+/**
+ * Start node of the control flow graph. Each graph has only one start node. It
+ * has no incoming arcs and one outgoing arc. It also contains iterator for
+ * function exit nodes.
+ *
+ * @noextend This interface is not intended to be extended by clients.
+ * @noimplement This interface is not intended to be implemented by clients.
+ */
+public interface IStartNode extends IBasicBlock, ISingleOutgoing {
+}