Example usage for org.eclipse.jdt.core.dom SingleVariableDeclaration VARARGS_PROPERTY

List of usage examples for org.eclipse.jdt.core.dom SingleVariableDeclaration VARARGS_PROPERTY

Introduction

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

Prototype

SimplePropertyDescriptor VARARGS_PROPERTY

To view the source code for org.eclipse.jdt.core.dom SingleVariableDeclaration VARARGS_PROPERTY.

Click Source Link

Document

The "varargs" structural property of this node type (type: Boolean ) (added in JLS3 API).

Usage

From source file:ac.at.tuwien.dsg.uml.statemachine.export.transformation.engines.AbstractStateMachineTestStrategy.java

License:Open Source License

/**
 * Creates abstract methods which return true   
 * @param javadoc//from  ww  w.j  a  v a 2s .co  m
 * @param methodName
 * @param ast
 * @return an AST method declaration
 */
protected MethodDeclaration createAbstractAssertMethod(Javadoc javadoc, String methodName, AST ast) {

    MethodDeclaration method = ast.newMethodDeclaration();

    method.setJavadoc(javadoc);

    method.modifiers().add(ast.newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD));
    method.modifiers().add(ast.newModifier(Modifier.ModifierKeyword.ABSTRACT_KEYWORD));
    method.setName(ast.newSimpleName(methodName)); //escape all spaces in state name

    /**
     * add to method generic arguments  Object... arguments
     */
    SingleVariableDeclaration param = ast.newSingleVariableDeclaration();
    param.setName(ast.newSimpleName("arguments"));
    param.setType(ast.newSimpleType(ast.newName("Object")));
    param.setStructuralProperty(SingleVariableDeclaration.VARARGS_PROPERTY, true);

    method.setReturnType2(ast.newPrimitiveType(PrimitiveType.BOOLEAN));

    return method;
}

From source file:org.moe.natjgen.MethodEditor.java

License:Apache License

@SuppressWarnings("unchecked")
public void setVariadicArgument(int idx, String arg_name) throws GeneratorException {
    editLock();//  ww w  .  j  a  v a  2  s .c o m

    ListRewrite mlrw = getRewrite().getListRewrite(methodDecl, MethodDeclaration.PARAMETERS_PROPERTY);
    List<SingleVariableDeclaration> list = (List<SingleVariableDeclaration>) mlrw.getRewrittenList();
    SingleVariableDeclaration svd = list.get(idx);

    SimpleName property = (SimpleName) getRewrite().get(svd, SingleVariableDeclaration.NAME_PROPERTY);
    if (property == null || !property.getFullyQualifiedName().equals(arg_name)) {
        getRewrite().set(svd, SingleVariableDeclaration.NAME_PROPERTY, getAST().newName(arg_name),
                getEditGroup());
    }

    SimpleType type = getAST().newSimpleType(getAST().newName("Object"));
    getRewrite().set(svd, SingleVariableDeclaration.TYPE_PROPERTY, type, getEditGroup());
    getRewrite().set(svd, SingleVariableDeclaration.VARARGS_PROPERTY, Boolean.TRUE, getEditGroup());
}