Package org.eclipse.jdt.core.dom

Examples of org.eclipse.jdt.core.dom.SingleVariableDeclaration


        List<SingleVariableDeclaration> parameters = method.parameters();
        if (parameters.size() != 1)
          continue;
        setMethods.add(method);
        MethodDeclaration newMethod = copyMethodDeclaration(newType.getAST(), method);
        SingleVariableDeclaration oldParameter = parameters.get(0);
        SimpleName paramName = oldParameter.getName();
        /*
         * the statement
         */
        org.eclipse.jdt.core.dom.Block block = ast.newBlock();
        MethodInvocation methodInvocation = ast.newMethodInvocation();
View Full Code Here


    MethodDeclaration aMethod = (MethodDeclaration) currDeclaration;
    Type returnType = aMethod.getReturnType2();
    aMethod.setReturnType2(ast.newPrimitiveType(PrimitiveType.VOID));

    // Add AsyncCallback parameter
    SingleVariableDeclaration asyncCallbackParam = ast.newSingleVariableDeclaration();
    asyncCallbackParam.setName(ast.newSimpleName("callback")); //$NON-NLS-1$

    Type asyncCallbackType;
    if (shouldUseGenerics)
      asyncCallbackType = createAsyncCallbackType(ast, returnType);
    else
      asyncCallbackType = ast.newSimpleType(ast.newName("AsyncCallback")); //$NON-NLS-1$

    asyncCallbackParam.setType(asyncCallbackType);
    aMethod.parameters().add(asyncCallbackParam);

    // Remove throws
    aMethod.thrownExceptions().clear();
View Full Code Here

            // Make return type void
            MethodDeclaration aMethod = (MethodDeclaration) currDeclaration;
            aMethod.setReturnType2(ast.newPrimitiveType(PrimitiveType.VOID));

            // Add AsyncCallback parameter
            SingleVariableDeclaration asyncCallbackParam = ast.newSingleVariableDeclaration();
            asyncCallbackParam.setName(ast.newSimpleName("callback")); //$NON-NLS-1$
            asyncCallbackParam.setType(ast.newSimpleType(ast.newName("AsyncCallback"))); //$NON-NLS-1$
            aMethod.parameters().add(asyncCallbackParam);
           
            // Remove throws
            aMethod.thrownExceptions().clear();
           
View Full Code Here

        method.setReturnType2(createType(ast, typeName));

        // If the field is static, add a checkpoint object argument.
        if (isStatic) {
            // Add a "$CHECKPOINT" argument.
            SingleVariableDeclaration checkpoint = ast
                    .newSingleVariableDeclaration();
            String checkpointType = getClassName(Checkpoint.class, state, root);
            checkpoint.setType(ast
                    .newSimpleType(createName(ast, checkpointType)));
            checkpoint.setName(ast.newSimpleName(CHECKPOINT_NAME));
            method.parameters().add(checkpoint);
        }

        if (special && _assignOperators.containsKey(fieldTypeName)) {
            // Add an operator parameter.
            SingleVariableDeclaration operator = ast
                    .newSingleVariableDeclaration();
            operator.setType(ast.newPrimitiveType(PrimitiveType.INT));
            operator.setName(ast.newSimpleName("operator"));
            method.parameters().add(operator);
        }

        // Add all the indices.
        for (int i = 0; i < indices; i++) {
            SingleVariableDeclaration index = ast
                    .newSingleVariableDeclaration();
            index.setType(ast.newPrimitiveType(PrimitiveType.INT));
            index.setName(ast.newSimpleName("index" + i));
            method.parameters().add(index);
        }

        // Add a new value argument with name "newValue".
        SingleVariableDeclaration argument = ast.newSingleVariableDeclaration();
        argument.setType((org.eclipse.jdt.core.dom.Type) ASTNode.copySubtree(
                ast, type));
        argument.setName(ast.newSimpleName("newValue"));
        method.parameters().add(argument);

        // If the field is static, the method is also static; the method
        // is also private.
        List modifiers = method.modifiers();
View Full Code Here

                state, root)));

        // If the field is static, add a checkpoint object argument.
        if (isStatic) {
            // Add a "$CHECKPOINT" argument.
            SingleVariableDeclaration checkpoint = ast
                    .newSingleVariableDeclaration();
            String checkpointType = getClassName(Checkpoint.class, state, root);
            checkpoint.setType(ast
                    .newSimpleType(createName(ast, checkpointType)));
            checkpoint.setName(ast.newSimpleName(CHECKPOINT_NAME));
            method.parameters().add(checkpoint);
        }

        // Add all the indices.
        for (int i = 0; i < indices; i++) {
            SingleVariableDeclaration index = ast
                    .newSingleVariableDeclaration();
            index.setType(ast.newPrimitiveType(PrimitiveType.INT));
            index.setName(ast.newSimpleName("index" + i));
            method.parameters().add(index);
        }

        Block body = ast.newBlock();
        method.setBody(body);
