Author: vrubezhny
Date: 2009-06-24 20:18:37 -0400 (Wed, 24 Jun 2009)
New Revision: 16196
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/FaceletPageContectAssistProcessor.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JspContentAssistProcessor.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/XmlContentAssistProcessor.java
Log:
JBIDE-2808: Improve/refactor org.jboss.tools.common.kb plugin.
The Var-s processing is added to the context calculation
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/FaceletPageContectAssistProcessor.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/FaceletPageContectAssistProcessor.java 2009-06-24
22:10:23 UTC (rev 16195)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/FaceletPageContectAssistProcessor.java 2009-06-25
00:18:37 UTC (rev 16196)
@@ -37,6 +37,11 @@
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
+/**
+ *
+ * @author Jeremy
+ *
+ */
public class FaceletPageContectAssistProcessor extends JspContentAssistProcessor {
private static final String UI_URI_JSF_FACELETS =
"http://java.sun.com/jsf/facelets";
private static final String UI_URI_XHTML_FACELETS =
"http://www.w3.org/1999/xhtml/facelets";
@@ -52,7 +57,7 @@
FaceletPageContextImpl context = new FaceletPageContextImpl();
context.setResource(superContext.getResource());
context.setElResolvers(superContext.getElResolvers());
- setVars(context);
+ setVars(context, superContext.getResource());
context.setResourceBundles(superContext.getResourceBundles());
context.setDocument(getDocument());
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JspContentAssistProcessor.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JspContentAssistProcessor.java 2009-06-24
22:10:23 UTC (rev 16195)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JspContentAssistProcessor.java 2009-06-25
00:18:37 UTC (rev 16196)
@@ -15,8 +15,6 @@
import java.util.Map;
import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.Region;
import org.eclipse.jface.text.contentassist.IContextInformation;
@@ -33,8 +31,6 @@
import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest;
import org.jboss.tools.common.el.core.resolver.ELContext;
import org.jboss.tools.common.text.TextProposal;
-import
org.jboss.tools.jst.jsp.contentassist.AbstractXMLContentAssistProcessor.TextRegion;
-import org.jboss.tools.jst.jsp.support.kb.WTPTextJspKbConnector.LoadBundleInfo;
import org.jboss.tools.jst.web.kb.IPageContext;
import org.jboss.tools.jst.web.kb.IResourceBundle;
import org.jboss.tools.jst.web.kb.KbQuery;
@@ -52,6 +48,11 @@
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
+/**
+ *
+ * @author Jeremy
+ *
+ */
public class JspContentAssistProcessor extends XmlContentAssistProcessor {
/**
@@ -68,7 +69,7 @@
context.setResource(superContext.getResource());
context.setElResolvers(superContext.getElResolvers());
context.setDocument(getDocument());
- setVars(context);
+ setVars(context, file);
setNameSpaces(context);
context.setLibraries(getTagLibraries(context));
context.setResourceBundles(getResourceBundles(context));
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/XmlContentAssistProcessor.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/XmlContentAssistProcessor.java 2009-06-24
22:10:23 UTC (rev 16195)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/XmlContentAssistProcessor.java 2009-06-25
00:18:37 UTC (rev 16196)
@@ -10,17 +10,31 @@
******************************************************************************/
package org.jboss.tools.jst.jsp.contentassist;
+import java.util.List;
+
import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.Region;
import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest;
+import org.jboss.tools.common.el.core.model.ELExpression;
+import org.jboss.tools.common.el.core.parser.ELParserFactory;
+import org.jboss.tools.common.el.core.parser.ELParserUtil;
+import org.jboss.tools.common.el.core.resolver.ELCompletionEngine;
import org.jboss.tools.common.el.core.resolver.ELContext;
import org.jboss.tools.common.el.core.resolver.ELContextImpl;
+import org.jboss.tools.common.el.core.resolver.ELOperandResolveStatus;
import org.jboss.tools.common.el.core.resolver.ELResolver;
-import org.jboss.tools.jst.web.kb.IFaceletPageContext;
+import org.jboss.tools.common.el.core.resolver.ElVarSearcher;
+import org.jboss.tools.common.el.core.resolver.Var;
import org.jboss.tools.jst.web.kb.IPageContext;
import org.jboss.tools.jst.web.kb.KbQuery;
import org.jboss.tools.jst.web.kb.KbQuery.Type;
-import org.jboss.tools.jst.web.kb.internal.JspContextImpl;
+/**
+ *
+ * @author Jeremy
+ *
+ */
public class XmlContentAssistProcessor extends AbstractXMLContentAssistProcessor {
/*
@@ -35,13 +49,33 @@
ELContextImpl context = new ELContextImpl();
context.setResource(getResource());
context.setElResolvers(elResolvers);
- setVars(context);
+ setVars(context, file);
return context;
}
- protected void setVars(ELContext context) {
- // TODO
+ protected void setVars(ELContextImpl context, IFile file) {
+ ELCompletionEngine fakeEngine = new ELCompletionEngine(){
+
+ public ELOperandResolveStatus resolveELOperand(IFile file,
+ ELExpression operand, boolean returnEqualedVariablesOnly,
+ List<Var> vars, ElVarSearcher varSearcher)
+ throws BadLocationException, StringIndexOutOfBoundsException {
+ return null;
+ }
+
+ public ELParserFactory getParserFactory() {
+ return ELParserUtil.getJbossFactory();
+ }
+ };
+ ElVarSearcher varSearcher = new ElVarSearcher(file, fakeEngine);
+ List<Var> vars = varSearcher.findAllVars(file, getOffset());
+
+ if (vars != null) {
+ for (Var var : vars) {
+ context.addVar(new Region(getOffset(), 0), var);
+ }
+ }
}
@Override
Show replies by date