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

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


  /**
   * these "deep" parenting is not normal, but just in case.
   */
  private IStructuredDocument _getParentDocument() {
    // go up enough parents to get to document
    ITextRegionCollection parent = getParent();
    while (!(parent instanceof IStructuredDocumentRegion)) {
      // would be an error not to be container, but
      // won't check for it now
      parent = ((ITextRegionContainer) parent).getParent();
    }
View Full Code Here


    }
    unloadPreferences();
  }

  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

              catch (BadLocationException e) {
                displayText.setText(""); //$NON-NLS-1$
              }
            }
            else if (o instanceof ITextRegionCollection) {
              ITextRegionCollection region = (ITextRegionCollection) o;
              displayText.setText(region.getFullText());
            }
            else
              displayText.setText("" + o); //$NON-NLS-1$
          }
        }
View Full Code Here

    Iterator regions = container.getRegions().iterator();
    ITextRegion region = null;
    while (regions.hasNext()) {
      region = (ITextRegion) regions.next();
      if (region instanceof ITextRegionCollection) {
        ITextRegionCollection parentRegion = ((ITextRegionCollection) region);
        Iterator childRegions = parentRegion.getRegions().iterator();
        while (childRegions.hasNext()) {
          ITextRegion childRegion = (ITextRegion) childRegions.next();
          if (childRegion.getType() == DOMJSPRegionContexts.JSP_EL_OPEN)
            return true;
        }
View Full Code Here

     * unbalanced them with scriptlets.
     */
    Iterator regionAndTaglibVariables = fTagToVariableMap.values().iterator();
    while (regionAndTaglibVariables.hasNext()) {
      RegionTags regionTag = (RegionTags) regionAndTaglibVariables.next();
      ITextRegionCollection extraStartRegion = regionTag.region;
      IJSPProblem missingEndTag = createJSPProblem(IJSPProblem.EndCustomTagMissing, IJSPProblem.F_PROBLEM_ID_LITERAL, NLS.bind(JSPCoreMessages.JSPTranslator_5,regionTag.tag.getTagName()), extraStartRegion.getStartOffset(), extraStartRegion.getEndOffset());
      fTranslationProblems.add(missingEndTag);

      StringBuffer text = new StringBuffer();
      // Account for iteration tags that have a missing end tag
      if (regionTag.tag.isIterationTag())
        doAfterBody(text, regionTag);
      text.append("} // [</"); //$NON-NLS-1$
      text.append(regionTag.tag.getTagName());
      text.append(">]"); //$NON-NLS-1$
      appendToBuffer(text.toString(), fUserCode, false, fStructuredDocument.getLastStructuredDocumentRegion());
    }
    fTagToVariableMap.clear();

    /*
     * Now do the same for jsp:useBean tags, whose contents get their own
     * { & }
     */
    while (!fUseBeansStack.isEmpty()) {
      appendToBuffer("}", fUserCode, false, fStructuredDocument.getLastStructuredDocumentRegion()); //$NON-NLS-1$
      ITextRegionCollection extraStartRegion = (ITextRegionCollection) fUseBeansStack.pop();
      IJSPProblem missingEndTag = createJSPProblem(IJSPProblem.UseBeanEndTagMissing, IJSPProblem.F_PROBLEM_ID_LITERAL, NLS.bind(JSPCoreMessages.JSPTranslator_5,JSP11Namespace.ElementName.USEBEAN), extraStartRegion.getStartOffset(), extraStartRegion.getEndOffset());
      fTranslationProblems.add(missingEndTag);
    }

    buildResult(true);
  }
View Full Code Here

   * This method should only be called in this class and for containers in
   * the primary structured document as all buffer appends will be direct
   */
  protected void translateRegionContainer(ITextRegionCollection container, int JSPType) {

    ITextRegionCollection containerRegion = container;

    Iterator regions = containerRegion.getRegions().iterator();
    ITextRegion region = null;
    while (regions.hasNext()) {
      region = (ITextRegion) regions.next();
      String type = region.getType();

      // content assist was not showing up in JSP inside a javascript region
      if (DOMRegionContext.BLOCK_TEXT == type) {
        // check if it's nested jsp in a script tag...
        if (region instanceof ITextRegionContainer) {
          // pass in block text's container & iterator
          Iterator regionIterator = ((ITextRegionCollection) region).getRegions().iterator();
          translateJSPNode(region, regionIterator, type, EMBEDDED_JSP);
        }
        else {
          //be sure to combine all of the text from the block region
          StringBuffer fullText = new StringBuffer(containerRegion.getFullText(region));
          while(regions.hasNext()) {
            region = (ITextRegion)regions.next();
            if (region instanceof ITextRegionContainer) {
              // pass in block text's container & iterator
              Iterator regionIterator = ((ITextRegionCollection) region).getRegions().iterator();
              translateJSPNode(region, regionIterator, type, EMBEDDED_JSP);
            }
           
            if(region.getType() == DOMRegionContext.BLOCK_TEXT) {
              fullText.append(containerRegion.getFullText(region));
            } else {
              //update type for when we exit if statement for BLOCK_TEXT
              type = region.getType();
              break;
            }
          }
         
          /**
           * LIMITATION - Normally the script content within a
           * script tag is a single document region with a single
           * BLOCK_TEXT text region within it. Any JSP scripting
           * will be within its own region container (for the sake
           * of keeping the scripting open/content/end as a group)
           * also of BLOCK_TEXT. That ignores custom tags that might
           * be in there, though, as they require proper scoping and
           * variable declaration to be performed even though
           * they're not proper nodes in the DOM. The only way to
           * really do this is to treat the entire script content as
           * JSP content on its own, akin to an included segment.
           * Further complicating this solution is that tagdependent
           * custom tags have their comment marked as BLOCK_TEXT as
           * well, so there's no clear way to tell the two cases
           * apart.
           */

          // ////////////////////////////////////////////////////////////////////////////////
          // THIS EMBEDDED JSP TEXT WILL COME OUT LATER WHEN
          // PARTITIONING HAS
          // SUPPORT FOR NESTED XML-JSP
          // CMVC 241882
          decodeScriptBlock(fullText.toString(), containerRegion.getStartOffset());
          // ////////////////////////////////////////////////////////////////////////////////
        }
      }
      // if (region instanceof ITextRegionCollection &&
      // ((ITextRegionCollection) region).getNumberOfRegions() > 0) {
View Full Code Here

  protected void translateJSPNode(ITextRegion region, Iterator regions, String type, int JSPType) {
    if (type == DOMJSPRegionContexts.JSP_DIRECTIVE_OPEN && regions != null) {
      translateDirective(regions);
    }
    else {
      ITextRegionCollection contentRegion = null;
      if (JSPType == STANDARD_JSP && (setCurrentNode(getCurrentNode().getNext())) != null) {
        contentRegion = getCurrentNode();
      }
      else if (JSPType == EMBEDDED_JSP && region instanceof ITextRegionCollection) {
        translateEmbeddedJSPInBlock((ITextRegionCollection) region, regions);
        // ensure the rest of this method won't be called
      }
      /* NOTE: the type here is of the node preceding the current node
       * thus must check to see if the current node is JSP close, if it is
       * then the JSP is something akin to <%%> and should not be translated
       * (Bug 189318)
       */
      if (contentRegion != null && contentRegion.getType() != DOMJSPRegionContexts.JSP_CLOSE) {
        if (type == DOMJSPRegionContexts.JSP_EXPRESSION_OPEN) {
          translateExpression(contentRegion);
        }
        else if (type == DOMJSPRegionContexts.JSP_DECLARATION_OPEN) {
          translateDeclaration(contentRegion);
View Full Code Here

        fUseBeansStack.pop();
        appendToBuffer("}", fUserCode, false, fCurrentNode); //$NON-NLS-1$
      }
      else {
        // no useBean start tag being remembered
        ITextRegionCollection extraEndRegion = container;
        IJSPProblem missingStartTag = createJSPProblem(IJSPProblem.UseBeanStartTagMissing, IJSPProblem.F_PROBLEM_ID_LITERAL, NLS.bind(JSPCoreMessages.JSPTranslator_4,JSP11Namespace.ElementName.USEBEAN), extraEndRegion.getStartOffset(), extraEndRegion.getEndOffset());
        fTranslationProblems.add(missingStartTag);
      }
      return;
    }
View Full Code Here

    }
    unloadPreferences();
  }

  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

    {
        final ITextRegion attrValueRegion = attrAdapter
                .getAttributeValueRegion();
        if (attrValueRegion instanceof ITextRegionCollection)
        {
            final ITextRegionCollection parentRegion = ((ITextRegionCollection) attrValueRegion);
            if (parentRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE)
            {
                final ITextRegionList regionList = parentRegion.getRegions();

                if (regionList.size() >= 3)
                {
                    final ITextRegion openQuote = regionList.get(0);
                    final ITextRegion vblOpen = regionList.get(1);

                    if ((openQuote.getType() == DOMJSPRegionContexts.XML_TAG_ATTRIBUTE_VALUE_DQUOTE || openQuote
                            .getType() == DOMJSPRegionContexts.JSP_VBL_DQUOTE ||
                            openQuote.getType() == DOMJSPRegionContexts.JSP_TAG_ATTRIBUTE_VALUE_DQUOTE)
                            && vblOpen.getType() == DOMJSPRegionContexts.JSP_VBL_OPEN)
                    {
                        boolean foundClosingQuote = false;
                        for (int i = 2; !foundClosingQuote
                                && i < regionList.size(); i++)
                        {
                            final ITextRegion searchRegion = regionList.get(i);
                            if (searchRegion.getType() == DOMJSPRegionContexts.JSP_VBL_CLOSE)
                            {
                                foundClosingQuote = true;
                            }
                        }

                        if (!foundClosingQuote
                                && _validationContext.shouldValidateEL())
                        {
                            final int offset = sDocContext
                                    .getDocumentPosition() + 1;
                            final int length = parentRegion.getText().length();
                            final Diagnostic diagnostic = _validationContext
                                    .getDiagnosticFactory()
                                    .create_MISSING_CLOSING_EXPR_BRACKET();
                            _validationContext.getReporter().report(diagnostic,
                                    offset, length);
View Full Code Here

TOP

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

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.