diff --git a/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/model/AbstractCIndexChecker.java b/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/model/AbstractCIndexChecker.java index 557d0473f06..a433ef8671c 100644 --- a/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/model/AbstractCIndexChecker.java +++ b/codan/org.eclipse.cdt.codan.core.cxx/src/org/eclipse/cdt/codan/core/cxx/model/AbstractCIndexChecker.java @@ -11,7 +11,7 @@ package org.eclipse.cdt.codan.core.cxx.model; import org.eclipse.cdt.codan.core.CodanCorePlugin; -import org.eclipse.cdt.codan.core.model.AbstractChecker; +import org.eclipse.cdt.codan.core.model.AbstractCheckerWithProblemPreferences; import org.eclipse.cdt.core.CCorePlugin; import org.eclipse.cdt.core.index.IIndex; import org.eclipse.cdt.core.model.CoreModel; @@ -26,7 +26,7 @@ import org.eclipse.core.runtime.CoreException; * * Clients may extend this class. */ -public abstract class AbstractCIndexChecker extends AbstractChecker implements ICIndexChecker { +public abstract class AbstractCIndexChecker extends AbstractCheckerWithProblemPreferences implements ICIndexChecker { private IFile file; protected IIndex index; diff --git a/codan/org.eclipse.cdt.codan.examples/src/org/eclipse/cdt/codan/examples/checkers/NamingConventionFunctionIIndexChecker.java b/codan/org.eclipse.cdt.codan.examples/src/org/eclipse/cdt/codan/examples/checkers/NamingConventionFunctionIIndexChecker.java index e7d1172e5b4..f99d01a1013 100644 --- a/codan/org.eclipse.cdt.codan.examples/src/org/eclipse/cdt/codan/examples/checkers/NamingConventionFunctionIIndexChecker.java +++ b/codan/org.eclipse.cdt.codan.examples/src/org/eclipse/cdt/codan/examples/checkers/NamingConventionFunctionIIndexChecker.java @@ -21,9 +21,10 @@ import org.eclipse.cdt.codan.core.param.IProblemPreference; import org.eclipse.cdt.core.model.ICElement; import org.eclipse.cdt.core.model.ICElementVisitor; import org.eclipse.cdt.core.model.ITranslationUnit; -import org.eclipse.core.runtime.CoreException; /** + * Example demonstrate how to write checked using "C Model" + * * @author Alena * */ @@ -44,16 +45,15 @@ public class NamingConventionFunctionIIndexChecker extends final IProblem pt = getProblemById(ER_ID, getFile()); try { unit.accept(new ICElementVisitor() { - public boolean visit(ICElement element) throws CoreException { + public boolean visit(ICElement element) { if (element.getElementType() == ICElement.C_FUNCTION) { String parameter = (String) pt.getPreference() .getValue(); Pattern pattern = Pattern.compile(parameter); String name = element.getElementName(); if (!pattern.matcher(name).find()) { - reportProblem(ER_ID, getFile(), 1, // TODO: line - // number - name, parameter); + // TODO: line number + reportProblem(ER_ID, getFile(), 1, name, parameter); } return false; } @@ -73,10 +73,10 @@ public class NamingConventionFunctionIIndexChecker extends * (org.eclipse.cdt.codan.core.model.IProblemWorkingCopy) */ public void initPreferences(IProblemWorkingCopy problem) { + super.initPreferences(problem); IProblemPreference info = new BasicProblemPreference(PARAM_KEY, "Name Pattern"); - info.setValue(DEFAULT_PATTERN); - problem.setPreference(info); + addPreference(problem, info, DEFAULT_PATTERN); } @Override