Examples of TextEdit


Examples of org.eclipse.text.edits.TextEdit

      String str= this.prefix + nodeString + this.suffix;
     
      Position pos1= new Position(this.start, nodeStart + 1 - this.start);
      Position pos2= new Position(nodeEnd, 2);

      TextEdit res= formatString(CodeFormatter.K_STATEMENTS, str, 0, str.length(), indent);
      if (res != null) {
        str= evaluateFormatterEdit(str, res, new Position[] { pos1, pos2 });
      }
      return new String[] {
        str.substring(pos1.offset + 1, pos1.offset + pos1.length - 1),
View Full Code Here

Examples of org.eclipse.text.edits.TextEdit

   * @param snippet the code snippet
   * @return the formatted code snippet
   */
  private String formatCodeSnippet(String snippet) {
    String lineDelimiter= TextUtilities.getDefaultLineDelimiter(getDocument());
    TextEdit edit= CommentFormatterUtil.format2(CodeFormatter.K_UNKNOWN, snippet, 0, lineDelimiter, this.preferences.getMap());
    if (edit != null)
      snippet= CommentFormatterUtil.evaluateFormatterEdit(snippet, edit, null);
    return snippet;
  }
View Full Code Here

Examples of org.eclipse.text.edits.TextEdit

   
    return internalRewriteAST(content, lineInfo, lineDelim, astRoot.getCommentList(), options, rootNode);
  }
 
  private TextEdit internalRewriteAST(char[] content, LineInformation lineInfo, String lineDelim, List commentNodes, Map options, ASTNode rootNode) {
    TextEdit result= new MultiTextEdit();
    //validateASTNotModified(rootNode);
   
    TargetSourceRangeComputer sourceRangeComputer= getExtendedSourceRangeComputer();
    this.eventStore.prepareMovedNodes(sourceRangeComputer);
   
View Full Code Here

Examples of org.eclipse.text.edits.TextEdit

          String curr= (String) this.removedImports.get(i);
          computer.removeImport(curr.substring(1), STATIC_PREFIX == curr.charAt(0));
        }
      }
       
      TextEdit result= computer.getResultingEdits(new SubProgressMonitor(monitor, 1));
      this.createdImports= computer.getCreatedImports();
      this.createdStaticImports= computer.getCreatedStaticImports();
      return result;
    } finally {
      monitor.done();
View Full Code Here

Examples of org.eclipse.text.edits.TextEdit

   * @param options options
   * @throws IllegalArgumentException if the rewrite fails
   * @return Returns the edit describing the text changes.
   */
  public TextEdit rewriteAST(IDocument document, Map options) {
    TextEdit result = new MultiTextEdit();
   
    final CompilationUnit rootNode = getRootNode();
    if (rootNode != null) {
      TargetSourceRangeComputer xsrComputer = new TargetSourceRangeComputer() {
        /**
 
View Full Code Here

Examples of org.eclipse.text.edits.TextEdit

       
    ASTRewrite rewriter= sortCompilationUnit(ast, null);
    if (rewriter == null)
      return document.get();
   
    TextEdit edits = rewriter.rewriteAST(document, null);
   
    RangeMarker[] markers = null;
    if (this.positions != null) {
      markers = new RangeMarker[this.positions.length];
      for (int i = 0, max = this.positions.length; i < max; i++) {
        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

Examples of org.eclipse.text.edits.TextEdit

      return;
    }
    TextEdit[] children= parent.getChildren();
    // First dive down to find the right parent.
    for (int i= 0; i < children.length; i++) {
      TextEdit child= children[i];
      if (covers(child, edit)) {
        insert(child, edit);
        return;
      }
    }
    // We have the right parent. Now check if some of the children have to
    // be moved under the new edit since it is covering it.
    for (int i= children.length - 1; i >= 0; i--) {
      TextEdit child= children[i];
      if (covers(edit, child)) {
        parent.removeChild(i);
        edit.addChild(child);
      }
    }
View Full Code Here

Examples of org.eclipse.text.edits.TextEdit

    final char[] compilationUnitSource = string.toCharArray();
   
    this.scribe.initializeScanner(compilationUnitSource);

    TextEdit result = null;
    try {
      result = region.format(this.preferences.initial_indentation_level, true);
    } catch(AbortFormatting e){
      return failedToFormat();
    }
View Full Code Here

Examples of org.eclipse.text.edits.TextEdit

        System.out.println(Messages.bind(Messages.CommandLineFormatting, file.getAbsolutePath()));
      }
      String contents = new String(org.aspectj.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, 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

Examples of org.eclipse.text.edits.TextEdit

      Assert.isTrue(false, "Failed to locate " + elementToRemove.getElementName() + " in " + cu.getElementName()); //$NON-NLS-1$//$NON-NLS-2$
    IDocument document = getDocument(cu);
    AST ast = astCU.getAST();
    ASTRewrite rewriter = ASTRewrite.create(ast);
    rewriter.remove(node, null);
     TextEdit edits = rewriter.rewriteAST(document, null);
     try {
       edits.apply(document);
     } catch (BadLocationException e) {
       throw new JavaModelException(e, IJavaModelStatusConstants.INVALID_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.