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

Examples of org.eclipse.jdt.core.dom.rewrite.ImportRewrite.addImport()


        // add import
        try
        {
            ImportRewrite rewrite = CodeStyleConfiguration.createImportRewrite(
                fCompilationUnit, true);
            rewrite.addImport(result.getClassName());
            JavaModelUtil.applyEdit(fCompilationUnit, rewrite.rewriteImports(null),
                false, null);
        }
        catch (CoreException e)
        {
View Full Code Here


        for (final Iterator emit = ecd.modifiers().iterator(); emit
            .hasNext();) {
          final Object o = emit.next();
          if (o instanceof Annotation) {
            final Annotation anno = (Annotation) o;
            final String newName = importRewrite
                .addImport((String) annotationToQualifiedNameMap
                    .get(anno));
            anno.setTypeName(ast.newName(newName));
          }
        }
View Full Code Here

    listRewrite.insertFirst(annotation, null);
   
    TextEdit importEdits = null;
    if (importDeclaration != null) {
      ImportRewrite importRewrite = ImportRewrite.create(compilationUnit, true);
      importRewrite.addImport(importDeclaration.getName().getFullyQualifiedName());
      importEdits = importRewrite.rewriteImports(null);
    }
   
    Map options = compilationUnit.getJavaProject().getOptions(true);
    TextEdit edits = rewrite.rewriteAST(document, options);
View Full Code Here

    listRewrite.insertFirst(annotation, null);
   
    TextEdit importEdits = null;
    if (importDeclaration != null) {
      ImportRewrite importRewrite = ImportRewrite.create(compilationUnit, true);
      importRewrite.addImport(importDeclaration.getName().getFullyQualifiedName());
      importEdits = importRewrite.rewriteImports(null);
    }
   
    Map options = compilationUnit.getJavaProject().getOptions(true);
    TextEdit edits = rewrite.rewriteAST(document, options);
View Full Code Here

    maintainValuesProperty(normalAnnotation, memberValues, ast, rewrite);

    TextEdit importEdits = null;
    ImportRewrite importRewrite = ImportRewrite.create(compilationUnit, true);
    importRewrite.addImport(importDeclaration.getName().getFullyQualifiedName());
    importEdits = importRewrite.rewriteImports(null);
   
    Map options = compilationUnit.getJavaProject().getOptions(true);
    TextEdit edits = rewrite.rewriteAST(document, options);
   
View Full Code Here

    maintainValuesProperty(normalAnnotation, memberValues, ast, rewrite);

    TextEdit importEdits = null;
    ImportRewrite importRewrite = ImportRewrite.create(compilationUnit, true);
    importRewrite.addImport(importDeclaration.getName().getFullyQualifiedName());
    importEdits = importRewrite.rewriteImports(null);
   
    Map options = compilationUnit.getJavaProject().getOptions(true);
    TextEdit edits = rewrite.rewriteAST(document, options);
   
View Full Code Here

        IJavaProject javaProject = src.getJavaProject();

        MultiTextEdit edit = new MultiTextEdit();
        ImportRewrite imports = StubUtility.createImportRewrite(cu, true);
        imports.addStaticImport("org.junit.Assert", "*", false);
        imports.addImport(JUnitCorePlugin.JUNIT4_ANNOTATION_NAME);
        edit.addChild(imports.rewriteImports(null));

        AST ast = cu.getAST();
        ASTRewrite astRewrite = ASTRewrite.create(ast);
        ASTNode node = cu.findDeclaringNode(typeBinding);
View Full Code Here

      edits = new MultiTextEdit();
      ImportRewrite importRewrite = StubUtility.createImportRewrite(astRoot, true);
      ImportRewriteContext context = new ContextSensitiveImportRewriteContext(
          astRoot, offset, importRewrite);
      String res = importRewrite.addImport(type, context);
      if (type.equals(res)){
        return CodeGenerationMessages.AddImportsOperation_error_importclash;
      }

      TextEdit rewrite = importRewrite.rewriteImports(null);
View Full Code Here

    AST ast = astRewrite.getAST();

    String importName = ResponseBody.class.getCanonicalName();
    if (!ProposalCalculatorUtil.containsImport(getCompilationUnit(), importName)) {
      ImportRewrite importRewrite = createImportRewrite(astRoot);
      importRewrite.addImport(importName);
    }

    MarkerAnnotation annotation = ast.newMarkerAnnotation();
    annotation.setTypeName(ast.newSimpleName("ResponseBody"));
View Full Code Here

  public static TextEdit getTextEditForImport(ICompilationUnit cu, String importTypeNString) {
    try {
      IImportDeclaration requestMappingDecl = cu.getImport(importTypeNString);
      if (requestMappingDecl == null || !requestMappingDecl.exists()) {
        ImportRewrite importRewrite = StubUtility.createImportRewrite(cu, true);
        importRewrite.addImport(importTypeNString);
        return importRewrite.rewriteImports(null);
      }

    }
    catch (JavaModelException e) {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.