Author: scabanovich
Date: 2010-12-09 09:41:00 -0500 (Thu, 09 Dec 2010)
New Revision: 27279
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/tld/model/handlers/JSPAdopt.java
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/tld/model/helpers/TLDToPaletteHelper.java
Log:
JBIDE-5661
https://issues.jboss.org/browse/JBIDE-5661
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/tld/model/handlers/JSPAdopt.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/tld/model/handlers/JSPAdopt.java 2010-12-09
14:30:23 UTC (rev 27278)
+++
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/tld/model/handlers/JSPAdopt.java 2010-12-09
14:41:00 UTC (rev 27279)
@@ -126,6 +126,7 @@
if(!Character.isJavaIdentifierPart(c) && c != '.' && c !=
':') return false;
}
int q = s.indexOf('<');
+ if(q < 0) q = s.indexOf("${");
if(q < 0) return false;
if(s.indexOf(n, q) < 0) return false;
return true;
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/tld/model/helpers/TLDToPaletteHelper.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/tld/model/helpers/TLDToPaletteHelper.java 2010-12-09
14:30:23 UTC (rev 27278)
+++
trunk/jst/plugins/org.jboss.tools.jst.web/src/org/jboss/tools/jst/web/tld/model/helpers/TLDToPaletteHelper.java 2010-12-09
14:41:00 UTC (rev 27279)
@@ -11,6 +11,7 @@
package org.jboss.tools.jst.web.tld.model.helpers;
import java.util.*;
+
import org.jboss.tools.common.model.*;
import org.jboss.tools.jst.web.tld.URIConstants;
import org.jboss.tools.jst.web.tld.model.TLDUtil;
@@ -167,6 +168,13 @@
if(TLDUtil.isTag(tags[i])) tab.addChild(createMacroByTag(tags[i], model));
if(TLDUtil.isFaceletTag(tags[i])) tab.addChild(createMacroByFaceletTag(tags[i],
model));
}
+ XModelObject f = tld.getChildByPath("Functions"); //$NON-NLS-1$
+ if(f != null) {
+ XModelObject[] fs = f.getChildren();
+ for (int i = 0; i < fs.length; i++) {
+ tab.addChild(createMacroByFunction(fs[i], model));
+ }
+ }
return tab;
}
@@ -174,5 +182,43 @@
return (s.length() == 0) ? s : Character.toUpperCase(s.charAt(0)) +
s.substring(1);
}
+ public XModelObject createMacroByFunction(XModelObject tag, XModel model) {
+ Properties p = new Properties();
+// String parentname = getTldName(tag.getParent());
+// String prefix = (parentname.length() == 0) ? "" : parentname +
":"; //$NON-NLS-1$ //$NON-NLS-2$
+ String shortname = tag.getAttributeValue("name"); //$NON-NLS-1$
+ p.setProperty("name", shortname); //$NON-NLS-1$
+ String signature = tag.getAttributeValue("function-signature");
//$NON-NLS-1$
+ int i = signature.indexOf("("); //$NON-NLS-1$
+ int j = signature.indexOf(")"); //$NON-NLS-1$
+ List<String> paramTypes = new ArrayList<String>();
+ if(i >= 0 && j > i) {
+ String params = signature.substring(i + 1, j);
+ StringTokenizer st = new StringTokenizer(params, ","); //$NON-NLS-1$
+ while(st.hasMoreTokens()) {
+ String param = st.nextToken().trim();
+ paramTypes.add(param);
+ }
+ }
+
+ StringBuffer sb = new StringBuffer();
+ sb.append("${"); //$NON-NLS-1$
+ sb.append(shortname);
+ sb.append("("); //$NON-NLS-1$
+ for (int k = 0; k < paramTypes.size(); k++) {
+ if(k > 0) sb.append(", "); //$NON-NLS-1$
+ sb.append("''"); //$NON-NLS-1$
+ }
+ sb.append(")"); //$NON-NLS-1$
+ sb.append("}"); //$NON-NLS-1$
+ p.setProperty(START_TEXT, sb.toString());
+
+ sb = new StringBuffer();
+
sb.append("<b>").append(shortname).append("</b><br>");
//$NON-NLS-1$ //$NON-NLS-2$
+ sb.append(signature);
+ p.setProperty(DESCRIPTION, sb.toString());
+ return model.createModelObject("SharableMacroHTML", p); //$NON-NLS-1$
+ }
+
}