summaryrefslogtreecommitdiffstats
path: root/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model
diff options
context:
space:
mode:
authorElliott Baron <ebaron@fedoraproject.org>2009-12-16 16:51:53 -0500
committerElliott Baron <ebaron@fedoraproject.org>2009-12-16 16:51:53 -0500
commitaf92b8417ae76946c7d10772d8848abbe1126209 (patch)
tree4f1f7ab3def1e2e5facd2582645f663aba399fc3 /org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model
parent4baa2f35d979b4e2336431460e313e055661327f (diff)
downloadcodan-af92b8417ae76946c7d10772d8848abbe1126209.tar.gz
codan-af92b8417ae76946c7d10772d8848abbe1126209.tar.xz
codan-af92b8417ae76946c7d10772d8848abbe1126209.zip
Update codan plugins to HEAD.
* org.eclipse.cdt.codan.checkers.ui: Updated. * org.eclipse.cdt.codan.checkers: Updated. * org.eclipse.cdt.codan.core: Updated. * org.eclipse.cdt.codan.ui: Updated.
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/AbstractIndexAstChecker.java14
-rw-r--r--org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CVS/Entries15
-rw-r--r--org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CVS/Template0
-rw-r--r--org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IChecker.java16
-rw-r--r--org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblem.java28
-rw-r--r--org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemCategory.java19
-rw-r--r--org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemElement.java2
-rw-r--r--org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemProfile.java6
-rw-r--r--org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemReporter.java1
-rw-r--r--org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ProblemProfile.java103
10 files changed, 84 insertions, 120 deletions
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
index 2c87b07..d805f2f 100644
--- 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
@@ -85,12 +85,18 @@ public abstract class AbstractIndexAstChecker extends AbstractChecker implements
if (astFile == null) {
astFile = file;
}
- getProblemReporter().reportProblem(
- id,
- new ProblemLocation(astFile, astLocation
- .getStartingLineNumber()), message);
+ 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/CVS/Entries b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CVS/Entries
index 736d312..8635b9d 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,17 +1,16 @@
/AbstractChecker.java/1.4/Sat Aug 22 21:31:29 2009//
-/AbstractIndexAstChecker.java/1.5/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.2/Sat Aug 22 21:31:29 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.3/Sat Aug 22 21:16:48 2009//
-/IProblemCategory.java/1.2/Thu Apr 16 01:46:57 2009//
-/IProblemElement.java/1.1/Thu Apr 16 01:46:57 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.3/Sat May 9 01:54:38 2009//
-/IProblemReporter.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//
-/ProblemProfile.java/1.4/Sat Aug 22 21:16:48 2009//
D
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CVS/Template b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CVS/Template
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CVS/Template
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 4f995db..60f7cb2 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
@@ -12,9 +12,23 @@ 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.
+ */
public interface IChecker {
- public boolean processResource(IResource resource);
+ /**
+ * Main method that checker should implement that actually detects errors
+ * @param resource - resource to run on
+ * @return true if need to traverse children
+ */
+ 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
+ * @param resource
+ * @return
+ */
boolean enabledInContext(IResource resource);
/**
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 52cfff2..bbab313 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
@@ -12,15 +12,38 @@ package org.eclipse.cdt.codan.core.model;
import java.util.Collection;
+/**
+ * Interface representing code analysis problem
+ *
+ */
public interface IProblem extends IProblemElement {
+ /**
+ * Name of the problem - user visible "title", not the message
+ */
String getName();
+ /**
+ * Unique problem id. Should be qualified by plugin name to maintain uniqueness.
+ * @return
+ */
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
+ */
String getMessagePattern();
void setSeverity(CodanSeverity sev);
@@ -31,6 +54,11 @@ public interface IProblem extends IProblemElement {
public void setProperty(Object key, Object value);
+ /**
+ * Get custom property
+ * @param property name
+ * @return property object
+ */
public Object getProperty(Object key);
public Collection<Object> getPropertyKeys();
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 45a62a0..cd3de3a 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
@@ -10,20 +10,37 @@
*******************************************************************************/
package org.eclipse.cdt.codan.core.model;
+/**
+ * Problem category
+ *
+ */
public interface IProblemCategory extends IProblemElement {
+ /**
+ * Category name
+ */
String getName();
+ /**
+ * Unique category id
+ * @return id
+ */
String getId();
- Object[] getChildren();
+ /**
+ * Category children (other categories or problems)
+ * @return
+ */
+ 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
*/
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 b9f7fb8..318f304 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
@@ -11,7 +11,7 @@
package org.eclipse.cdt.codan.core.model;
/**
- * @author Alena
+ * Problem category or problem
*
*/
public interface IProblemElement extends Cloneable {
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 9dc465e..896eb10 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
@@ -11,8 +11,10 @@
package org.eclipse.cdt.codan.core.model;
/**
- * Problem Profile contains tree of categories and problems. Profiles can have
- * different categories and different problems set, problems with the same id
+ * 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()}
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 814cc40..059f155 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
@@ -16,6 +16,7 @@ package org.eclipse.cdt.codan.core.model;
*
*/
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.
diff --git a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ProblemProfile.java b/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ProblemProfile.java
deleted file mode 100644
index ae90e76..0000000
--- a/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ProblemProfile.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 java.util.ArrayList;
-import java.util.Collection;
-
-import org.eclipse.cdt.codan.internal.core.model.CodanProblemCategory;
-
-/**
- * @author Alena
- *
- */
-public class ProblemProfile implements IProblemProfile, Cloneable {
- private IProblemCategory rootCategory = new CodanProblemCategory("root",
- "root");
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.cdt.codan.core.model.IProblemProfile#getProblem(java.lang
- * .String)
- */
- public IProblem findProblem(String id) {
- return getRoot().findProblem(id);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.cdt.codan.core.model.IProblemProfile#getProblems()
- */
- public IProblem[] getProblems() {
- Collection<IProblem> problems = new ArrayList<IProblem>();
- collectProblems(getRoot(), problems);
- return problems.toArray(new IProblem[problems.size()]);
- }
-
- /**
- * @param root
- * @param problems
- */
- protected void collectProblems(IProblemCategory parent,
- Collection<IProblem> problems) {
- Object[] children = parent.getChildren();
- for (Object object : children) {
- if (object instanceof IProblemCategory) {
- IProblemCategory cat = (IProblemCategory) object;
- collectProblems(cat, problems);
- } else if (object instanceof IProblem) {
- problems.add((IProblem) object);
- }
- }
- }
-
- public IProblemCategory getRoot() {
- return rootCategory;
- }
-
- public void addProblem(IProblem p, IProblemCategory cat) {
- if (cat == null)
- cat = getRoot();
- ((CodanProblemCategory) cat).addChild(p);
- }
-
- public IProblemCategory findCategory(String id) {
- return getRoot().findCategory(id);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.lang.Object#clone()
- */
- @Override
- public Object clone() {
- try {
- ProblemProfile clone = (ProblemProfile) super.clone();
- clone.rootCategory = (IProblemCategory) ((CodanProblemCategory) this.rootCategory)
- .clone();
- return clone;
- } catch (CloneNotSupportedException e) {
- return this;
- }
- }
-
- /**
- * @param p
- * @param cat
- */
- public void addCategory(IProblemCategory category, IProblemCategory parent) {
- ((CodanProblemCategory) parent).addChild(category);
- }
-}