Package org.eclipse.jdt.core.dom

Examples of org.eclipse.jdt.core.dom.CompilationUnit.rewrite()


      TypeDeclaration typeDec = (TypeDeclaration) cunit.types().get(0);
      List list = typeDec.superInterfaceTypes();
      Name name = ast.newName(cName);
      Type interfaceType = ast.newSimpleType(name);
      list.add(interfaceType);
      TextEdit edits = cunit.rewrite(document, icunit.getJavaProject()
          .getOptions(true));
      edits.apply(document);
      String newSource = document.get();
      icunit.getBuffer().setContents(newSource);
    } catch (Exception e) {
View Full Code Here


        }

        bodyDeclarations.removeAll(declarationsToDelete);

        // computation of the text edits
        TextEdit edits = astRoot.rewrite(document, asyncContents.getJavaProject().getOptions(true));

        // computation of the new source code
        edits.apply(document);
        String newSource = document.get();
View Full Code Here

        }
       
        bodyDeclarations.removeAll(declarationsToDelete);
       
        // computation of the text edits
        TextEdit edits = astRoot.rewrite(document, asyncContents.getJavaProject().getOptions(true));

        // computation of the new source code
        edits.apply(document);
        String newSource = document.get();
View Full Code Here

         // modify the AST
        node.bodyDeclarations().add(createToGXT(node.getAST(), getMethods, newClass.getFullyQualifiedName()));

         // computation of the text edits
         TextEdit edits = astRoot.rewrite(document, oldCompilationUnit.getJavaProject().getOptions(true));

         // computation of the new source code
         edits.apply(document);
         String newSource = document.get();
View Full Code Here

        }
       
        bodyDeclarations.removeAll(declarationsToDelete);
       
        // computation of the text edits
        TextEdit edits = astRoot.rewrite(document, asyncContents.getJavaProject().getOptions(true));

        // computation of the new source code
        edits.apply(document);
        String newSource = document.get();
View Full Code Here

    }

    bodyDeclarations.removeAll(declarationsToDelete);

    // computation of the text edits
    TextEdit edits = astRoot.rewrite(document, asyncContents.getJavaProject().getOptions(true));

    // computation of the new source code
    edits.apply(document);
    String newSource = document.get();
View Full Code Here

        bufferManager.connect(path, null);

        ITextFileBuffer textFileBuffer = bufferManager.getTextFileBuffer(path);
        IDocument document = textFileBuffer.getDocument();

        TextEdit edit = cu.rewrite(document, javaProject.getOptions(true));
        TextFileChange dc = new TextFileChange(path.toString(), (IFile) cu.getJavaElement().getResource());
        dc.setTextType("java"); //$NON-NLS-1$
        dc.setEdit(edit);
        dc.setSaveMode(TextFileChange.FORCE_SAVE);
View Full Code Here

    // create text edits corresponding to that changes in AST
    TextEdit astTextEdit;
    {
      String source = serviceCompilationUnit.getBuffer().getContents();
      Document document = new Document(source);
      astTextEdit = serviceUnit.rewrite(document, serviceType.getJavaProject().getOptions(true));
    }
    // merge AST edit with existing edit for service type file
    {
      IFile serviceTypeFile = (IFile) serviceType.getUnderlyingResource();
      TextChange existingTextChange = getTextChange(serviceTypeFile);
View Full Code Here

    {
      String source = serviceUnit.getBuffer().getContents();
      Document document = new Document(source);
      // prepare text edits
      MultiTextEdit edits =
          (MultiTextEdit) serviceRoot.rewrite(document, javaProject.getOptions(true));
      removeAnnotations(serviceType, source, edits);
      // prepare new source code
      edits.apply(document);
      newSource = document.get();
    }
View Full Code Here

    CompilationUnit cu = (CompilationUnit) parser.createAST(null);
    cu.recordModifications();
    rewrite = ASTRewrite.create(cu.getAST());
    cu.accept(new XQASTVisitor());

    TextEdit edits = cu.rewrite(doc, null);
    try {
      edits.apply(doc);
    } catch (MalformedTreeException e) {
      e.printStackTrace();
    } catch (BadLocationException 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.