Example usage for org.eclipse.jdt.core.dom Initializer getModifiers

List of usage examples for org.eclipse.jdt.core.dom Initializer getModifiers

Introduction

In this page you can find the example usage for org.eclipse.jdt.core.dom Initializer getModifiers.

Prototype

public int getModifiers() 

Source Link

Document

Returns the modifiers explicitly specified on this declaration.

Usage

From source file:ca.mcgill.cs.swevo.jayfx.ASTCrawler.java

License:Open Source License

@Override
public boolean visit(final Initializer pNode) {
    if (this.aCurrMethod != null)
        this.aCurrMethodReminder.push(this.aCurrMethod);

    if (Flags.isStatic(pNode.getModifiers()))
        this.aCurrMethod = (MethodElement) FlyweightElementFactory.getElement(Category.METHOD,
                this.aCurrType.getId() + "." + ASTCrawler.aCLINIT_METHOD_NAME);
    else {//from w  w w.jav  a 2 s.  com
        this.aCurrMethod = (MethodElement) FlyweightElementFactory.getElement(Category.METHOD,
                this.aCurrType.getId() + "." + ASTCrawler.aINIT_METHOD_NAME);
        this.aCurrConstructorList.add(this.aCurrMethod);
    }

    this.aDB.addElement(this.aCurrMethod, pNode.getModifiers());
    this.aDB.addRelation(this.aCurrType, Relation.DECLARES_METHOD, this.aCurrMethod);
    return true;
}

From source file:com.google.devtools.j2cpp.translate.InitializationNormalizer.java

License:Open Source License

/**
 * Add a static or instance init block's statements to the appropriate list
 * of initialization statements.//from w ww .  j  a  v a  2s.  co  m
 */
private void addInitializer(BodyDeclaration member, List<Statement> initStatements,
        List<Statement> classInitStatements) {
    Initializer initializer = (Initializer) member;
    List<Statement> l = Modifier.isStatic(initializer.getModifiers()) ? classInitStatements : initStatements;
    @SuppressWarnings("unchecked")
    List<Statement> stmts = initializer.getBody().statements(); // safe by specification
    l.addAll(stmts);
}

From source file:com.google.devtools.j2objc.ast.DebugASTPrinter.java

License:Apache License

@Override
public boolean visit(Initializer node) {
    printModifiers(node.getModifiers());
    node.getBody().accept(this);
    return false;
}

From source file:com.ibm.wala.cast.java.translator.jdt.JDTJava2CAstTranslator.java

License:Open Source License

/**
 * //ww  w.  j a  v  a  2s . c  om
 * @param n
 * @param bodyDecls
 * @param enumConstants
 * @param typeBinding
 * @param name Used in creating default constructor, and passed into new ClassEntity()
 * @param context
 * @return
 */
