Example usage for org.eclipse.jdt.core.dom EnumConstantDeclaration getJavadoc

List of usage examples for org.eclipse.jdt.core.dom EnumConstantDeclaration getJavadoc

Introduction

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

Prototype

public Javadoc getJavadoc() 

Source Link

Document

Returns the doc comment node.

Usage

From source file:at.bestsolution.fxide.jdt.corext.dom.ASTFlattener.java

License:Open Source License

@Override
public boolean visit(EnumConstantDeclaration node) {
    if (node.getJavadoc() != null) {
        node.getJavadoc().accept(this);
    }//from ww  w.  j  a  va  2  s . c om
    printModifiers(node.modifiers());
    node.getName().accept(this);
    if (!node.arguments().isEmpty()) {
        this.fBuffer.append("(");//$NON-NLS-1$
        for (Iterator<Expression> it = node.arguments().iterator(); it.hasNext();) {
            Expression e = it.next();
            e.accept(this);
            if (it.hasNext()) {
                this.fBuffer.append(",");//$NON-NLS-1$
            }
        }
        this.fBuffer.append(")");//$NON-NLS-1$
    }
    if (node.getAnonymousClassDeclaration() != null) {
        node.getAnonymousClassDeclaration().accept(this);
    }
    return false;
}

From source file:coloredide.utils.CopiedNaiveASTFlattener.java

License:Open Source License

public boolean visit(EnumConstantDeclaration node) {
    if (node.getJavadoc() != null) {
        node.getJavadoc().accept(this);
    }/*from  www. j av  a 2  s .  c  om*/
    printIndent();
    printModifiers(node.modifiers());
    node.getName().accept(this);
    if (!node.arguments().isEmpty()) {
        this.buffer.append("(");//$NON-NLS-1$
        for (Iterator it = node.arguments().iterator(); it.hasNext();) {
            Expression e = (Expression) it.next();
            e.accept(this);
            if (it.hasNext()) {
                this.buffer.append(",");//$NON-NLS-1$
            }
        }
        this.buffer.append(")");//$NON-NLS-1$
    }
    if (node.getAnonymousClassDeclaration() != null) {
        node.getAnonymousClassDeclaration().accept(this);
    }
    return false;
}

From source file:com.bsiag.eclipse.jdt.java.formatter.LineBreaksPreparator.java

License:Open Source License

@Override
public boolean visit(EnumDeclaration node) {
    handleBracedCode(node, node.getName(), this.options.brace_position_for_enum_declaration,
            this.options.indent_body_declarations_compare_to_enum_declaration_header,
            this.options.insert_new_line_in_empty_enum_declaration);
    handleBodyDeclarations(node.bodyDeclarations());

    List<EnumConstantDeclaration> enumConstants = node.enumConstants();
    for (int i = 0; i < enumConstants.size(); i++) {
        EnumConstantDeclaration declaration = enumConstants.get(i);
        if (declaration.getJavadoc() != null)
            this.tm.firstTokenIn(declaration, TokenNameCOMMENT_JAVADOC).breakBefore();
        if (declaration.getAnonymousClassDeclaration() != null && i < enumConstants.size() - 1)
            this.tm.firstTokenAfter(declaration, TokenNameCOMMA).breakAfter();
    }/* w w  w . j a v a 2 s  .  c  o  m*/

    // put breaks after semicolons
    int index = enumConstants.isEmpty() ? this.tm.firstIndexAfter(node.getName(), TokenNameLBRACE) + 1
            : this.tm.firstIndexAfter(enumConstants.get(enumConstants.size() - 1), -1);
    for (;; index++) {
        Token token = this.tm.get(index);
        if (token.isComment())
            continue;
        if (token.tokenType == TokenNameSEMICOLON)
            token.breakAfter();
        else
            break;
    }

    this.declarationModifierVisited = false;
    return true;
}

From source file:org.eclipse.xtend.core.javaconverter.JavaASTFlattener.java

License:Open Source License

@Override
public boolean visit(final EnumConstantDeclaration node) {
    Javadoc _javadoc = node.getJavadoc();
    boolean _tripleNotEquals = (_javadoc != null);
    if (_tripleNotEquals) {
        node.getJavadoc().accept(this);
    }/* w w w  .j av  a  2  s.com*/
    this.appendModifiers(node, node.modifiers());
    node.getName().accept(this);
    boolean _isEmpty = node.arguments().isEmpty();
    boolean _not = (!_isEmpty);
    if (_not) {
        this.addProblem(node, "Enum constant cannot have any arguments");
        this.appendToBuffer("(");
        this.visitAllSeparatedByComma(node.arguments());
        this.appendToBuffer(")");
    }
    AnonymousClassDeclaration _anonymousClassDeclaration = node.getAnonymousClassDeclaration();
    boolean _tripleNotEquals_1 = (_anonymousClassDeclaration != null);
    if (_tripleNotEquals_1) {
        this.addProblem(node, "Enum constant cannot have any anonymous class declarations");
        node.getAnonymousClassDeclaration().accept(this);
    }
    return false;
}

From source file:org.modeshape.sequencer.javafile.JdtRecorder.java

License:Apache License

