diff options
author | Wooyoung Cho | 2013-08-13 21:55:20 +0000 |
---|---|---|
committer | Chris | 2013-08-14 17:33:58 +0000 |
commit | 90c2977e67c89b74ec3bd4a081b89defb7ba43fd (patch) | |
tree | 6bcb393e632b8f33b2bdabfd475314c09c9f0639 | |
parent | 4deb657c4579a2d040ca6f7afab2e46a95d6c5d8 (diff) | |
download | webtools.jsdt.core-90c2977e67c89b74ec3bd4a081b89defb7ba43fd.tar.gz webtools.jsdt.core-90c2977e67c89b74ec3bd4a081b89defb7ba43fd.tar.xz webtools.jsdt.core-90c2977e67c89b74ec3bd4a081b89defb7ba43fd.zip |
Bugzilla 315660. Insert of assist proposal fails inside nested object
literal
There is a separate commit for changes in org.eclipse.jsdt.tests
-rw-r--r-- | bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/AbstractJavaCompletionProposal.java | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/AbstractJavaCompletionProposal.java b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/AbstractJavaCompletionProposal.java index 26070432..6e70fed8 100644 --- a/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/AbstractJavaCompletionProposal.java +++ b/bundles/org.eclipse.wst.jsdt.ui/src/org/eclipse/wst/jsdt/internal/ui/text/java/AbstractJavaCompletionProposal.java @@ -637,6 +637,22 @@ public abstract class AbstractJavaCompletionProposal implements IJavaCompletionP return validate(document, offset, null); } + /** + * As JavaCompletionProposal can have multiple left parenthesis and block comments, + * find variable location where ContentAssist invoked and modify ReplacementOffset to check validate successfully and replace proposal correctly. + * @param strPrefix the prefix string of this proposal + */ + private void correctReplacementOffset(String strPrefix) { + int strLength = strPrefix.length(); + for (int index = strLength - 1; index >= 0; index--) { + char ch = strPrefix.charAt(index); + if (ch == '(' || ch == '/' || Character.isWhitespace(ch)) { + setReplacementOffset(getReplacementOffset() + index + 1); + break; + } + } + } + /* * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#validate(org.eclipse.jface.text.IDocument, int, org.eclipse.jface.text.DocumentEvent) */ @@ -645,6 +661,8 @@ public abstract class AbstractJavaCompletionProposal implements IJavaCompletionP if (offset < getReplacementOffset()) return false; + correctReplacementOffset(getPrefix(document, offset)); + boolean validated= isValidPrefix(getPrefix(document, offset)); if (validated && event != null) { |