use of org.eclipse.jst.jsp.core.internal.contentmodel.tld.provisional.TLDVariable 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()));
}
}
}
Aggregations