Package org.eclipse.jdt.core.dom

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


                _output("<");

                Iterator it;

                for (it = node.typeArguments().iterator(); it.hasNext();) {
                    Type t = (Type) it.next();
                    t.accept(this);

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


                _output("<");

                Iterator it;

                for (it = node.typeArguments().iterator(); it.hasNext();) {
                    Type t = (Type) it.next();
                    t.accept(this);

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

  }

  public String getSuperClass(String targetClass) {
    try {
      TypeDeclaration type = compilationUnitCache.getTypeDeclaration(targetClass);
      Type superclassType = type.getSuperclassType();

      if (superclassType == null) {
        return targetClass;
      }

      return superclassType.resolveBinding().getQualifiedName();
    } catch (Exception e) {
      warnings.add(String.format(Messages.getString("org.apache.openejb.helper.annotation.warnings.9"), targetClass)); //$NON-NLS-1$
    }

    return ""; //$NON-NLS-1$
View Full Code Here

      VariableDeclarationFragment variableDeclaration = typeDeclaration.getAST().newVariableDeclarationFragment();
      variableDeclaration.setName(typeDeclaration.getAST().newSimpleName(fieldName));

      FieldDeclaration fieldDeclaration = typeDeclaration.getAST().newFieldDeclaration(variableDeclaration);
      Type type = JDTUtils.createQualifiedType(compilationUnit.getAST(), fieldType);
      fieldDeclaration.setType(type);
      Modifier privateModifier = fieldDeclaration.getAST().newModifier(ModifierKeyword.PRIVATE_KEYWORD);
      fieldDeclaration.modifiers().add(privateModifier);
      typeDeclaration.bodyDeclarations().add(fieldDeclaration);
    } catch (Exception e) {
View Full Code Here

              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;
               
                ClassInstanceCreation newClassInstanceCreation = vdf.getAST().newClassInstanceCreation();
                Type newType = JDTUtils.createQualifiedType(vdf.getAST(), toClass);
                newClassInstanceCreation.setType(newType);
                List arguments = newClassInstanceCreation.arguments();
                arguments.clear();
               
                MethodInvocation initializer = (MethodInvocation) vdf.getInitializer();
View Full Code Here

public class JDTUtils {

  public static Type createQualifiedType(AST ast, String targetClass) {
    String[] parts = targetClass.split("\\."); //$NON-NLS-1$

    Type type = null;

    for (int i = 0; i < parts.length; i++) {
      SimpleName name = ast.newSimpleName(parts[i]);
      if (i == 0) {
        type = ast.newSimpleType(name);
View Full Code Here

      return false;
    }

    for (int i = 0; i < signature.length; i++) {
      SingleVariableDeclaration var = (SingleVariableDeclaration) method.parameters().get(i);
      Type type = var.getType();

      ITypeBinding typeBinding = type.resolveBinding();

      if (!(typeBinding.getQualifiedName().toString().equals(signature[i]))) {
        return false;
      }
    }
View Full Code Here

  private String[] getSignature(MethodDeclaration methodDeclaration) {
    List<String> params = new ArrayList<String>();
   
    for (int i = 0; i < methodDeclaration.parameters().size(); i++) {
      SingleVariableDeclaration var = (SingleVariableDeclaration) methodDeclaration.parameters().get(i);
      Type type = var.getType();

      ITypeBinding typeBinding = type.resolveBinding();
      String param = typeBinding.getQualifiedName().toString();
      params.add(param);
    }
   
    return params.toArray(new String[params.size()]);
View Full Code Here

    return ast.newSimpleName(name + suffix);
  }

  @Override
  public void writeTo(AST ast, MethodDeclaration declaration) {
    Type type = toType(ast);
    declaration.setReturnType2(type);
  }
View Full Code Here

  @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);
View Full Code Here

TOP

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

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.