|
TPTP 4.5.0 Platform Project Public API Specification |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.eclipse.tptp.platform.analysis.codereview.cpp.RulesHelper
public class RulesHelper
| Constructor Summary | |
|---|---|
RulesHelper()
|
|
| Method Summary | |
|---|---|
static boolean |
functionTakesVarArgs(org.eclipse.cdt.core.dom.ast.IASTName functionName)
Given a function's IASTName, returns true if the function takes variable arguments |
static org.eclipse.cdt.core.dom.ast.IASTExpression[] |
getArgumentListForFunctionCall(org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression fCall)
Given a function call, returns a string list of parameters being passed to that function |
static org.eclipse.cdt.core.dom.ast.IBinding |
getBindingFromExpression(org.eclipse.cdt.core.dom.ast.IASTExpression expression)
Gets the binding of the variable given in expression |
static org.eclipse.cdt.core.dom.ast.IASTDeclarator |
getDeclaratorOfVariable(CodeReviewResource resource,
org.eclipse.cdt.core.dom.ast.IASTNode expression,
boolean searchOnlyCurrentFunction)
Gets the declarator of the parameter in the given expression. |
static org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier |
getDeclSpecifierOfParentDeclaration(org.eclipse.cdt.core.dom.ast.IASTDeclarator declarator)
This function can be used to get the specifier of a variable given its declarator. |
static org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition |
getDefinitionOfFucntionDeclared(CodeReviewResource resource,
org.eclipse.cdt.core.dom.ast.IBinding classNameBinding,
org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration declaration)
Retrieves a function definition for the given declaration (if the decalaration is that of a function) and the definition can be found. |
static java.lang.String |
getIncludeName(org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement statement)
Get's the name or path being included in the file. |
static java.util.HashMap |
getLocalVisibleDeclarationsMap(CodeReviewResource resource,
org.eclipse.cdt.core.dom.ast.IASTNode childNode,
java.lang.String type)
This function isn't being used by any rules any more. |
static org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier |
getParentClassSpecifier(org.eclipse.cdt.core.dom.ast.IASTNode childNode)
Gets the parent function of the node passed, or null if not found. |
static org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition |
getParentFunctionDefinition(org.eclipse.cdt.core.dom.ast.IASTNode childNode)
Gets the parent function of the node passed, or null if not found. |
static java.util.List |
getVariablesDeclaredInFile(CodeReviewResource resource,
boolean onlyGlobalVars,
boolean includeConst)
Return a String list of variables declared in the file (or just the global variables). |
static boolean |
nameIsTypeClass(CodeReviewResource resource,
org.eclipse.cdt.core.dom.ast.IASTName name)
Method to check whether a name is from a class. |
static boolean |
nameIsTypeStruct(CodeReviewResource resource,
org.eclipse.cdt.core.dom.ast.IASTName name)
Method to check whether a name is from a structure. |
static int |
stringIndexOf(java.lang.String str,
java.lang.String searchFor,
int start)
Alternative to java.lang.String.indexOf(java.lang.String,int) which does a bitwise match and does not support Unicode supplementary characters. |
static boolean |
variableIsGlobal(CodeReviewResource resource,
org.eclipse.cdt.core.dom.ast.IASTName varName)
Checks if the given IdExpression is a global variable. |
static boolean |
variableIsPointer(CodeReviewResource resource,
org.eclipse.cdt.core.dom.ast.IASTNode expression,
boolean searchOnlyCurrentFunction,
boolean assumeThisIfDecNotFound)
This should only be used when the pointer operators cannot be verified directly. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public RulesHelper()
| Method Detail |
|---|
public static org.eclipse.cdt.core.dom.ast.IBinding getBindingFromExpression(org.eclipse.cdt.core.dom.ast.IASTExpression expression)
expression -
public static org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition getParentFunctionDefinition(org.eclipse.cdt.core.dom.ast.IASTNode childNode)
childNode -
public static org.eclipse.cdt.core.dom.ast.IASTCompositeTypeSpecifier getParentClassSpecifier(org.eclipse.cdt.core.dom.ast.IASTNode childNode)
childNode -
public static java.util.HashMap getLocalVisibleDeclarationsMap(CodeReviewResource resource,
org.eclipse.cdt.core.dom.ast.IASTNode childNode,
java.lang.String type)
getDeclaratorOfVariable(CodeReviewResource, IASTNode, boolean) and
getDeclSpecifierOfParentDeclaration(IASTDeclarator)
resource - childNode - type - of variables to find. If this is null, it will include every variable, otherwise only variables of type are included
public static boolean variableIsPointer(CodeReviewResource resource,
org.eclipse.cdt.core.dom.ast.IASTNode expression,
boolean searchOnlyCurrentFunction,
boolean assumeThisIfDecNotFound)
getDeclaratorOfVariable(CodeReviewResource, IASTNode, boolean)
Identifies if the parameter in the given expression is a pointer.
RulesHelper.variableIsPointer(resource, variable, false, true)) - returns true if var IS pointer or UnknownThis works for the following node types: IASTUnaryExpression, IASTArraySubscriptExpression, IASTIdExpression, IASTFieldReference, IASTName
resource - expression - one of: IASTUnaryExpression, IASTIdExpression, IASTFieldReference, IASTNamesearchOnlyCurrentFunction - if true, searches only in the context of the current function, if false tries to find declaration from the class it belongs toassumeThisIfDecNotFound - returns this value if the declaration of the expression was not found, ie assumes this result if result is actually unkown
public static org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier getDeclSpecifierOfParentDeclaration(org.eclipse.cdt.core.dom.ast.IASTDeclarator declarator)
getDeclaratorOfVariable(CodeReviewResource, IASTNode, boolean)
can be used directly. Returns null if the specifier is not found.
This method works for declarators of variables and functions
declarator - of variable or function
getDeclaratorOfVariable(CodeReviewResource, IASTNode, boolean)
public static org.eclipse.cdt.core.dom.ast.IASTDeclarator getDeclaratorOfVariable(CodeReviewResource resource,
org.eclipse.cdt.core.dom.ast.IASTNode expression,
boolean searchOnlyCurrentFunction)
resource - expression, - one of: IASTArraySubscriptExpression, IASTIdExpression, IASTFieldReference, IASTNamesearchOnlyCurrentFunction - if true, searches only in the context of the current function, setting to true is only sometimes necessary
variableIsPointer(CodeReviewResource, IASTNode, boolean, boolean)
public static boolean nameIsTypeClass(CodeReviewResource resource,
org.eclipse.cdt.core.dom.ast.IASTName name)
resource - name - the IASTName from the variable to check
public static boolean nameIsTypeStruct(CodeReviewResource resource,
org.eclipse.cdt.core.dom.ast.IASTName name)
resource - name - the IASTName from the variable to check
public static boolean functionTakesVarArgs(org.eclipse.cdt.core.dom.ast.IASTName functionName)
functionName - IASTName of a function
#getMemberFunctionName(IASTDeclaration)public static org.eclipse.cdt.core.dom.ast.IASTExpression[] getArgumentListForFunctionCall(org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression fCall)
fCall -
public static org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition getDefinitionOfFucntionDeclared(CodeReviewResource resource,
org.eclipse.cdt.core.dom.ast.IBinding classNameBinding,
org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration declaration)
resource - classNameBinding - declaration -
public static java.lang.String getIncludeName(org.eclipse.cdt.core.dom.ast.IASTPreprocessorIncludeStatement statement)
statement - IASTPreprocessorIncludeStatement
public static boolean variableIsGlobal(CodeReviewResource resource,
org.eclipse.cdt.core.dom.ast.IASTName varName)
#getVariablesDeclared(CodeReviewResource, boolean, boolean)
in order to only report on variables that are in the current file, like this:
if(globalVarsDeclaredInFile.contains(idExpName) && RulesHelper.variableIsGlobal(resource, idExp)){ //result }
resource - varName - varName to verify if global
public static java.util.List getVariablesDeclaredInFile(CodeReviewResource resource,
boolean onlyGlobalVars,
boolean includeConst)
resource - onlyGlobalVars - if true, includes only global variables, not all variablesincludeConst - if false, will ignore constant fields
public static int stringIndexOf(java.lang.String str,
java.lang.String searchFor,
int start)
str - String to searchsearchFor - String to search for
|
TPTP 4.5.0 Platform Project Public API Specification |
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||