public interface ConstructorHandler
TypeAnalyzer
.
Users may register constructor handlers (and other kinds of supported
handlers) to the TypeAnalyzer
used to analyze Java source code.
When the analyzer detects a constructor declaration or a call to a
constructor, it calls back those constructor handlers after proper types are
assigned to all the arguments.
Constructor handlers are allowed to modify the constructor, either by modifying its children in the AST, or by replacing the whole constructor with another valid AST node. This is because the handler is called after the subtree rooted at the constructor is completely visited by the analyzer. However, modifying any node out of this subtree (e.g., changing the parent of this constructor to another one) may cause unexpected effect.
Red (tfeng) |
Red (tfeng) |
Modifier and Type | Method and Description |
---|---|
void |
enter(org.eclipse.jdt.core.dom.FieldDeclaration node,
TypeAnalyzerState state)
Enter a field declaration.
|
void |
exit(org.eclipse.jdt.core.dom.FieldDeclaration node,
TypeAnalyzerState state)
Exit a field declaration.
|
void |
handle(org.eclipse.jdt.core.dom.ClassInstanceCreation node,
TypeAnalyzerState state)
Handle a class instance creation (with the new operator).
|
void |
handle(org.eclipse.jdt.core.dom.MethodDeclaration node,
TypeAnalyzerState state)
Handle a method declaration node that corresponds to a constructor.
|
void |
handle(org.eclipse.jdt.core.dom.SuperConstructorInvocation node,
TypeAnalyzerState state)
Handle a super constructor invocation (with the super
keyword).
|
void enter(org.eclipse.jdt.core.dom.FieldDeclaration node, TypeAnalyzerState state)
node
- The field declaration node.state
- The current state of the type analyzer.void exit(org.eclipse.jdt.core.dom.FieldDeclaration node, TypeAnalyzerState state)
node
- The field declaration node.state
- The current state of the type analyzer.void handle(org.eclipse.jdt.core.dom.ClassInstanceCreation node, TypeAnalyzerState state)
node
- The class instance creation node.state
- The current state of the type analyzer.void handle(org.eclipse.jdt.core.dom.MethodDeclaration node, TypeAnalyzerState state)
MethodDeclaration
as other methods, but its isConstructor
method returns true.node
- The constructor node.state
- The current state of the type analyzer.void handle(org.eclipse.jdt.core.dom.SuperConstructorInvocation node, TypeAnalyzerState state)
node
- The super constructor invocation node.state
- The current state of the type analyzer.