Author: vrubezhny
Date: 2011-11-10 16:23:19 -0500 (Thu, 10 Nov 2011)
New Revision: 36286
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.seam.core/src/org/jboss/tools/cdi/seam/core/international/el/CDIInternationalMessagesELResolver.java
trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/ca/ELProposalProcessor.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFMessageELCompletionEngine.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELCompletionEngine.java
Log:
JBIDE-9910 Proposal info for message bundles in code completion for EL
Fix CA for resource bundle properties in Java files and Validation Issues over resource
bundle properties
Modified:
trunk/cdi/plugins/org.jboss.tools.cdi.seam.core/src/org/jboss/tools/cdi/seam/core/international/el/CDIInternationalMessagesELResolver.java
===================================================================
---
trunk/cdi/plugins/org.jboss.tools.cdi.seam.core/src/org/jboss/tools/cdi/seam/core/international/el/CDIInternationalMessagesELResolver.java 2011-11-10
21:00:49 UTC (rev 36285)
+++
trunk/cdi/plugins/org.jboss.tools.cdi.seam.core/src/org/jboss/tools/cdi/seam/core/international/el/CDIInternationalMessagesELResolver.java 2011-11-10
21:23:19 UTC (rev 36286)
@@ -424,21 +424,18 @@
}
}
} else if(expr.getType() == ELObjectType.EL_ARGUMENT_INVOCATION) {
-// Set<String> proposalsToFilter = new TreeSet<String>();
-// boolean isMessages = false;
String filter = expr.getMemberName() == null ? "" : expr.getMemberName();
boolean b = filter.startsWith("'") ||
filter.startsWith("\""); //$NON-NLS-1$ //$NON-NLS-2$
+ boolean e = filter.length() > 1 && filter.endsWith("'") ||
filter.endsWith("\"");//$NON-NLS-1$ //$NON-NLS-2$
filter = StringUtil.trimQuotes(filter);
for (Variable mbr : members) {
- if (!b && filter.length() > 0) {
+ if ((!b && filter.length() > 0) || (b && e &&
filter.length() == 0)) {
//Value is set as expression itself, we cannot compute it
resolution.setMapOrCollectionOrBundleAmoungTheTokens(true);
return;
}
-// isMessages = true;
-// filterSingularMember(mbr, proposalsToFilter);
Collection<String> keys = mbr.getKeys();
for (String key : keys) {
if(returnEqualedVariablesOnly) {
Modified:
trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/ca/ELProposalProcessor.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/ca/ELProposalProcessor.java 2011-11-10
21:00:49 UTC (rev 36285)
+++
trunk/common/plugins/org.jboss.tools.common.el.ui/src/org/jboss/tools/common/el/ui/ca/ELProposalProcessor.java 2011-11-10
21:23:19 UTC (rev 36286)
@@ -562,8 +562,18 @@
String proposalSufix = ""; //$NON-NLS-1$
String elStartChar = "#"; //$NON-NLS-1$
String documentContent = ref.getELModel().getSource();
- // Is '}'-bracket exists? If not - add the
- if(getELEndPosition(offset - ref.getStartPosition(), documentContent) == -1) {
+ // Is '#{', or '${', or '}'-bracket exists? If not - add the
+ int elEndPosition = documentContent.indexOf("#{", offset -
ref.getStartPosition()); //$NON-NLS-1$
+ int limit = documentContent.indexOf("${", offset - ref.getStartPosition());
//$NON-NLS-1$
+ if (limit != -1 && elEndPosition != -1 && limit < elEndPosition) {
+ elEndPosition = limit;
+ }
+ limit = documentContent.indexOf('}', offset - ref.getStartPosition());
+ if (limit != -1 && elEndPosition != -1 && limit < elEndPosition) {
+ elEndPosition = limit+1;
+ }
+ String restOfEL = elEndPosition == -1 ? "" : documentContent.substring(offset
- ref.getStartPosition(), elEndPosition); //$NON-NLS-1$
+ if(restOfEL.indexOf('}') == -1) {
proposalSufix = "}"; //$NON-NLS-1$
}
@@ -578,7 +588,7 @@
Image image = kbProposal.hasImage() ? kbProposal.getImage()
: getImage();
if (string.length() >= 0) {
- string = proposalPrefix + string + proposalSufix;
+ string = proposalPrefix + string;
if (string.length() > 0 && ('#' == string.charAt(0) ||
'$' == string.charAt(0)))
string = elStartChar + string.substring(1);
@@ -592,11 +602,25 @@
source = (MessagesELTextProposal)kbProposal;
}
- if (string.startsWith("['") &&
string.endsWith("']") && prefix != null &&
prefix.endsWith(".")) { //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
- String newPrefix = prefix.substring(0, prefix.length() - 1);
- resultList.add(new Proposal(string, prefix, newPrefix, offset, offset - 1 +
string.length() - proposalSufix.length(), image,
+ if (string.startsWith("[") && prefix != null &&
prefix.indexOf('.') != -1) { //$NON-NLS-1$
+ String newPrefix = prefix.substring(0, prefix.lastIndexOf('.'));
+ if (string.indexOf('\'') != -1 &&
restOfEL.indexOf('\'') != -1) // Exclude last quote if this char already
exists
+ string = string.substring(0, string.lastIndexOf('\''));
+
+ if (string.indexOf(']') == -1 && restOfEL.indexOf(']') ==
-1) // Add closing square bracket if needed
+ string += ']';
+
+ string += proposalSufix;
+ resultList.add(new Proposal(string, prefix, newPrefix, offset, offset -
(prefix.length() - newPrefix.length()) + string.length() - proposalSufix.length(), image,
kbProposal.getLabel(), additionalProposalInfo, javaElements, source));
} else {
+ if (string.indexOf('\'') != -1 &&
restOfEL.indexOf('\'') != -1) // Exclude last quote if this char already
exists
+ string = string.substring(0, string.lastIndexOf('\''));
+
+ if (string.indexOf(']') == -1 && restOfEL.indexOf(']') ==
-1) // Add closing square bracket if needed
+ string += ']';
+
+ string += proposalSufix;
resultList.add(new Proposal(string, prefix, offset, offset + string.length() -
proposalSufix.length(), image,
kbProposal.getLabel(), additionalProposalInfo, javaElements, source));
}
@@ -622,13 +646,49 @@
}
/*
+ * @return non-paired quote char if exists, otherwise 0
+ */
+ private char getPreceedingQuoteChar(int initialOffset, String restOfCurrentValue) {
+ int offset = initialOffset;
+
+ char inQuotesChar = 0;
+ while (--offset >= 0) {
+ if ('"' == restOfCurrentValue.charAt(offset) ||
+ '\'' == restOfCurrentValue.charAt(offset) &&
+ (inQuotesChar == 0 || inQuotesChar == restOfCurrentValue.charAt(offset))) {
+ if (initialOffset + offset > 0 && restOfCurrentValue.charAt(offset - 1) ==
'\\') {
+ int backslashCount = 1;
+ while ((offset - backslashCount) >= 0 &&
+ restOfCurrentValue.charAt(offset - backslashCount) == '\\') {
+ backslashCount++;
+ }
+
+ if (backslashCount % 2 == 1) {
+ inQuotesChar = inQuotesChar == 0 ? restOfCurrentValue.charAt(offset)
: 0;
+ offset -= backslashCount;
+ }
+ } else {
+ inQuotesChar = inQuotesChar == 0 ? restOfCurrentValue.charAt(offset) : 0;
+ }
+ } else if ('{' == restOfCurrentValue.charAt(offset)) {
+ if (offset > 0 &&
+ ('#' == restOfCurrentValue.charAt(offset -1) ||
+ '$' == restOfCurrentValue.charAt(offset -1))) {
+ return inQuotesChar;
+ }
+ }
+ }
+ return inQuotesChar;
+ }
+
+ /*
* Checks if the EL operand ending character is present
* @return
*/
private int getELEndPosition(int initialOffset, String restOfCurrentValue) {
int offset = -1;
- char inQuotesChar = 0;
+ char inQuotesChar = getPreceedingQuoteChar(initialOffset, restOfCurrentValue);
while (++offset < restOfCurrentValue.length() - initialOffset) {
if (inQuotesChar == 0) {
if ('}' == restOfCurrentValue.charAt(initialOffset + offset))
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFMessageELCompletionEngine.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFMessageELCompletionEngine.java 2011-11-10
21:00:49 UTC (rev 36285)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/JSFMessageELCompletionEngine.java 2011-11-10
21:23:19 UTC (rev 36286)
@@ -454,10 +454,11 @@
} else if(expr.getType() == ELObjectType.EL_ARGUMENT_INVOCATION) {
String filter = expr.getMemberName() == null ? "" : expr.getMemberName();
boolean b = filter.startsWith("'") ||
filter.startsWith("\""); //$NON-NLS-1$ //$NON-NLS-2$
+ boolean e = filter.length() > 1 && filter.endsWith("'") ||
filter.endsWith("\"");//$NON-NLS-1$ //$NON-NLS-2$
filter = StringUtil.trimQuotes(filter);
-
+
for (Variable mbr : members) {
- if (!b && filter.length() > 0) {
+ if ((!b && filter.length() > 0) || (b && e &&
filter.length() == 0)) {
//Value is set as expression itself, we cannot compute it
resolution.setMapOrCollectionOrBundleAmoungTheTokens(true);
return;
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELCompletionEngine.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELCompletionEngine.java 2011-11-10
21:00:49 UTC (rev 36285)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/el/SeamELCompletionEngine.java 2011-11-10
21:23:19 UTC (rev 36286)
@@ -273,10 +273,11 @@
} else if(expr.getType() == ELObjectType.EL_ARGUMENT_INVOCATION) {
String filter = expr.getMemberName() == null ? "" : expr.getMemberName();
boolean b = filter.startsWith("'") ||
filter.startsWith("\""); //$NON-NLS-1$ //$NON-NLS-2$
+ boolean e = filter.length() > 1 && filter.endsWith("'") ||
filter.endsWith("\"");//$NON-NLS-1$ //$NON-NLS-2$
filter = StringUtil.trimQuotes(filter);
for (TypeInfoCollector.MemberInfo mbr : members) {
- if (!b && filter.length() > 0) {
+ if ((!b && filter.length() > 0) || (b && e &&
filter.length() == 0)) {
//Value is set as expression itself, we cannot compute it
resolution.setMapOrCollectionOrBundleAmoungTheTokens(true);
return true;
@@ -302,7 +303,9 @@
replacement = '\'' + key + '\'';
label = "['" + key + "']";
}
- replacement = replacement.substring(existingString.length());
+ replacement = replacement.startsWith(existingString) ?
+ replacement.substring(existingString.length()) :
+ replacement;
kbProposal.setReplacementString(replacement);
kbProposal.setLabel(label);