Search in sources :

Example 1 with TLDVariable

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()));
        }
    }
}
Also used : ITextRegionList(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList) TLDElementDeclaration(org.eclipse.jst.jsp.core.internal.contentmodel.tld.provisional.TLDElementDeclaration) ITextRegion(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion) Iterator(java.util.Iterator) List(java.util.List) ITextRegionList(org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList) ArrayList(java.util.ArrayList) TLDVariable(org.eclipse.jst.jsp.core.internal.contentmodel.tld.provisional.TLDVariable)

Aggregations

ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 List (java.util.List)1 TLDElementDeclaration (org.eclipse.jst.jsp.core.internal.contentmodel.tld.provisional.TLDElementDeclaration)1 TLDVariable (org.eclipse.jst.jsp.core.internal.contentmodel.tld.provisional.TLDVariable)1 ITextRegion (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion)1 ITextRegionList (org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList)1