use of com.google.javascript.jscomp.Es6RewriteClass.ClassDeclarationMetadata in project closure-compiler by google.
the class Es6TypedToEs6Converter method visitClass.
private void visitClass(NodeTraversal t, Node n, Node parent) {
maybeAddGenerics(n, n);
JSDocInfoBuilder doc = JSDocInfoBuilder.maybeCopyFrom(n.getJSDocInfo());
Node interfaces = (Node) n.getProp(Node.IMPLEMENTS);
if (interfaces != null) {
for (Node child : interfaces.children()) {
Node type = convertWithLocation(child);
doc.recordImplementedInterface(new JSTypeExpression(type, n.getSourceFileName()));
}
n.removeProp(Node.IMPLEMENTS);
}
Node superType = n.getSecondChild();
Node newSuperType = maybeGetQualifiedNameNode(superType);
if (newSuperType != superType) {
n.replaceChild(superType, newSuperType);
}
Node classMembers = n.getLastChild();
ClassDeclarationMetadata metadata = ClassDeclarationMetadata.create(n, parent);
for (Node member : classMembers.children()) {
if (member.isCallSignature()) {
compiler.report(JSError.make(n, CALL_SIGNATURE_NOT_SUPPORTED));
continue;
}
if (member.isIndexSignature()) {
doc.recordImplementedInterface(createIObject(t, member));
continue;
}
// Functions are handled by the regular Es6ToEs3Converter
if (!member.isMemberVariableDef() && !member.getBooleanProp(Node.COMPUTED_PROP_VARIABLE)) {
maybeAddVisibility(member);
continue;
}
if (metadata == null) {
compiler.report(JSError.make(n, CANNOT_CONVERT_MEMBER_VARIABLES));
return;
}
metadata.insertNodeAndAdvance(createPropertyDefinition(t, member, metadata.fullClassName));
t.reportCodeChange();
}
n.setJSDocInfo(doc.build());
maybeCreateQualifiedDeclaration(t, n, parent);
}
Aggregations