Author: vrubezhny
Date: 2009-06-19 13:21:16 -0400 (Fri, 19 Jun 2009)
New Revision: 16074
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
Log:
JBIDE-2808: Improve/refactor org.jboss.tools.common.kb plugin.
The skeleton to prompt for the EL in text and attribute value regions is updated
Attribute value proposal processing is updated
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
17:18:58 UTC (rev 16073)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/FaceletPageContectAssistProcessor.java 2009-06-19
17:21:16 UTC (rev 16074)
@@ -212,12 +212,10 @@
contentAssistRequest.addProposal(proposal);
}
- if (proposals == null || proposals.length == 0) {
- if (prefix.isELStarted() && !prefix.isELClosed()) {
- CustomCompletionProposal proposal = new CustomCompletionProposal("}",
contentAssistRequest.getReplacementBeginPosition(),
- 0, 1, null, "}", null, "Close EL Expression", 10000);
- contentAssistRequest.addProposal(proposal);
- }
+ if (prefix.isELStarted() && !prefix.isELClosed()) {
+ CustomCompletionProposal proposal = new CustomCompletionProposal("}",
getOffset(),
+ 0, 1, null, "}", null, "Close EL Expression", 10001);
+ contentAssistRequest.addProposal(proposal);
}
} finally {
System.out.println("FaceletPageContectAssistProcessor: addTextELProposals()
exited");
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
17:18:58 UTC (rev 16073)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/JspContentAssistProcessor.java 2009-06-19
17:21:16 UTC (rev 16074)
@@ -29,6 +29,7 @@
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.web.kb.IPageContext;
import org.jboss.tools.jst.web.kb.IResourceBundle;
import org.jboss.tools.jst.web.kb.KbQuery;
@@ -412,6 +413,14 @@
* Calculates and adds the attribute value proposals to the Content Assist Request
object
*/
protected void addAttributeValueProposals(ContentAssistRequest contentAssistRequest) {
+
+ // 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;
+ }
+
System.out.println("JspContentAssistProcessor: addAttributeValueProposals()
invoked");
try {
String matchString = contentAssistRequest.getMatchString();
@@ -473,11 +482,23 @@
System.out.println("JspContentAssistProcessor: addAttributeValueELProposals()
invoked");
try {
TextRegion prefix = getELPrefix();
- String matchString = prefix.getText();
+ if (prefix == null) {
+ return;
+ }
+
+ if(!prefix.isELStarted()) {
+ CustomCompletionProposal proposal = new CustomCompletionProposal("#{}",
getOffset(),
+ 0, 2, null, "#{}", null, "New EL Expression", 10000);
+ contentAssistRequest.addProposal(proposal);
+ return;
+ }
+ String matchString = "#{" + prefix.getText();
String query = matchString;
if (query == null)
query = "";
String stringQuery = matchString;
+
+ int beginChangeOffset = prefix.getStartOffset() + prefix.getOffset();
KbQuery kbQuery = createKbQuery(Type.ATTRIBUTE_VALUE, query, stringQuery);
TextProposal[] proposals = PageProcessor.getInstance().getProposals(kbQuery,
getContext());
@@ -487,20 +508,26 @@
System.out.println("Tag Attribute Value EL proposal [" + (i + 1) +
"/" + proposals.length + "]: " +
textProposal.getReplacementString());
- String replacementString = textProposal.getReplacementString();
+ int replacementOffset = beginChangeOffset;
+ int replacementLength = prefix.getLength();
+ String replacementString = prefix.getText().substring(0, replacementLength) +
textProposal.getReplacementString();
+ int cursorPosition = replacementString.length();
+ Image image = textProposal.getImage();
- int replacementOffset = contentAssistRequest.getReplacementBeginPosition();
- int replacementLength = contentAssistRequest.getReplacementLength();
- int cursorPosition = getCursorPositionForProposedText(replacementString);
- Image image = textProposal.getImage();
- String displayString = (textProposal.getLabel() == null ? replacementString :
textProposal.getLabel());
+ String displayString = prefix.getText().substring(0, replacementLength) +
textProposal.getReplacementString();
IContextInformation contextInformation = null;
String additionalProposalInfo = (textProposal.getContextInfo() == null ? ""
: textProposal.getContextInfo());
int relevance = textProposal.getRelevance() + 10000;
-
+
CustomCompletionProposal proposal = new CustomCompletionProposal(replacementString,
replacementOffset, replacementLength, cursorPosition, image, displayString,
contextInformation, additionalProposalInfo, relevance);
contentAssistRequest.addProposal(proposal);
}
+
+ if (prefix.isELStarted() && !prefix.isELClosed()) {
+ CustomCompletionProposal proposal = new CustomCompletionProposal("}",
getOffset(),
+ 0, 1, null, "}", null, "Close EL Expression", 10001);
+ contentAssistRequest.addProposal(proposal);
+ }
} finally {
System.out.println("JspContentAssistProcessor: addAttributeELProposals()
exited");
}