Examples of IStructuredDocument


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

      if (newAttrName.compareTo(oldAttrName) != 0) {
        int attrNameStartOffset = eachAttr.getStartOffset();
        int attrNameLength = oldAttrName.length();

        IDOMModel structuredModel = node.getModel();
        IStructuredDocument structuredDocument = structuredModel.getStructuredDocument();
        replaceSource(structuredModel, structuredDocument, attrNameStartOffset, attrNameLength, newAttrName);
      }
    }
  }
View Full Code Here

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

      newTagName = oldTagName.toLowerCase(Locale.US);
    else if (tagNameCase == HTMLCorePreferenceNames.UPPER)
      newTagName = oldTagName.toUpperCase(Locale.US);

    IDOMModel structuredModel = node.getModel();
    IStructuredDocument structuredDocument = structuredModel.getStructuredDocument();

    IStructuredDocumentRegion startTagStructuredDocumentRegion = node.getStartStructuredDocumentRegion();
    if (startTagStructuredDocumentRegion != null) {
      ITextRegionList regions = startTagStructuredDocumentRegion.getRegions();
      if (regions != null && regions.size() > 0) {
View Full Code Here

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

    if (element.isCommentTag()) {
      // do nothing
    }
    else if (isEmptyElement(element)) {
      IStructuredDocument structuredDocument = structuredModel.getStructuredDocument();
      IStructuredDocumentRegion startStructuredDocumentRegion = node.getStartStructuredDocumentRegion();
      ITextRegionList regions = startStructuredDocumentRegion.getRegions();
      ITextRegion lastRegion = regions.get(regions.size() - 1);
      replaceSource(structuredModel, structuredDocument, startStructuredDocumentRegion.getStartOffset(lastRegion), lastRegion.getLength(), EMPTY_TAG_CLOSE);

      if (regions.size() > 1) {
        ITextRegion regionBeforeTagClose = regions.get(regions.size() - 1 - 1);

        // insert a space separator before tag close if the previous
        // region does not have extra spaces
        if (regionBeforeTagClose.getTextLength() == regionBeforeTagClose.getLength())
          replaceSource(structuredModel, structuredDocument, startStructuredDocumentRegion.getStartOffset(lastRegion), 0, " "); //$NON-NLS-1$
      }
    }
    else {
      String tagName = node.getNodeName();
      String endTag = END_TAG_OPEN.concat(tagName).concat(TAG_CLOSE);

      IDOMNode lastChild = (IDOMNode) node.getLastChild();
      int endTagStartOffset = 0;
      if (lastChild != null)
        // if this node has children, insert the end tag after the
        // last child
        endTagStartOffset = lastChild.getEndOffset();
      else
        // if this node does not has children, insert the end tag
        // after the start tag
        endTagStartOffset = node.getEndOffset();

      IStructuredDocument structuredDocument = structuredModel.getStructuredDocument();
      replaceSource(structuredModel, structuredDocument, endTagStartOffset, 0, endTag);
    }

    newNode = (IDOMNode) structuredModel.getIndexedRegion(startTagStartOffset); // save
    // new
View Full Code Here

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

    String tagName = node.getNodeName();
    String startTag = START_TAG_OPEN.concat(tagName).concat(TAG_CLOSE);
    int startTagStartOffset = node.getStartOffset();

    IDOMModel structuredModel = node.getModel();
    IStructuredDocument structuredDocument = structuredModel.getStructuredDocument();
    replaceSource(structuredModel, structuredDocument, startTagStartOffset, 0, startTag);
    newNode = (IDOMNode) structuredModel.getIndexedRegion(startTagStartOffset); // save
    // new
    // node
View Full Code Here

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

      ITextRegionList regionList = flatNode.getRegions();
      ITextRegion lastRegion = regionList.get(regionList.size() - 1);
      if (lastRegion != null) {
        String regionType = lastRegion.getType();
        if ((regionType != DOMRegionContext.XML_EMPTY_TAG_CLOSE) && (regionType != DOMRegionContext.XML_TAG_CLOSE)) {
          IStructuredDocument structuredDocument = structuredModel.getStructuredDocument();

          // insert ">" after lastRegion of flatNode
          // as in "<a</a>" if flatNode is for start tag, or in
          // "<a></a" if flatNode is for end tag
          replaceSource(structuredModel, structuredDocument, flatNode.getTextEndOffset(lastRegion), 0, ">"); //$NON-NLS-1$
View Full Code Here

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

          if (isXMLType(structuredModel)) {
            // TODO: Kit, please check. Is there any way to not
            // rely on getting regions from attributes?
            String newAttrValue = "=\"" + eachAttr.getNameRegionText() + "\""; //$NON-NLS-1$ //$NON-NLS-2$

            IStructuredDocument structuredDocument = structuredModel.getStructuredDocument();
            replaceSource(structuredModel, structuredDocument, eachAttr.getNameRegionEndOffset(), 0, newAttrValue);
            newNode = (IDOMNode) structuredModel.getIndexedRegion(node.getStartOffset()); // save
            // new
            // node
          }
        }
        else {

          char quote = StringUtils.isQuoted(oldAttrValue) ? oldAttrValue.charAt(0) : DOUBLE_QUOTE;
          String newAttrValue = generator.generateAttrValue(eachAttr, quote);

          // There is a problem in
          // StructuredDocumentRegionUtil.getAttrValue(ITextRegion)
          // when the region is instanceof ContextRegion.
          // Workaround for now...
          if (oldAttrValue.length() == 1) {
            char firstChar = oldAttrValue.charAt(0);
            if (firstChar == SINGLE_QUOTE)
              newAttrValue = SINGLE_QUOTES;
            else if (firstChar == DOUBLE_QUOTE)
              newAttrValue = DOUBLE_QUOTES;
          }

          if (newAttrValue != null) {
            if (newAttrValue.compareTo(oldAttrValue) != 0) {
              int attrValueStartOffset = eachAttr.getValueRegionStartOffset();
              int attrValueLength = oldAttrValue.length();
              int startTagStartOffset = node.getStartOffset();

              IDOMModel structuredModel = node.getModel();
              IStructuredDocument structuredDocument = structuredModel.getStructuredDocument();
              replaceSource(structuredModel, structuredDocument, attrValueStartOffset, attrValueLength, newAttrValue);
              newNode = (IDOMNode) structuredModel.getIndexedRegion(startTagStartOffset); // save
              // new
              // node
            }
View Full Code Here

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

        // format children and end tag if not empty element tag
        if (lastRegion.getType() != DOMRegionContext.XML_EMPTY_TAG_CLOSE) {
          NodeList childNodes = newNode.getChildNodes();
          if (childNodes == null || childNodes.getLength() == 0 || (childNodes.getLength() == 1 && (childNodes.item(0)).getNodeType() == Node.TEXT_NODE && ((childNodes.item(0)).getNodeValue().trim().length() == 0))) {
            IDOMModel structuredModel = newNode.getModel();
            IStructuredDocument structuredDocument = structuredModel.getStructuredDocument();

            int startTagStartOffset = newNode.getStartOffset();
            int offset = endTagStructuredDocumentRegion.getStart();
            int length = endTagStructuredDocumentRegion.getLength();
            structuredDocument.replaceText(structuredDocument, offset, length, ""); //$NON-NLS-1$
            newNode = (IDOMNode) structuredModel.getIndexedRegion(startTagStartOffset); // save

            offset = startTagStructuredDocumentRegion.getStart() + lastRegion.getStart();
            structuredDocument.replaceText(structuredDocument, offset, 0, "/"); //$NON-NLS-1$
            newNode = (IDOMNode) structuredModel.getIndexedRegion(startTagStartOffset); // save
          }
        }
      }
    }
View Full Code Here

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

      return;
    if (node.getNodeType() == Node.TEXT_NODE)
      return;

    // get delimiter string
    IStructuredDocument structuredDocument = model.getStructuredDocument();
    if (structuredDocument == null)
      return;
    String delim = structuredDocument.getLineDelimiter();
    if (delim == null || delim.length() == 0)
      return;

    Node parent = node.getParentNode();
    if (parent == null)
View Full Code Here

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

  /**
   */
  private void writeModel(IDOMModel model, IFile file) throws IOException, CoreException {
    if (model == null || file == null)
      return;
    IStructuredDocument structuredDocument = model.getStructuredDocument();
    if (structuredDocument == null)
      return;
    //ByteArrayOutputStream output = null;
    ByteArrayInputStream input = null;
    try {
View Full Code Here

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

    if (model == null && isModelNecessary()) {
      model = createModel();
      if (model == null)
        return null;
     
      IStructuredDocument structuredDocument = model.getStructuredDocument();
      if (structuredDocument == null)
        return null;

      RegionParser parser = structuredDocument.getParser();
      if (parser instanceof CSSSourceParser) {
        ((CSSSourceParser)parser).setParserMode(CSSSourceParser.MODE_DECLARATION);
      } else {
        return null;
      }
     
      structuredDocument.addDocumentChangedListener(this);

      setModel(model); // need to set before valueChanged()
      valueChanged();
    }
    if (model != null && !isModelNecessary()) {
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.