Author: vrubezhny
Date: 2011-05-30 12:17:53 -0400 (Mon, 30 May 2011)
New Revision: 31639
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/HTMLTextViewerConfiguration.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/JSPTextViewerConfiguration.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/computers/FaceletsELCompletionProposalComputer.java
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/computers/XmlELCompletionProposalComputer.java
Log:
JBIDE-3845
Code assist for #{messages['...']} should suggest properties when user types
"[".
Fixed for ELs in JSP/XHTML tag attribute values and partially for ELs in XHTML Text
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/HTMLTextViewerConfiguration.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/HTMLTextViewerConfiguration.java 2011-05-30
16:10:31 UTC (rev 31638)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/HTMLTextViewerConfiguration.java 2011-05-30
16:17:53 UTC (rev 31639)
@@ -52,7 +52,7 @@
ITextViewerConfiguration {
private static final char[] PROPOSAL_AUTO_ACTIVATION_CHARS = new char[] {
- '<', '=', '"', '\'', '.',
'{'
+ '<', '=', '"', '\'', '.',
'{', '['
};
TextViewerConfigurationDelegate configurationDelegate;
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/JSPTextViewerConfiguration.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/JSPTextViewerConfiguration.java 2011-05-30
16:10:31 UTC (rev 31638)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/JSPTextViewerConfiguration.java 2011-05-30
16:17:53 UTC (rev 31639)
@@ -38,7 +38,7 @@
@SuppressWarnings("restriction")
public class JSPTextViewerConfiguration extends StructuredTextViewerConfigurationJSP
implements ITextViewerConfiguration {
private static final char[] PROPOSAL_AUTO_ACTIVATION_CHARS = new char[] {
- '<', '=', '"', '\'', '.',
'{'
+ '<', '=', '"', '\'', '.',
'{', '['
};
private TextViewerConfigurationDelegate configurationDelegate;
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/computers/FaceletsELCompletionProposalComputer.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/computers/FaceletsELCompletionProposalComputer.java 2011-05-30
16:10:31 UTC (rev 31638)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/computers/FaceletsELCompletionProposalComputer.java 2011-05-30
16:17:53 UTC (rev 31639)
@@ -14,6 +14,8 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
import org.eclipse.swt.graphics.Image;
import org.eclipse.wst.html.core.internal.contentmodel.HTMLCMDocument;
import org.eclipse.wst.html.core.internal.provisional.HTMLCMProperties;
@@ -191,8 +193,54 @@
String replacementString = prefix.getText().substring(0, replacementLength) +
textProposal.getReplacementString();
int cursorPosition = replacementString.length();
- if (!prefix.isELClosed()) {
- replacementString += "}"; //$NON-NLS-1$
+ // Check if it is a long named property to be inserted
+ if (replacementString.indexOf('[') != -1) {
+ // That's it - The long message property
+
+ // Need to get the rest of line from context.getInvocationOffset()
+ IDocument doc = context.getDocument();
+
+ String restOfLine = "";
+ String restOfValue = "";
+ int endPosition = -1;
+ try {
+ int line = doc.getLineOfOffset(context.getInvocationOffset());
+ int lineStart = doc.getLineOffset(line);
+ int lineLength = doc.getLineLength(line);
+ String sDoc = doc.get();
+ restOfValue = restOfLine = sDoc.substring(context.getInvocationOffset(), lineStart +
lineLength);
+ if (endPosition != -1) {
+ // Use end of line
+ restOfValue = restOfValue.substring(0, endPosition);
+ }
+ } catch (BadLocationException e) {
+ // Ignore it
+ }
+
+ // Check if the replacementString is already configured
+ if (replacementString.indexOf(']') == -1) {
+ // Is closing ']' is in it?
+ int paraIndex = restOfValue.indexOf(']');
+ // Is the quotation is in it?
+ int quoteIndex = restOfValue.indexOf('\'');
+ if (quoteIndex == -1 || (paraIndex != -1 && quoteIndex > paraIndex)) {
+ // Need to insert closing single-quote
+ replacementString += '\'';
+ }
+ if (paraIndex == -1) {
+ // Closing ']' is to be added
+ replacementString += ']';
+ }
+ }
+
+ if (restOfLine.indexOf('}') == -1) {
+ // Add closing }-char
+ replacementString += '}';
+ }
+ } else {
+ if (!prefix.isELClosed()) {
+ replacementString += "}"; //$NON-NLS-1$
+ }
}
Image image = textProposal.getImage();
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/computers/XmlELCompletionProposalComputer.java
===================================================================
---
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/computers/XmlELCompletionProposalComputer.java 2011-05-30
16:10:31 UTC (rev 31638)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/computers/XmlELCompletionProposalComputer.java 2011-05-30
16:17:53 UTC (rev 31639)
@@ -220,18 +220,22 @@
// Ignore it
}
- // Is closing ']' is in it?
- int paraIndex = restOfValue.indexOf(']');
- // Is the quotation is in it?
- int quoteIndex = restOfValue.indexOf('\'');
- if (quoteIndex == -1 || (paraIndex != -1 && quoteIndex > paraIndex)) {
- // Need to insert closing single-quote
- replacementString += '\'';
+ // Check if the replacementString is already configured
+ if (replacementString.indexOf(']') == -1) {
+ // Is closing ']' is in it?
+ int paraIndex = restOfValue.indexOf(']');
+ // Is the quotation is in it?
+ int quoteIndex = restOfValue.indexOf('\'');
+ if (quoteIndex == -1 || (paraIndex != -1 && quoteIndex > paraIndex)) {
+ // Need to insert closing single-quote
+ replacementString += '\'';
+ }
+ if (paraIndex == -1) {
+ // Closing ']' is to be added
+ replacementString += ']';
+ }
}
- if (paraIndex == -1) {
- // Closing ']' is to be added
- replacementString += ']';
- }
+
if (prefix.isAttributeValue() && prefix.hasOpenQuote() && endPosition
== -1) {
// Add closing attr-quote
replacementString += quoteChar;
@@ -328,10 +332,55 @@
String replacementString = prefix.getText().substring(0, replacementLength) +
textProposal.getReplacementString();
int cursorPosition = replacementString.length();
- if (!prefix.isELClosed()) {
- replacementString += "}"; //$NON-NLS-1$
+ // Check if it is a long named property to be inserted
+ if (replacementString.indexOf('[') != -1) {
+ // That's it - The long message property
+
+ // Need to get the rest of line from context.getInvocationOffset()
+ IDocument doc = context.getDocument();
+
+ String restOfLine = "";
+ String restOfValue = "";
+ int endPosition = -1;
+ try {
+ int line = doc.getLineOfOffset(context.getInvocationOffset());
+ int lineStart = doc.getLineOffset(line);
+ int lineLength = doc.getLineLength(line);
+ String sDoc = doc.get();
+ restOfValue = restOfLine = sDoc.substring(context.getInvocationOffset(), lineStart +
lineLength);
+ if (endPosition != -1) {
+ // Use end of line
+ restOfValue = restOfValue.substring(0, endPosition);
+ }
+ } catch (BadLocationException e) {
+ // Ignore it
+ }
+
+ // Check if the replacementString is already configured
+ if (replacementString.indexOf(']') == -1) {
+ // Is closing ']' is in it?
+ int paraIndex = restOfValue.indexOf(']');
+ // Is the quotation is in it?
+ int quoteIndex = restOfValue.indexOf('\'');
+ if (quoteIndex == -1 || (paraIndex != -1 && quoteIndex > paraIndex)) {
+ // Need to insert closing single-quote
+ replacementString += '\'';
+ }
+ if (paraIndex == -1) {
+ // Closing ']' is to be added
+ replacementString += ']';
+ }
+ }
+
+ if (restOfLine.indexOf('}') == -1) {
+ // Add closing }-char
+ replacementString += '}';
+ }
+ } else {
+ if (!prefix.isELClosed()) {
+ replacementString += "}"; //$NON-NLS-1$
+ }
}
-
Image image = textProposal.getImage();
// JBIDE-512, JBIDE-2541 related changes ===>>>
Show replies by date