Package org.eclipse.jdt.core.dom.rewrite

Examples of org.eclipse.jdt.core.dom.rewrite.ASTRewrite


  }

  @Override
  protected ASTRewrite getRewrite() throws CoreException {
    AST ast = decl.getAST();
    ASTRewrite rewrite = ASTRewrite.create(ast);
    String qualifierTypeName = Qualifier.class.getCanonicalName();
    if (!ProposalCalculatorUtil.containsImport(getCompilationUnit(), qualifierTypeName)) {
      CompilationUnit astRoot = ASTResolving.findParentCompilationUnit(decl);
      ImportRewrite importRewrite = createImportRewrite(astRoot);
      importRewrite.addImport(qualifierTypeName);
    }

    SingleMemberAnnotation annotation = ast.newSingleMemberAnnotation();
    SimpleName typeName = ast.newSimpleName("Qualifier");
    StringLiteral beanValue = ast.newStringLiteral();
    // beanValue.setLiteralValue("beanName");
    annotation.setTypeName(typeName);
    // SimpleName beanValue = ast.newSimpleName("beanName");
    annotation.setValue(beanValue);

    setTrackPosition(new StringLiteralTrackedPosition(rewrite.track(beanValue)));

    rewrite.replace(annotationNode, annotation, null);

    return rewrite;
  }
View Full Code Here


  @SuppressWarnings("unchecked")
  @Override
  protected ASTRewrite getRewrite() throws CoreException {
    CompilationUnit astRoot = ASTResolving.findParentCompilationUnit(decl);
    ASTRewrite astRewrite = ASTRewrite.create(astRoot.getAST());

    AST ast = astRewrite.getAST();

    ImportRewrite importRewrite = createImportRewrite(astRoot);
    if (params.length == 0) {
      createAnnotation(Autowired.class.getCanonicalName(), Autowired.class.getSimpleName(), astRoot, ast,
          astRewrite, importRewrite, false, null);
    }
    else {
      NormalAnnotation autowiredAnnotation = (NormalAnnotation) createAnnotation(Autowired.class
          .getCanonicalName(), Autowired.class.getSimpleName(), astRoot, ast, astRewrite, importRewrite,
          true, null);

      for (int i = 0; i < params.length; i++) {
        switch (params[i]) {
        case REQUIRED:
          MemberValuePair requiredValue = ast.newMemberValuePair();
          requiredValue.setName(ast.newSimpleName("required"));
          requiredValue.setValue(ast.newBooleanLiteral(false));
          addLinkedPosition(astRewrite.track(requiredValue.getValue()), i == 0, "Autowire");
          autowiredAnnotation.values().add(requiredValue);
          break;
        // case QUALIFIER:
        // SingleMemberAnnotation qualifierAnnotation =
        // (SingleMemberAnnotation) createAnnotation(
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.core.dom.rewrite.ASTRewrite

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.