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 enum
The type of node in an abstract syntax tree. -
Method Summary
Modifier and TypeMethodDescriptiongetName()
getScope()
getType()
static ASTPos
static ASTPos
static ASTPos
ofConstructor
(Class<?> submission, Class<?>... params) static ASTPos
ofConstructor
(Class<?> submission, Object... params) static ASTPos
ofConstructor
(String submission, String... params) static ASTPos
ofEqualsMethod
(Class<?> submission) Declares the equals methodstatic ASTPos
Declares a field by name and field typestatic ASTPos
Declares a field by name, leaving field type unspecifiedstatic ASTPos
Declares a field by name and field typestatic ASTPos
Declares a field by name leaving the field type unspecifiedstatic ASTPos
Declares a field by name, leaving field type unspecifiedstatic ASTPos
Declares a field by name and field typestatic ASTPos
ofFullyQualifiedClass
(String fqnSubmission) static ASTPos
ofFullyQualifiedMethod
(String fqnSubmission, Class<?> returnType, String methodName, Object... params) Declares a method by name and leaves parameters and returntype undeclared.static ASTPos
ofFullyQualifiedMethod
(String fqnSubmission, String methodName) Declares a method by name and leaves parameters and returntype undeclared.static ASTPos
ofHashCodeMethod
(Class<?> submission) Declares the equals methodstatic ASTPos
ofMainMethod
(Class<?> submission) Declares the main methodstatic ASTPos
Declares a method by name, return type and parameter types.static ASTPos
Declares a method by name, return type and parameter types.static ASTPos
Declares a method by name and leaves parameters and returntype undeclared.static ASTPos
Declares a method by name and leaves parameters and returntype undeclared.static ASTPos
Declares a method by name, return type and parameter types.static ASTPos
ofToStringMethod
(Class<?> submission) Declares the toString methodstatic ASTPos
ofVariable
(String submission, String variableName) Declares a variable by name, leaving variable type unspecifiedstatic ASTPos
ofVariable
(String submission, String variableType, String variableName) Declares a variable by name and typevoid
void
-
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:
-