mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Moved parameter control up
This commit is contained in:
parent
e1dfb2e746
commit
a355f5145a
3 changed files with 27 additions and 26 deletions
|
@ -14,7 +14,6 @@ import java.util.Iterator;
|
||||||
|
|
||||||
import org.eclipse.cdt.codan.core.cxx.model.AbstractAstFunctionChecker;
|
import org.eclipse.cdt.codan.core.cxx.model.AbstractAstFunctionChecker;
|
||||||
import org.eclipse.cdt.codan.core.cxx.model.CxxModelsCache;
|
import org.eclipse.cdt.codan.core.cxx.model.CxxModelsCache;
|
||||||
import org.eclipse.cdt.codan.core.model.ICheckerWithParameters;
|
|
||||||
import org.eclipse.cdt.codan.core.model.IProblem;
|
import org.eclipse.cdt.codan.core.model.IProblem;
|
||||||
import org.eclipse.cdt.codan.core.model.IProblemWorkingCopy;
|
import org.eclipse.cdt.codan.core.model.IProblemWorkingCopy;
|
||||||
import org.eclipse.cdt.codan.core.model.cfg.ICfgData;
|
import org.eclipse.cdt.codan.core.model.cfg.ICfgData;
|
||||||
|
@ -37,8 +36,7 @@ import org.eclipse.cdt.core.dom.ast.c.ICASTSimpleDeclSpecifier;
|
||||||
* <li>Function declared as returning non-void has no return (requires control
|
* <li>Function declared as returning non-void has no return (requires control
|
||||||
* flow graph)
|
* flow graph)
|
||||||
*/
|
*/
|
||||||
public class ReturnChecker extends AbstractAstFunctionChecker implements
|
public class ReturnChecker extends AbstractAstFunctionChecker {
|
||||||
ICheckerWithParameters {
|
|
||||||
private static final String PARAM_IMPLICIT = "implicit"; //$NON-NLS-1$
|
private static final String PARAM_IMPLICIT = "implicit"; //$NON-NLS-1$
|
||||||
public final String RET_NO_VALUE_ID = "org.eclipse.cdt.codan.checkers.noreturn"; //$NON-NLS-1$
|
public final String RET_NO_VALUE_ID = "org.eclipse.cdt.codan.checkers.noreturn"; //$NON-NLS-1$
|
||||||
public final String RET_ERR_VALUE_ID = "org.eclipse.cdt.codan.checkers.errreturnvalue"; //$NON-NLS-1$
|
public final String RET_ERR_VALUE_ID = "org.eclipse.cdt.codan.checkers.errreturnvalue"; //$NON-NLS-1$
|
||||||
|
|
|
@ -11,11 +11,6 @@
|
||||||
package org.eclipse.cdt.codan.core.cxx.model;
|
package org.eclipse.cdt.codan.core.cxx.model;
|
||||||
|
|
||||||
import org.eclipse.cdt.codan.core.model.ICheckerWithParameters;
|
import org.eclipse.cdt.codan.core.model.ICheckerWithParameters;
|
||||||
import org.eclipse.cdt.codan.core.model.IProblemWorkingCopy;
|
|
||||||
import org.eclipse.cdt.codan.core.param.MapParameterInfo;
|
|
||||||
import org.eclipse.cdt.codan.core.param.IProblemParameterInfo;
|
|
||||||
import org.eclipse.cdt.codan.core.param.IProblemParameterInfo.ParameterType;
|
|
||||||
import org.eclipse.cdt.codan.core.param.SingleParameterInfo;
|
|
||||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||||
|
@ -62,22 +57,5 @@ public abstract class AbstractAstFunctionChecker extends
|
||||||
*/
|
*/
|
||||||
protected abstract void processFunction(IASTFunctionDefinition func);
|
protected abstract void processFunction(IASTFunctionDefinition func);
|
||||||
|
|
||||||
public void initParameters(IProblemWorkingCopy problem) {
|
|
||||||
// do nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
public IProblemParameterInfo addParam(IProblemWorkingCopy problem,
|
|
||||||
String key, String label, Object defaultValue) {
|
|
||||||
MapParameterInfo map = (MapParameterInfo) problem.getParameterInfo();
|
|
||||||
if (map == null) {
|
|
||||||
map = new MapParameterInfo();
|
|
||||||
problem.setParameterInfo(map);
|
|
||||||
}
|
|
||||||
SingleParameterInfo info = new SingleParameterInfo(key,
|
|
||||||
label,
|
|
||||||
ParameterType.typeOf(defaultValue));
|
|
||||||
map.setElement(info);
|
|
||||||
problem.setParameter(key, defaultValue);
|
|
||||||
return info;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,8 +13,14 @@ package org.eclipse.cdt.codan.core.cxx.model;
|
||||||
import org.eclipse.cdt.codan.core.CodanCorePlugin;
|
import org.eclipse.cdt.codan.core.CodanCorePlugin;
|
||||||
import org.eclipse.cdt.codan.core.cxx.Activator;
|
import org.eclipse.cdt.codan.core.cxx.Activator;
|
||||||
import org.eclipse.cdt.codan.core.model.AbstractChecker;
|
import org.eclipse.cdt.codan.core.model.AbstractChecker;
|
||||||
|
import org.eclipse.cdt.codan.core.model.ICheckerWithParameters;
|
||||||
import org.eclipse.cdt.codan.core.model.IProblemLocation;
|
import org.eclipse.cdt.codan.core.model.IProblemLocation;
|
||||||
|
import org.eclipse.cdt.codan.core.model.IProblemWorkingCopy;
|
||||||
import org.eclipse.cdt.codan.core.model.IRunnableInEditorChecker;
|
import org.eclipse.cdt.codan.core.model.IRunnableInEditorChecker;
|
||||||
|
import org.eclipse.cdt.codan.core.param.IProblemParameterInfo;
|
||||||
|
import org.eclipse.cdt.codan.core.param.MapParameterInfo;
|
||||||
|
import org.eclipse.cdt.codan.core.param.SingleParameterInfo;
|
||||||
|
import org.eclipse.cdt.codan.core.param.IProblemParameterInfo.ParameterType;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
|
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
import org.eclipse.cdt.core.dom.ast.IASTNode;
|
||||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||||
|
@ -34,7 +40,7 @@ import org.eclipse.core.runtime.Path;
|
||||||
* Clients may extend this class.
|
* Clients may extend this class.
|
||||||
*/
|
*/
|
||||||
public abstract class AbstractIndexAstChecker extends AbstractChecker implements
|
public abstract class AbstractIndexAstChecker extends AbstractChecker implements
|
||||||
ICAstChecker, IRunnableInEditorChecker {
|
ICAstChecker, IRunnableInEditorChecker, ICheckerWithParameters {
|
||||||
private IFile file;
|
private IFile file;
|
||||||
|
|
||||||
protected IFile getFile() {
|
protected IFile getFile() {
|
||||||
|
@ -128,4 +134,23 @@ public abstract class AbstractIndexAstChecker extends AbstractChecker implements
|
||||||
processAst(ast);
|
processAst(ast);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void initParameters(IProblemWorkingCopy problem) {
|
||||||
|
// do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
public IProblemParameterInfo addParam(IProblemWorkingCopy problem,
|
||||||
|
String key, String label, Object defaultValue) {
|
||||||
|
MapParameterInfo map = (MapParameterInfo) problem.getParameterInfo();
|
||||||
|
if (map == null) {
|
||||||
|
map = new MapParameterInfo();
|
||||||
|
problem.setParameterInfo(map);
|
||||||
|
}
|
||||||
|
SingleParameterInfo info = new SingleParameterInfo(key,
|
||||||
|
label,
|
||||||
|
ParameterType.typeOf(defaultValue));
|
||||||
|
map.setElement(info);
|
||||||
|
problem.setParameter(key, defaultValue);
|
||||||
|
return info;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue