Package de.hsh.graja.modules.junit.api
Class ASTPos
java.lang.Object
de.hsh.graja.modules.junit.api.ASTPos
This class represents the source code position of a node in an abstract syntax tree (AST).
It can be used to throw a
It can be used to throw a
PositionAssertionError.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe type of node in an abstract syntax tree. -
Method Summary
Modifier and TypeMethodDescriptiongetName()getScope()getType()static ASTPosstatic ASTPosstatic ASTPosofConstructor(Class<?> submission, Class<?>... params) static ASTPosofConstructor(Class<?> submission, Object... params) static ASTPosofConstructor(String submission, String... params) static ASTPosofEqualsMethod(Class<?> submission) Declares the equals methodstatic ASTPosDeclares a field by name and field typestatic ASTPosDeclares a field by name, leaving field type unspecifiedstatic ASTPosDeclares a field by name and field typestatic ASTPosDeclares a field by name leaving the field type unspecifiedstatic ASTPosDeclares a field by name, leaving field type unspecifiedstatic ASTPosDeclares a field by name and field typestatic ASTPosofFullyQualifiedClass(String fqnSubmission) static ASTPosofFullyQualifiedMethod(String fqnSubmission, Class<?> returnType, String methodName, Object... params) Declares a method by name and leaves parameters and returntype undeclared.static ASTPosofFullyQualifiedMethod(String fqnSubmission, String methodName) Declares a method by name and leaves parameters and returntype undeclared.static ASTPosofHashCodeMethod(Class<?> submission) Declares the equals methodstatic ASTPosofMainMethod(Class<?> submission) Declares the main methodstatic ASTPosDeclares a method by name, return type and parameter types.static ASTPosDeclares a method by name, return type and parameter types.static ASTPosDeclares a method by name and leaves parameters and returntype undeclared.static ASTPosDeclares a method by name and leaves parameters and returntype undeclared.static ASTPosDeclares a method by name, return type and parameter types.static ASTPosofToStringMethod(Class<?> submission) Declares the toString methodstatic ASTPosofVariable(String submission, String variableName) Declares a variable by name, leaving variable type unspecifiedstatic ASTPosofVariable(String submission, String variableType, String variableName) Declares a variable by name and typevoidvoid
-
Method Details
-
getScope
-
getName
-
getSubmission
-
getType
-
getParams
-
setType
-
setParams
-
ofClass
- Parameters:
submission- Compilation unit class name's "simple name" (this is the name of the submitted file - .java stripped of). This one also defines the name of the class, so it is assumed that the class is inside a compilation unit of the same name as the class.
-
ofFullyQualifiedClass
- Parameters:
submission- Compilation unit class name's "simple name" (this is the name of the submitted file - .java stripped of). This one also defines the name of the class, so it is assumed that the class is inside a compilation unit of the same name as the class.
-
ofClass
- Parameters:
submission- Compilation unit class name (this is the name of the submitted file - .java stripped of). This one also defines the name of the class, so it is assumed that the class is inside a compilation unit of the same name as the class.
-
ofConstructor
- Parameters:
submission- Compilation unit class name (this is the name of the submitted file - .java stripped of). This one also defines the name of the class of which a constructor is declared. It is assumed that the class is inside a compilation unit of the same name as the class. This parameter denotes the "simple name" of the class.params-- Returns:
-
ofConstructor
- Parameters:
submission- Compilation unit class name (this is the name of the submitted file - .java stripped of). This one also defines the name of the class of which a constructor is declared.params-- Returns:
-
ofConstructor
- Parameters:
submission- Compilation unit class name (this is the name of the submitted file - .java stripped of). This one also defines the name of the class of which a constructor is declared.params-- Returns:
-
ofMethod
Declares a method by name and leaves parameters and returntype undeclared.- Parameters:
submission- Compilation unit class name (this is the name of the submitted file - .java stripped of) It is assumed that the class is inside a compilation unit of the same name as the class. This parameter denotes the "simple name" of the class.methodName-- Returns:
-
ofFullyQualifiedMethod
Declares a method by name and leaves parameters and returntype undeclared.- Parameters:
submission- Compilation unit class name (this is the name of the submitted file - .java stripped of) It is assumed that the class is inside a compilation unit of the same name as the class. This parameter denotes the "simple name" of the class.methodName-- Returns:
-
ofFullyQualifiedMethod
public static ASTPos ofFullyQualifiedMethod(String fqnSubmission, Class<?> returnType, String methodName, Object... params) Declares a method by name and leaves parameters and returntype undeclared.- Parameters:
submission- Compilation unit class name (this is the name of the submitted file - .java stripped of) It is assumed that the class is inside a compilation unit of the same name as the class. This parameter denotes the "simple name" of the class.methodName-- Returns:
-
ofMethod
Declares a method by name and leaves parameters and returntype undeclared.- Parameters:
submission- Compilation unit class name (this is the name of the submitted file - .java stripped of)methodName-- Returns:
-
ofMainMethod
Declares the main method- Parameters:
submission- Compilation unit class name (this is the name of the submitted file - .java stripped of)- Returns:
-
ofToStringMethod
Declares the toString method- Parameters:
submission- Compilation unit class name (this is the name of the submitted file - .java stripped of)- Returns:
-
ofHashCodeMethod
Declares the equals method- Parameters:
submission- Compilation unit class name (this is the name of the submitted file - .java stripped of)- Returns:
-
ofEqualsMethod
Declares the equals method- Parameters:
submission- Compilation unit class name (this is the name of the submitted file - .java stripped of)- Returns:
-
ofMethod
public static ASTPos ofMethod(String submission, String returnType, String methodName, String... params) Declares a method by name, return type and parameter types.- Parameters:
submission- Compilation unit class name (this is the name of the submitted file - .java stripped of) It is assumed that the class is inside a compilation unit of the same name as the class. This parameter denotes the "simple name" of the class.methodName-returnType- if null, the return type matches all found return typesparams- if no parameters are given, the search matches any parameters- Returns:
-
ofMethod
public static ASTPos ofMethod(Class<?> submission, Class<?> returnType, String methodName, Class<?>... params) Declares a method by name, return type and parameter types.- Parameters:
submission- Compilation unit class name (this is the name of the submitted file - .java stripped of) It is assumed that the class is inside a compilation unit of the same name as the class.methodName-returnType- if null, the return type matches all found return typesparams- if no parameters are given, the search matches any parameters- Returns:
-
ofMethod
public static ASTPos ofMethod(Class<?> submission, Class<?> returnType, String methodName, Object... params) Declares a method by name, return type and parameter types.- Parameters:
submission- Compilation unit class name (this is the name of the submitted file - .java stripped of) It is assumed that the class is inside a compilation unit of the same name as the class.methodName-returnType- if null, the return type matches all found return typesparams- if no parameters are given, the search matches any parameters- Returns:
-
ofField
Declares a field by name and field type- Parameters:
submission- Compilation unit class name (this is the name of the submitted file - .java stripped of) It is assumed that the class is inside a compilation unit of the same name as the class. This parameter denotes the "simple name" of the class.fieldName-fieldType- if null, the field type matches all found return types- Returns:
-
ofField
Declares a field by name and field type- Parameters:
submission- Compilation unit class name (this is the name of the submitted file - .java stripped of) It is assumed that the class is inside a compilation unit of the same name as the class.fieldName-fieldType- if null, the field type matches all found return types- Returns:
-
ofField
Declares a field by name and field type- Parameters:
submission- Compilation unit class name (this is the name of the submitted file - .java stripped of) It is assumed that the class defining the type of "submission" is inside a compilation unit of the same name as the class.fieldName-fieldType- if null, the field type matches all found return types- Returns:
-
ofField
Declares a field by name leaving the field type unspecified- Parameters:
submission- Compilation unit class name (this is the name of the submitted file - .java stripped of) It is assumed that the class defining the type of "submission" is inside a compilation unit of the same name as the class.fieldName-- Returns:
-
ofField
Declares a field by name, leaving field type unspecified- Parameters:
submission- Compilation unit class name (this is the name of the submitted file - .java stripped of) It is assumed that the class is inside a compilation unit of the same name as the class. This parameter denotes the "simple name" of the class.fieldName-- Returns:
-
ofField
Declares a field by name, leaving field type unspecified- Parameters:
submission- Compilation unit class name (this is the name of the submitted file - .java stripped of) It is assumed that the class is inside a compilation unit of the same name as the class.fieldName-- Returns:
-
ofVariable
Declares a variable by name and type- Parameters:
submission- Compilation unit class name (this is the name of the submitted file - .java stripped of) It is assumed that the class is inside a compilation unit of the same name as the class. This parameter denotes the "simple name" of the class.variableType- if null, the variable type matches all found variable typesvariableName-- Returns:
-
ofVariable
Declares a variable by name, leaving variable type unspecified- Parameters:
submission- Compilation unit class name (this is the name of the submitted file - .java stripped of) It is assumed that the class is inside a compilation unit of the same name as the class. This parameter denotes the "simple name" of the class.variableName-- Returns:
-