Package org.eclipse.jdt.core.dom

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


      int size = parameters.size();
      this.parameterTypes = new String[size];
      Iterator iterator = parameters.iterator();
      // convert the AST types to signatures
      for (int i = 0; i < size; i++) {
        SingleVariableDeclaration parameter = (SingleVariableDeclaration) iterator.next();
        String typeSig = Util.getSignature(parameter.getType());
        int extraDimensions = parameter.getExtraDimensions();
        if (methodDeclaration.isVarargs() && i == size-1)
          extraDimensions++;
        this.parameterTypes[i] = Signature.createArraySignature(typeSig, extraDimensions);
      }
    }
View Full Code Here


    // on state before execution for the parameters
   
    List param = node.parameters();

    for (int i=0; i<param.size(); i++) {
      SingleVariableDeclaration tmp = (SingleVariableDeclaration) param.get(i);
      String name = tmp.getName().toString();
      parameters.add(name);
      if (tmp.getType().isArrayType()) {
        arrVar.add(name);
      }
      else
        intVar.add(name);
    }
View Full Code Here

  }

  private void printNames(Iterable<SingleVariableDeclaration> parameters) {
    for (Iterator<SingleVariableDeclaration> it = parameters.iterator(); it
        .hasNext();) {
      SingleVariableDeclaration v = it.next();

      v.getName().accept(this);

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

    return this;
  }

  @Override
  public SingleVariableDeclaration toSingleVariableDeclaration(AST ast) {
    SingleVariableDeclaration declaration = ast.newSingleVariableDeclaration();

    Type type = simpleTypeInfo.toType(ast);
    declaration.setType(type);

    SimpleName variableName = ast.newSimpleName(name);
    declaration.setName(variableName);

    return declaration;
  }
View Full Code Here

*/
@Test
public class ParameterInfoTest {

  public void from_ast() {
    SingleVariableDeclaration ast = SingleVariableDeclarationFake.SOURCE_FILE_THAT;
    ParameterInfo res = ParameterInfoPojo.of(ast);
    assertThat(res, isEqualTo(ParameterInfoFake.SOURCE_FILE_THAT));
  }
View Full Code Here

    source.append(' ').append('(');

    boolean first = true;
    for (Iterator<SingleVariableDeclaration> iterator = methodDeclaration.parameters().iterator(); iterator
        .hasNext();) {
      SingleVariableDeclaration singleVariableDeclaration = iterator
          .next();
      if (first) {
        first = false;
      } else {
        source.append(',');
      }
      source.append(getDotName(getTypeName(singleVariableDeclaration
          .getType())));
      if (singleVariableDeclaration.isVarargs()) {
        source.append("..."); //$NON-NLS-1$
      }
      source.append(' ');
      source.append(singleVariableDeclaration.getName().getIdentifier());
      appendExtraDimensions(source,
          singleVariableDeclaration.getExtraDimensions());
    }

    source.append(')');

    appendExtraDimensions(source, methodDeclaration.getExtraDimensions());
View Full Code Here

        fullName.append('(');
        if (!md.parameters().isEmpty()) {
          List<ASTNode> params = md.parameters();
          for (ASTNode par : params) {
            if (par instanceof SingleVariableDeclaration) {
              SingleVariableDeclaration svd = (SingleVariableDeclaration) par;
              fullName.append(svd.getType() + " " + svd.getName() + ",");
            }
          }
        }
        if(fullName.charAt(fullName.length() - 1) == ',')
          fullName.deleteCharAt(fullName.length() - 1);
        fullName.append(')');
      }
      else if(node.getNode() instanceof FieldDeclaration){
        type = ((FieldDeclaration) node.getNode()).getType().toString();
      }
      int x = fullName.indexOf(".");
      fullName.delete(0, x + 1);
      return type + " " + fullName;
   
    case ASTNode.SINGLE_VARIABLE_DECLARATION:
      SingleVariableDeclaration svd = (SingleVariableDeclaration)node.getNode();
      return svd.getType() + " " + svd.getName();
     
    case ASTNode.VARIABLE_DECLARATION_STATEMENT:
      return ((VariableDeclarationStatement) node.getNode()).getType() + " "
          + simpleName;
    case ASTNode.VARIABLE_DECLARATION_EXPRESSION:
View Full Code Here

      final IASTParameterDeclaration parentReference = f.newParameterDeclaration(parentReferenceDeclSpecifier, parentReferenceDeclarator);
      functionDeclarator.addParameterDeclaration(parentReference);
    }

    for (final Object parameterObject : methodDeclaration.parameters()) {
      final SingleVariableDeclaration parameter = (SingleVariableDeclaration) parameterObject;
      final SingleVariableDeclarationInfo declarationInfo = new SingleVariableDeclarationInfo(parameter, compilationUnitInfo);
      final IASTParameterDeclaration parameterDeclaration = f.newParameterDeclaration(declarationInfo.getDeclSpecifier(), declarationInfo.getDeclarator());
      functionDeclarator.addParameterDeclaration(parameterDeclaration);
    }
  }
View Full Code Here

    String umlPropertyName = "person";
    jdtHelper.createParameterTypes(ast, td, md, umlTypeName,
        umlQualifiedTypeName, umlPropertyName,
        sourceDirectoryPackageName);

    SingleVariableDeclaration variableDeclaration = (SingleVariableDeclaration) md
        .parameters().get(0);
    assertEquals("Person person", variableDeclaration.toString());
  }
View Full Code Here

    String umlPropertyName = "persons";
    jdtHelper.createParameterTypesAsCollection(ast, td, md, umlTypeName,
        umlQualifiedTypeName, umlPropertyName,
        sourceDirectoryPackageName, JdtHelper.JAVA_UTIL_COLLECTION);

    SingleVariableDeclaration variableDeclaration = (SingleVariableDeclaration) md
        .parameters().get(0);
    assertEquals("java.util.Collection<Person> persons",
        variableDeclaration.toString());
  }
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.