View Full Code Here

        // Set the method name.
        method.setName(ast.newSimpleName(methodName));

        // Add a timestamp parameter.
        SingleVariableDeclaration timestamp = ast
                .newSingleVariableDeclaration();
        timestamp.setType(ast.newPrimitiveType(PrimitiveType.LONG));
        timestamp.setName(ast.newSimpleName("timestamp"));
        method.parameters().add(timestamp);

        // Return type default to "void".
        if (!isInterface) {
            // The method body.
View Full Code Here

        // Add a commit method.
        MethodDeclaration commit = ast.newMethodDeclaration();
        commit.setName(ast.newSimpleName(_getCommitMethodName(false)));

        // Add two parameters.
        SingleVariableDeclaration timestamp = ast
                .newSingleVariableDeclaration();
        timestamp.setType(ast.newPrimitiveType(PrimitiveType.LONG));
        timestamp.setName(ast.newSimpleName("timestamp"));
        commit.parameters().add(timestamp);

        // Add a call to the restore method in the enclosing anonymous class.
        MethodInvocation invocation = ast.newMethodInvocation();
        invocation.setName(ast.newSimpleName(_getCommitMethodName(true)));
        invocation.arguments().add(ast.newSimpleName("timestamp"));

        Block body = ast.newBlock();
        body.statements().add(ast.newExpressionStatement(invocation));
        commit.setBody(body);

        commit.modifiers().add(
                ast.newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD));
        commit.modifiers().add(
                ast.newModifier(Modifier.ModifierKeyword.FINAL_KEYWORD));
        classDeclaration.bodyDeclarations().add(commit);

        // Add a restore method.
        MethodDeclaration restore = ast.newMethodDeclaration();
        restore.setName(ast.newSimpleName(_getRestoreMethodName(false)));

        // Add two parameters.
        timestamp = ast.newSingleVariableDeclaration();
        timestamp.setType(ast.newPrimitiveType(PrimitiveType.LONG));
        timestamp.setName(ast.newSimpleName("timestamp"));
        restore.parameters().add(timestamp);

        SingleVariableDeclaration trim = ast.newSingleVariableDeclaration();
        trim.setType(ast.newPrimitiveType(PrimitiveType.BOOLEAN));
        trim.setName(ast.newSimpleName("trim"));
        restore.parameters().add(trim);

        // Add a call to the restore method in the enclosing anonymous class.
        invocation = ast.newMethodInvocation();
        invocation.setName(ast.newSimpleName(_getRestoreMethodName(true)));
        invocation.arguments().add(ast.newSimpleName("timestamp"));
        invocation.arguments().add(ast.newSimpleName("trim"));

        body = ast.newBlock();
        body.statements().add(ast.newExpressionStatement(invocation));
        restore.setBody(body);

        restore.modifiers().add(
                ast.newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD));
        restore.modifiers().add(
                ast.newModifier(Modifier.ModifierKeyword.FINAL_KEYWORD));
        classDeclaration.bodyDeclarations().add(restore);

        // Add a get checkpoint method.
        MethodDeclaration getCheckpoint = ast.newMethodDeclaration();
        String checkpointType = getClassName(Checkpoint.class, state, root);
        getCheckpoint.setName(ast
                .newSimpleName(_getGetCheckpointMethodName(false)));
        getCheckpoint.setReturnType2(createType(ast, checkpointType));
        invocation = ast.newMethodInvocation();
        invocation
                .setName(ast.newSimpleName(_getGetCheckpointMethodName(true)));
        body = ast.newBlock();

        ReturnStatement returnStatement = ast.newReturnStatement();
        returnStatement.setExpression(invocation);
        body.statements().add(returnStatement);
        getCheckpoint.setBody(body);

        getCheckpoint.modifiers().add(
                ast.newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD));
        getCheckpoint.modifiers().add(
                ast.newModifier(Modifier.ModifierKeyword.FINAL_KEYWORD));
        classDeclaration.bodyDeclarations().add(getCheckpoint);

        // Add a set checkpoint method.
        MethodDeclaration setCheckpoint = ast.newMethodDeclaration();
        setCheckpoint.setName(ast
                .newSimpleName(_getSetCheckpointMethodName(false)));
        setCheckpoint.setReturnType2(createType(ast, getClassName(Object.class,
                state, root)));

        // Add a single checkpoint parameter.
        SingleVariableDeclaration checkpoint = ast
                .newSingleVariableDeclaration();
        checkpoint.setType(createType(ast, checkpointType));
        checkpoint.setName(ast.newSimpleName("checkpoint"));
        setCheckpoint.parameters().add(checkpoint);

        // Add a call to the setcheckpoint method in the enclosing anonymous
        // class.
        invocation = ast.newMethodInvocation();
View Full Code Here

        // Set the method name.
        method.setName(ast.newSimpleName(methodName));

        // Add a timestamp parameter.
        SingleVariableDeclaration timestamp = ast
                .newSingleVariableDeclaration();
        timestamp.setType(ast.newPrimitiveType(PrimitiveType.LONG));
        timestamp.setName(ast.newSimpleName("timestamp"));
        method.parameters().add(timestamp);

        // Add a trim parameter.
        SingleVariableDeclaration trim = ast.newSingleVariableDeclaration();
        trim.setType(ast.newPrimitiveType(PrimitiveType.BOOLEAN));
        trim.setName(ast.newSimpleName("trim"));
        method.parameters().add(trim);

        // Return type default to "void".
        if (!isInterface) {
            // The method body.
View Full Code Here

        // Set the method name.
        method.setName(ast.newSimpleName(methodName));

        // Add a checkpoint parameter.
        SingleVariableDeclaration checkpoint = ast
                .newSingleVariableDeclaration();
        String checkpointType = getClassName(Checkpoint.class, state, root);
        checkpoint.setType(createType(ast, checkpointType));
        checkpoint.setName(ast.newSimpleName("checkpoint"));
        method.parameters().add(checkpoint);

        // Return type is Object.
        method.setReturnType2(createType(ast, getClassName(Object.class, state,
                root)));
View Full Code Here

        node.getName().accept(this);
        _output("(");

        for (Iterator it = node.parameters().iterator(); it.hasNext();) {
            SingleVariableDeclaration v = (SingleVariableDeclaration) it.next();
            v.accept(this);

            if (it.hasNext()) {
                _output(", ");
            }
        }
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.core.dom.SingleVariableDeclaration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.