Skip to main content
summaryrefslogtreecommitdiffstats
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/src/org/eclipse/cdt/codan/core/model/CheckersRegisry.java
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/src/org/eclipse/cdt/codan/core/model/CheckersRegisry.java')
-rw-r--r--codan/org.eclipse.cdt.codan.core/src/org/eclipse/cdt/codan/core/model/CheckersRegisry.java36
1 files changed, 34 insertions, 2 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) {

Back to the top