Author: vrubezhny
Date: 2011-12-07 13:14:11 -0500 (Wed, 07 Dec 2011)
New Revision: 37071
Modified:
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/computers/XmlELCompletionProposalComputer.java
Log:
JBIDE-10320 Code assist for #{messages['...']} does not work properly
Issue is fixed
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-12-07
18:12:30 UTC (rev 37070)
+++
trunk/jst/plugins/org.jboss.tools.jst.jsp/src/org/jboss/tools/jst/jsp/contentassist/computers/XmlELCompletionProposalComputer.java 2011-12-07
18:14:11 UTC (rev 37071)
@@ -191,8 +191,8 @@
if (proposals == null || proposals.length == 0)
return;
- String restOfValue = getRestOfEL(context.getDocument(),
context.getInvocationOffset());
for (TextProposal textProposal : proposals) {
+ String restOfValue = getRestOfEL(context.getDocument(),
context.getInvocationOffset());
int replacementOffset = beginChangeOffset;
int replacementLength = prefix.getLength();
String replacementString = prefix.getText().substring(0, replacementLength);
@@ -237,16 +237,9 @@
replacementString = replacementString.substring(0, replacementString.length() -1);
}
}
- cursorPosition = replacementString.length(); // Cursor will be put right after the
replacement
- if (replacementString.indexOf(']') == -1) { // Find closing square bracket in
restOfValue
- if (restOfValue.indexOf(']') != -1) {
- cursorPosition += restOfValue.indexOf(']') + 1;
- }
- }
if (restOfValue.indexOf('}') == -1) {
// Add closing }-char
-
if (replacementString.indexOf(']') == -1 &&
restOfValue.indexOf(']') != -1) {
// Need to move chars before ']' (including this char) from restOfValue to
replacementString before adding closing '}'-char
int shift = restOfValue.indexOf(']') + 1;
@@ -261,7 +254,15 @@
replacementString += "}"; //$NON-NLS-1$
}
}
-
+
+ cursorPosition = replacementString.length(); // Cursor will be put right after the
replacement
+ if (replacementString.indexOf(']') == -1) { // Find closing square bracket in
restOfValue
+ if (restOfValue.indexOf(']') != -1) {
+ cursorPosition += restOfValue.indexOf(']') + 1;
+ }
+ } else {
+ cursorPosition = replacementString.indexOf(']') + 1;
+ }
if (prefix.isAttributeValue() && prefix.hasOpenQuote() &&
!prefix.hasCloseQuote()) {
replacementString += String.valueOf(quoteChar);
}
@@ -337,8 +338,8 @@
if (proposals == null || proposals.length == 0)
return;
- String restOfValue = getRestOfEL(context.getDocument(),
context.getInvocationOffset());
for (TextProposal textProposal : proposals) {
+ String restOfValue = getRestOfEL(context.getDocument(),
context.getInvocationOffset());
int replacementOffset = beginChangeOffset;
int replacementLength = prefix.getLength();
String replacementString = prefix.getText().substring(0, replacementLength);
@@ -388,6 +389,13 @@
if (restOfValue.indexOf('}') == -1) {
// Add closing }-char
+ if (replacementString.indexOf(']') == -1 &&
restOfValue.indexOf(']') != -1) {
+ // Need to move chars before ']' (including this char) from restOfValue to
replacementString before adding closing '}'-char
+ int shift = restOfValue.indexOf(']') + 1;
+ replacementString += restOfValue.substring(0, shift);
+ replacementLength += shift;
+ restOfValue = restOfValue.substring(shift);
+ }
replacementString += '}';
}
} else {