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

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


      }
    }
    else {
      if (info.isXHTML) { // XHTML
        //if editor closed during validation this could be null
        IStructuredDocumentRegion structRegion = info.target.getStartStructuredDocumentRegion();
        if (!info.target.isEmptyTag() && structRegion != null && DOMRegionContext.XML_TAG_OPEN.equals(structRegion.getFirstRegion().getType())) {
          /*
           * https://bugs.eclipse.org/bugs/show_bug.cgi?id=248963 :
           * report empty tags not written as such, but only when
           * they follow actual XML/HTML syntax
           */
 
View Full Code Here


    super();
  }

  public IStructuredTypedRegion createPartition(int offset, int length, String type) {
    if (type == IHTMLPartitions.SCRIPT) {
      IStructuredDocumentRegion node = fStructuredDocument.getRegionAtCharacterOffset(offset);
      if (node != null) {
        String stype = getScriptingPartitionType(node);
        return super.createPartition(offset, length, stype);
      }
    }
View Full Code Here

  }

  protected void setInternalPartition(int offset, int length, String type) {
    String localType = type;
    if (type == IHTMLPartitions.SCRIPT) {
      IStructuredDocumentRegion node = fStructuredDocument.getRegionAtCharacterOffset(offset);
      if (node != null) {
        localType = getScriptingPartitionType(node);
      }
    }
    super.setInternalPartition(offset, length, localType);
View Full Code Here

  private String getScriptingPartitionType(IStructuredDocumentRegion coreNode) {
    String language = null;
    String type = null;
    String result = IHTMLPartitions.SCRIPT;
    IStructuredDocumentRegion node = coreNode;
    ITextRegion attrNameRegion = null;
    while (node != null && isValidScriptingRegionType(node.getType())) {
      node = node.getPrevious();
    }

    ITextRegionList regions = node.getRegions();
    if (regions.size() > 4 && regions.get(1).getType() == DOMRegionContext.XML_TAG_NAME) {
      ITextRegion potentialLanguageRegion = regions.get(1);
      String potentialLanguageString = node.getText(potentialLanguageRegion);
      if (potentialLanguageString.equalsIgnoreCase(HTML40Namespace.ElementName.SCRIPT)) {
        for (int i = 0; i < regions.size(); i++) {
          ITextRegion region = regions.get(i);
          String regionType = region.getType();
          if (regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME)
            attrNameRegion = region;
          else if (regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) {
            String attrName = node.getText(attrNameRegion);
            if (attrName.equalsIgnoreCase(HTML40Namespace.ATTR_NAME_LANGUAGE))
              language = StringUtils.strip(node.getText(region));
            else if (attrName.equalsIgnoreCase(HTML40Namespace.ATTR_NAME_TYPE)) {
              type = StringUtils.strip(node.getText(region));
              /*
               * Avoid partition names built with MIME subtypes,
               * e.g. type="text/javascript;e4x=1"
               */
              if (type != null) {
View Full Code Here

   * @param offset offset in an attribute region to determine if it is in the list of given attribute names
   * @return <code>true</code> if the attribute name associated with the given offset is in the given
   * list of attribute names, <code>false</code> otherwise
   */
  private boolean isAttributeNameForValueInArray(String[] attributeNames, ITextRegion attrValueRegion, int offset) {
    IStructuredDocumentRegion node = fStructuredDocument.getRegionAtCharacterOffset(offset);
    ITextRegionList regionList = node.getRegions();
    int currentIndex = regionList.indexOf(attrValueRegion);
   
    /*
     * 4 is the minimum index allowing for the tag's open, name, attribute
     * name and equals character to appear first
     */
    if (currentIndex < 4)
      return false;
    ITextRegion tagAttrNameRegion = regionList.get(currentIndex - 2);
   
    boolean foundAttributeName = false;
    if (fStructuredDocument instanceof IRegionComparible) {
      int start = node.getStartOffset(tagAttrNameRegion);
      for (int i = 0; !foundAttributeName && i < attributeNames.length; i++) {
        foundAttributeName = ((IRegionComparible) fStructuredDocument).regionMatchesIgnoreCase(start, tagAttrNameRegion.getTextLength(), attributeNames[i]);
      }
    }
    else {
      String tagAttrName = node.getText(tagAttrNameRegion);
      foundAttributeName = StringUtils.contains(attributeNames, tagAttrName, false);
    }
    return foundAttributeName;
  }
View Full Code Here

    }
        int index = p.getOffset();
        if (!parent.hasChildNodes()) {
          // Element:
          if (!isDocument(parent)) {
            IStructuredDocumentRegion region = ((IDOMNode) parent)
                .getStartStructuredDocumentRegion();
            return region.getEnd();
          }
            // Document node:
            int offset = ((IndexedRegion) parent).getStartOffset();
            return offset;
        }
View Full Code Here

  public static int getNodeStartNameEndIndex(Node node) {
    if (isText(node)) {
      return getNodeStartIndex(node);
    }
    if (EditValidateUtil.validNode(node) && node instanceof IDOMNode) {
      IStructuredDocumentRegion region = ((IDOMNode) node)
          .getStartStructuredDocumentRegion();
      if (region != null) {
        return region.getEndOffset();
      }
      // else
      // {
      // // if (node.hasChildNodes())
      // // {
View Full Code Here

  public static int getNodeEndNameStartIndex(Node node) {
    if (isText(node)) {
      return getNodeEndIndex(node);
    }
    if (EditValidateUtil.validNode(node) && node instanceof IDOMNode) {
      IStructuredDocumentRegion region = ((IDOMNode) node)
          .getEndStructuredDocumentRegion();
      if (region != null) {
        return region.getStartOffset();
      }
      // else
      // {
      // if (node.hasChildNodes())
      // {
View Full Code Here

    if (rgn != null) {
      if (errorNode instanceof IDOMAttr) {
        IDOMElement ownerElement = (IDOMElement) ((IDOMAttr) errorNode).getOwnerElement();
        if (ownerElement != null) {
          //if editor closed during validation this could be null
          IStructuredDocumentRegion firstRegion = ownerElement.getFirstStructuredDocumentRegion();
          if(firstRegion != null) {
            int regionStartOffset = firstRegion.getStartOffset(rgn);
            int regionLength = rgn.getTextLength();
            return new Segment(regionStartOffset, regionLength);
          }
        }
      }
View Full Code Here

            }
          }
          else if (CMDataType.URI.equals(attrType.getDataTypeName())) {
            // TODO: URI validation?
            if (false && actualValue.indexOf('#') < 0 && actualValue.indexOf(":/") == -1 && CMUtil.isHTML(edec)) { //$NON-NLS-1$ //$NON-NLS-2$
              IStructuredDocumentRegion start = ((IDOMNode) node).getStartStructuredDocumentRegion();
              if (start != null && start.getFirstRegion().getTextLength() == 1) {
                IPath basePath = new Path(((IDOMNode) node).getModel().getBaseLocation());
                if (basePath.segmentCount() > 1) {
                  IPath path = ModuleCoreSupport.resolve(basePath, actualValue);
                  IResource found = ResourcesPlugin.getWorkspace().getRoot().findMember(path);
                  if (found == null || !found.isAccessible()) {
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.