public final class Es6TypedToEs6Converter extends java.lang.Object implements NodeTraversal.Callback, HotSwapCompilerPass
Node.getDeclaredTypeExpression()
to JSDocInfo.getType()
type
annotations. Types are marked as inline types.Modifier and Type | Class and Description |
---|---|
private static class |
Es6TypedToEs6Converter.Namespace |
private class |
Es6TypedToEs6Converter.ScanNamespaces |
Constructor and Description |
---|
Es6TypedToEs6Converter(AbstractCompiler compiler) |
Modifier and Type | Method and Description |
---|---|
private Node |
convertDeclaredTypeToJSDoc(Node type) |
private Node |
convertMemberFunctionToMemberVariable(Node member) |
private Node |
convertNamedType(Node type) |
private Node |
convertWithLocation(Node type) |
private JSTypeExpression |
createIObject(Node indexSignature) |
private Node |
createPropertyDefinition(Node member,
java.lang.String className) |
private static Node |
getQualifiedMemberAccess(AbstractCompiler compiler,
Node member,
Node staticAccess,
Node instanceAccess)
Constructs a Node that represents an access to the given class member, qualified by either the
static or the instance access context, depending on whether the member is static.
|
void |
hotSwapScript(Node scriptRoot,
Node originalRoot)
Process the JS with root node root.
|
private void |
maybeAddGenerics(Node n,
Node jsDocNode) |
private void |
maybeAddVisibility(Node n) |
private Node |
maybeCreateAnyType(Node n,
Node type) |
private void |
maybeCreateQualifiedDeclaration(Node n,
Node parent) |
private Node |
maybeGetQualifiedNameNode(Node oldNameNode) |
private java.lang.String |
maybePrependCurrNamespace(java.lang.String oldName) |
private Node |
maybeProcessOptionalParameter(Node n,
Node type) |
private Node |
maybeProcessOptionalProperty(Node n,
Node type) |
private void |
maybeVisitColonType(Node n,
Node jsDocNode) |
private void |
popNamespace(Node n,
Node parent) |
private void |
popOverloads() |
void |
process(Node externs,
Node scriptRoot)
Process the JS with root node root.
|
private void |
pushOverloads() |
private void |
replaceWithNodes(Node n,
java.lang.Iterable<Node> replacements) |
boolean |
shouldTraverse(NodeTraversal t,
Node n,
Node parent)
Visits a node in pre order (before visiting its children) and decides
whether this node's children should be traversed.
|
void |
visit(NodeTraversal t,
Node n,
Node parent)
Visits a node in postorder (after its children have been visited).
|
private void |
visitAmbientDeclaration(Node n,
Node parent) |
private void |
visitClass(Node n,
Node parent) |
private void |
visitEnum(Node n,
Node parent) |
private void |
visitExport(Node n,
Node parent) |
private void |
visitFunction(Node n,
Node parent) |
private void |
visitInterface(Node n,
Node parent) |
private void |
visitNamespaceDeclaration(Node n,
Node parent) |
private void |
visitTypeAlias(NodeTraversal t,
Node n,
Node parent) |
private void |
visitVarInsideNamespace(Node n,
Node parent) |
static final DiagnosticType CANNOT_CONVERT_MEMBER_VARIABLES
static final DiagnosticType CANNOT_CONVERT_BOUNDED_GENERICS
static final DiagnosticType TYPE_ALIAS_ALREADY_DECLARED
static final DiagnosticType TYPE_QUERY_NOT_SUPPORTED
static final DiagnosticType UNSUPPORTED_RECORD_TYPE
static final DiagnosticType COMPUTED_PROP_ACCESS_MODIFIER
static final DiagnosticType NON_AMBIENT_NAMESPACE_NOT_SUPPORTED
static final DiagnosticType CALL_SIGNATURE_NOT_SUPPORTED
static final DiagnosticType OVERLOAD_NOT_SUPPORTED
static final DiagnosticType SPECIALIZED_SIGNATURE_NOT_SUPPORTED
static final DiagnosticType DECLARE_IN_NON_EXTERNS
private final AbstractCompiler compiler
private final java.util.Map<Node,Es6TypedToEs6Converter.Namespace> nodeNamespaceMap
private final java.util.Set<java.lang.String> convertedNamespaces
private Es6TypedToEs6Converter.Namespace currNamespace
private final java.util.Deque<java.util.Map<java.lang.String,Node>> overloadStack
private final java.util.Set<Node> processedOverloads
Es6TypedToEs6Converter(AbstractCompiler compiler)
public void process(Node externs, Node scriptRoot)
CompilerPass
process
in interface CompilerPass
externs
- Top of external JS treescriptRoot
- Top of JS treepublic void hotSwapScript(Node scriptRoot, Node originalRoot)
HotSwapCompilerPass
hotSwapScript
in interface HotSwapCompilerPass
scriptRoot
- Root node corresponding to the file that is modified,
should be of type Token.SCRIPT
.originalRoot
- Root node corresponding to the original version of the
file that is modified. Should be of type token.SCRIPT
.public boolean shouldTraverse(NodeTraversal t, Node n, Node parent)
NodeTraversal.Callback
Visits a node in pre order (before visiting its children) and decides
whether this node's children should be traversed. If children are
traversed, they will be visited by
NodeTraversal.Callback.visit(NodeTraversal, Node, Node)
in postorder.
Implementations can have side effects (e.g. modifying the parse tree).
shouldTraverse
in interface NodeTraversal.Callback
public void visit(NodeTraversal t, Node n, Node parent)
NodeTraversal.Callback
Visits a node in postorder (after its children have been visited).
A node is visited only if all its parents should be traversed
(NodeTraversal.Callback.shouldTraverse(NodeTraversal, Node, Node)
).
Implementations can have side effects (e.g. modifying the parse tree).
visit
in interface NodeTraversal.Callback
private JSTypeExpression createIObject(Node indexSignature)
private Node createPropertyDefinition(Node member, java.lang.String className)
private static Node getQualifiedMemberAccess(AbstractCompiler compiler, Node member, Node staticAccess, Node instanceAccess)
WARNING: member
may be modified/destroyed by this method, do not use it
afterwards.
private void maybeAddVisibility(Node n)
private void visitTypeAlias(NodeTraversal t, Node n, Node parent)
private Node convertMemberFunctionToMemberVariable(Node member)
private void pushOverloads()
private void popOverloads()
private java.lang.String maybePrependCurrNamespace(java.lang.String oldName)