Package org.eclipse.text.edits

Examples of org.eclipse.text.edits.TextEdit


  private void rewriteAST(ICompilationUnit unit, ASTRewrite astRewrite,
      ImportRewrite importRewrite) {
    try {
      final MultiTextEdit edit = new MultiTextEdit();
      final TextEdit astEdit = astRewrite.rewriteAST();

      if (!this.isEmptyEdit(astEdit))
        edit.addChild(astEdit);
      final TextEdit importEdit = importRewrite
          .rewriteImports(new NullProgressMonitor());
      if (!this.isEmptyEdit(importEdit))
        edit.addChild(importEdit);
      if (this.isEmptyEdit(edit))
        return;
View Full Code Here


      return;
    }

    String lineSeparator = getLineEnding(code);

    TextEdit te = formatter.format(CodeFormatter.K_COMPILATION_UNIT + CodeFormatter.F_INCLUDE_COMMENTS, code,
        0, code.length(), 0, lineSeparator);
    if (te == null) {
      rc.skippedCount++;
      log.debug("Code cannot be formatted. Possible cause "
          + "is unmatched source/target/compliance version.");
      return;
    }

    IDocument doc = new Document(code);
    te.apply(doc);
    String formattedCode = doc.get();
    String formattedHash = md5hash(formattedCode);
    hashCache.setProperty(path, formattedHash);

    if (originalHash.equals(formattedHash)) {
View Full Code Here

          node.setLiteralValue(newServletName);
        }
      }
    });
    // 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));
    }
View Full Code Here

   private static String _format(String contents, CodeFormatter codeFormatter)
   {
      IDocument doc = new Document(contents);
      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

   public String toString()
   {
      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

   public String toString()
   {
      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

   private static String formatFile(String contents, CodeFormatter codeFormatter)
   {
      IDocument doc = new Document(contents);
      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

            String contents = new String(org.eclipse.jdt.internal.compiler.util.Util.getFileCharContent(file,
                    fileEncoding));
            doc.set(contents);

            // create delta
            TextEdit edit = codeFormatter.format(CodeFormatter.K_COMPILATION_UNIT, contents, 0, contents.length(), 0,
                    lineSeperator);

            // apply changes to content
            edit.apply(doc);

            BufferedWriter out = new BufferedWriter(new FileWriter(file));

            try {
                out.write(doc.get());
View Full Code Here

      // retrieve the buffer
      IDocument document = textFileBuffer
          .getDocument();

      // ask the textEditProvider for the change information
      TextEdit edit = textEditProvider.getTextEdit(document);

      // apply the changes to the document
      edit.apply(document);

      // write the changes from the buffer to the file
      textFileBuffer
          .commit(null /* ProgressMonitor */, false /* Overwrite */);

 
View Full Code Here

TOP

Related Classes of org.eclipse.text.edits.TextEdit

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.