public class ConstructorTransformer extends AbstractTransformer implements ConstructorHandler, ClassHandler, CrossAnalysisHandler, MethodDeclarationHandler
When the type analyzer detects constructor declarations or a constructor invocations, it calls back methods in this class to further handle them. This transformer simply adds an extra method call to certain constructor invocations to modify the checkpoint objects of the newly created objects.
Normally, when a new object is created as an instance of a refactored class, its checkpoint object is default to an empty checkpoint object. The checkpoint object then monitors the newly created object only. When the extra call is placed on the newly created object, its checkpoint object is set to be the same as the object that issues the call.
Red (tfeng) |
Red (tfeng) |
Modifier and Type | Field and Description |
---|---|
static boolean |
HANDLE_SPECIAL_TYPE_MAPPINGS
Whether to map special types to new types.
|
static java.util.Hashtable<java.lang.String,java.lang.String> |
SPECIAL_TYPE_MAPPING
Mapping from names of special types to the names of types used to
substitute them.
|
ASSIGN_PREFIX, BACKUP_PREFIX, CHECKPOINT_NAME, CHECKPOINT_RECORD_NAME, GET_CHECKPOINT_NAME, SET_CHECKPOINT_NAME
Constructor and Description |
---|
ConstructorTransformer() |
Modifier and Type | Method and Description |
---|---|
void |
enter(org.eclipse.jdt.core.dom.AnonymousClassDeclaration node,
TypeAnalyzerState state)
Enter an anonymous class declaration.
|
void |
enter(org.eclipse.jdt.core.dom.FieldDeclaration node,
TypeAnalyzerState state)
Enter a field declaration.
|
void |
enter(org.eclipse.jdt.core.dom.MethodDeclaration node,
TypeAnalyzerState state)
Enter a method declaration.
|
void |
enter(org.eclipse.jdt.core.dom.TypeDeclaration node,
TypeAnalyzerState state)
Enter a type declaration.
|
void |
exit(org.eclipse.jdt.core.dom.AnonymousClassDeclaration node,
TypeAnalyzerState state)
Exit an anonymous class declaration.
|
void |
exit(org.eclipse.jdt.core.dom.FieldDeclaration node,
TypeAnalyzerState state)
Exit a field declaration.
|
void |
exit(org.eclipse.jdt.core.dom.MethodDeclaration node,
TypeAnalyzerState state)
Exit a method declaration.
|
void |
exit(org.eclipse.jdt.core.dom.TypeDeclaration node,
TypeAnalyzerState state)
Exit a type declaration.
|
void |
handle(org.eclipse.jdt.core.dom.ClassInstanceCreation node,
TypeAnalyzerState state)
Handle a class instance creation.
|
void |
handle(org.eclipse.jdt.core.dom.MethodDeclaration node,
TypeAnalyzerState state)
Handle a method declaration.
|
void |
handle(org.eclipse.jdt.core.dom.SuperConstructorInvocation node,
TypeAnalyzerState state)
Handle a super constructor invocation.
|
void |
handle(TypeAnalyzerState state)
Fix the refactoring result when the set of cross-analyzed types
changes.
|
_getAssignMethodName, _getBackupMethodName, addToLists, createName, createType, getClassName, getClassName, hasMethod, hasMethod, indexOf, isFieldDuplicated, lastIndexOf, removeNode, replaceNode
public static final boolean HANDLE_SPECIAL_TYPE_MAPPINGS
SPECIAL_TYPE_MAPPING
,
Constant Field Valuespublic static final java.util.Hashtable<java.lang.String,java.lang.String> SPECIAL_TYPE_MAPPING
public void enter(org.eclipse.jdt.core.dom.AnonymousClassDeclaration node, TypeAnalyzerState state)
enter
in interface ClassHandler
node
- The AST node of the anonymous class declaration.state
- The current state of the type analyzer.public void enter(org.eclipse.jdt.core.dom.FieldDeclaration node, TypeAnalyzerState state)
enter
in interface ConstructorHandler
node
- The AST node of the field declaration.state
- The current state of the type analyzer.public void enter(org.eclipse.jdt.core.dom.MethodDeclaration node, TypeAnalyzerState state)
enter
in interface MethodDeclarationHandler
node
- The AST node of the method declaration.state
- The current state of the type analyzer.public void enter(org.eclipse.jdt.core.dom.TypeDeclaration node, TypeAnalyzerState state)
enter
in interface ClassHandler
node
- The AST node of the type declaration.state
- The current state of the type analyzer.public void exit(org.eclipse.jdt.core.dom.AnonymousClassDeclaration node, TypeAnalyzerState state)
exit
in interface ClassHandler
node
- The AST node of the anonymous class declaration.state
- The current state of the type analyzer.public void exit(org.eclipse.jdt.core.dom.FieldDeclaration node, TypeAnalyzerState state)
exit
in interface ConstructorHandler
node
- The AST node of the field declaration.state
- The current state of the type analyzer.public void exit(org.eclipse.jdt.core.dom.MethodDeclaration node, TypeAnalyzerState state)
exit
in interface MethodDeclarationHandler
node
- The AST node of the method declaration.state
- The current state of the type analyzer.public void exit(org.eclipse.jdt.core.dom.TypeDeclaration node, TypeAnalyzerState state)
exit
in interface ClassHandler
node
- The AST node of the type declaration.state
- The current state of the type analyzer.public void handle(org.eclipse.jdt.core.dom.ClassInstanceCreation node, TypeAnalyzerState state)
handle
in interface ConstructorHandler
node
- The AST node of the class instance creation.state
- The current state of the type analyzer.public void handle(org.eclipse.jdt.core.dom.MethodDeclaration node, TypeAnalyzerState state)
handle
in interface ConstructorHandler
node
- The AST node of the method declaration.state
- The current state of the type analyzer.public void handle(org.eclipse.jdt.core.dom.SuperConstructorInvocation node, TypeAnalyzerState state)
handle
in interface ConstructorHandler
node
- The AST node of the super constructor invocation.state
- The current state of the type analyzer.public void handle(TypeAnalyzerState state)
The set of cross-analyzed types defines the growing set of types that are analyzed in a run. Special care is taken for cross-analyzed types because they are monitored by checkpoint objects, and checkpoint-related extra methods are added to them. Unfortunately, it is not possible to know all the cross-analyzed types at the beginning. It is then necessary to fix the refactoring result when more cross-analyzed types are discovered later.
handle
in interface CrossAnalysisHandler
state
- The current state of the type analyzer.TypeAnalyzerState.getCrossAnalyzedTypes()