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

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


    return false; // all regions are valid.
  }

  private String getEndTagFullText(ElementInfo info) {
    String hint = "";//$NON-NLS-1$
    ITextRegionList regions = info.endTag.getRegions();
    Iterator iter = regions.iterator();
    while (iter.hasNext()) {
      ITextRegion rgn = (ITextRegion) iter.next();
      String type = rgn.getType();
      if (type == null)
        continue;
View Full Code Here


   *
   * @param info the <code>ElementInfo</code> about the tag to validate
   */
  private void validateAttributes(ElementInfo info) {
    if(info != null && info.hasStartTag()) {
      ITextRegionList list = info.startTag.getRegions();

      //for each region in the tag, these make up the arguments
      for(int i = 0; i < list.size(); ++i) {
        ITextRegion region = list.get(i);
        String type = region.getType();
 
        //if the type is undefined then there is a syntax error
        if(type == DOMRegionContext.UNDEFINED) {
          String invalidText = info.startTag.getFullText(region).trim();
View Full Code Here

        return;
      IStructuredDocumentRegion documentRegion = document.getFirstStructuredDocumentRegion();
      while (documentRegion != null) {
        if (documentRegion.getType().equals(DOMJSPRegionContexts.JSP_DIRECTIVE_NAME)) {
          if (documentRegion.getNumberOfRegions() > 2) {
            ITextRegionList regions = documentRegion.getRegions();
            String directiveName = documentRegion.getText(regions.get(1));
            if (JSP12TLDNames.TAG.equals(directiveName)) {
              // 8.5.1
              String attrName = null;
              for (int i = 2; i < documentRegion.getNumberOfRegions(); i++) {
                ITextRegion region = regions.get(i);
                String text = documentRegion.getText(region);
                if (region.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) {
                  attrName = text;
                }
                // process value
                else if (region.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) {
                  text = StringUtils.strip(text);
                  if (JSP12TLDNames.DISPLAY_NAME.equals(attrName)) {
                    ed.setDisplayName(text);
                  }
                  else if (JSP12TLDNames.BODY_CONTENT.equals(attrName)) {
                    ed.setBodycontent(text);
                  }
                  else if (JSP20TLDNames.DYNAMIC_ATTRIBUTES.equals(attrName)) {
                    ed.setDynamicAttributes(text);
                  }
                  else if (JSP12TLDNames.SMALL_ICON.equals(attrName)) {
                    ed.setSmallIcon(text);
                  }
                  else if (JSP12TLDNames.LARGE_ICON.equals(attrName)) {
                    ed.setLargeIcon(text);
                  }
                  else if (JSP12TLDNames.DESCRIPTION.equals(attrName)) {
                    ed.setDescription(text);
                  }
                  else if (JSP20TLDNames.EXAMPLE.equals(attrName)) {
                    ed.setExample(text);
                  }
                  else if (JSP20TLDNames.SCRIPTING_LANGUAGE.equals(attrName)) {
                    ed.setScriptingLanguage(text);
                  }
                  else if (JSP20TLDNames.IMPORT.equals(attrName)) {
                    ed.setImport(text);
                  }
                  else if (JSP20TLDNames.PAGE_ENCODING.equals(attrName)) {
                    ed.setPageEncoding(text);
                  }
                  else if (JSP20TLDNames.IS_EL_IGNORED.equals(attrName)) {
                    ed.setIsELIgnored(text);
                  }
                }
              }
            }
            else if (JSP12TLDNames.ATTRIBUTE.equals(directiveName)) {
              CMAttributeDeclarationImpl attribute = new CMAttributeDeclarationImpl(ed.getOwnerDocument());
              // 8.5.2
              String attrName = null;
              for (int i = 2; i < documentRegion.getNumberOfRegions(); i++) {
                ITextRegion region = regions.get(i);
                String text = documentRegion.getText(region);
                if (region.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) {
                  attrName = text;
                }
                // process value
                else if (region.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE && attrName != null) {
                  text = StringUtils.strip(text);
                  if (JSP12TLDNames.NAME.equals(attrName)) {
                    attribute.setNodeName(text);
                  }
                  else if (JSP20TLDNames.FRAGMENT.equals(attrName)) {
                    attribute.setFragment(Boolean.valueOf(text).booleanValue());
                  }
                  else if (JSP12TLDNames.RTEXPRVALUE.equals(attrName)) {
                    attribute.setRtexprvalue(text);
                  }
                  else if (JSP20TLDNames.TYPE.equals(attrName)) {
                    attribute.setType(text);
                  }
                  else if (JSP12TLDNames.DESCRIPTION.equals(attrName)) {
                    attribute.setDescription(text);
                  }
                  else if (JSP12TLDNames.REQUIRED.equals(attrName)) {
                    attribute.setRequiredString(text);
                  }
                }
              }
              if (attribute.getNodeName() != null) {
                ed.fAttributes.setNamedItem(attribute.getNodeName(), attribute);
              }
            }
            else if (JSP12TLDNames.VARIABLE.equals(directiveName)) {
              TLDVariableImpl variable = new TLDVariableImpl();
              String attrName = null;
              for (int i = 2; i < documentRegion.getNumberOfRegions(); i++) {
                ITextRegion region = regions.get(i);
                String text = documentRegion.getText(region);
                if (region.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) {
                  attrName = text;
                }
                // process value
                else if (region.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE && attrName != null) {
                  text = StringUtils.strip(text);
                  if (JSP12TLDNames.VARIABLE_NAME_GIVEN.equals(attrName)) {
                    variable.setNameGiven(text);
                  }
                  else if (JSP12TLDNames.VARIABLE_NAME_FROM_ATTRIBUTE.equals(attrName)) {
                    variable.setNameFromAttribute(text);
                  }
                  else if (JSP20TLDNames.VARIABLE_ALIAS.equals(attrName)) {
                    variable.setAlias(text);
                  }
                  else if (JSP12TLDNames.VARIABLE_CLASS.equals(attrName)) {
                    variable.setVariableClass(text);
                  }
                  else if (JSP12TLDNames.VARIABLE_DECLARE.equals(attrName)) {
                    variable.setDeclareString(text);
                  }
                  else if (JSP11Namespace.ATTR_NAME_SCOPE.equals(attrName)) {
                    variable.setScope(text);
                  }
                  else if (JSP12TLDNames.DESCRIPTION.equals(attrName)) {
                    variable.setDescription(text);
                  }
                }
              }
              if (variable.getAlias() != null || variable.getNameFromAttribute() != null || variable.getNameGiven() != null) {
                ed.getVariables().add(variable);
              }
            }
            else if ("include".equals(directiveName) && allowIncludes) {
              String attrName = null;
              for (int i = 2; i < documentRegion.getNumberOfRegions(); i++) {
                ITextRegion region = regions.get(i);
                String text = documentRegion.getText(region);
                if (region.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) {
                  attrName = text;
                }
                // process value
View Full Code Here

   * @param collection
   * @return the jsp directive name
   */
  protected String getDirectiveName(ITextRegionCollection collection) {
    String name = ""; //$NON-NLS-1$
    ITextRegionList subRegions = collection.getRegions();
    for (int j = 0; j < subRegions.size(); j++) {
      ITextRegion subRegion = subRegions.get(j);
      if (subRegion.getType() == DOMJSPRegionContexts.JSP_DIRECTIVE_NAME) {
        name = collection.getText(subRegion);
        break;
      }
    }
View Full Code Here

   * @return the ITextRegion for the attribute value of the given attribute
   *         name, case sensitive, null if no matching attribute is found
   */
  protected ITextRegion getAttributeValueRegion(ITextRegionCollection sdr, String attrName) {
    ITextRegion valueRegion = null;
    ITextRegionList subRegions = sdr.getRegions();
    for (int i = 0; i < subRegions.size(); i++) {
      ITextRegion subRegion = subRegions.get(i);
      if (subRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME && sdr.getText(subRegion).equals(attrName)) {
        for (int j = i; j < subRegions.size(); j++) {
          subRegion = subRegions.get(j);
          if (subRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) {
            valueRegion = subRegion;
            break;
          }
        }
View Full Code Here

        processJSPRoot(aCoreFlatNode);
      }
    }

    protected void processJSPRoot(IStructuredDocumentRegion taglibFlatNode) {
      ITextRegionList regions = taglibFlatNode.getRegions();
      String prefix = null;
      boolean taglib = false;
      try {
        for (int i = 0; i < regions.size(); i++) {
          ITextRegion region = regions.get(i);
          if (region.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) {
            int offset = taglibFlatNode.getStartOffset(region);
            int length = region.getTextLength();

            String name = getText(offset, length);
View Full Code Here

    /**
     * Pulls the prefix from the given taglib directive
     * IStructuredDocumentRegion and makes sure the prefix is nestable.
     */
    protected void processTaglib(IStructuredDocumentRegion taglibFlatNode) {
      ITextRegionList regions = taglibFlatNode.getRegions();
      String prefix = null;
      boolean prefixname = false;
      try {
        for (int i = 0; i < regions.size(); i++) {
          ITextRegion region = regions.get(i);
          if (region.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) {
            if (fCharSequenceSource != null && fCharSequenceSource instanceof IRegionComparible) {
              int offset = taglibFlatNode.getStartOffset(region);
              int length = region.getTextLength();
              prefixname = ((IRegionComparible) fCharSequenceSource).regionMatches(offset, length, JSP12TLDNames.PREFIX);
View Full Code Here

   * @param customTag
   * @return
   */
  private Hashtable extractTagData(ITextRegionCollection customTag) {
    Hashtable tagDataTable = new Hashtable();
    ITextRegionList regions = customTag.getRegions();
    ITextRegion r = null;
    String attrName = ""; //$NON-NLS-1$
    String attrValue = ""; //$NON-NLS-1$
    final int size = regions.size();
    for (int i = 2; i < size; i++) {
      r = regions.get(i);
      // check if attr name
      if (r.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) {
        attrName = customTag.getText(r);
        // check equals is next region
        if (size > ++i) {
          r = regions.get(i);
          if (r.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS && size > ++i) {
            // get attr value
            r = regions.get(i);
            final String type = r.getType();
            if (type == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) {
              // attributes in our document have quotes, so we
              // need to strip them
              attrValue = StringUtils.stripQuotes(customTag.getText(r));
              tagDataTable.put(attrName, attrValue);
            }
            else if (type == DOMJSPRegionContexts.JSP_TAG_ATTRIBUTE_VALUE_DQUOTE || type == DOMJSPRegionContexts.JSP_TAG_ATTRIBUTE_VALUE_SQUOTE) {
              final StringBuffer buffer = new StringBuffer();
              while (size > ++i && (r = regions.get(i)).getType() != type) {
                buffer.append(customTag.getText(r));
              }
              tagDataTable.put(attrName, buffer.toString());
            }
          }
        }
      }
    }

    tagDataTable.put("jsp:id", customTag.getText(regions.get(1)) + "_" + customTag.getStartOffset()); //$NON-NLS-1$

    return tagDataTable;
  }
View Full Code Here

    int detectionEnd = detectionRegion.getOffset() + detectionRegion.getLength();
    return (hyperLinkStart <= detectionStart && detectionStart < hyperLinkEnd) || (hyperLinkStart <= detectionEnd && detectionEnd <= hyperLinkEnd);// ||
  }

  private IRegion getNameRegion(ITextRegionCollection containerRegion) {
    ITextRegionList regions = containerRegion.getRegions();
    ITextRegion nameRegion = null;
    for (int i = 0; i < regions.size(); i++) {
      ITextRegion r = regions.get(i);
      if (r.getType() == DOMRegionContext.XML_TAG_NAME) {
        nameRegion = r;
        break;
      }
    }
View Full Code Here

        int matchStart = -1;
        int matchEnd = -1;
        String findRegionText = ""; //$NON-NLS-1$

        ITextRegion r = null;
        ITextRegionList regions = null;
        IStructuredDocumentRegion current = this.fFindRegionsDocument.getFirstStructuredDocumentRegion();

        // this is the main loop that iterates the document
        while (current != null && !isCanceled(monitor)) {
          regions = current.getRegions();
          for (int i = 0; i < regions.size() && !isCanceled(monitor); i++) {

            r = regions.get(i);

            // maybe this is the equals check where some valid
            // matches are failing (like searching on end tag)
            if (r.getType().equals(this.fMatchRegionType) && current.getText(r).equals(this.fMatchName)) {
View Full Code Here

TOP

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

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.