Search in sources :

Example 6 with ITextRegionContainer

use of org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer in project webtools.sourceediting by eclipse.

the class JSPTranslator method isEmptyTag.

private boolean isEmptyTag(ITextRegionCollection customTag) {
    ITextRegion lastRegion = customTag.getLastRegion();
    // custom tag is embedded
    if (customTag instanceof ITextRegionContainer) {
        ITextRegionList regions = customTag.getRegions();
        int size = customTag.getNumberOfRegions() - 1;
        while (size > 0 && !(DOMRegionContext.XML_EMPTY_TAG_CLOSE.equals(lastRegion.getType()) || DOMRegionContext.XML_TAG_NAME.equals(lastRegion.getType()) || DOMRegionContext.XML_TAG_CLOSE.equals(lastRegion.getType()))) {
            lastRegion = regions.get(--size);
        }
    }
    return DOMRegionContext.XML_EMPTY_TAG_CLOSE.equals(lastRegion.getType());
}
Also used : ITextRegionList(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList) ITextRegion(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion) ITextRegionContainer(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer) IExtensionPoint(org.eclipse.core.runtime.IExtensionPoint)

Example 7 with ITextRegionContainer

use of org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer in project webtools.sourceediting by eclipse.

the class JSPTranslator method checkAllAttributeValueContainers.

/**
 * translates embedded containers for ALL attribute values
 *
 * @param regions
 */
private void checkAllAttributeValueContainers(ITextRegionCollection container, Iterator regions) {
    // tag name is not jsp
    // handle embedded jsp attributes...
    ITextRegion embedded = null;
    // Iterator attrRegions = null;
    // ITextRegion attrChunk = null;
    ITextRegion prevRegion = null;
    while (regions.hasNext()) {
        embedded = (ITextRegion) regions.next();
        if (embedded.getType() == DOMRegionContext.XML_TAG_NAME || embedded.getType() == DOMJSPRegionContexts.JSP_DIRECTIVE_NAME) {
            String fullTagName = container.getText(embedded);
            if (fullTagName.indexOf(':') > -1 && !fullTagName.startsWith(JSP_PREFIX)) {
                if (prevRegion != null)
                    // it may be a custom tag
                    addCustomTaglibVariables(fullTagName, container, prevRegion, -1);
            }
        } else if (embedded instanceof ITextRegionContainer) {
            // parse out container
            // https://bugs.eclipse.org/bugs/show_bug.cgi?id=130606
            // fix exponential iteration problem w/ embedded expressions
            translateEmbeddedJSPInAttribute((ITextRegionContainer) embedded);
        // attrRegions = ((ITextRegionContainer)
        // embedded).getRegions().iterator();
        // while (attrRegions.hasNext()) {
        // attrChunk = (ITextRegion) attrRegions.next();
        // String type = attrChunk.getType();
        // // embedded JSP in attribute support only want to
        // // translate one time per
        // // embedded region so we only translate on the JSP open
        // // tags (not content)
        // if (type == DOMJSPRegionContexts.JSP_EXPRESSION_OPEN ||
        // type ==
        // DOMJSPRegionContexts.JSP_SCRIPTLET_OPEN || type ==
        // DOMJSPRegionContexts.JSP_DECLARATION_OPEN || type ==
        // DOMJSPRegionContexts.JSP_DIRECTIVE_OPEN || type ==
        // DOMJSPRegionContexts.JSP_EL_OPEN) {
        // // now call jsptranslate
        // translateEmbeddedJSPInAttribute((ITextRegionContainer)
        // embedded);
        // break;
        // }
        // }
        }
        prevRegion = embedded;
    }
}
Also used : ITextRegion(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion) ITextRegionContainer(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer)

Example 8 with ITextRegionContainer

use of org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer in project webtools.sourceediting by eclipse.

the class ScannerUnitTests method testJSPTagInAttValue.

public void testJSPTagInAttValue() {
    String text = "<a type=\"<a/>\"/>";
    IStructuredDocumentRegionList nodes = setUpJSP(text);
    boolean sizeCheck = checkSimpleRegionCounts(nodes, new int[] { 6 });
    assertTrue("IStructuredDocumentRegion and ITextRegion count", sizeCheck);
    sizeCheck = checkSimpleRegionCount(((ITextRegionContainer) nodes.item(0).getRegions().get(4)), 5);
    assertTrue("IStructuredDocumentRegion and ITextRegion count", sizeCheck);
    boolean typeCheck = checkSimpleRegionTypes(nodes.item(0).getRegions(), new String[] { DOMRegionContext.XML_TAG_OPEN, DOMRegionContext.XML_TAG_NAME, DOMRegionContext.XML_TAG_ATTRIBUTE_NAME, DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS, DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE, DOMRegionContext.XML_EMPTY_TAG_CLOSE });
    assertTrue("region context type check (tag)", typeCheck);
    typeCheck = checkSimpleRegionTypes(((ITextRegionContainer) nodes.item(0).getRegions().get(4)).getRegions(), new String[] { DOMJSPRegionContexts.XML_TAG_ATTRIBUTE_VALUE_DQUOTE, DOMRegionContext.XML_TAG_OPEN, DOMRegionContext.XML_TAG_NAME, DOMRegionContext.XML_EMPTY_TAG_CLOSE, DOMJSPRegionContexts.XML_TAG_ATTRIBUTE_VALUE_DQUOTE });
    assertTrue("region context type check (att value)", typeCheck);
    verifyLengths(0, nodes, text);
}
Also used : IStructuredDocumentRegionList(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegionList) ITextRegionContainer(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer)

