use of org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer in project webtools.sourceediting by eclipse.
the class XMLContentAssistUtilities method isXMLJSPDelimiter.
/**
* Tells you if the flatnode is the <jsp:scriptlet>, <jsp:expression>, or
* <jsp:declaration>tag
*
* ISSUE: this is a bit of hidden JSP knowledge that was implemented this
* way for expedency. Should be evolved in future to depend on
* "nestedContext".
*/
public static boolean isXMLJSPDelimiter(IStructuredDocumentRegion fn) {
boolean isDelimiter = false;
if ((fn != null) && (fn instanceof ITextRegionContainer)) {
Object[] regions = ((ITextRegionContainer) fn).getRegions().toArray();
ITextRegion temp = null;
// $NON-NLS-1$
String regionText = "";
for (int i = 0; i < regions.length; i++) {
temp = (ITextRegion) regions[i];
if (temp.getType() == DOMRegionContext.XML_TAG_NAME) {
regionText = fn.getText(temp);
if (regionText.equalsIgnoreCase("jsp:scriptlet") || regionText.equalsIgnoreCase("jsp:expression") || regionText.equalsIgnoreCase("jsp:declaration")) {
isDelimiter = true;
}
}
}
}
return isDelimiter;
}
use of org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer in project webtools.sourceediting by eclipse.
the class JSPActionValidator method hasJSPRegion.
private boolean hasJSPRegion(ITextRegion container) {
if (!(container instanceof ITextRegionContainer))
return false;
ITextRegionList regions = ((ITextRegionContainer) container).getRegions();
if (regions == null)
return false;
Iterator e = regions.iterator();
while (e.hasNext()) {
ITextRegion region = (ITextRegion) e.next();
if (region == null)
continue;
String regionType = region.getType();
if (regionType == DOMRegionContext.XML_TAG_OPEN || (isNestedTagName(regionType)))
return true;
}
return false;
}
use of org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer in project webtools.sourceediting by eclipse.
the class ScannerUnitTests method testELtolerance_transparency_Squote.
public void testELtolerance_transparency_Squote() {
IStructuredDocumentRegionList nodes = setUpJSP("<a type='${out.foo}'/>");
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_EL_OPEN, DOMJSPRegionContexts.JSP_EL_CONTENT, DOMJSPRegionContexts.JSP_EL_CLOSE, DOMJSPRegionContexts.XML_TAG_ATTRIBUTE_VALUE_SQUOTE });
assertTrue("region context type check", typeCheck);
verifyModelLength();
}
use of org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer in project webtools.sourceediting by eclipse.
the class ScannerUnitTests method checkComplexRegionTypes.
public static boolean checkComplexRegionTypes(ITextRegionList regions, String[] contexts, String[][] embeddedContexts) {
int embedCount = 0;
Iterator iterator = regions.iterator();
for (int i = 0; i < contexts.length; i++) {
if (!iterator.hasNext())
return false;
ITextRegion region = (ITextRegion) iterator.next();
assertEquals("context " + i + " incorrect", contexts[i], region.getType());
if (region instanceof ITextRegionContainer) {
ITextRegionContainer container = (ITextRegionContainer) region;
boolean embeddedResult = checkSimpleRegionCount(container, embeddedContexts[embedCount].length) && checkSimpleRegionTypes(container.getRegions(), embeddedContexts[embedCount]);
embedCount++;
assertTrue(embeddedResult);
}
}
return true;
}
use of org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer in project webtools.sourceediting by eclipse.
the class ScannerUnitTests method testVBLtolerance_transparency_Dquote.
public void testVBLtolerance_transparency_Dquote() {
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_DQUOTE, DOMJSPRegionContexts.JSP_VBL_OPEN, DOMJSPRegionContexts.JSP_VBL_CONTENT, DOMJSPRegionContexts.JSP_VBL_CLOSE, DOMJSPRegionContexts.XML_TAG_ATTRIBUTE_VALUE_DQUOTE });
assertTrue("region context type check", typeCheck);
verifyLengths(0, nodes.item(0), text);
}
Aggregations