return JavascriptKeywords.CONSTRUCTOR + typeName.substring(pos);
}
@SuppressWarnings("unused")
private boolean generareEnum(WriterVisitor<JS> visitor, ClassTree tree, GenerationContext<JS> context, List<JS> stmts) {
Element type = TreeUtils.elementFromDeclaration(tree);
if (type.getKind() != ElementKind.ENUM) {
return false;
}
JavaScriptBuilder<JS> js = context.js();
// add all anum entries
List<JS> enumEntries = new ArrayList<JS>();
for (Element member : ElementUtils.getAllFieldsIn((TypeElement) type)) {
if (member.getKind() == ElementKind.ENUM_CONSTANT) {
enumEntries.add(js.string(member.getSimpleName().toString()));
}
}
JS enumConstructor = js.functionCall(js.property(js.name(GeneratorConstants.STJS), "enumeration"), enumEntries);
String typeName = context.getNames().getTypeName(context, type);
if (typeName.contains(".")) {
// inner class or namespace
boolean innerClass = type.getEnclosingElement().getKind() != ElementKind.PACKAGE;
String leftSide = innerClass ? replaceFullNameWithConstructor(typeName) : typeName;
stmts.add(js.expressionStatement(js.assignment(AssignOperator.ASSIGN, js.name(leftSide), enumConstructor)));
} else {
// regular class