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

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


  }

  /**
   */
  private Segment getErrorSegment(IDOMNode errorNode, int regionType) {
    ITextRegion rgn = null;
    switch (regionType) {
      case REGION_NAME :
        rgn = errorNode.getNameRegion();
        break;
      case REGION_VALUE :
        rgn = errorNode.getValueRegion();
        break;
      default :
        // nothing to do.
        break;
    }
    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


      result = true;
    }
    // case 2 test
    if (region instanceof ITextRegionContainer) {
      ITextRegionContainer container = (ITextRegionContainer) region;
      ITextRegion internal = container.getRegions().get(container.getRegions().size() - 1);
      if (internal.getType() == DOMRegionContext.WHITE_SPACE && container.getRegions().size() >= 2)
        internal = container.getRegions().get(container.getRegions().size() - 2);
      if (internal.getType() == DOMRegionContext.XML_EMPTY_TAG_CLOSE) {
        result = true;
      }
    }
    // case 3 test
    if (changesIncludeA_lt && (region.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME || region.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE)) {
View Full Code Here

   */
  private boolean isTaglibOrInclude(IStructuredDocumentRegion node, ITextRegionList regions) {
    boolean sizeAndTypesMatch = (regions.size() > 1) && (regions.get(1).getType() == DOMJSPRegionContexts.JSP_DIRECTIVE_NAME) && (regions.get(0).getType() == DOMJSPRegionContexts.JSP_DIRECTIVE_OPEN || regions.get(0).getType() == DOMRegionContext.XML_TAG_OPEN);
    if (!sizeAndTypesMatch)
      return false;
    ITextRegion region = regions.get(1);
    String directiveName = node.getText(region);
    return sizeAndTypesMatch && (directiveName.equals(JSP11TLDNames.TAGLIB) || directiveName.equals(JSP11TLDNames.INCLUDE) || directiveName.equals(JSP12Namespace.ElementName.DIRECTIVE_TAGLIB) || directiveName.equals(JSP12Namespace.ElementName.DIRECTIVE_INCLUDE));
  }
View Full Code Here

    IStructuredDocumentRegion node = start;
    int endReplace = fStart + fLengthToReplace;
    while (end != null && node != end.getNext()) {
      Iterator i = node.getRegions().iterator();
      while (i.hasNext()) {
        ITextRegion region = (ITextRegion) i.next();
        if (intersects(node, region, fStart, endReplace)) {

          result = isBreakingWithNestedTag(changesIncludeA_lt, delsIncludeA_gt, node, region);

          if (result)
View Full Code Here

  }

  protected void validateRegionContainer(ITextRegionCollection container, IReporter reporter, IFile file) {
    ITextRegionCollection containerRegion = container;
    Iterator regions = containerRegion.getRegions().iterator();
    ITextRegion region = null;
    while (regions.hasNext() && !reporter.isCancelled()) {
      region = (ITextRegion) regions.next();
      String type = region.getType();
      if (type != null && region instanceof ITextRegionCollection) {
        ITextRegionCollection parentRegion = ((ITextRegionCollection) region);
        Iterator childRegions = parentRegion.getRegions().iterator();
        while (childRegions.hasNext() && !reporter.isCancelled()) {
          ITextRegion childRegion = (ITextRegion) childRegions.next();
          /* [136795] Validate everything in the EL container, not just JSP_EL_CONTENT */
          if (childRegion.getType() == DOMJSPRegionContexts.JSP_EL_OPEN)
            validateELContent(parentRegion, childRegion, childRegions, reporter, file);
        }
      }
    }
  }
View Full Code Here

  protected void validateELContent(ITextRegionCollection container, ITextRegion elOpenRegion, Iterator elRegions, IReporter reporter, IFile file) {
    int contentStart = elOpenRegion.getEnd();
    int contentDocStart = container.getEndOffset(elOpenRegion);
    int contentLength = container.getLength();
    int regionCount = 0;
    ITextRegion elRegion = null;
    /* Find the EL closing region, otherwise the last region will be used to calculate the EL content text */
    while (elRegions != null && elRegions.hasNext() && (regionCount++ < MAX_REGIONS)) {
      elRegion = (ITextRegion) elRegions.next();
      if (elRegion.getType() == DOMJSPRegionContexts.JSP_EL_CLOSE)
        break;
    }
   
    String elText = container.getFullText().substring(contentStart, (elRegion != null) ? elRegion.getStart() : (contentLength - 1));
    JSPELParser elParser = JSPELParser.createParser(elText);
    try {
      elParser.Expression();
    }
    catch (ParseException e) {
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))
View Full Code Here

    return result;
  }

  public String getPartitionTypeBetween(IStructuredDocumentRegion previousNode, IStructuredDocumentRegion nextNode) {
   
    ITextRegion previousStartTagNameRegion = null;
    ITextRegion nextEndTagNameRegion = null;
   
    ITextRegion[] regions = previousNode.getRegions().toArray();
    for (int i = 0; i < regions.length; i++) {
      if(regions[i].getType() == DOMRegionContext.XML_TAG_NAME) {
        previousStartTagNameRegion = regions[i];
View Full Code Here

     * 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);
View Full Code Here

        }
        break;
      case SEG_START_TAG_NAME :
        startTag = target.getStartStructuredDocumentRegion();
        if (startTag != null) {
          ITextRegion nameRegion = getNameRegion(startTag);
          if (nameRegion != null) {
            seg = new Segment(startTag.getStartOffset(nameRegion), nameRegion.getTextLength());
          }
        }
        if (seg == null) {
          seg = getSegment(target, SEG_START_TAG);
        }
        break;
      case SEG_END_TAG_NAME :
        endTag = target.getEndStructuredDocumentRegion();
        if (endTag != null) {
          ITextRegion nameRegion = getNameRegion(endTag);
          if (nameRegion != null) {
            seg = new Segment(endTag.getStartOffset(nameRegion), nameRegion.getTextLength());
          }
        }
        if (seg == null) {
          seg = getSegment(target, SEG_END_TAG);
        }
View Full Code Here

TOP

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

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.