Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlena Laskavaia2009-04-19 03:01:40 +0000
committerAlena Laskavaia2009-04-19 03:01:40 +0000
commit40a7d9c364bfec6d62c3a2435a6502c6986b835e (patch)
treefdcf74f9b386489b7aa43012b27a30db69a840a0 /codan/org.eclipse.cdt.codan.core
parenta2e8d0f91a532a14e9769df1ab183e948e5f8373 (diff)
downloadorg.eclipse.cdt-40a7d9c364bfec6d62c3a2435a6502c6986b835e.tar.gz
org.eclipse.cdt-40a7d9c364bfec6d62c3a2435a6502c6986b835e.tar.xz
org.eclipse.cdt-40a7d9c364bfec6d62c3a2435a6502c6986b835e.zip
- fixed categories support
Diffstat (limited to 'codan/org.eclipse.cdt.codan.core')
-rw-r--r--codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CheckersRegisry.java36
-rw-r--r--codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CodanProblemCategory.java2
-rw-r--r--codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemProfile.java2
-rw-r--r--codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ProblemProfile.java8
4 files changed, 45 insertions, 3 deletions
diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CheckersRegisry.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CheckersRegisry.java
index 69b01d34bfc..e2370c9d86c 100644
--- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CheckersRegisry.java
+++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CheckersRegisry.java
@@ -32,6 +32,7 @@ public class CheckersRegisry implements Iterable<IChecker> {
private static final String EXTENSION_POINT_NAME = "checkers";
private static final String CHECKER_ELEMENT = "checker";
private static final String PROBLEM_ELEMENT = "problem";
+ private static final String CATEGORY_ELEMENT = "category";
private static final Object DEFAULT = "DEFAULT";
private Collection<IChecker> checkers = new ArrayList<IChecker>();
private static CheckersRegisry instance;
@@ -50,6 +51,10 @@ public class CheckersRegisry implements Iterable<IChecker> {
return;
IConfigurationElement[] elements = ep.getConfigurationElements();
// process categories
+ for (int i = 0; i < elements.length; i++) {
+ IConfigurationElement configurationElement = elements[i];
+ processCategories(configurationElement);
+ }
// process shared problems
for (int i = 0; i < elements.length; i++) {
IConfigurationElement configurationElement = elements[i];
@@ -65,6 +70,24 @@ public class CheckersRegisry implements Iterable<IChecker> {
/**
* @param configurationElement
*/
+ private void processCategories(IConfigurationElement configurationElement) {
+ if (configurationElement.getName().equals(CATEGORY_ELEMENT)) {
+ String id = getAtt(configurationElement, "id");
+ if (id == null)
+ return;
+ String name = getAtt(configurationElement, "name");
+ if (name == null)
+ return;
+ CodanProblemCategory cat = new CodanProblemCategory(id, name);
+ String category = getAtt(configurationElement, "parentCategory",
+ false);
+ addCategory(cat, category);
+ }
+ }
+
+ /**
+ * @param configurationElement
+ */
private void processChecker(IConfigurationElement configurationElement) {
try {
if (configurationElement.getName().equals(CHECKER_ELEMENT)) {
@@ -168,8 +191,17 @@ public class CheckersRegisry implements Iterable<IChecker> {
}
public void addProblem(IProblem p, String category) {
- ((ProblemProfile) getDefaultProfile()).addProblem(p,
- getDefaultProfile().getRoot());
+ IProblemCategory cat = getDefaultProfile().findCategory(category);
+ if (cat == null)
+ cat = getDefaultProfile().getRoot();
+ ((ProblemProfile) getDefaultProfile()).addProblem(p, cat);
+ }
+
+ public void addCategory(IProblemCategory p, String category) {
+ IProblemCategory cat = getDefaultProfile().findCategory(category);
+ if (cat == null)
+ cat = getDefaultProfile().getRoot();
+ ((ProblemProfile) getDefaultProfile()).addCategory(p, cat);
}
public void addRefProblem(IChecker c, IProblem p) {
diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CodanProblemCategory.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CodanProblemCategory.java
index 9e5e0096dc4..efc320476c8 100644
--- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CodanProblemCategory.java
+++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CodanProblemCategory.java
@@ -40,7 +40,7 @@ public class CodanProblemCategory implements IProblemCategory, Cloneable {
return list.toArray();
}
- public void addChild(IProblem p) {
+ public void addChild(IProblemElement p) {
list.add(p);
}
diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemProfile.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemProfile.java
index 86e2880582a..6b4a9c6d875 100644
--- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemProfile.java
+++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/IProblemProfile.java
@@ -19,5 +19,7 @@ public interface IProblemProfile extends IProblemElement {
IProblem findProblem(String id);
+ IProblemCategory findCategory(String id);
+
IProblem[] getProblems();
}
diff --git a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ProblemProfile.java b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ProblemProfile.java
index 5a60d13c990..bd41e356f1b 100644
--- a/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ProblemProfile.java
+++ b/codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/ProblemProfile.java
@@ -98,4 +98,12 @@ public class ProblemProfile implements IProblemProfile, Cloneable {
return this;
}
}
+
+ /**
+ * @param p
+ * @param cat
+ */
+ public void addCategory(IProblemCategory category, IProblemCategory parent) {
+ ((CodanProblemCategory) parent).addChild(category);
+ }
}

Back to the top