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());
}
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;
}
}
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);
}
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);
}
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);
}
Aggregations