/**
 * <pre>//from   ww w .ja va 2 s  .c om
 * EnumConstantDeclaration:
 *     [ Javadoc ] { ExtendedModifier } Identifier
 *         [ ( [ Expression { , Expression } ] ) ]
 *         [ AnonymousClassDeclaration ]
 * </pre>
 *
 * @param enumConstant the enum constant being processed (cannot be <code>null</code>)
 * @param parentNode the {@link Node node} where the enum constant node will be created (cannot be <code>null</code>)
 * @throws Exception if there is a problem
 */
protected void record(final EnumConstantDeclaration enumConstant, final Node parentNode) throws Exception {
    final String name = enumConstant.getName().getIdentifier();
    final Node constantNode = parentNode.addNode(name, ClassFileSequencerLexicon.ENUM_CONSTANT);

    { // javadocs
        final Javadoc javadoc = enumConstant.getJavadoc();

        if (javadoc != null) {
            record(javadoc, constantNode);
        }
    }

    { // no modifiers but can have annotations
        @SuppressWarnings("unchecked")
        final List<IExtendedModifier> modifiers = enumConstant.modifiers();
        recordAnnotations(modifiers, constantNode);
    }

    { // args
        @SuppressWarnings("unchecked")
        final List<Expression> args = enumConstant.arguments();

        if ((args != null) && !args.isEmpty()) {
            final Node containerNode = constantNode.addNode(ClassFileSequencerLexicon.ARGUMENTS,
                    ClassFileSequencerLexicon.ARGUMENTS);

            for (final Expression arg : args) {
                recordExpression(arg, ClassFileSequencerLexicon.ARGUMENT, containerNode);
            }
        }
    }

    // anonymous classes
    final AnonymousClassDeclaration acd = enumConstant.getAnonymousClassDeclaration();

    if (acd != null) {
        recordBodyDeclarations(acd, constantNode);
    }

    recordSourceReference(enumConstant, constantNode);
}

From source file:org.whole.lang.java.util.JDTTransformerVisitor.java

License:Open Source License

@Override
public boolean visit(EnumConstantDeclaration node) {
    org.whole.lang.java.model.EnumConstantDeclaration enumConstantDeclaration;
    appendBodyDeclaration(//from   w  w  w  .j av  a  2 s  .  com
            enumConstantDeclaration = createResolver(JavaEntityDescriptorEnum.EnumConstantDeclaration));

    if (acceptChild(node.getJavadoc()))
        enumConstantDeclaration.setJavadoc(this.javadoc);

    List<?> modifiers = node.modifiers();
    if (!modifiers.isEmpty()) {
        enumConstantDeclaration.setModifiers(lf.create(JavaEntityDescriptorEnum.ExtendedModifiers));
        setExtendedModifiers(enumConstantDeclaration.getModifiers(), modifiers);
    }
    if (acceptChild(node.getName()))
        enumConstantDeclaration.setName((org.whole.lang.java.model.SimpleName) this.name);

    Iterator<?> i = node.arguments().iterator();
    while (i.hasNext()) {
        ((ASTNode) i.next()).accept(this);
        enumConstantDeclaration.getArguments().wAdd(this.exp);
    }

    if (acceptChild(node.getAnonymousClassDeclaration()))
        enumConstantDeclaration.setAnonymousClassDeclaration(this.anonymousClassDeclaration);

    return false;
}

From source file:ptolemy.backtrack.eclipse.ast.ASTFormatter.java

License:Open Source License

/** Visit an ast node, and return whether its children should be further
 *  visited.//from w  ww.  ja  v a 2  s .c om
 *
 *  @param node The AST node.
 *  @return Whether its children should be further visited.
 */
public boolean visit(EnumConstantDeclaration node) {
    if (node.getJavadoc() != null) {
        node.getJavadoc().accept(this);
    }

    _output(_indent);
    _outputModifiers(node.modifiers());
    node.getName().accept(this);

    if (!node.arguments().isEmpty()) {
        _output("(");

        for (Iterator it = node.arguments().iterator(); it.hasNext();) {
            Expression e = (Expression) it.next();
            e.accept(this);

            if (it.hasNext()) {
                _output(", ");
            }
        }

        _output(")");
    }

    // bodyDeclarations() no longer exists in JDT 3.1.

    /*if (!node.bodyDeclarations().isEmpty()) {
     _openBrace();
     Iterator it;
     for (it = node.bodyDeclarations().iterator(); it.hasNext(); ) {
     BodyDeclaration d = (BodyDeclaration) it.next();
     d.accept(this);
     }
     _closeBrace();
     }*/
    return false;
}

From source file:simpack.util.tree.visitor.ast.ASTFullTransformer.java

License:LGPL

public boolean visit(EnumConstantDeclaration node) {
    pushValuedNode(node, node.getName().getFullyQualifiedName());

    // visit children by hand because Name is used as value
    if (node.getJavadoc() != null) {
        node.getJavadoc().accept(this);
    }//from  w  w w.ja  v  a2 s  .c  o  m

    visitList(MODIFIERS, node.modifiers());
    visitList(ARGUMENTS, node.arguments());

    if (node.getAnonymousClassDeclaration() != null) {
        node.getAnonymousClassDeclaration().accept(this);
    }

    return false;
}