use of org.eclipse.jst.jsp.core.internal.contentmodel.tld.provisional.TLDElementDeclaration in project webtools.sourceediting by eclipse.
the class TaglibHelper method addVariables.
/**
* Adds 1.2 style TaglibVariables to the results list.
*
* @param results
* list where the <code>TaglibVariable</code> s are added
* @param node
*/
private void addVariables(List results, CMNode node, ITextRegionCollection customTag) {
List list = ((TLDElementDeclaration) node).getVariables();
Iterator it = list.iterator();
while (it.hasNext()) {
TLDVariable var = (TLDVariable) it.next();
if (!var.getDeclare())
continue;
String varName = var.getNameGiven();
if (varName == null) {
// 2.0
varName = var.getAlias();
}
if (varName == null) {
String attrName = var.getNameFromAttribute();
/*
* Iterate through the document region to find the
* corresponding attribute name, and then use its value
*/
ITextRegionList regions = customTag.getRegions();
boolean attrNameFound = false;
for (int i = 2; i < regions.size(); i++) {
ITextRegion region = regions.get(i);
if (DOMRegionContext.XML_TAG_ATTRIBUTE_NAME.equals(region.getType())) {
attrNameFound = attrName.equals(customTag.getText(region));
}
if (attrNameFound && DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE.equals(region.getType())) {
varName = StringUtils.strip(customTag.getText(region));
}
}
}
if (varName != null) {
// the default
String varClass = "java.lang.String";
// class...//$NON-NLS-1$
if (var.getVariableClass() != null) {
varClass = getVariableClass(var.getVariableClass());
}
results.add(new TaglibVariable(varClass, varName, var.getScope(), var.getDescription()));
}
}
}
use of org.eclipse.jst.jsp.core.internal.contentmodel.tld.provisional.TLDElementDeclaration in project webtools.sourceediting by eclipse.
the class TestModelIncludes method testContentModelSingleLineIncludedFileWithNoSpacesButWithTaglibInInclude.
/**
* Tests the custom tag content model when single line fragments are used
* without trailing white space
*
* @throws Exception
*/
public void testContentModelSingleLineIncludedFileWithNoSpacesButWithTaglibInInclude() throws Exception {
String projectName = "prj119576_a";
BundleResourceUtil.createSimpleProject(projectName, null, null);
BundleResourceUtil.copyBundleEntriesIntoWorkspace("/testfiles/" + projectName, "/" + projectName);
assertTrue("project could not be created", ResourcesPlugin.getWorkspace().getRoot().getProject(projectName).exists());
IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path("/prj119576_a/WebContent/body2.jsp"));
IDOMModel model = null;
try {
model = (IDOMModel) StructuredModelManager.getModelManager().getModelForRead(file);
assertTrue("model has no content", model.getStructuredDocument().getLength() > 0);
Element element = (Element) model.getIndexedRegion(75);
CMElementDeclaration ed = ModelQueryUtil.getModelQuery(model).getCMElementDeclaration(element);
assertNotNull("no (TLD) element declaration found for " + element.getNodeName(), ed);
assertTrue("not a wrapping content model element declaration: " + ed.getNodeName(), ed instanceof CMNodeWrapper);
assertTrue("not a taglib content model element declaration: " + ed.getNodeName(), ((CMNodeWrapper) ed).getOriginNode() instanceof TLDElementDeclaration);
String tagClassName = ((TLDElementDeclaration) ((CMNodeWrapper) ed).getOriginNode()).getTagclass();
assertNotNull("no tag class name found", tagClassName);
} finally {
if (model != null)
model.releaseFromRead();
}
}
use of org.eclipse.jst.jsp.core.internal.contentmodel.tld.provisional.TLDElementDeclaration in project webtools.sourceediting by eclipse.
the class JSPTranslator method addBlockMarkers.
/*
* adds block markers to JSPTranslator's block marker list for all
* elements in doc @param doc
*/
protected void addBlockMarkers(String prefix, CMDocument doc) {
if (doc.getElements().getLength() > 0) {
Iterator elements = doc.getElements().iterator();
CMNode node = null;
while (elements.hasNext()) {
node = (CMNode) elements.next();
if (node instanceof TLDElementDeclaration && ((TLDElementDeclaration) node).getBodycontent().equals(JSP12TLDNames.CONTENT_TAGDEPENDENT))
getBlockMarkers().add(new BlockMarker(prefix + node.getNodeName(), null, DOMRegionContext.BLOCK_TEXT, true));
else
getBlockMarkers().add(new BlockMarker(prefix + node.getNodeName(), null, DOMJSPRegionContexts.JSP_CONTENT, true));
}
}
}
Aggregations