Author: vrubezhny
Date: 2009-06-11 14:39:49 -0400 (Thu, 11 Jun 2009)
New Revision: 15894
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageProcessor.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractComponent.java
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractTagLib.java
Log:
JBIDE-2808: Improve/refactor org.jboss.tools.common.kb plugin.
PageProcessor.getProposals() method is updated to separate EL and ordinar proposal
requests
A number of methods are fixed: a number of NullPointerException-s are fixed.
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageProcessor.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageProcessor.java 2009-06-11
18:36:44 UTC (rev 15893)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/PageProcessor.java 2009-06-11
18:39:49 UTC (rev 15894)
@@ -48,30 +48,43 @@
*/
public TextProposal[] getProposals(KbQuery query, IPageContext context) {
ArrayList<TextProposal> proposals = new ArrayList<TextProposal>();
- ITagLibrary[] libs = context.getLibraries();
- for (int i = 0; libs != null && i < libs.length; i++) {
- TextProposal[] libProposals = libs[i].getProposals(query, context);
- for (int j = 0; libProposals != null && j < libProposals.length; j++) {
- proposals.add(libProposals[j]);
+
+ if (!isQueryForELProposals(query)) {
+ ITagLibrary[] libs = context.getLibraries();
+ for (int i = 0; libs != null && i < libs.length; i++) {
+ TextProposal[] libProposals = libs[i].getProposals(query, context);
+ for (int j = 0; libProposals != null && j < libProposals.length; j++) {
+ proposals.add(libProposals[j]);
+ }
}
- }
- for (int i = 0; customTagLibs != null && i < customTagLibs.length; i++) {
- // TODO
- }
- if(query.getType() == KbQuery.Type.ATTRIBUTE_VALUE || ((query.getType() ==
KbQuery.Type.TEXT )&& context instanceof IFaceletPageContext)) {
- String value = query.getValue();
- //TODO convert value to EL string.
- String elString = value;
- ELResolver[] resolvers = context.getElResolvers();
- for (int i = 0; resolvers != null && i < resolvers.length; i++) {
- proposals.addAll(resolvers[i].getCompletions(elString, !query.isMask(),
query.getOffset(), context));
+ for (int i = 0; customTagLibs != null && i < customTagLibs.length; i++) {
+ // TODO
}
+ } else {
+ if(query.getType() == KbQuery.Type.ATTRIBUTE_VALUE || ((query.getType() ==
KbQuery.Type.TEXT )&& context instanceof IFaceletPageContext)) {
+ String value = query.getValue();
+ //TODO convert value to EL string.
+ String elString = value;
+ ELResolver[] resolvers = context.getElResolvers();
+ for (int i = 0; resolvers != null && i < resolvers.length; i++) {
+ proposals.addAll(resolvers[i].getCompletions(elString, !query.isMask(),
query.getOffset(), context));
+ }
+ }
}
-
return proposals.toArray(new TextProposal[proposals.size()]);
}
- /**
+ private boolean isQueryForELProposals(KbQuery query) {
+ if (query.getType() != KbQuery.Type.ATTRIBUTE_VALUE &&
+ query.getType() != KbQuery.Type.TEXT)
+ return false;
+
+ return (query.getValue() != null &&
+ ( query.getValue().startsWith("#{") ||
+ query.getValue().startsWith("${") ) );
+ }
+
+ /**
* Returns components
* @param query
* @param context
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractComponent.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractComponent.java 2009-06-11
18:36:44 UTC (rev 15893)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractComponent.java 2009-06-11
18:39:49 UTC (rev 15894)
@@ -326,7 +326,7 @@
*/
public TextProposal[] getProposals(KbQuery query, IPageContext context) {
IAttribute[] attributes = getAttributes(query, context);
- if(attributes.length == 0) {
+ if(attributes == null || attributes.length == 0) {
return EMPTY_PROPOSAL_LIST;
}
List<TextProposal> proposals = null;
Modified:
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractTagLib.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractTagLib.java 2009-06-11
18:36:44 UTC (rev 15893)
+++
trunk/jst/plugins/org.jboss.tools.jst.web.kb/src/org/jboss/tools/jst/web/kb/internal/taglib/AbstractTagLib.java 2009-06-11
18:39:49 UTC (rev 15894)
@@ -158,7 +158,7 @@
return EMPTY_ARRAY;
}
IComponent comp = getComponent(tagName);
- if(checkExtended(comp, context)) {
+ if(comp != null && checkExtended(comp, context)) {
return new IComponent[]{comp};
}
return EMPTY_ARRAY;
Show replies by date