private CAstEntity createClassDeclaration(ASTNode n, List/* <BodyDeclaration> */ bodyDecls,
        List/* EnumConstantDeclaration */ enumConstants, ITypeBinding typeBinding, String name, int modifiers,
        boolean isInterface, boolean isAnnotation, WalkContext context) {
    final List<CAstEntity> memberEntities = new ArrayList<CAstEntity>();

    // find and collect all initializers (type Initializer) and field initializers (type VariableDeclarationFragment).
    // instance initializer code will be inserted into each constructors.
    // all static initializer code will be grouped together in its own entity.
    ArrayList<ASTNode> inits = new ArrayList<ASTNode>();
    ArrayList<ASTNode> staticInits = new ArrayList<ASTNode>();

    if (enumConstants != null) {
        for (Object decl : enumConstants) {
            EnumConstantDeclaration ecd = (EnumConstantDeclaration) decl;
            staticInits.add(ecd); // always (implicitly) static,final (actually, no modifiers allowed)
        }
    }

    for (Object decl : bodyDecls) {
        if (decl instanceof Initializer) {
            Initializer initializer = (Initializer) decl;
            boolean isStatic = ((initializer.getModifiers() & Modifier.STATIC) != 0);
            (isStatic ? staticInits : inits).add(initializer);
        } else if (decl instanceof FieldDeclaration) {
            FieldDeclaration fd = (FieldDeclaration) decl;

            for (Object f : fd.fragments()) {
                VariableDeclarationFragment frag = (VariableDeclarationFragment) f;
                if (frag.getInitializer() != null) {
                    boolean isStatic = ((fd.getModifiers() & Modifier.STATIC) != 0);
                    (isStatic ? staticInits : inits).add(frag);
                }
            }
        }
    }

    // process entities. initializers will be folded in here.
    if (enumConstants != null) {
        for (Object decl : enumConstants) {
            memberEntities.add(visit((EnumConstantDeclaration) decl, context));
        }
    }

    for (Object d : bodyDecls) {
        BodyDeclaration decl = (BodyDeclaration) d;
        if (decl instanceof FieldDeclaration) {
            FieldDeclaration fieldDecl = (FieldDeclaration) decl;
            Collection<CAstQualifier> quals = JDT2CAstUtils.mapModifiersToQualifiers(fieldDecl.getModifiers(),
                    false, false);
            for (Object f : fieldDecl.fragments()) {
                VariableDeclarationFragment fieldFrag = (VariableDeclarationFragment) f;
                IVariableBinding fieldBinding = fieldFrag.resolveBinding();
                memberEntities
                        .add(new FieldEntity(fieldFrag.getName().getIdentifier(), fieldBinding.getType(), quals,
                                makePosition(fieldFrag.getStartPosition(),
                                        fieldFrag.getStartPosition() + fieldFrag.getLength()),
                                handleAnnotations(fieldBinding)));
            }
        } else if (decl instanceof Initializer) {
            // Initializers are inserted into constructors when making constructors.
        } else if (decl instanceof MethodDeclaration) {
            MethodDeclaration metDecl = (MethodDeclaration) decl;

            if (typeBinding.isEnum() && metDecl.isConstructor())
                memberEntities.add(createEnumConstructorWithParameters(metDecl.resolveBinding(), metDecl,
                        context, inits, metDecl));
            else {
                memberEntities.add(visit(metDecl, typeBinding, context, inits));

                // /////////////// Java 1.5 "overridden with subtype" thing (covariant return type) ///////////
                Collection<IMethodBinding> overriddenMets = JDT2CAstUtils
                        .getOverriddenMethod(metDecl.resolveBinding());
                if (overriddenMets != null) {
                    for (IMethodBinding overridden : overriddenMets)
                        if (!JDT2CAstUtils.sameErasedSignatureAndReturnType(metDecl.resolveBinding(),
                                overridden))
                            memberEntities.add(makeSyntheticCovariantRedirect(metDecl, metDecl.resolveBinding(),
                                    overridden, context));
                }
            }
        } else if (decl instanceof AbstractTypeDeclaration) {
            memberEntities.add(visit((AbstractTypeDeclaration) decl, context));
        } else if (decl instanceof AnnotationTypeMemberDeclaration) {
            // TODO: need to decide what to do with these
        } else {
            Assertions.UNREACHABLE("BodyDeclaration not Field, Initializer, or Method");
        }
    }

    // add default constructor(s) if necessary
    // most default constructors have no parameters; however, those created by anonymous classes will have parameters
    // (they just call super with those parameters)
    for (Object m : typeBinding.getDeclaredMethods()) {
        IMethodBinding met = (IMethodBinding) m;
        if (met.isDefaultConstructor()) {
            if (typeBinding.isEnum())
                memberEntities.add(createEnumConstructorWithParameters(met, n, context, inits, null));
            else if (met.getParameterTypes().length > 0)
                memberEntities.add(createDefaultConstructorWithParameters(met, n, context, inits));
            else
                memberEntities.add(createDefaultConstructor(name, typeBinding, context, inits, n));
        }
    }

    if (typeBinding.isEnum() && !typeBinding.isAnonymous())
        doEnumHiddenEntities(typeBinding, staticInits, memberEntities, context);

    // collect static inits
    if (!staticInits.isEmpty()) {
        Map<CAstNode, CAstEntity> childEntities = HashMapFactory.make();
        final MethodContext newContext = new MethodContext(context, childEntities);
        // childEntities is the same one as in the ProcedureEntity. later visit(New), etc. may add to this.

        CAstNode[] bodyNodes = new CAstNode[staticInits.size()];
        for (int i = 0; i < staticInits.size(); i++)
            bodyNodes[i] = visitFieldInitNode(staticInits.get(i), newContext);
        CAstNode staticInitAst = makeNode(newContext, fFactory, n, CAstNode.BLOCK_STMT, bodyNodes);
        memberEntities.add(new ProcedureEntity(staticInitAst, typeBinding, childEntities, newContext, null));
    }

    Collection<CAstQualifier> quals = JDT2CAstUtils.mapModifiersToQualifiers(modifiers, isInterface,
            isAnnotation);

    Set<CAstAnnotation> annotations = handleAnnotations(typeBinding);

    return new ClassEntity(typeBinding, name, quals, memberEntities, makePosition(n), annotations);
}

