Examples of MultiTextEdit


Examples of org.eclipse.text.edits.MultiTextEdit

   * @return
   */
  private TextEdit createMultiTextEdit(TextEdit[] edits) {

    if (edits.length == 0)
      return new MultiTextEdit();

    /* should not specify a limited region because other edits outside
     * these original edits might be added later.
     */
    MultiTextEdit multiEdit = new MultiTextEdit();
    for (int i = 0; i < edits.length; i++) {
      addToMultiEdit(edits[i], multiEdit);
    }
    return multiEdit;
  }
View Full Code Here

Examples of org.eclipse.text.edits.MultiTextEdit

  private void addJavaEdit(String searchDocPath, ReplaceEdit javaEdit) {
   
    Object o = this.fSearchDocPath2JavaEditMap.get(searchDocPath);
    if(o != null) {

      MultiTextEdit multi = (MultiTextEdit)o;
      multi.addChild(javaEdit);
    }
    else {
      // use a multi edit so doc position offsets get updated automatically
      // when adding multiple child edits
      MultiTextEdit multi = new MultiTextEdit();
      multi.addChild(javaEdit);
      this.fSearchDocPath2JavaEditMap.put(searchDocPath, multi);
    }
  }
View Full Code Here

Examples of org.eclipse.text.edits.MultiTextEdit

    SearchDocument delegate = null;
   
    while(keys.hasNext()) {
      // create on the fly
      searchDocPath = (String)keys.next();
      MultiTextEdit javaEdit = (MultiTextEdit)fSearchDocPath2JavaEditMap.get(searchDocPath);
      delegate = support.getSearchDocument(searchDocPath);
     
      if(delegate != null && delegate instanceof JavaSearchDocumentDelegate) {
        JavaSearchDocumentDelegate javaDelegate = (JavaSearchDocumentDelegate)delegate;
        changes.add(createChange(javaDelegate, javaDelegate.getJspTranslation().getJspEdit(javaEdit)));
View Full Code Here

Examples of org.eclipse.text.edits.MultiTextEdit

    SearchDocument delegate = null;
   
    while(keys.hasNext()) {
      // create on the fly
      searchDocPath = (String)keys.next();
      MultiTextEdit javaEdit = (MultiTextEdit)fSearchDocPath2JavaEditMap.get(searchDocPath);
      delegate = support.getSearchDocument(searchDocPath);
     
      if(delegate != null && delegate instanceof JavaSearchDocumentDelegate) {
        JavaSearchDocumentDelegate javaDelegate = (JavaSearchDocumentDelegate)delegate;
        Change change = createChange(javaDelegate, javaDelegate.getJspTranslation().getJspEdit(javaEdit), participant);
View Full Code Here

Examples of org.eclipse.text.edits.MultiTextEdit

  }

  public TextEdit format(IStructuredModel model, int start, int length, XMLFormattingPreferences preferences) {
    setFormattingPreferences(preferences);

    TextEdit edit = new MultiTextEdit();
    IStructuredDocument document = model.getStructuredDocument();
    // get initial document region
    IStructuredDocumentRegion currentRegion = document.getRegionAtCharacterOffset(start);
    if (currentRegion != null) {
      int startOffset = currentRegion.getStartOffset();
View Full Code Here

Examples of org.eclipse.text.edits.MultiTextEdit

            lastRegion = startStructuredDocumentRegion.getRegionAtCharacterOffset(index - 1);
          } else if (lastRegion.getType() == DOMRegionContext.XML_EMPTY_TAG_CLOSE) {
            index = index - 2;
            lastRegion = startStructuredDocumentRegion.getRegionAtCharacterOffset(index - 1);
          }
          MultiTextEdit multiTextEdit = new MultiTextEdit();
          try {
            for (int i = insertAttrs.size() - 1; i >= 0; i--) {
              CMAttributeDeclaration attrDecl = (CMAttributeDeclaration) insertAttrs.get(i);
              String requiredAttributeName = attrDecl.getAttrName();
              String defaultValue = attrDecl.getDefaultValue();
              if (defaultValue == null)
                defaultValue = ""; //$NON-NLS-1$
              String nameAndDefaultValue = " "; //$NON-NLS-1$
              if (i == 0 && lastRegion.getLength() > lastRegion.getTextLength())
                nameAndDefaultValue = ""; //$NON-NLS-1$
              nameAndDefaultValue += requiredAttributeName + "=\"" + defaultValue + "\""; //$NON-NLS-1$ //$NON-NLS-2$
              multiTextEdit.addChild(new InsertEdit(index, nameAndDefaultValue));
              // BUG3381: MultiTextEdit applies all child
              // TextEdit's basing on offsets
              //          in the document before the first TextEdit, not
              // after each
              //          child TextEdit. Therefore, do not need to
              // advance the index.
              //index += nameAndDefaultValue.length();
            }
            multiTextEdit.apply(newNode.getStructuredDocument());
          } catch (BadLocationException e) {
            // log for now, unless we find reason not to
            Logger.log(Logger.INFO, e.getMessage());
          }
        }
View Full Code Here

Examples of org.eclipse.text.edits.MultiTextEdit

        startTagOffset = cursorNode.getStartOffset();
        endTagOffset = cursorNode.getEndOffset();
      }

      // insert new element
      MultiTextEdit multiTextEdit = new MultiTextEdit();
      // element tag name cannot be DBCS, do not translate "<element>"
      // and "</element>"
      final String startElement = "<" + ELEMENT_NAME + ">"; //$NON-NLS-1$ //$NON-NLS-2$
      multiTextEdit.addChild(new InsertEdit(startTagOffset, startElement));
      multiTextEdit.addChild(new InsertEdit(endTagOffset, "</"+ELEMENT_NAME +">")); //$NON-NLS-1$ //$NON-NLS-2$
      multiTextEdit.apply(viewer.getDocument());
      Position start = new Position(startTagOffset);
      Position end = new Position(endTagOffset + startElement.length());

      try {
        viewer.getDocument().addPosition(start);
View Full Code Here

Examples of org.eclipse.text.edits.MultiTextEdit

    int startTagOffset = ((Integer) ((Object[]) fAdditionalFixInfo)[0]).intValue();
    int startTagLength = ((Integer) ((Object[]) fAdditionalFixInfo)[1]).intValue();
    int endTagOffset = ((Integer) ((Object[]) fAdditionalFixInfo)[2]).intValue();
    int endTagLength = ((Integer) ((Object[]) fAdditionalFixInfo)[3]).intValue();

    MultiTextEdit multiTextEdit = new MultiTextEdit();
    if (endTagOffset != -1) {
      multiTextEdit.addChild(new DeleteEdit(endTagOffset, endTagLength));
      fSelection = new Point(endTagOffset, 0);
    }
    if (startTagOffset != -1) {
      multiTextEdit.addChild(new DeleteEdit(startTagOffset, startTagLength));
      fSelection = new Point(startTagOffset, 0);
    }

    try {
      multiTextEdit.apply(viewer.getDocument());
    }
    catch (MalformedTreeException e) {
      // log for now, unless find reasons not to.
      Logger.log(Logger.INFO, e.getMessage());
    }
View Full Code Here

Examples of org.eclipse.text.edits.MultiTextEdit

      IFile file = getFile(info.getAtgEditor());
      TextFileChange textFileChange = new TextFileChange( file.getName(), file );
      rootChange.add(textFileChange);
     
      //a file change contains a tree of edits, first add the root of them
      final MultiTextEdit fileChangeRootEdit = new MultiTextEdit();
      textFileChange.setEdit(fileChangeRootEdit);   
     
      AtgAstVisitor renameCharacterVisitor = new AtgAstVisitor() {
       
        @Override
        public boolean visit(AbstractAtgAstNode node) {
         
          if (node instanceof ProductionNode &&     // production node
            (globalReformat() || localSelection(node) || localCursorPos(node)))
          {             
            ProductionNode productionNode = (ProductionNode) node;
            IEditorInput editorInput = info.getAtgEditor().getEditorInput();
            IDocumentProvider documentProvider = info.getAtgEditor().getDocumentProvider();
            IDocument document = documentProvider.getDocument(editorInput);

            String production = null;
            try {
              production = document.get
                  productionNode.getRegion().getOffset(),
                  productionNode.getRegion().getLength());
              try {
                ATGProductionReformatter atgProductionReformatter = new ATGProductionReformatter(document, productionNode, info);
                production = atgProductionReformatter.reformat();
                ReplaceEdit edit = new ReplaceEdit
                    productionNode.getRegion().getOffset(),
                    productionNode.getRegion().getLength(),
                    production);     
                fileChangeRootEdit.addChild(edit);
              } catch (Exception e) {
                e.printStackTrace();
              }
            } catch (BadLocationException e) {
              e.printStackTrace();
View Full Code Here

Examples of org.epic.perleditor.templates.textmanipulation.MultiTextEdit

   */
  public void edit(TemplateBuffer templateBuffer, TemplateContext context) throws CoreException {
    TextBuffer textBuffer = TextBuffer.create(templateBuffer.getString());
    TemplatePosition[] variables = templateBuffer.getVariables();

    MultiTextEdit positions = variablesToPositions(variables);
    MultiTextEdit multiEdit = new MultiTextEdit();

    // iterate over all variables and try to resolve them
    for (int i = 0; i != variables.length; i++) {
      TemplatePosition variable = variables[i];

      if (variable.isResolved())
        continue;

      String name = variable.getName();
      int[] offsets = variable.getOffsets();
      int length = variable.getLength();

      TemplateVariable evaluator = (TemplateVariable) fVariables.get(name);
      String value = (evaluator == null) ? null : evaluator.evaluate(context);

      if (value == null)
        continue;

      variable.setLength(value.length());
      variable.setResolved(evaluator.isResolved(context));

      for (int k = 0; k != offsets.length; k++)
        multiEdit.add(SimpleTextEdit.createReplace(offsets[k], length, value));
    }

    TextBufferEditor editor = new TextBufferEditor(textBuffer);
    editor.add(positions);
    editor.add(multiEdit);
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.