Search in sources :

Example 46 with IStructuredDocumentRegionList

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

the class ScannerUnitTests method testVBLinContent.

public void testVBLinContent() {
    String text = "#{out.foo}";
    IStructuredDocumentRegionList nodes = setUpJSP(text);
    boolean sizeCheck = checkSimpleRegionCounts(nodes, new int[] { 1 });
    assertTrue("IStructuredDocumentRegion and ITextRegion count", sizeCheck);
    sizeCheck = checkSimpleRegionCount(((ITextRegionContainer) nodes.item(0).getRegions().get(0)), 3);
    assertTrue("IStructuredDocumentRegion and ITextRegion count", sizeCheck);
    boolean typeCheck = checkSimpleRegionTypes(nodes.item(0).getRegions(), new String[] { DOMRegionContext.XML_CONTENT });
    assertTrue("region context type check", typeCheck);
    typeCheck = checkSimpleRegionTypes(((ITextRegionContainer) nodes.item(0).getRegions().get(0)).getRegions(), new String[] { DOMJSPRegionContexts.JSP_VBL_OPEN, DOMJSPRegionContexts.JSP_VBL_CONTENT, DOMJSPRegionContexts.JSP_VBL_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 47 with IStructuredDocumentRegionList

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

the class ScannerUnitTests method testEmbeddedTagInAttr.

public void testEmbeddedTagInAttr() {
    IStructuredDocumentRegionList nodes = setUpJSP("<a href=\"<jsp:getProperty/>\">");
    boolean sizeCheck = checkSimpleRegionCounts(nodes, new int[] { 6 });
    assertTrue("IStructuredDocumentRegion and ITextRegion count", sizeCheck);
    boolean typeCheck = checkComplexRegionTypes(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_CLOSE }, 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", typeCheck);
    verifyModelLength();
}
Also used : IStructuredDocumentRegionList(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegionList)

Example 48 with IStructuredDocumentRegionList

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

the class ScannerUnitTests method testBlockTagWithJSPExpressions.

/**
 * Check block tag scanning between XML content
 */
public void testBlockTagWithJSPExpressions() {
    IStructuredDocumentRegionList nodes = setUpJSP("begin <script type=\"pl2\"> <%= \"expression\"%> </scrIPt> <a></a> <disallowJSP> <%= \"expression\" %> </disallowJSP> end");
    // OLD
    // boolean sizeCheck = checkSimpleRegionCounts(nodes, new int[]{1, 6,
    // 3, 3, 1, 3, 3, 1, 3, 3, 3, 1});
    // NEW
    boolean sizeCheck = checkSimpleRegionCounts(nodes, new int[] { 1, 6, 3, 3, 1, 3, 3, 1, 3, 1, 3, 1 });
    assertTrue("IStructuredDocumentRegion and ITextRegion count", sizeCheck);
    int i = 0;
    boolean typeCheck = checkSimpleRegionTypes(nodes.item(i++).getRegions(), new String[] { DOMRegionContext.XML_CONTENT }) && checkSimpleRegionTypes(nodes.item(i++).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_CLOSE }) && checkComplexRegionTypes(nodes.item(i++).getRegions(), new String[] { DOMRegionContext.BLOCK_TEXT, DOMRegionContext.BLOCK_TEXT, DOMRegionContext.BLOCK_TEXT }, new String[][] { { DOMJSPRegionContexts.JSP_EXPRESSION_OPEN, DOMJSPRegionContexts.JSP_CONTENT, DOMJSPRegionContexts.JSP_CLOSE } }) && checkSimpleRegionTypes(nodes.item(i++).getRegions(), new String[] { DOMRegionContext.XML_END_TAG_OPEN, DOMRegionContext.XML_TAG_NAME, DOMRegionContext.XML_TAG_CLOSE }) && checkSimpleRegionTypes(nodes.item(i++).getRegions(), new String[] { DOMRegionContext.XML_CONTENT }) && checkSimpleRegionTypes(nodes.item(i++).getRegions(), new String[] { DOMRegionContext.XML_TAG_OPEN, DOMRegionContext.XML_TAG_NAME, DOMRegionContext.XML_TAG_CLOSE }) && checkSimpleRegionTypes(nodes.item(i++).getRegions(), new String[] { DOMRegionContext.XML_END_TAG_OPEN, DOMRegionContext.XML_TAG_NAME, DOMRegionContext.XML_TAG_CLOSE }) && checkSimpleRegionTypes(nodes.item(i++).getRegions(), new String[] { DOMRegionContext.XML_CONTENT }) && checkSimpleRegionTypes(nodes.item(i++).getRegions(), new String[] { DOMRegionContext.XML_TAG_OPEN, DOMRegionContext.XML_TAG_NAME, DOMRegionContext.XML_TAG_CLOSE }) && // CORRECT BEHAVIOR
    checkSimpleRegionTypes(nodes.item(i++).getRegions(), new String[] { DOMRegionContext.BLOCK_TEXT }) && // XMLRegionContext.BLOCK_TEXT})
    checkSimpleRegionTypes(nodes.item(i++).getRegions(), new String[] { DOMRegionContext.XML_END_TAG_OPEN, DOMRegionContext.XML_TAG_NAME, DOMRegionContext.XML_TAG_CLOSE }) && checkSimpleRegionTypes(nodes.item(i++).getRegions(), new String[] { DOMRegionContext.XML_CONTENT });
    assertTrue("region context type check", typeCheck);
    verifyModelLength();
}
Also used : IStructuredDocumentRegionList(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegionList)

Example 49 with IStructuredDocumentRegionList

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

the class ScannerUnitTests method testEmbeddedJSPDeclaration.

public void testEmbeddedJSPDeclaration() {
    IStructuredDocumentRegionList nodes = setUpJSP("content <foo bar=\"<%! int foo; %>\" baz=\"il\">");
    boolean sizeCheck = checkSimpleRegionCounts(nodes, new int[] { 1, 9 });
    assertTrue("IStructuredDocumentRegion and ITextRegion count", sizeCheck);
    boolean typeCheck = checkSimpleRegionTypes(nodes.item(0).getRegions(), new String[] { DOMRegionContext.XML_CONTENT }) && checkComplexRegionTypes(nodes.item(1).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_TAG_ATTRIBUTE_EQUALS, DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE, DOMRegionContext.XML_TAG_CLOSE }, new String[][] { { DOMJSPRegionContexts.XML_TAG_ATTRIBUTE_VALUE_DQUOTE, DOMJSPRegionContexts.JSP_DECLARATION_OPEN, DOMJSPRegionContexts.JSP_CONTENT, DOMJSPRegionContexts.JSP_CLOSE, DOMJSPRegionContexts.XML_TAG_ATTRIBUTE_VALUE_DQUOTE, DOMRegionContext.WHITE_SPACE } });
    assertTrue("region context type check", typeCheck);
    verifyModelLength();
}
Also used : IStructuredDocumentRegionList(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegionList)

Example 50 with IStructuredDocumentRegionList

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

the class ScannerUnitTests method testJSPRootTag.

/**
 * Check JSP code sections, as a tag, scanning between HTML content
 */
// public void testJSPScriptletTag() {
// IStructuredDocumentRegionList nodes = setUpJSP("begin <jsp:scriptlet>
// int foo = bar; //<jsp:Scriptlet>//</jsp:scriptlets</jsp:scriptlet>
// end");
// 
// boolean sizeCheck = checkSimpleRegionCounts(nodes, new int[]{1, 3, 1,
// 3,
// 1});
// assertTrue("IStructuredDocumentRegion and ITextRegion count",
// sizeCheck);
// 
// boolean typeCheck =
// checkSimpleRegionTypes(nodes.item(0).getRegions(), new String[]{
// XMLRegionContext.XML_CONTENT})
// && checkSimpleRegionTypes(nodes.item(1).getRegions(), new String[]{
// XMLRegionContext.XML_TAG_OPEN,
// XMLRegionContext.XML_TAG_NAME,
// XMLRegionContext.XML_TAG_CLOSE})
// && checkSimpleRegionTypes(nodes.item(2).getRegions(), new String[]{
// XMLJSPRegionContexts.JSP_CONTENT})
// && checkSimpleRegionTypes(nodes.item(3).getRegions(), new String[]{
// XMLRegionContext.XML_END_TAG_OPEN,
// XMLRegionContext.XML_TAG_NAME,
// XMLRegionContext.XML_TAG_CLOSE})
// && checkSimpleRegionTypes(nodes.item(4).getRegions(), new String[]{
// XMLJSPRegionContexts.XML_CONTENT});
// assertTrue("region context type check", typeCheck);
// 
// verifyModelLength();
// }
/**
 * Check JSP code sections, as a tag, scanning between HTML content
 */
// public void testJSPTextTag() {
// IStructuredDocumentRegionList nodes = setUpJSP("begin <jsp:text> int
// foo
// = bar; //<jsp:TEXT>//</jsp:Texts</jsp:text> <a> </a> end");
// 
// boolean sizeCheck = checkSimpleRegionCounts(nodes, new int[]{1, 3, 1,
// 3,
// 1, 3, 1, 3, 1});
// assertTrue("IStructuredDocumentRegion and ITextRegion count",
// sizeCheck);
// 
// boolean typeCheck =
// checkSimpleRegionTypes(nodes.item(0).getRegions(), new String[]{
// XMLJSPRegionContexts.XML_CONTENT})
// && checkSimpleRegionTypes(nodes.item(1).getRegions(), new String[]{
// XMLJSPRegionContexts.XML_TAG_OPEN,
// XMLJSPRegionContexts.XML_TAG_NAME,
// XMLJSPRegionContexts.XML_TAG_CLOSE})
// && checkSimpleRegionTypes(nodes.item(2).getRegions(), new String[]{
// XMLJSPRegionContexts.XML_CDATA_TEXT})
// && checkSimpleRegionTypes(nodes.item(3).getRegions(), new String[]{
// XMLJSPRegionContexts.XML_END_TAG_OPEN,
// XMLJSPRegionContexts.XML_TAG_NAME,
// XMLJSPRegionContexts.XML_TAG_CLOSE})
// && checkSimpleRegionTypes(nodes.item(4).getRegions(), new String[]{
// XMLJSPRegionContexts.XML_CONTENT})
// && checkSimpleRegionTypes(nodes.item(5).getRegions(), new String[]{
// XMLJSPRegionContexts.XML_TAG_OPEN,
// XMLJSPRegionContexts.XML_TAG_NAME,
// XMLJSPRegionContexts.XML_TAG_CLOSE})
// && checkSimpleRegionTypes(nodes.item(6).getRegions(), new String[]{
// XMLJSPRegionContexts.XML_CONTENT})
// && checkSimpleRegionTypes(nodes.item(7).getRegions(), new String[]{
// XMLJSPRegionContexts.XML_END_TAG_OPEN,
// XMLJSPRegionContexts.XML_TAG_NAME,
// XMLJSPRegionContexts.XML_TAG_CLOSE})
// && checkSimpleRegionTypes(nodes.item(8).getRegions(), new String[]{
// XMLJSPRegionContexts.XML_CONTENT});
// assertTrue("region context type check", typeCheck);
// 
// verifyModelLength();
// }
/**
 * Check that jsp:root is recognized and treated properly
 */
public void testJSPRootTag() {
    IStructuredDocumentRegionList nodes = setUpJSP("begin <jsp:root> <jsp:roots a> <jsp:roo a=> </jsp:root a=b><a>end");
    boolean sizeCheck = checkSimpleRegionCounts(nodes, new int[] { 1, 3, 1, 4, 1, 5, 1, 6, 3, 1 });
    assertTrue("IStructuredDocumentRegion and ITextRegion count", sizeCheck);
    boolean typeCheck = checkSimpleRegionTypes(nodes.item(0).getRegions(), new String[] { DOMRegionContext.XML_CONTENT }) && checkSimpleRegionTypes(nodes.item(1).getRegions(), new String[] { DOMRegionContext.XML_TAG_OPEN, DOMJSPRegionContexts.JSP_ROOT_TAG_NAME, DOMRegionContext.XML_TAG_CLOSE }) && checkSimpleRegionTypes(nodes.item(2).getRegions(), new String[] { DOMRegionContext.XML_CONTENT }) && checkSimpleRegionTypes(nodes.item(3).getRegions(), new String[] { DOMRegionContext.XML_TAG_OPEN, DOMRegionContext.XML_TAG_NAME, DOMRegionContext.XML_TAG_ATTRIBUTE_NAME, DOMRegionContext.XML_TAG_CLOSE }) && checkSimpleRegionTypes(nodes.item(4).getRegions(), new String[] { DOMRegionContext.XML_CONTENT }) && checkSimpleRegionTypes(nodes.item(5).getRegions(), new String[] { DOMRegionContext.XML_TAG_OPEN, DOMRegionContext.XML_TAG_NAME, DOMRegionContext.XML_TAG_ATTRIBUTE_NAME, DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS, DOMRegionContext.XML_TAG_CLOSE }) && checkSimpleRegionTypes(nodes.item(6).getRegions(), new String[] { DOMRegionContext.XML_CONTENT }) && checkSimpleRegionTypes(nodes.item(7).getRegions(), new String[] { DOMRegionContext.XML_END_TAG_OPEN, DOMJSPRegionContexts.JSP_ROOT_TAG_NAME, DOMRegionContext.XML_TAG_ATTRIBUTE_NAME, DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS, DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE, DOMRegionContext.XML_TAG_CLOSE }) && checkSimpleRegionTypes(nodes.item(8).getRegions(), new String[] { DOMRegionContext.XML_TAG_OPEN, DOMRegionContext.XML_TAG_NAME, DOMRegionContext.XML_TAG_CLOSE }) && checkSimpleRegionTypes(nodes.item(9).getRegions(), new String[] { DOMRegionContext.XML_CONTENT });
    assertTrue("region context type check", typeCheck);
    verifyModelLength();
}
Also used : IStructuredDocumentRegionList(org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegionList)

Aggregations

IStructuredDocumentRegionList (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegionList)68 ITextRegionContainer (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer)11 IStructuredDocumentRegion (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion)10 IStructuredDocument (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)6 ICSSModel (org.eclipse.wst.css.core.internal.provisional.document.ICSSModel)3 ITextRegionCollection (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionCollection)3 Enumeration (java.util.Enumeration)2 Iterator (java.util.Iterator)2 ITextRegion (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion)2 IDOMNode (org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode)2 DOMException (org.w3c.dom.DOMException)2 Element (org.w3c.dom.Element)2 NodesEvent (org.eclipse.wst.dtd.core.internal.event.NodesEvent)1 IStructuredModel (org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)1 NewDocumentEvent (org.eclipse.wst.sse.core.internal.provisional.events.NewDocumentEvent)1 NoChangeEvent (org.eclipse.wst.sse.core.internal.provisional.events.NoChangeEvent)1 RegionChangedEvent (org.eclipse.wst.sse.core.internal.provisional.events.RegionChangedEvent)1 RegionsReplacedEvent (org.eclipse.wst.sse.core.internal.provisional.events.RegionsReplacedEvent)1 StructuredDocumentRegionsReplacedEvent (org.eclipse.wst.sse.core.internal.provisional.events.StructuredDocumentRegionsReplacedEvent)1 CoreNodeList (org.eclipse.wst.sse.core.internal.text.CoreNodeList)1