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 { 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 checkers = new ArrayList(); private static CheckersRegisry instance; @@ -50,6 +51,10 @@ public class CheckersRegisry implements Iterable { 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]; @@ -62,6 +67,24 @@ public class CheckersRegisry implements Iterable { } } + /** + * @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 */ @@ -168,8 +191,17 @@ public class CheckersRegisry implements Iterable { } 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); + } }