Example 9 with ITextRegionContainer

use of org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer in project webtools.sourceediting by eclipse.

the class ScannerUnitTests method testELinTag.

public void testELinTag() {
    String text = "<input type=\"button\" ${disabled? 'disabled=\"disabled\"':''}/>";
    IStructuredDocumentRegionList nodes = setUpJSP(text);
    boolean sizeCheck = checkSimpleRegionCounts(nodes, new int[] { 7 });
    assertTrue("IStructuredDocumentRegion and ITextRegion count", sizeCheck);
    sizeCheck = checkSimpleRegionCount(((ITextRegionContainer) nodes.item(0).getRegions().get(5)), 9);
    assertTrue("IStructuredDocumentRegion and ITextRegion count", sizeCheck);
    boolean typeCheck = checkSimpleRegionTypes(nodes.item(0).getRegions(), new String[] { DOMRegionContext.XML_TAG_OPEN, DOMRegionContext.XML_TAG_NAME, DOMRegionContext.XML_TAG_ATTRIBUTE_NAME, DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS, DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE, DOMRegionContext.XML_TAG_ATTRIBUTE_NAME, DOMRegionContext.XML_EMPTY_TAG_CLOSE });
    assertTrue("region context type check", typeCheck);
    typeCheck = checkSimpleRegionTypes(((ITextRegionContainer) nodes.item(0).getRegions().get(5)).getRegions(), new String[] { DOMJSPRegionContexts.JSP_EL_OPEN, DOMJSPRegionContexts.JSP_EL_CONTENT, DOMJSPRegionContexts.JSP_EL_SQUOTE, DOMJSPRegionContexts.JSP_EL_QUOTED_CONTENT, DOMJSPRegionContexts.JSP_EL_SQUOTE, DOMJSPRegionContexts.JSP_EL_CONTENT, DOMJSPRegionContexts.JSP_EL_SQUOTE, DOMJSPRegionContexts.JSP_EL_SQUOTE, DOMJSPRegionContexts.JSP_EL_CLOSE });
    assertTrue("region context type check", typeCheck);
    verifyLengths(0, nodes.item(0), text);
}
Also used : IStructuredDocumentRegionList(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegionList) ITextRegionContainer(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer)

Example 10 with ITextRegionContainer

use of org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer in project webtools.sourceediting by eclipse.

the class ScannerUnitTests method testVBLtolerance_transparency_Squote.

public void testVBLtolerance_transparency_Squote() {
    String text = "<a type='#{out.foo}'/>";
    IStructuredDocumentRegionList nodes = setUpJSP(text);
    boolean sizeCheck = checkSimpleRegionCounts(nodes, new int[] { 6 });
    sizeCheck &= checkSimpleRegionCount(((ITextRegionContainer) nodes.item(0).getRegions().get(4)), 5);
    assertTrue("IStructuredDocumentRegion and ITextRegion count", sizeCheck);
    boolean typeCheck = checkSimpleRegionTypes(nodes.item(0).getRegions(), new String[] { DOMRegionContext.XML_TAG_OPEN, DOMRegionContext.XML_TAG_NAME, DOMRegionContext.XML_TAG_ATTRIBUTE_NAME, DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS, DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE, DOMRegionContext.XML_EMPTY_TAG_CLOSE });
    typeCheck &= checkSimpleRegionTypes(((ITextRegionContainer) nodes.item(0).getRegions().get(4)).getRegions(), new String[] { DOMJSPRegionContexts.XML_TAG_ATTRIBUTE_VALUE_SQUOTE, DOMJSPRegionContexts.JSP_VBL_OPEN, DOMJSPRegionContexts.JSP_VBL_CONTENT, DOMJSPRegionContexts.JSP_VBL_CLOSE, DOMJSPRegionContexts.XML_TAG_ATTRIBUTE_VALUE_SQUOTE });
    assertTrue("region context type check", typeCheck);
    verifyLengths(0, nodes, text);
}
Also used : IStructuredDocumentRegionList(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegionList) ITextRegionContainer(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer)

Aggregations

ITextRegionContainer (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer)52 ITextRegion (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion)39 IStructuredDocumentRegion (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion)26 ITextRegionList (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList)25 IStructuredDocumentRegionList (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegionList)11 Iterator (java.util.Iterator)10 IDOMNode (org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode)10 List (java.util.List)8 ArrayList (java.util.ArrayList)7 CustomCompletionProposal (org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal)6 ICompletionProposal (org.eclipse.jface.text.contentassist.ICompletionProposal)4 IExtensionPoint (org.eclipse.core.runtime.IExtensionPoint)3 ITextViewer (org.eclipse.jface.text.ITextViewer)3 Image (org.eclipse.swt.graphics.Image)3 IStructuredDocument (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)3 ITextRegionCollection (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionCollection)3 CMElementDeclaration (org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration)3 CMNamedNodeMap (org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap)3 CMNode (org.eclipse.wst.xml.core.internal.contentmodel.CMNode)3 NamedNodeMap (org.w3c.dom.NamedNodeMap)3