Examples of TextEdit


Examples of org.eclipse.text.edits.TextEdit

        DefaultCodeFormatterConstants.TRUE);

    // instantiate the default code formatter with the given options
    final CodeFormatter codeFormatter = ToolFactory
        .createCodeFormatter(options);
    final TextEdit editCode = codeFormatter.format(
        CodeFormatter.K_COMPILATION_UNIT
            | CodeFormatter.F_INCLUDE_COMMENTS, source, 0,
        source.length(), 0, System.getProperty("line.separator"));

    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

Examples of org.eclipse.text.edits.TextEdit

      String source = icu.getSource();
      Document document = new Document(source);

      // computation of the text edits
      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

Examples of org.eclipse.text.edits.TextEdit

        public String addStaticImport(String declaringTypeName, String simpleName, boolean isField) {
            return fImportsRewrite.addStaticImport(declaringTypeName, simpleName, isField);
        }

        /* package */void create(boolean needsSave, IProgressMonitor monitor) throws CoreException {
            TextEdit edit = fImportsRewrite.rewriteImports(monitor);
            JavaModelUtil.applyEdit(fImportsRewrite.getCompilationUnit(), edit, needsSave, null);
        }
View Full Code Here

Examples of org.eclipse.text.edits.TextEdit

    }
    this.preferences.initial_indentation_level = indentationLevel;

    this.newCodeFormatter = new CodeFormatterVisitor(this.preferences, this.options, regions, this.codeSnippetParsingUtil, includeComments);

    TextEdit textEdit = this.newCodeFormatter.format(source, expression);
    return textEdit;
  }
View Full Code Here

Examples of org.eclipse.text.edits.TextEdit

  final void doCopySourcePreVisit(CopySourceInfo[] infos, Stack nodeEndStack) {
    if (infos != null) {
      for (int i= 0; i < infos.length; i++) {
        CopySourceInfo curr= infos[i];
        TextEdit edit= getCopySourceEdit(curr);
        addEdit(edit);
        this.currentEdit= edit;
        nodeEndStack.push(curr.getNode());
      }
    }
View Full Code Here

Examples of org.eclipse.text.edits.TextEdit

    return internalRewriteAST(content, lineInfo, lineDelim, astRoot.getCommentList(), options, rootNode, (RecoveryScannerData)astRoot.getStatementsRecoveryData());
  }

  private TextEdit internalRewriteAST(char[] content, LineInformation lineInfo, String lineDelim, List commentNodes, Map options, ASTNode rootNode, RecoveryScannerData recoveryScannerData) {
    TextEdit result= new MultiTextEdit();
    //validateASTNotModified(rootNode);

    TargetSourceRangeComputer sourceRangeComputer= getExtendedSourceRangeComputer();
    this.eventStore.prepareMovedNodes(sourceRangeComputer);
View Full Code Here

Examples of org.eclipse.text.edits.TextEdit

   * @param options the given 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

          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

    TargetSourceRangeComputer.SourceRange range= getExtendedRange(node);
    return range.getStartPosition() + range.getLength();
  }

  final TextEdit getCopySourceEdit(CopySourceInfo info) {
    TextEdit edit= (TextEdit) this.sourceCopyInfoToEdit.get(info);
    if (edit == null) {
      SourceRange range= getExtendedRange(info.getNode());
      int start= range.getStartPosition();
      int end= start + range.getLength();
      if (info.isMove) {
View Full Code Here

Examples of org.eclipse.text.edits.TextEdit

  final void doTextInsert(int offset, String insertString, TextEditGroup editGroup) {
    if (insertString.length() > 0) {
      // bug fix for 95839: problem with inserting at the end of a line comment
      if (this.lineCommentEndOffsets.isEndOfLineComment(offset, this.content)) {
        if (!insertString.startsWith(getLineDelimiter())) {
          TextEdit edit= new InsertEdit(offset, getLineDelimiter())// add a line delimiter
          addEdit(edit);
          if (editGroup != null) {
            addEditGroup(editGroup, edit);
          }
        }
        this.lineCommentEndOffsets.remove(offset); // only one line delimiter per line comment required
      }
      TextEdit edit= new InsertEdit(offset, insertString);
      addEdit(edit);
      if (editGroup != null) {
        addEditGroup(editGroup, edit);
      }
    }
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.