Package org.eclipse.text.edits

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


      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


         @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

      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

      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

        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

    ASTNode placeHolder = rewrite.createStringPlaceholder("//mycomment",
        ASTNode.COMMENT);
    listRewrite.insertFirst(placeHolder, null);

    TextEdit textEdits = rewrite.rewriteAST(document, null);
    textEdits.apply(document);
    checkResult("<?php\n class A { \n  //mycomment\n  public function foo(int $a){}\n }?> ");
  }

  public void testException() throws Exception {
    String str = "<?php\n function A() { throw new Exception(); }";
View Full Code Here

    return PHPVersion.PHP5;
  }

  protected final void rewrite() throws Exception {
    TextEdit edits = program.rewrite(document, null);
    edits.apply(document);
  }

  protected final void checkResult(String expected) {
    String actual = document.get();
    String diff = PHPCoreTests.compareContentsIgnoreWhitespace(expected,
View Full Code Here

    return PHPVersion.PHP5;
  }

  private void rewrite(Program program, IDocument document) throws Exception {
    TextEdit edits = program.rewrite(document, null);
    edits.apply(document);
  }

  public <T extends ASTNode> List<T> getAllOfType(Program program,
      final Class<T> nodeClass) {
    final List<T> list = new ArrayList<T>();
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

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.