Package org.eclipse.text.edits

Examples of org.eclipse.text.edits.TextEdit.apply()


        markers[i]= new RangeMarker(this.positions[i], 0);
        insert(edits, markers[i]);
      }
    }
    try {
      edits.apply(document, TextEdit.UPDATE_REGIONS);
      if (this.positions != null) {
        for (int i= 0, max = markers.length; i < max; i++) {
          this.positions[i]= markers[i].getOffset();
        }
      }
View Full Code Here


         @SuppressWarnings("rawtypes")
         Map options = JavaCore.getOptions();
         options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7);
         options.put(CompilerOptions.OPTION_Encoding, "UTF-8");
         TextEdit edit = unit.rewrite(document, options);
         edit.apply(document);
      }
      catch (Exception e)
      {
         throw new ParserException("Could not modify source: " + unit.toString(), e);
      }
View Full Code Here

      try
      {
         TextEdit edit = codeFormatter.format(CodeFormatter.K_COMPILATION_UNIT, contents, 0, contents.length(), 0, null);
         if (edit != null)
         {
            edit.apply(doc);
         }
         else
         {
            return contents;
         }
View Full Code Here

      Document document = new Document(this.document.get());

      try
      {
         TextEdit edit = unit.rewrite(document, null);
         edit.apply(document);
      }
      catch (Exception e)
      {
         throw new ParserException("Could not modify source: " + unit.toString(), e);
      }
View Full Code Here

      String contents = new String(org.eclipse.jdt.internal.compiler.util.Util.getFileCharContent(file, null));
      // format the file (the meat and potatoes)
      doc.set(contents);
      TextEdit edit = codeFormatter.format(CodeFormatter.K_COMPILATION_UNIT | CodeFormatter.F_INCLUDE_COMMENTS, contents, 0, contents.length(), 0, null);
      if (edit != null) {
        edit.apply(doc);
      } else {
        System.err.println(Messages.bind(Messages.FormatProblem, file.getAbsolutePath()));
        return;
      }
View Full Code Here

        System.out.println(originalList);
        System.out.println(listRewrite.getRewrittenList());
      }
    }
    TextEdit rewriteAst = rewriter.rewriteAST(doc, null);
    rewriteAst.apply(doc);
    System.out.println(doc.get());
  }


  private ASTNode createNode(AST ast) {
View Full Code Here

        addTagToJavaDoc(clazz, declaratingNode, ast);

        Document document = new Document();
        document.set(jdtUnit.getSource());
        TextEdit edits = unit.rewrite(document,jdtUnit.getJavaProject().getOptions(true));
        edits.apply(document);
        String newSource = document.get();
        ICompilationUnit workingCopy = jdtUnit.getWorkingCopy(monitor);
        IBuffer buffer = workingCopy.getBuffer();
        buffer.setContents(newSource);
        workingCopy.commitWorkingCopy(true, monitor);
View Full Code Here

      Document document = new Document(this.document.get());

      try
      {
         TextEdit edit = unit.rewrite(document, null);
         edit.apply(document);
      }
      catch (Exception e)
      {
         throw new ParserException("Could not modify source: " + unit.toString(), e);
      }
View Full Code Here

         @SuppressWarnings("rawtypes")
         Map options = JavaCore.getOptions();
         options.put(CompilerOptions.OPTION_Source, CompilerOptions.VERSION_1_7);
         options.put(CompilerOptions.OPTION_Encoding, "UTF-8");
         TextEdit edit = unit.rewrite(document, options);
         edit.apply(document);
      }
      catch (Exception e)
      {
         throw new ParserException("Could not modify source: " + unit.toString(), e);
      }
View Full Code Here

      try
      {
         TextEdit edit = codeFormatter.format(CodeFormatter.K_COMPILATION_UNIT, contents, 0, contents.length(), 0, null);
         if (edit != null)
         {
            edit.apply(doc);
         }
         else
         {
            return contents;
         }
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.