From source file:com.j2swift.ast.DebugASTPrinter.java

License:Apache License

@Override
public boolean visit(Initializer node) {
    printAnnotations(node.getAnnotations());
    printModifiers(node.getModifiers());
    node.getBody().accept(this);
    return false;
}

From source file:edu.uci.ics.sourcerer.extractor.ast.ReferenceExtractorVisitor.java

License:Open Source License

/**
 * This method writes://w w w  .j a v  a 2  s .c o  m
 * <ul>
 *   <li>Initializer entity to <code>IEntityWriter</code>
 *   <ul>
 *     <li>Inside relation to <code>IRelationWriter</code></li>
 *   </ul></li>
 * </ul>
 * 
 * Enum constant fully qualified names (FQNs) adhere to the following format:<br> 
 * parent fqn + . + simple name
 */
@Override
public boolean visit(Initializer node) {
    // Get the fqn
    String fqn = fqnStack.getInitializerFqn();

    // Write the entity
    entityWriter.writeInitializer(fqn, node.getModifiers(),
            MetricsCalculator.computeLinesOfCode(getSource(node)), getLocation(node));

    // Write the inside relation
    relationWriter.writeInside(fqn, fqnStack.getFqn(), getUnknownLocation());

    fqnStack.push(fqn, Entity.INITIALIZER);

    return true;
}

From source file:edu.uci.ics.sourcerer.tools.java.extractor.eclipse.ReferenceExtractorVisitor.java

License:Open Source License

/**
 * This method writes://w  ww  .j  a  va 2  s  .  c o  m
 * <ul>
 *   <li>Initializer entity to <code>IEntityWriter</code>
 *   <ul>
 *     <li>Inside relation to <code>IRelationWriter</code></li>
 *   </ul></li>
 * </ul>
 * 
 * Enum constant fully qualified names (FQNs) adhere to the following format:<br> 
 * parent fqn + . + simple name
 */
@Override
public boolean visit(Initializer node) {
    // Get the fqn
    String fqn = fqnStack.peek(EnclosingDeclaredType.class).getInitializerFqn();

    String parentFqn = fqnStack.getFqn();

    // Visit the children
    fqnStack.push(fqn, Entity.INITIALIZER);
    accept(node.getJavadoc());
    accept(node.modifiers());
    accept(node.getBody());

    // Write the entity
    entityWriter.writeEntity(Entity.INITIALIZER, fqn, node.getModifiers(), createMetrics(node),
            createLocation(node));

    // Write the contains relation
    relationWriter.writeRelation(Relation.CONTAINS, parentFqn, fqn, createUnknownLocation());

    fqnStack.pop();

    return false;
}

From source file:jayfx.ASTCrawler.java

License:Open Source License

