Author: vrubezhny
Date: 2009-06-19 09:09:31 -0400 (Fri, 19 Jun 2009)
New Revision: 16064
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/AbstractXMLContentAssistProcessor.java
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
Log:
JBIDE-2808: Improve/refactor org.jboss.tools.common.kb plugin.
The skeleton to prompt for the EL in text regions is updated
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/AbstractXMLContentAssistProcessor.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/AbstractXMLContentAssistProcessor.java 2009-06-19
12:00:16 UTC (rev 16063)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/AbstractXMLContentAssistProcessor.java 2009-06-19
13:09:31 UTC (rev 16064)
@@ -12,7 +12,6 @@
import java.util.ArrayList;
import java.util.List;
-import java.util.Map;
import org.eclipse.core.filebuffers.FileBuffers;
import org.eclipse.core.resources.IFile;
@@ -20,9 +19,7 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.Region;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.jface.text.contentassist.IContextInformation;
import org.eclipse.jface.text.contentassist.IContextInformationValidator;
@@ -31,8 +28,6 @@
import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
@@ -41,6 +36,7 @@
import org.eclipse.wst.xml.ui.internal.contentassist.AbstractContentAssistProcessor;
import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest;
import org.jboss.tools.common.el.core.model.ELInstance;
+import org.jboss.tools.common.el.core.model.ELInvocationExpression;
import org.jboss.tools.common.el.core.model.ELModel;
import org.jboss.tools.common.el.core.model.ELUtil;
import org.jboss.tools.common.el.core.parser.ELParser;
@@ -49,9 +45,7 @@
import org.jboss.tools.common.el.core.resolver.ELResolver;
import org.jboss.tools.common.el.core.resolver.ELResolverFactoryManager;
import org.jboss.tools.jst.web.kb.KbQuery;
-import org.jboss.tools.jst.web.kb.PageProcessor;
import org.jboss.tools.jst.web.kb.KbQuery.Type;
-import org.jboss.tools.jst.web.kb.taglib.INameSpace;
import org.w3c.dom.Attr;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
@@ -702,13 +696,13 @@
ELParser p = ELParserUtil.getJbossFactory().createParser();
ELModel model = p.parse(text);
- ELInstance is = ELUtil.findInstance(model, inValueOffset);// ELInstance
- model.toString(); model.getSyntaxErrors();
- boolean isELStarted = (is != null) && (model != null &&
(model.toString().startsWith("#{") ||
+ ELInvocationExpression ie = ELUtil.findExpression(model, inValueOffset);// ELInstance
+
+ boolean isELStarted = (model != null &&
(model.toString().startsWith("#{") ||
model.toString().startsWith("${")));
- boolean isELClosed = (is == null) || (model != null &&
model.toString().endsWith("}"));
- TextRegion tr = new TextRegion(startOffset, is == null ? inValueOffset :
is.getStartPosition(), is == null ? 0 : inValueOffset - is.getStartPosition(), is == null
? "" : is.getText(), isELStarted, isELClosed);
+ boolean isELClosed = (model != null &&
model.toString().endsWith("}"));
+ TextRegion tr = new TextRegion(startOffset, ie == null ? inValueOffset :
ie.getStartPosition(), ie == null ? 0 : inValueOffset - ie.getStartPosition(), ie == null
? "" : ie.getText(), isELStarted, isELClosed);
return tr;
} finally {
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-19
12:00:16 UTC (rev 16063)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/FaceletPageContectAssistProcessor.java 2009-06-19
13:09:31 UTC (rev 16064)
@@ -19,14 +19,11 @@
import org.eclipse.wst.sse.core.StructuredModelManager;
import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
import org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest;
import org.jboss.tools.common.text.TextProposal;
-import
org.jboss.tools.jst.jsp.contentassist.AbstractXMLContentAssistProcessor.TextRegion;
import org.jboss.tools.jst.web.kb.IFaceletPageContext;
import org.jboss.tools.jst.web.kb.IPageContext;
import org.jboss.tools.jst.web.kb.KbQuery;
@@ -39,7 +36,6 @@
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
public class FaceletPageContectAssistProcessor extends JspContentAssistProcessor {
private static final String UI_URI_JSF_FACELETS =
"http://java.sun.com/jsf/facelets";
@@ -184,7 +180,7 @@
contentAssistRequest.addProposal(proposal);
return;
}
- String matchString = prefix.getText();
+ String matchString = "#{" + prefix.getText();
String query = matchString;
if (query == null)
query = "";
@@ -207,7 +203,7 @@
int cursorPosition = replacementString.length();
Image image = textProposal.getImage();
- String displayString = prefix.getText().substring(0, replacementLength) +
textProposal.getReplacementString() + "}";
+ String displayString = prefix.getText().substring(0, replacementLength) +
textProposal.getReplacementString();
IContextInformation contextInformation = null;
String additionalProposalInfo = textProposal.getContextInfo();
int relevance = textProposal.getRelevance() + 10000;
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-19
12:00:16 UTC (rev 16063)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JspContentAssistProcessor.java 2009-06-19
13:09:31 UTC (rev 16064)
@@ -27,7 +27,6 @@
import org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal;
import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
import org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest;
-import org.eclipse.wst.xml.ui.internal.contentassist.XMLRelevanceConstants;
import org.jboss.tools.common.el.core.resolver.ELContext;
import org.jboss.tools.common.text.TextProposal;
import org.jboss.tools.jst.web.kb.IPageContext;
@@ -247,6 +246,14 @@
@Override
protected void addTagInsertionProposals(
ContentAssistRequest contentAssistRequest, int childPosition) {
+
+ // Need to check if an EL Expression is opened here.
+ // If it is true we don't need to start any new tag proposals
+ TextRegion prefix = getELPrefix();
+ if (prefix != null && prefix.isELStarted()) {
+ return;
+ }
+
// TODO Auto-generated method stub
System.out.println("JspContentAssistProcessor: addTagInsertionProposals()
invoked");
try {