Package org.eclipse.wst.sse.core.internal.provisional.text

Examples of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion


  }

  /**
   */
  public boolean isClosed() {
    IStructuredDocumentRegion flatNode = getStructuredDocumentRegion();
    if (flatNode == null)
      return true; // will be generated
    String regionType = StructuredDocumentRegionUtil.getLastRegionType(flatNode);
    return (regionType == DOMRegionContext.XML_COMMENT_CLOSE || isNestedCommentClose(regionType));
  }
View Full Code Here


  public int getStartOffset(Node node) {
    if ((node == null) || !(node instanceof IDOMText)) {
      return -1;
    }

    IStructuredDocumentRegion fnode = ((IDOMText) node).getFirstStructuredDocumentRegion();
    return fnode.getStartOffset();
  }
View Full Code Here

  }

  private void getInsertRequiredAttrs(List proposals, ISourceViewer viewer, int offset) {
    IDOMNode node = (IDOMNode) getNodeAt(viewer, offset);
    if ((node != null) && (node.getNodeType() == Node.ELEMENT_NODE)) {
      IStructuredDocumentRegion startStructuredDocumentRegion = node.getStartStructuredDocumentRegion();
      if ((startStructuredDocumentRegion != null) && startStructuredDocumentRegion.containsOffset(offset)) {
        IDOMNode cursorNode = (IDOMNode) getNodeAt(viewer, offset);
        List requiredAttrs = getRequiredAttrs(cursorNode);
        if (requiredAttrs.size() > 0) {
          NamedNodeMap currentAttrs = node.getAttributes();
          List insertAttrs = new ArrayList();
View Full Code Here

    }
  }

  private void getLocalRenameQuickAssistProposal(List proposals, ISourceViewer viewer, int offset) {
    IDOMNode node = (IDOMNode) getNodeAt(viewer, offset);
    IStructuredDocumentRegion startStructuredDocumentRegion = node == null ? null : node.getStartStructuredDocumentRegion();
    IStructuredDocumentRegion endStructuredDocumentRegion = node == null ? null : node.getEndStructuredDocumentRegion();

    ITextRegion region = null;
    int regionTextEndOffset = 0;
    if ((startStructuredDocumentRegion != null) && startStructuredDocumentRegion.containsOffset(offset)) {
      region = startStructuredDocumentRegion.getRegionAtCharacterOffset(offset);
      regionTextEndOffset = startStructuredDocumentRegion.getTextEndOffset(region);
    }
    else if ((endStructuredDocumentRegion != null) && endStructuredDocumentRegion.containsOffset(offset)) {
      region = endStructuredDocumentRegion.getRegionAtCharacterOffset(offset);
      regionTextEndOffset = endStructuredDocumentRegion.getTextEndOffset(region);
    }

    if ((region != null) && ((region.getType() == DOMRegionContext.XML_TAG_NAME) || (region.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME)) && (offset <= regionTextEndOffset)) {
      proposals.add(new RenameInFileQuickAssistProposal());
    }
View Full Code Here

   * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#apply(org.eclipse.jface.text.ITextViewer,
   *      char, int, int)
   */
  public void apply(ITextViewer viewer, char trigger, int stateMask, int offset) {
    IDOMNode node = (IDOMNode) ContentAssistUtils.getNodeAt(viewer, offset);
    IStructuredDocumentRegion startStructuredDocumentRegion = node.getStartStructuredDocumentRegion();
    int index = startStructuredDocumentRegion.getEndOffset();
    ITextRegion lastRegion = startStructuredDocumentRegion.getLastRegion();
    if (lastRegion.getType() == DOMRegionContext.XML_TAG_CLOSE) {
      index--;
      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 = 0; i < fRequiredAttrs.size(); i++) {
        CMAttributeDeclaration attrDecl = (CMAttributeDeclaration) fRequiredAttrs.get(i);
View Full Code Here

    if (nextText == null && prevText == null)
      return;
    if (nextText != null && prevText != null) {
      // consecutive Text nodes created by setupContext(),
      // concat them
      IStructuredDocumentRegion flatNode = nextText.getStructuredDocumentRegion();
      if (flatNode != null)
        prevText.appendStructuredDocumentRegion(flatNode);
      Node newNext = next.getNextSibling();
      parent.removeChild(next);
      next = null;
View Full Code Here

  private void removeStructuredDocumentRegion(IStructuredDocumentRegion oldStructuredDocumentRegion) {
    NodeImpl next = (NodeImpl) this.context.getNextNode();
    if (next != null) {
      short nodeType = next.getNodeType();
      if (nodeType != Node.ELEMENT_NODE) {
        IStructuredDocumentRegion flatNode = next.getStructuredDocumentRegion();
        if (flatNode == oldStructuredDocumentRegion) {
          removeNode(next);
          return;
        }
        if (nodeType != Node.TEXT_NODE) {
          throw new StructuredDocumentRegionManagementException();
        }
        if (flatNode == null) {
          // this is the case for empty Text
          // remove and continue
          removeNode(next);
          removeStructuredDocumentRegion(oldStructuredDocumentRegion);
          return;
        }
        TextImpl text = (TextImpl) next;
        boolean isShared = text.isSharingStructuredDocumentRegion(oldStructuredDocumentRegion);
        if (isShared) {
          // make sure there is next Text node sharing this
          TextImpl nextText = (TextImpl) this.context.findNextText();
          if (nextText == null || !nextText.hasStructuredDocumentRegion(oldStructuredDocumentRegion)) {
            isShared = false;
          }
        }
        oldStructuredDocumentRegion = text.removeStructuredDocumentRegion(oldStructuredDocumentRegion);
        if (oldStructuredDocumentRegion == null) {
          throw new StructuredDocumentRegionManagementException();
        }
        if (text.getStructuredDocumentRegion() == null) {
          // this is the case partial IStructuredDocumentRegion is
          // removed
          removeNode(text);
        }
        else {
          // notify the change
          text.notifyValueChanged();
        }
        // if shared, continue to remove IStructuredDocumentRegion
        // from them
        if (isShared)
          removeStructuredDocumentRegion(oldStructuredDocumentRegion);
        return;
      }

      ElementImpl element = (ElementImpl) next;
      if (element.hasStartTag()) {
        IStructuredDocumentRegion flatNode = element.getStartStructuredDocumentRegion();
        if (flatNode != oldStructuredDocumentRegion) {
          throw new StructuredDocumentRegionManagementException();
        }
        if (element.hasEndTag() || element.hasChildNodes()) {
          element.setStartStructuredDocumentRegion(null);
          removeStartTag(element);
        }
        else {
          removeNode(element);
        }
      }
      else {
        Node child = element.getFirstChild();
        if (child != null) {
          this.context.setNextNode(child);
          removeStructuredDocumentRegion(oldStructuredDocumentRegion);
          return;
        }

        if (!element.hasEndTag()) {
          // implicit element
          removeNode(element);
          removeStructuredDocumentRegion(oldStructuredDocumentRegion);
          return;
        }

        IStructuredDocumentRegion flatNode = element.getEndStructuredDocumentRegion();
        if (flatNode != oldStructuredDocumentRegion) {
          throw new StructuredDocumentRegionManagementException();
        }
        removeNode(element);
      }
      return;
    }

    Node parent = this.context.getParentNode();
    if (parent == null || parent.getNodeType() != Node.ELEMENT_NODE) {
      throw new StructuredDocumentRegionManagementException();
    }

    ElementImpl end = (ElementImpl) parent;
    if (end.hasEndTag()) {
      IStructuredDocumentRegion flatNode = end.getEndStructuredDocumentRegion();
      if (flatNode != oldStructuredDocumentRegion) {
        throw new StructuredDocumentRegionManagementException();
      }
      if (!end.hasStartTag() && !end.hasChildNodes()) {
        this.context.setNextNode(end);
View Full Code Here

    if (oldCount > 0) {
      setupContext(oldStructuredDocumentRegions.item(0));
      // Node startParent = this.context.getParentNode();

      for (int i = 0; i < oldCount; i++) {
        IStructuredDocumentRegion documentRegion = oldStructuredDocumentRegions.item(i);
        removeStructuredDocumentRegion(documentRegion);
      }
    }
    else {
      if (newCount == 0)
        return;
      setupContext(newStructuredDocumentRegions.item(0));
    }
    // make sure the parent is set to deepest level
    // when end tag has been removed
    this.context.setLast();

    if (newCount > 0) {
      for (int i = 0; i < newCount; i++) {
        IStructuredDocumentRegion documentRegion = newStructuredDocumentRegions.item(i);
        insertStructuredDocumentRegion(documentRegion);
      }
    }

    cleanupText();
View Full Code Here

    if (flatNode instanceof StructuredDocumentRegionContainer) {
      StructuredDocumentRegionContainer container = (StructuredDocumentRegionContainer) flatNode;
      int n = container.getStructuredDocumentRegionCount();
      for (int i = 0; i < n; i++) {
        IStructuredDocumentRegion c = container.getStructuredDocumentRegion(i);
        if (c == null) {
          reportError("null"); //$NON-NLS-1$
          continue;
        }
        checkStructuredDocumentRegion(c);
      }
      return;
    }

    int start = flatNode.getStart();
    if (start < this.offset)
      reportError("overwrap"); //$NON-NLS-1$
    if (start > this.offset)
      reportError("gap"); //$NON-NLS-1$
    int end = flatNode.getEnd();
    this.offset = end;

    if (flatNode instanceof StructuredDocumentRegionProxy) {
      StructuredDocumentRegionProxy proxy = (StructuredDocumentRegionProxy) flatNode;
      IStructuredDocumentRegion p = proxy.getStructuredDocumentRegion();
      if (p == null) {
        reportError("null"); //$NON-NLS-1$
        return;
      }
      int s = p.getStart();
      int e = p.getEnd();
      if (s > start || e < end)
        reportError("out"); //$NON-NLS-1$
      if (s == start && e == end)
        reportWarning("vain"); //$NON-NLS-1$
    }
View Full Code Here

        && (node.getParentNode() != null)) {
      node = node.getParentNode();
    }
    IDOMNode xmlnode = (IDOMNode) node;
    ContentAssistRequest contentAssistRequest = null;
    IStructuredDocumentRegion sdRegion = getStructuredDocumentRegion(documentPosition);
    ITextRegion completionRegion = getCompletionRegion(documentPosition,
        node);

    String matchString = getMatchString(sdRegion, completionRegion,
        documentPosition);
View Full Code Here

TOP

Related Classes of org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion

Copyright © 2018 www.massapicom. 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.