mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 10:16:03 +02:00
- fixed categories support
This commit is contained in:
parent
a2e8d0f91a
commit
40a7d9c364
4 changed files with 45 additions and 3 deletions
|
@ -32,6 +32,7 @@ public class CheckersRegisry implements Iterable<IChecker> {
|
||||||
private static final String EXTENSION_POINT_NAME = "checkers";
|
private static final String EXTENSION_POINT_NAME = "checkers";
|
||||||
private static final String CHECKER_ELEMENT = "checker";
|
private static final String CHECKER_ELEMENT = "checker";
|
||||||
private static final String PROBLEM_ELEMENT = "problem";
|
private static final String PROBLEM_ELEMENT = "problem";
|
||||||
|
private static final String CATEGORY_ELEMENT = "category";
|
||||||
private static final Object DEFAULT = "DEFAULT";
|
private static final Object DEFAULT = "DEFAULT";
|
||||||
private Collection<IChecker> checkers = new ArrayList<IChecker>();
|
private Collection<IChecker> checkers = new ArrayList<IChecker>();
|
||||||
private static CheckersRegisry instance;
|
private static CheckersRegisry instance;
|
||||||
|
@ -50,6 +51,10 @@ public class CheckersRegisry implements Iterable<IChecker> {
|
||||||
return;
|
return;
|
||||||
IConfigurationElement[] elements = ep.getConfigurationElements();
|
IConfigurationElement[] elements = ep.getConfigurationElements();
|
||||||
// process categories
|
// process categories
|
||||||
|
for (int i = 0; i < elements.length; i++) {
|
||||||
|
IConfigurationElement configurationElement = elements[i];
|
||||||
|
processCategories(configurationElement);
|
||||||
|
}
|
||||||
// process shared problems
|
// process shared problems
|
||||||
for (int i = 0; i < elements.length; i++) {
|
for (int i = 0; i < elements.length; i++) {
|
||||||
IConfigurationElement configurationElement = elements[i];
|
IConfigurationElement configurationElement = elements[i];
|
||||||
|
@ -62,6 +67,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
|
* @param configurationElement
|
||||||
*/
|
*/
|
||||||
|
@ -168,8 +191,17 @@ public class CheckersRegisry implements Iterable<IChecker> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addProblem(IProblem p, String category) {
|
public void addProblem(IProblem p, String category) {
|
||||||
((ProblemProfile) getDefaultProfile()).addProblem(p,
|
IProblemCategory cat = getDefaultProfile().findCategory(category);
|
||||||
getDefaultProfile().getRoot());
|
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) {
|
public void addRefProblem(IChecker c, IProblem p) {
|
||||||
|
|
|
@ -40,7 +40,7 @@ public class CodanProblemCategory implements IProblemCategory, Cloneable {
|
||||||
return list.toArray();
|
return list.toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addChild(IProblem p) {
|
public void addChild(IProblemElement p) {
|
||||||
list.add(p);
|
list.add(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,5 +19,7 @@ public interface IProblemProfile extends IProblemElement {
|
||||||
|
|
||||||
IProblem findProblem(String id);
|
IProblem findProblem(String id);
|
||||||
|
|
||||||
|
IProblemCategory findCategory(String id);
|
||||||
|
|
||||||
IProblem[] getProblems();
|
IProblem[] getProblems();
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,4 +98,12 @@ public class ProblemProfile implements IProblemProfile, Cloneable {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param p
|
||||||
|
* @param cat
|
||||||
|
*/
|
||||||
|
public void addCategory(IProblemCategory category, IProblemCategory parent) {
|
||||||
|
((CodanProblemCategory) parent).addChild(category);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue