mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-23 22:52:11 +02:00
make CIndex checker extened AbtractCheckerWithParamters because it should
This commit is contained in:
parent
d71dfb3b20
commit
353b63daf9
2 changed files with 9 additions and 9 deletions
|
@ -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;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue