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

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


   *
   * @param jspReferenceRegion
   * @return
   */
  private boolean isUsebeanTag(ITextRegionCollection jspReferenceRegion) {
    ITextRegionList regions = jspReferenceRegion.getRegions();
    ITextRegion r = null;
    boolean isUseBean = false;
    for (int i = 0; i < regions.size(); i++) {
      r = regions.get(i);
      // https://bugs.eclipse.org/bugs/show_bug.cgi?id=128490
      // length of 11 is the length of jsp:useBean
      // and saves the expensive getText.equals call
      if (r.getType() == DOMRegionContext.XML_TAG_NAME) {
        if (r.getTextLength() == 11 && jspReferenceRegion.getText(r).equals("jsp:useBean")) { //$NON-NLS-1$
View Full Code Here


    // these positions will be updated below
    Position javaRange = new Position(fOffsetInUserImports + 7, 1);
    Position jspRange = new Position(jspReferenceRegion.getStart(), jspReferenceRegion.getLength());

    // calculate JSP range by finding "import" attribute
    ITextRegionList regions = jspReferenceRegion.getRegions();
    int size = regions.size();

    int start = -1;
    int length = -1;

    ITextRegion r = null;
    for (int i = 0; i < size; i++) {
      r = regions.get(i);
      if (r.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME)
        if (jspReferenceRegion.getText(r).trim().equals("import")) { //$NON-NLS-1$
          // get the attr value region
          if (size > i + 2) {
            r = regions.get(i + 2);
            if (r.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) {

              String jspImportText = jspReferenceRegion.getText(r);

              // the position in question (in the JSP) is what
View Full Code Here

    }

    // ---------------------
    // calculate jsp ranges
    // ---------------------
    ITextRegionList regions = jspReferenceRegion.getRegions();
    ITextRegion r = null;
    String attrName = "", attrValue = ""; //$NON-NLS-1$ //$NON-NLS-2$
    int quoteOffset = 0;
    Position jspTypeRange = null;
    Position jspIdRange = null;
    Position jspClassRange = null;

    for (int j = 0; j < regions.size(); j++) {
      r = regions.get(j);
      if (r.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) {
        attrName = jspReferenceRegion.getText(r);
        if (regions.size() > j + 2 && regions.get(j + 2).getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) {
          // get attr value
          r = regions.get(j + 2);
          attrValue = jspReferenceRegion.getText(r);

          // may have quotes
          quoteOffset = (attrValue.startsWith("\"") || attrValue.startsWith("'")) ? 1 : 0; //$NON-NLS-1$ //$NON-NLS-2$
View Full Code Here

      }

      // this is in case it's a <%@, it will be a region container...
      ITextRegion openRegion = null;
      if (flat != null && flat instanceof ITextRegionContainer) {
        ITextRegionList v = ((ITextRegionContainer) flat).getRegions();
        if (v.size() > 0)
          openRegion = v.get(0);
      }

      // ADD CDATA PROPOSAL IF IT'S AN XML-JSP TAG
      if (flat != null && flat.getType() != DOMJSPRegionContexts.JSP_SCRIPTLET_OPEN &&
          flat.getType() != DOMJSPRegionContexts.JSP_DECLARATION_OPEN &&
View Full Code Here

    // ////////////////////////////////////////////////////////////////////////////
    // ANOTHER WORKAROUND UNTIL PARTITIONING TAKES CARE OF THIS
    // check for xml-jsp tags...
    if (partitionType == IJSPPartitions.JSP_DIRECTIVE && fn != null) {
      IStructuredDocumentRegion possibleXMLJSP = ((fn.getType() == DOMRegionContext.XML_CONTENT) && fn.getPrevious() != null) ? fn.getPrevious() : fn;
      ITextRegionList regions = possibleXMLJSP.getRegions();
      if (regions.size() > 1) {
        // check bounds cases
        ITextRegion xmlOpenOrClose = regions.get(0);
        if (xmlOpenOrClose.getType() != DOMRegionContext.XML_TAG_OPEN &&
            documentPosition != possibleXMLJSP.getStartOffset() &&
            xmlOpenOrClose.getType() != DOMRegionContext.XML_END_TAG_OPEN &&
            documentPosition <= possibleXMLJSP.getStartOffset()) {
         
          // possible xml-jsp
          ITextRegion nameRegion = regions.get(1);
          String name = possibleXMLJSP.getText(nameRegion);
          if (name.equals("jsp:scriptlet") || name.equals("jsp:expression") || name.equals("jsp:declaration")) { //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            return true;
          }
        }
View Full Code Here

        String attrName = var.getNameFromAttribute();
        /*
         * Iterate through the document region to find the
         * corresponding attribute name, and then use its value
         */
        ITextRegionList regions = customTag.getRegions();
        boolean attrNameFound = false;
        for (int i = 2; i < regions.size(); i++) {
          ITextRegion region = regions.get(i);
          if (DOMRegionContext.XML_TAG_ATTRIBUTE_NAME.equals(region.getType())) {
            attrNameFound = attrName.equals(customTag.getText(region));
          }
          if (attrNameFound && DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE.equals(region.getType())) {
            varName = StringUtils.strip(customTag.getText(region));
View Full Code Here

  void applyStyles() {
    if (fText == null || fText.isDisposed())
      return;
    IStructuredDocumentRegion documentRegion = fDocument.getFirstStructuredDocumentRegion();
    while (documentRegion != null) {
      ITextRegionList regions = documentRegion.getRegions();
      for (int i = 0; i < regions.size(); i++) {
        ITextRegion currentRegion = regions.get(i);
        // lookup the local coloring type and apply it
        String namedStyle = (String) fContextToStyleMap.get(currentRegion.getType());
        if (namedStyle == null)
          continue;
        TextAttribute attribute = getAttributeFor(namedStyle);
View Full Code Here

    IStructuredDocumentRegion startTagStructuredDocumentRegion = newNode.getFirstStructuredDocumentRegion();
    IStructuredDocumentRegion endTagStructuredDocumentRegion = newNode.getLastStructuredDocumentRegion();

    if (compressEmptyElementTags && startTagStructuredDocumentRegion != endTagStructuredDocumentRegion && startTagStructuredDocumentRegion != null) {
      ITextRegionList regions = startTagStructuredDocumentRegion.getRegions();
      ITextRegion lastRegion = regions.get(regions.size() - 1);
      // 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();
View Full Code Here

    IDOMModel structuredModel = node.getModel();

    if (isEmptyElement(element)) {
      IStructuredDocument structuredDocument = structuredModel.getStructuredDocument();
      IStructuredDocumentRegion startStructuredDocumentRegion = node.getStartStructuredDocumentRegion();
      ITextRegionList regions = startStructuredDocumentRegion.getRegions();
      ITextRegion lastRegion = regions.get(regions.size() - 1);
      structuredDocument.replaceText(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())
          structuredDocument.replaceText(structuredDocument, startStructuredDocumentRegion.getStartOffset(lastRegion), 0, " "); //$NON-NLS-1$
View Full Code Here

        newNode = insertStartTag(node);
        startTagStructuredDocumentRegion = newNode.getStartStructuredDocumentRegion();
      }

      IStructuredDocumentRegion endTagStructuredDocumentRegion = newNode.getEndStructuredDocumentRegion();
      ITextRegionList startStructuredDocumentRegionRegions = startTagStructuredDocumentRegion.getRegions();
      if (startTagStructuredDocumentRegion != null && startStructuredDocumentRegionRegions != null && (startStructuredDocumentRegionRegions.get(startStructuredDocumentRegionRegions.size() - 1)).getType() == DOMRegionContext.XML_EMPTY_TAG_CLOSE) {

      } else {
        if (startTagStructuredDocumentRegion == null) {
          // start tag missing
          if (isStartTagRequired(newNode))
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.