public boolean visit(Initializer pNode) {
    if (aCurrMethod != null) {
        aCurrMethodReminder.push(aCurrMethod);
    }/*from   w  w w . j av a 2  s .c  o  m*/

    if (Flags.isStatic(pNode.getModifiers())) {
        aCurrMethod = (MethodElement) FlyweightElementFactory.getElement(ICategories.METHOD,
                aCurrType.getId() + "." + aCLINIT_METHOD_NAME);
    } else {
        aCurrMethod = (MethodElement) FlyweightElementFactory.getElement(ICategories.METHOD,
                aCurrType.getId() + "." + aINIT_METHOD_NAME);
        aCurrConstructorList.add(aCurrMethod);
    }

    aDB.addElement(aCurrMethod, pNode.getModifiers());
    //aDB.addRelation( aCurrType, Relation.DECLARES, aCurrMethod );
    aDB.addRelationAndTranspose(aCurrType, Relation.DECLARES, aCurrMethod);
    return true;
}

From source file:net.sf.j2s.core.astvisitors.ASTScriptVisitor.java

License:Open Source License

public boolean visit(AnonymousClassDeclaration node) {
    ITypeBinding binding = node.resolveBinding();
    ASTTypeVisitor typeVisitor = ((ASTTypeVisitor) getAdaptable(ASTTypeVisitor.class));

    String anonClassName = null;/*from  w  w w  .  j a v a2  s .c o m*/
    if (binding.isAnonymous() || binding.isLocal()) {
        String binaryName = binding.getBinaryName();
        if (binaryName == null) {
            String bindingKey = binding.getKey();
            if (bindingKey != null) {
                binaryName = bindingKey = bindingKey.substring(1, bindingKey.length() - 1).replace('/', '.');
            }
        }
        anonClassName = assureQualifiedName(shortenQualifiedName(binaryName));
    } else {
        anonClassName = assureQualifiedName(shortenQualifiedName(binding.getQualifiedName()));
    }
    String shortClassName = null;
    int idx = anonClassName.lastIndexOf('.');
    if (idx == -1) {
        shortClassName = anonClassName;
    } else {
        shortClassName = anonClassName.substring(idx + 1);
    }

    //      typeVisitor.increaseAnonymousClassCount();
    //      //ClassInstanceCreation parent = (ClassInstanceCreation) node.getParent();
    String className = typeVisitor.getClassName();
    //      String anonymousName = className + "$" + typeVisitor.getAnonymousCount();
    //
    String fullClassName = anonClassName;
    //      String fullClassName = null;
    String packageName = ((ASTPackageVisitor) getAdaptable(ASTPackageVisitor.class)).getPackageName();
    //      if (packageName != null && packageName.length() != 0) {
    //         fullClassName = packageName + '.' + anonymousName;
    //      } else {
    //         fullClassName = anonymousName;
    //      }

    //      if (thisPackageName != null && thisPackageName.length() != 0) {
    //         fullClassName = thisPackageName + '.' + anonymousName;
    //      } else {
    //         fullClassName = anonymousName;
    //      }

    buffer.append("(Clazz.isClassDefined (\"");
    buffer.append(fullClassName);
    buffer.append("\") ? 0 : ");

    StringBuffer tmpBuffer = buffer;
    buffer = methodBuffer;
    methodBuffer = new StringBuffer();

    buffer.append("cla$$.$");
    buffer.append(shortClassName);
    buffer.append("$ = function () {\r\n");

    buffer.append("Clazz.pu$h ();\r\n");
    buffer.append("cla$$ = ");
    //buffer.append("Clazz.decorateAsType (");
    buffer.append("Clazz.decorateAsClass (");
    //      buffer.append(JavaLangUtil.ripJavaLang(fullClassName));
    String oldClassName = className;
    typeVisitor.setClassName(shortClassName);
    //      buffer.append(" = function () {\r\n");
    buffer.append("function () {\r\n");
    if (!(node.getParent() instanceof EnumConstantDeclaration)) {
        buffer.append("Clazz.prepareCallback (this, arguments);\r\n");
    }
    StringBuffer oldLaterBuffer = laterBuffer;
    laterBuffer = new StringBuffer();
    List bodyDeclarations = node.bodyDeclarations();

    boolean needPreparation = false;
    for (Iterator iter = bodyDeclarations.iterator(); iter.hasNext();) {
        ASTNode element = (ASTNode) iter.next();
        if (element instanceof FieldDeclaration) {
            FieldDeclaration field = (FieldDeclaration) element;
            needPreparation = isFieldNeedPreparation(field);
            if (needPreparation) {
                break;
            }
        } else if (element instanceof Initializer) {
            Initializer init = (Initializer) element;
            if ((init.getModifiers() & Modifier.STATIC) == 0) {
                needPreparation = true;
                break;
            }
        }
    }

    for (Iterator iter = bodyDeclarations.iterator(); iter.hasNext();) {
        ASTNode element = (ASTNode) iter.next();
        if (element instanceof MethodDeclaration) {
            //MethodDeclaration method = (MethodDeclaration) element;
            //if ((method.getModifiers() & Modifier.STATIC) != 0) {
            continue;
            //}
            // there are no static members/methods in the inner type 
            // but there are static final members
            //         } else if (element instanceof Initializer) {
            //            continue;
        } else if (element instanceof FieldDeclaration
        /*&& isFieldNeedPreparation((FieldDeclaration) element)*/) {
            //            continue;
            FieldDeclaration fieldDeclaration = (FieldDeclaration) element;
            if (isFieldNeedPreparation(fieldDeclaration)) {
                visitWith(fieldDeclaration, true);
                continue;
            }
        }
        element.accept(this);
        //         element.accept(this);
    }

    //      ASTScriptVisitor scriptVisitor = new ASTScriptVisitor();
    //      scriptVisitor.isInnerClass = true;
    //      scriptVisitor.thisClassName = anonymousName;
    //      node.accept(scriptVisitor);
    //      buffer.append(scriptVisitor.getBuffer());

    buffer.append("Clazz.instantialize (this, arguments);\r\n");

    buffer.append("}, ");

    String emptyFun = "Clazz.decorateAsClass (function () {\r\n" + "Clazz.instantialize (this, arguments);\r\n"
            + "}, ";
    idx = buffer.lastIndexOf(emptyFun);

    if (idx != -1 && idx == buffer.length() - emptyFun.length()) {
        buffer.replace(idx, buffer.length(), "Clazz.declareType (");
    } else {
        emptyFun = "Clazz.decorateAsClass (function () {\r\n" + "Clazz.prepareCallback (this, arguments);\r\n"
                + "Clazz.instantialize (this, arguments);\r\n" + "}, ";
        idx = buffer.lastIndexOf(emptyFun);

        if (idx != -1 && idx == buffer.length() - emptyFun.length()) {
            buffer.replace(idx, buffer.length(), "Clazz.declareAnonymous (");
        }
    }

    int lastIndexOf = fullClassName.lastIndexOf('.');
    if (lastIndexOf != -1) {
        buffer.append(assureQualifiedName(shortenPackageName(fullClassName)));
        buffer.append(", \"" + fullClassName.substring(lastIndexOf + 1) + "\"");
    } else {
        buffer.append("null, \"" + fullClassName + "\"");
    }

    if (binding != null) {
        ITypeBinding superclass = binding.getSuperclass();
        if (superclass != null) {
            String clazzName = superclass.getQualifiedName();
            clazzName = assureQualifiedName(shortenQualifiedName(clazzName));
            if (clazzName != null && clazzName.length() != 0 && !"Object".equals(clazzName)) {
                buffer.append(", ");
                buffer.append(clazzName);
            } else {
                ITypeBinding[] declaredTypes = binding.getInterfaces();
                if (declaredTypes != null && declaredTypes.length > 0) {
                    clazzName = declaredTypes[0].getQualifiedName();
                    if (clazzName != null && clazzName.length() != 0) {
                        clazzName = assureQualifiedName(shortenQualifiedName(clazzName));
                        buffer.append(", null, ");
                        buffer.append(clazzName);
                    }
                }
            }
        }
    }
    buffer.append(");\r\n");

    bodyDeclarations = node.bodyDeclarations();

    if (needPreparation) {
        buffer.append("Clazz.prepareFields (cla$$, function () {\r\n");
        for (Iterator iter = bodyDeclarations.iterator(); iter.hasNext();) {
            ASTNode element = (ASTNode) iter.next();
            if (element instanceof FieldDeclaration) {
                FieldDeclaration field = (FieldDeclaration) element;
                if (!isFieldNeedPreparation(field)) {
                    continue;
                }
                element.accept(this);
            } else if (element instanceof Initializer) {
                Initializer init = (Initializer) element;
                if ((init.getModifiers() & Modifier.STATIC) == 0) {
                    element.accept(this);
                }
            }
        }
        buffer.append("});\r\n");
    }

    for (Iterator iter = bodyDeclarations.iterator(); iter.hasNext();) {
        ASTNode element = (ASTNode) iter.next();
        if (element instanceof MethodDeclaration) {
            element.accept(this);
        }
    }

    for (Iterator iter = bodyDeclarations.iterator(); iter.hasNext();) {
        ASTNode element = (ASTNode) iter.next();
        if (element instanceof FieldDeclaration) {
            FieldDeclaration fields = (FieldDeclaration) element;
            if ((fields.getModifiers() & Modifier.STATIC) != 0) {
                List fragments = fields.fragments();
                for (int j = 0; j < fragments.size(); j++) {
                    //if (fragments.size () == 1) {
                    /* replace full class name with short variable name */
                    buffer.append("cla$$");
                    //buffer.append(fullClassName);
                    buffer.append(".");
                    VariableDeclarationFragment vdf = (VariableDeclarationFragment) fragments.get(j);
                    //buffer.append(vdf.getName());
                    vdf.getName().accept(this);
                    buffer.append(" = ");
                    Expression initializer = vdf.getInitializer();
                    if (initializer != null) {
                        initializer.accept(this);
                    } else {
                        Type type = fields.getType();
                        if (type.isPrimitiveType()) {
                            PrimitiveType pType = (PrimitiveType) type;
                            if (pType.getPrimitiveTypeCode() == PrimitiveType.BOOLEAN) {
                                buffer.append("false");
                            } else {
                                buffer.append("0");
                            }
                        } else {
                            buffer.append("null");
                        }
                    }
                    buffer.append(";\r\n");
                }
            }
        }
    }

    buffer.append("cla$$ = Clazz.p0p ();\r\n");

    typeVisitor.setClassName(oldClassName);

    buffer.append(laterBuffer);
    laterBuffer = oldLaterBuffer;

    buffer.append("};\r\n");

    String methods = methodBuffer.toString();
    methodBuffer = buffer;
    methodBuffer.append(methods);
    buffer = tmpBuffer;

    buffer.append(packageName);
    buffer.append(".");
    idx = className.indexOf('$');
    if (idx != -1) {
        buffer.append(className.substring(0, idx));
    } else {
        buffer.append(className);
    }
    buffer.append(".$");
    buffer.append(shortClassName);
    buffer.append("$ ())");
    /*
     * Anonymouse class won't have static members and methods and initializers
     */
    return false;
}

