Package org.eclipse.jdt.core.dom

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


     * @param vname
     */
    public void addLocalVariableDeclaration(String type, String vname) {
        VariableDeclarationFragment vfrag = m_ast.newVariableDeclarationFragment();
        vfrag.setName(m_ast.newSimpleName(vname));
        VariableDeclarationStatement stmt = m_ast.newVariableDeclarationStatement(vfrag);
        stmt.setType(m_source.createType(type));
        m_block.statements().add(stmt);
    }
View Full Code Here


     */
    public void addLocalVariableDeclaration(Type type, String vname, ExpressionBuilderBase expr) {
        VariableDeclarationFragment vfrag = m_ast.newVariableDeclarationFragment();
        vfrag.setName(m_ast.newSimpleName(vname));
        vfrag.setInitializer(expr.getExpression());
        VariableDeclarationStatement stmt = m_ast.newVariableDeclarationStatement(vfrag);
        stmt.setType(type);
        m_block.statements().add(stmt);
    }
View Full Code Here

      VariableDeclarationExpression parent = (VariableDeclarationExpression)parentASTNode;
      parent.getType().accept(this);
      visitListOfModifiers(parent.modifiers());
    }
    else {
      VariableDeclarationStatement parent = (VariableDeclarationStatement)parentASTNode;
      parent.getType().accept(this);
      visitListOfModifiers(parent.modifiers());
    }
    scopeManager.pop();
    return true;
  }
View Full Code Here

    List<Statement> stmts = m.getBody().statements();
    Assert.assertTrue(stmts.size() == 5);
   
    TACInstruction decl, init;
    for(int i = 0; i < 4; i++) {
      VariableDeclarationStatement s = (VariableDeclarationStatement) stmts.get(i);
      Assert.assertTrue("Statement: " + s, s.fragments().size() == 1);
      VariableDeclaration d = (VariableDeclaration) s.fragments().get(0);
      decl = tac.instruction(d);
      Assert.assertNotNull("Statement: " + s, decl);
      Assert.assertNotNull("Statement: " + s, d.getInitializer());
      if(d.getInitializer() instanceof ParenthesizedExpression)
        init = tac.instruction(((ParenthesizedExpression) d.getInitializer()).getExpression());
View Full Code Here

    VariableDeclarationFragment fragment = ast.newVariableDeclarationFragment();
    fragment.setName(returnValueName);
    ClassInstanceCreation newClassInstance = ast.newClassInstanceCreation();
    newClassInstance.setType((Type)returnType.copySubtree(ast, returnType));
    fragment.setInitializer(newClassInstance);
    VariableDeclarationStatement returnValue = ast.newVariableDeclarationStatement(fragment);
    returnValue.setType((Type)returnType.copySubtree(ast, returnType));
    block.statements().add(returnValue);
    /*
     * call each get method in the original and pass the result to the new set method
     *
     */
 
View Full Code Here

            VariableDeclarationFragment fragment = ast
                    .newVariableDeclarationFragment();
            fragment.setName(ast.newSimpleName("oldCheckpoint"));
            fragment.setInitializer(ast.newSimpleName(CHECKPOINT_NAME));

            VariableDeclarationStatement tempDeclaration = ast
                    .newVariableDeclarationStatement(fragment);
            tempDeclaration.setType(createType(ast, checkpointType));
            thenBranch.statements().add(tempDeclaration);

            // Record the old checkpoint if the new checkpoint is not null.
            // If it is null, it is impossible to roll back to the previous
            // checkpoint.
View Full Code Here

            if (invokedMethod.getElementName().equals(fromMethod.getElementName())
              && invokedMethod.getSignature().equals(fromMethod.getSignature())){

              ASTNode varDeclarationStmt = node.getParent().getParent();
              if (varDeclarationStmt instanceof VariableDeclarationStatement) {
                VariableDeclarationStatement vds = (VariableDeclarationStatement) varDeclarationStmt;
               
                // change the type
                Type returnType = JDTUtils.createQualifiedType(vds.getAST(), toClass);
                vds.setType(returnType);
              }
             
              ASTNode varDeclarationFragment = node.getParent();
              if (varDeclarationFragment instanceof VariableDeclarationFragment) {
                VariableDeclarationFragment vdf = (VariableDeclarationFragment) varDeclarationFragment;
View Full Code Here

            Messages.ASTNodeProcessor_IllegalAssignmentExpression, node);
      break;
    }

    case ASTNode.VARIABLE_DECLARATION_STATEMENT: {
      final VariableDeclarationStatement vds = (VariableDeclarationStatement) node;
      for (final Iterator it = vds.fragments().iterator(); it.hasNext();) {
        final VariableDeclarationFragment vdf = (VariableDeclarationFragment) it
            .next();
        final IJavaElement elem = vdf.resolveBinding().getJavaElement();
        if (elem.isReadOnly() || vdf.getName().resolveBoxing())
          throw new DefinitelyNotEnumerizableException(
View Full Code Here

            if (parentNode instanceof VariableDeclarationExpression) {
                VariableDeclarationExpression varDeclExpression = (VariableDeclarationExpression) parentNode;
                declType = varDeclExpression.getType();
   
            } else if (parentNode instanceof VariableDeclarationStatement) {
                VariableDeclarationStatement varDeclStatement = (VariableDeclarationStatement) parentNode;
                declType = varDeclStatement.getType();
            } else {
                sLogger.warn("Parent of this variable declaration statement currently not supported " + getASTNode());
            }
        }
View Full Code Here

   */
  @Override
  protected void deleteOldVariableDeclaration(VariableBindingManager manager) {
    VariableDeclarationFragment fragment = manager
        .getVariableDeclarationFragment();
    VariableDeclarationStatement statement = (VariableDeclarationStatement) fragment
        .getParent();
    fragment.delete();
    if (statement.fragments().size() == 0) {
      statement.delete();
    }
  }
View Full Code Here

TOP

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

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.