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

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

Introduction

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

Prototype

public List modifiers() 

Source Link

Document

Returns the live ordered list of modifiers and annotations of this declaration (added in JLS3 API).

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 w  w  w.  ja  v a2s.c  o m
    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);
    }//ww  w . ja va  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.google.googlejavaformat.java.JavaInputAstVisitor.java

License:Apache License

/** Visitor method for {@link EnumConstantDeclaration}s. */
@Override/*from   w  ww  .  ja  v a2  s .  c  o m*/
public boolean visit(EnumConstantDeclaration node) {
    sync(node);
    List<Op> breaks = visitModifiers(node.modifiers(), Direction.VERTICAL, Optional.<BreakTag>absent());
    if (!breaks.isEmpty()) {
        builder.open(ZERO);
        builder.addAll(breaks);
        builder.close();
    }
    visit(node.getName());
    if (node.arguments().isEmpty()) {
        builder.guessToken("(");
        builder.guessToken(")");
    } else {
        addArguments(node.arguments(), plusFour);
    }
    if (node.getAnonymousClassDeclaration() != null) {
        visit(node.getAnonymousClassDeclaration());
    }
    return false;
}

From source file:lang.java.jdt.internal.JdtAstToRascalAstConverter.java

License:Open Source License

public boolean visit(EnumConstantDeclaration node) {
    java.util.Map.Entry<IValueList, IValueList> extendedModifiers = parseExtendedModifiers(node.modifiers());
    IValue name = values.string(node.getName().getFullyQualifiedName());

    IValueList arguments = new IValueList(values);
    if (!node.arguments().isEmpty()) {
        for (Iterator it = node.arguments().iterator(); it.hasNext();) {
            Expression e = (Expression) it.next();
            arguments.add(visitChild(e));
        }/*w ww .  jav  a 2 s  . c  o  m*/
    }

    IValue anonymousClassDeclaration = node.getAnonymousClassDeclaration() == null ? null
            : visitChild(node.getAnonymousClassDeclaration());

    ownValue = constructRascalNode(node, extendedModifiers.getKey().asList(),
            extendedModifiers.getValue().asList(), name, arguments.asList(),
            optional(anonymousClassDeclaration));
    return false;
}

From source file:org.asup.dk.compiler.rpj.writer.JDTNamedNodeWriter.java

License:Open Source License

@SuppressWarnings("unchecked")
public void writeEnumField(EnumConstantDeclaration enumField, QSpecialElement elem) {
    AST ast = enumField.getAST();//  w  w  w  . j  av  a 2 s.c  o  m
    NormalAnnotation normalAnnotation = ast.newNormalAnnotation();

    String name = new String("*" + enumField.getName());
    if (elem.getValue() != null && !name.equals(elem.getValue())) {
        normalAnnotation.setTypeName(ast.newSimpleName(Special.class.getSimpleName()));
        MemberValuePair memberValuePair = ast.newMemberValuePair();
        memberValuePair.setName(ast.newSimpleName("value"));
        StringLiteral stringLiteral = ast.newStringLiteral();
        stringLiteral.setLiteralValue(elem.getValue());
        memberValuePair.setValue(stringLiteral);
        normalAnnotation.values().add(memberValuePair);

        enumField.modifiers().add(normalAnnotation);
    }
}

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);
    }//ww w . jav  a  2s  . c o m
    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.j av  a 2  s.  c  o m
 * 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(/* w ww.jav  a 2s .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./*  w  w w  . ja  v a  2  s.co m*/
 *
 *  @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);
    }//www  . j a  v a  2 s .c om

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

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

    return false;
}