From source file:net.sf.j2s.core.astvisitors.ASTScriptVisitor.java

License:Open Source License

public void endVisit(EnumDeclaration node) {
    if (node != rootTypeNode && node.getParent() != null
            && node.getParent() instanceof AbstractTypeDeclaration) {
        return;/*from  w w w. j  a v a2 s  .  c  o  m*/
    }
    //      if (!node.isInterface()) {
    buffer.append("Clazz.instantialize (this, arguments);\r\n");
    //      }

    buffer.append("}, ");

    String emptyFun = "Clazz.decorateAsClass (function () {\r\n" + "Clazz.instantialize (this, arguments);\r\n"
            + "}, ";
    int idx = buffer.lastIndexOf(emptyFun);

    if (idx != -1 && idx == buffer.length() - emptyFun.length()) {
        buffer.replace(idx, buffer.length(), "Clazz.declareType (");
    }

    ASTNode parent = node.getParent();
    if (parent != null && parent instanceof AbstractTypeDeclaration) {
        String packageName = ((ASTPackageVisitor) getAdaptable(ASTPackageVisitor.class)).getPackageName();
        String className = ((ASTTypeVisitor) getAdaptable(ASTTypeVisitor.class)).getClassName();
        //String className = ((AbstractTypeDeclaration) parent).getName().getFullyQualifiedName();
        String fullClassName = null;
        if (packageName != null && packageName.length() != 0) {
            fullClassName = packageName + '.' + className;
        } else {
            fullClassName = className;
        }
        String name = node.getName().getIdentifier();
        buffer.append(assureQualifiedName(fullClassName));
        buffer.append(", \"" + name + "\"");
        buffer.append(", Enum");
    } else {

        String fullClassName = null;//getFullClassName();
        String packageName = ((ASTPackageVisitor) getAdaptable(ASTPackageVisitor.class)).getPackageName();
        String className = ((ASTTypeVisitor) getAdaptable(ASTTypeVisitor.class)).getClassName();
        if (packageName != null && packageName.length() != 0) {
            fullClassName = packageName + '.' + className;
        } else {
            fullClassName = className;
        }
        //         if (thisPackageName != null && thisPackageName.length() != 0) {
        //            fullClassName = thisPackageName + '.' + thisClassName;
        //         } else {
        //            fullClassName = thisClassName;
        //         }

        int lastIndexOf = fullClassName.lastIndexOf('.');
        if (lastIndexOf != -1) {
            buffer.append(assureQualifiedName(shortenPackageName(fullClassName)));
            buffer.append(", \"" + fullClassName.substring(lastIndexOf + 1) + "\"");
        } else {
            buffer.append("null, \"" + fullClassName + "\"");
        }
        buffer.append(", Enum");
    }

    List superInterfaces = node.superInterfaceTypes();
    int size = superInterfaces.size();
    if (size > 0) {
        buffer.append(", ");
    }
    if (size > 1) {
        buffer.append("[");
    }
    for (Iterator iter = superInterfaces.iterator(); iter.hasNext();) {
        ASTNode element = (ASTNode) iter.next();
        ITypeBinding binding = ((Type) element).resolveBinding();
        if (binding != null) {
            String clazzName = binding.getQualifiedName();
            clazzName = assureQualifiedName(shortenQualifiedName(clazzName));
            buffer.append(clazzName);
        } else {
            buffer.append(element);
        }
        if (iter.hasNext()) {
            buffer.append(", ");
        }
    }
    if (size > 1) {
        buffer.append("]");
    }
    buffer.append(");\r\n");

    buffer.append(laterBuffer);

    //      EnumTypeWrapper enumWrapper = new EnumTypeWrapper(node);
    //      
    //      MethodDeclaration[] methods = enumWrapper.getMethods();
    List bd = node.bodyDeclarations();
    int methodCount = 0;
    for (Iterator it = bd.listIterator(); it.hasNext();) {
        if (it.next() instanceof MethodDeclaration) {
            methodCount++;
        }
    }
    MethodDeclaration[] methods = new MethodDeclaration[methodCount];
    int next = 0;
    for (Iterator it = bd.listIterator(); it.hasNext();) {
        Object decl = it.next();
        if (decl instanceof MethodDeclaration) {
            methods[next++] = (MethodDeclaration) decl;
        }
    }
    for (int i = 0; i < methods.length; i++) {
        methods[i].accept(this);
    }

    List bodyDeclarations = node.bodyDeclarations();

    boolean needPreparation = false;
    for (Iterator iter = bodyDeclarations.iterator(); iter.hasNext();) {
        ASTNode element = (ASTNode) iter.next();
        if (element instanceof FieldDeclaration) {
            FieldDeclaration field = (FieldDeclaration) element;
            needPreparation = isFieldNeedPreparation(field);
            if (needPreparation) {
                break;
            }
        } else if (element instanceof Initializer) {
            Initializer init = (Initializer) element;
            if ((init.getModifiers() & Modifier.STATIC) == 0) {
                needPreparation = true;
                break;
            }
        }
    }
    if (needPreparation) {
        buffer.append("Clazz.prepareFields (cla$$, function () {\r\n");
        for (Iterator iter = bodyDeclarations.iterator(); iter.hasNext();) {
            ASTNode element = (ASTNode) iter.next();
            if (element instanceof FieldDeclaration) {
                FieldDeclaration field = (FieldDeclaration) element;
                if (!isFieldNeedPreparation(field)) {
                    continue;
                }
                element.accept(this);
            } else if (element instanceof Initializer) {
                Initializer init = (Initializer) element;
                if ((init.getModifiers() & Modifier.STATIC) == 0) {
                    element.accept(this);
                }
            }
        }
        buffer.append("};\r\n");
    }

    for (Iterator iter = bodyDeclarations.iterator(); iter.hasNext();) {
        ASTNode element = (ASTNode) iter.next();
        if (element instanceof Initializer) {
            element.accept(this);

        } else if (element instanceof FieldDeclaration) {
            FieldDeclaration field = (FieldDeclaration) element;
            if ((field.getModifiers() & Modifier.STATIC) != 0) {
                List fragments = field.fragments();
                for (int j = 0; j < fragments.size(); j++) {
                    //if (fragments.size () == 1) {
                    /* replace full class name with short variable name */
                    buffer.append("cla$$");
                    //buffer.append(fullClassName);
                    buffer.append(".");
                    VariableDeclarationFragment vdf = (VariableDeclarationFragment) fragments.get(j);
                    //buffer.append(vdf.getName());
                    vdf.getName().accept(this);
                    buffer.append(" = ");
                    Expression initializer = vdf.getInitializer();
                    if (initializer != null) {
                        initializer.accept(this);
                    } else {
                        Type type = field.getType();
                        if (type.isPrimitiveType()) {
                            PrimitiveType pType = (PrimitiveType) type;
                            if (pType.getPrimitiveTypeCode() == PrimitiveType.BOOLEAN) {
                                buffer.append("false");
                            } else {
                                buffer.append("0");
                            }
                        } else {
                            buffer.append("null");
                        }
                    }
                    buffer.append(";\r\n");
                }
            }
        }
    }

    List constants = node.enumConstants();
    for (int i = 0; i < constants.size(); i++) {
        EnumConstantDeclaration enumConst = (EnumConstantDeclaration) constants.get(i);
        AnonymousClassDeclaration anonDeclare = enumConst.getAnonymousClassDeclaration();
        if (anonDeclare == null) {
            buffer.append("Clazz.defineEnumConstant (");
            /* replace full class name with short variable name */
            buffer.append("cla$$");
            //buffer.append(fullClassName);
            buffer.append(", \"");
            enumConst.getName().accept(this);
            buffer.append("\", " + i + ", [");
            visitList(enumConst.arguments(), ", ");
            buffer.append("]);\r\n");

        } else {
            ITypeBinding binding = node.resolveBinding();
            String anonClassName = null;
            if (binding.isAnonymous() || binding.isLocal()) {
                anonClassName = assureQualifiedName(shortenQualifiedName(binding.getBinaryName()));
            } else {
                anonClassName = assureQualifiedName(shortenQualifiedName(binding.getQualifiedName()));
            }
            //int anonCount = ((ASTTypeVisitor) getAdaptable(ASTTypeVisitor.class)).getAnonymousCount() + 1;
            anonDeclare.accept(this);

            buffer.append("Clazz.defineEnumConstant (");
            /* replace full class name with short variable name */
            buffer.append("cla$$");
            //buffer.append(fullClassName);
            buffer.append(", \"");
            enumConst.getName().accept(this);
            buffer.append("\", " + i + ", [");
            visitList(enumConst.arguments(), ", ");
            buffer.append("], ");
            //            buffer.append(getFullClassName());
            //            buffer.append("$" + anonCount + ");\r\n");
            buffer.append(anonClassName);
            buffer.append(");\r\n");

        }
    }

    super.endVisit(node);
}