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

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


  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;
      if (type == DOMRegionContext.XML_END_TAG_OPEN || type == DOMRegionContext.XML_TAG_CLOSE)
        continue;
      hint += info.endTag.getFullText(rgn);
View Full Code Here


    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();
          Segment errorSeg = new Segment(info.startTag.getStartOffset() + region.getStart(), invalidText.length());
          report(INVALID_TEXT_IN_ELEM_ERROR, errorSeg, info.target, new String[]{invalidText}, new String[0]);
        }
      }
    }
  }
View Full Code Here

    // iterate backwards until you hit the include directive
    for (int i = regions.length - 1; i >= 0; i--) {
      IStructuredDocumentRegion region = regions[i];
      if (region.getType() == DOMJSPRegionContexts.JSP_DIRECTIVE_NAME) {
        if (getDirectiveName(region).equals("include")) { //$NON-NLS-1$
          ITextRegion fileValueRegion = getAttributeValueRegion(region, "file"); //$NON-NLS-1$
          if (fileValueRegion != null) {
            m.setOffset(region.getStartOffset(fileValueRegion));
            m.setLength(fileValueRegion.getTextLength());
          }
          else {
            m.setOffset(region.getStartOffset());
            m.setLength(region.getTextLength());
          }
View Full Code Here

            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
                else if (region.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE && attrName != null) {
                  text = StringUtils.strip(text);
                  if (JSP11Namespace.ATTR_NAME_FILE.equals(attrName)) {
                    IPath filePath = FacetModuleCoreSupport.resolve(new Path(((CMDocumentImpl) ed.getOwnerDocument()).getBaseLocation()), text);

                    IFile includedFile = ResourcesPlugin.getWorkspace().getRoot().getFile(filePath);
View Full Code Here

    // scanned input
    // they are adjusted here to be indexes from the currentNode's start
    // offset
    IStructuredDocumentRegion headNode = null;
    IStructuredDocumentRegion lastNode = null;
    ITextRegion region = null;
    // DMW: 2/12/03. Made current node local variable, since
    // we changed class to not require state
    IStructuredDocumentRegion currentNode = null;
    String type = null;

    while ((region = getNextRegion()) != null) {
      type = region.getType();
      // these types (might) demand a IStructuredDocumentRegion for each
      // of them
      if (type == DOMRegionContext.BLOCK_TEXT) {
        if (currentNode != null && currentNode.getLastRegion().getType() == DOMRegionContext.BLOCK_TEXT) {
          // multiple block texts indicated embedded containers; no
          // new IStructuredDocumentRegion
          currentNode.addRegion(region);
          currentNode.setLength(region.getStart() + region.getLength() - currentNode.getStart());
          region.adjustStart(-currentNode.getStart());
          // DW, 4/16/2003 token regions no longer have parents
          // region.setParent(currentNode);
          if (region instanceof ITextRegionContainer) {
            ((ITextRegionContainer) region).setParent(currentNode);
          }
        }
        else {
          // not continuing a IStructuredDocumentRegion
          if (currentNode != null) {
            // ensure that any existing node is at least
            // terminated
            if (!currentNode.isEnded()) {
              currentNode.setLength(region.getStart() - currentNode.getStart());
              // fCurrentNode.setTextLength(region.getStart() -
              // fCurrentNode.getStart());
            }
            lastNode = currentNode;
          }
          fireNodeParsed(currentNode);
          currentNode = createStructuredDocumentRegion(type);
          if (lastNode != null) {
            lastNode.setNext(currentNode);
          }
          currentNode.setPrevious(lastNode);
          currentNode.setStart(region.getStart());
          currentNode.setLength(region.getStart() + region.getLength() - currentNode.getStart());
          currentNode.setEnded(true);
          region.adjustStart(-currentNode.getStart());
          currentNode.addRegion(region);
          // DW, 4/16/2003 token regions no longer have parents
          // region.setParent(currentNode);
          if (region instanceof ITextRegionContainer) {
            ((ITextRegionContainer) region).setParent(currentNode);
          }

        }
      }
      // the following contexts OPEN new StructuredDocumentRegions
      else if ((currentNode != null && currentNode.isEnded()) || (type == DOMRegionContext.XML_CONTENT) || (type == DOMRegionContext.XML_CHAR_REFERENCE) || (type == DOMRegionContext.XML_ENTITY_REFERENCE) || (type == DOMRegionContext.XML_PI_OPEN) || (type == DOMRegionContext.XML_TAG_OPEN) || (type == DOMRegionContext.XML_END_TAG_OPEN) || (type == DOMRegionContext.XML_COMMENT_OPEN) || (type == DOMRegionContext.XML_CDATA_OPEN) || (type == DOMRegionContext.XML_DECLARATION_OPEN) || (type == DOMJSPRegionContexts.JSP_COMMENT_OPEN) || (type == DOMJSPRegionContexts.JSP_DECLARATION_OPEN) || (type == DOMJSPRegionContexts.JSP_DIRECTIVE_OPEN) || (type == DOMJSPRegionContexts.JSP_EXPRESSION_OPEN) || (type == DOMJSPRegionContexts.JSP_SCRIPTLET_OPEN) || (type == DOMJSPRegionContexts.JSP_CLOSE) || type == DOMJSPRegionContexts.JSP_EL_OPEN) {
        if (currentNode != null) {
          // ensure that any existing node is at least terminated
          if (!currentNode.isEnded()) {
            currentNode.setLength(region.getStart() - currentNode.getStart());
            // fCurrentNode.setTextLength(region.getStart() -
            // fCurrentNode.getStart());
          }
          lastNode = currentNode;
        }
        fireNodeParsed(currentNode);
        currentNode = createStructuredDocumentRegion(type);
        if (lastNode != null) {
          lastNode.setNext(currentNode);
        }
        currentNode.setPrevious(lastNode);
        currentNode.setStart(region.getStart());
        currentNode.addRegion(region);
        currentNode.setLength(region.getStart() + region.getLength() - currentNode.getStart());
        region.adjustStart(-currentNode.getStart());
        // DW, 4/16/2003 token regions no longer have parents
        // region.setParent(currentNode);
        if (region instanceof ITextRegionContainer) {
          ((ITextRegionContainer) region).setParent(currentNode);
        }

      }
      // the following contexts NEITHER open nor close
      // StructuredDocumentRegions; just add to them
      else if ((type == DOMRegionContext.XML_TAG_NAME) || (type == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) || (type == DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS) || (type == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) || (type == DOMRegionContext.XML_COMMENT_TEXT) || (type == DOMRegionContext.XML_PI_CONTENT) || (type == DOMRegionContext.XML_DOCTYPE_INTERNAL_SUBSET) || (type == DOMJSPRegionContexts.JSP_COMMENT_TEXT) || (type == DOMJSPRegionContexts.JSP_ROOT_TAG_NAME) || (type == DOMJSPRegionContexts.JSP_DIRECTIVE_NAME) || type == DOMJSPRegionContexts.JSP_EL_CONTENT) {
        currentNode.addRegion(region);
        currentNode.setLength(region.getStart() + region.getLength() - currentNode.getStart());
        region.adjustStart(-currentNode.getStart());
        // DW, 4/16/2003 token regions no longer have parents
        // region.setParent(currentNode);
        if (region instanceof ITextRegionContainer) {
          ((ITextRegionContainer) region).setParent(currentNode);
        }
      }
      // the following contexts close off StructuredDocumentRegions
      // cleanly
      else if ((type == DOMRegionContext.XML_PI_CLOSE) || (type == DOMRegionContext.XML_TAG_CLOSE) || (type == DOMRegionContext.XML_EMPTY_TAG_CLOSE) || (type == DOMRegionContext.XML_COMMENT_CLOSE) || (type == DOMRegionContext.XML_CDATA_CLOSE) || (type == DOMJSPRegionContexts.JSP_CLOSE) || (type == DOMJSPRegionContexts.JSP_COMMENT_CLOSE) || (type == DOMJSPRegionContexts.JSP_DIRECTIVE_CLOSE) || (type == DOMRegionContext.XML_DECLARATION_CLOSE) || type == DOMJSPRegionContexts.JSP_EL_CLOSE) {
        currentNode.setEnded(true);
        currentNode.setLength(region.getStart() + region.getLength() - currentNode.getStart());
        currentNode.addRegion(region);
        region.adjustStart(-currentNode.getStart());
        // DW, 4/16/2003 token regions no longer have parents
        // region.setParent(currentNode);
        if (region instanceof ITextRegionContainer) {
          ((ITextRegionContainer) region).setParent(currentNode);
        }
      }
      // this is extremely rare, but valid
      else if (type == DOMRegionContext.WHITE_SPACE) {
        ITextRegion lastRegion = currentNode.getLastRegion();
        // pack the embedded container with this region
        if (lastRegion instanceof ITextRegionContainer) {
          ITextRegionContainer container = (ITextRegionContainer) lastRegion;
          container.getRegions().add(region);
          // DW, 4/16/2003 container regions have parent. Probably a
View Full Code Here

          || tagName.equalsIgnoreCase("page"); //$NON-NLS-1$
  }

  // different btwn XML-JSP and JSP tags   
  protected String getRegionName(IStructuredDocumentRegion sdRegion) {
    ITextRegion nameRegion = null;
    String nameStr = ""; //$NON-NLS-1$
    int size = sdRegion.getRegions().size();
    if (size > 1) {
      // presumably XML-JSP <jsp:scriptlet> | <jsp:expression> | <jsp:declaration>
      nameRegion = sdRegion.getRegions().get(1);
View Full Code Here

   */
  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;
      }
    }
    return name;
View Full Code Here

   * @param attrName
   * @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;
          }
        }
        break;
View Full Code Here

    }
    return valueRegion;
  }

  protected String getAttributeValue(ITextRegionCollection sdr, String attrName) {
    ITextRegion r = getAttributeValueRegion(sdr, attrName);
    if (r != null)
      return sdr.getText(r).trim();
    return ""; //$NON-NLS-1$
  }
View Full Code Here

    public void nodeParsed(IStructuredDocumentRegion aCoreFlatNode) {
      // could test > 1, but since we only care if there are 8 (<%@,
      // taglib, uri, =, where, prefix, =, what) [or 4 for includes]
      if (aCoreFlatNode.getNumberOfRegions() > 4 && aCoreFlatNode.getRegions().get(1).getType() == DOMJSPRegionContexts.JSP_DIRECTIVE_NAME) {
        ITextRegion name = aCoreFlatNode.getRegions().get(1);
        try {
          int offset = aCoreFlatNode.getStartOffset(name);
          int length = name.getTextLength();
          boolean taglibdetected = false;
          boolean taglibdirectivedetected = false;
          if (fCharSequenceSource instanceof IRegionComparible) {
            taglibdetected = ((IRegionComparible) fCharSequenceSource).regionMatches(offset, length, JSP12TLDNames.TAGLIB);
            taglibdirectivedetected = ((IRegionComparible) fCharSequenceSource).regionMatches(offset, length, JSP12Namespace.ElementName.DIRECTIVE_TAGLIB);
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.