Package org.eclipse.text.edits

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


    IDocument document = new Document(source);

    if (icu != null && document != null && editCode != null) {
      try {
        editCode.apply(document);
      } catch (MalformedTreeException e) {
        CrashReporter.reportException(e);
      } catch (BadLocationException e) {
        CrashReporter.reportException(e);
      }
View Full Code Here


    IDocument document = new Document(source);

    if (icu != null && document != null && editCode != null) {
      try {
        editCode.apply(document);
      } catch (MalformedTreeException e) {
        e.printStackTrace();
      } catch (BadLocationException e) {
        e.printStackTrace();
      }
View Full Code Here

    IDocument document = new Document(source);

    if (icu != null && document != null && editCode != null) {
      try {
        editCode.apply(document);
      } catch (MalformedTreeException e) {
        e.printStackTrace();
      } catch (BadLocationException e) {
        e.printStackTrace();
      }
View Full Code Here

      TextEdit edits = rewrite.rewriteAST(document, icu.getJavaProject()
          .getOptions(true));

      // computation of the new source code
      if (edits != null) {
        edits.apply(document);
      }

      String newSource = document.get();

      // update of the compilation unit
View Full Code Here

  public static String formatCode(String source) {
    TextEdit edit = getCodeFormatter().format(CodeFormatter.K_UNKNOWN, source, 0, source.length(), 0, System.getProperty("line.separator")); //$NON-NLS-1$
    if (edit != null) {
      IDocument document = new Document(source);
      try {
        edit.apply(document);
        return document.get();
      } catch (Exception e) {
        VisualSwingPlugin.getLogger().error(e);
      }
    }
View Full Code Here

      return;
    }
    try {
      IDocumentUndoManager manager = getDocumentUndoManager(document);
      manager.beginCompoundChange();
      edit.apply(document);
      manager.endCompoundChange();
    } catch (Throwable t) {
      throw new CoreException(error(t));
    }
  }
View Full Code Here

        // 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();

        // update of the compilation unit
        clientPackage.createCompilationUnit(remoteServiceAsyncName + ".java", newSource, true, monitor); //$NON-NLS-1$
View Full Code Here

       
        // 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();

        // update of the compilation unit     
        clientPackage.createCompilationUnit(remoteServiceAsyncName+".java", newSource, true, monitor); //$NON-NLS-1$
       
View Full Code Here

          null);

      // check if text formatted successfully
      if (edit != null) {
        try {
          edit.apply(doc);
          info.setBuffer(new StringBuffer(doc.get()));
        } catch (MalformedTreeException e) {
          log.warn("Error during code formatting. Illegal code edit tree (" + e.getMessage() + ").");
        } catch (BadLocationException e) {
          log.warn("Error during code formatting. Bad location (" + e.getMessage() + ").");
View Full Code Here

    // 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();

    // update of the compilation unit
    clientPackage.createCompilationUnit(remoteServiceAsyncName + ".java", newSource, true, monitor); //$NON-NLS-1$
  }
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.