diff options
author | Gábor Kövesdán | 2015-07-14 13:11:53 +0000 |
---|---|---|
committer | Noopur Gupta | 2015-11-02 09:26:46 +0000 |
commit | dc2a60fbf2f942a819906d44b23c20e7e86a0b34 (patch) | |
tree | 81a71eacd32137f77425a91d85aaa2cfa9464349 | |
parent | b727c4c8f0e9596358fb8e0a8dc95e2eb4febeb8 (diff) | |
download | eclipse.jdt.ui-dc2a60fbf2f942a819906d44b23c20e7e86a0b34.tar.gz eclipse.jdt.ui-dc2a60fbf2f942a819906d44b23c20e7e86a0b34.tar.xz eclipse.jdt.ui-dc2a60fbf2f942a819906d44b23c20e7e86a0b34.zip |
Bug 350000 - [content assist] Include non-prefix matches in
auto-complete suggestions
TODO:
- Add type code completion and corresponding tests
Change-Id: I97a3f781a03aa5aa7ce96b9afa56aaccf18c0076
Signed-off-by: Gábor Kövesdán <gabor@kovesdan.org>
4 files changed, 25 insertions, 1 deletions
diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/CodeAssistConfigurationBlock.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/CodeAssistConfigurationBlock.java index 125995fafc..241e0f3a7c 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/CodeAssistConfigurationBlock.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/CodeAssistConfigurationBlock.java @@ -8,6 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation * Christian Georgi<christian.georgi@sap.com> - Bug 462770: Use OS symbol for 'Ctrl' + * Gábor Kövesdán - Contribution for Bug 350000 - [content assist] Include non-prefix matches in auto-complete suggestions *******************************************************************************/ package org.eclipse.jdt.internal.ui.preferences; @@ -76,6 +77,7 @@ class CodeAssistConfigurationBlock extends OptionsConfigurationBlock { private static final Key PREF_CODEASSIST_PREFIX_COMPLETION= getJDTUIKey(PreferenceConstants.CODEASSIST_PREFIX_COMPLETION); private static final Key PREF_CODEASSIST_DEPRECATION_CHECK= getJDTCoreKey(JavaCore.CODEASSIST_DEPRECATION_CHECK); private static final Key PREF_CODEASSIST_CAMEL_CASE_MATCH= getJDTCoreKey(JavaCore.CODEASSIST_CAMEL_CASE_MATCH); + private static final Key PREF_CODEASSIST_SUBSTRING_MATCH= getJDTCoreKey(JavaCore.CODEASSIST_SUBSTRING_MATCH); private static Key[] getAllKeys() { return new Key[] { @@ -95,6 +97,7 @@ class CodeAssistConfigurationBlock extends OptionsConfigurationBlock { PREF_CODEASSIST_PREFIX_COMPLETION, PREF_CODEASSIST_DEPRECATION_CHECK, PREF_CODEASSIST_CAMEL_CASE_MATCH, + PREF_CODEASSIST_SUBSTRING_MATCH }; } @@ -273,6 +276,9 @@ class CodeAssistConfigurationBlock extends OptionsConfigurationBlock { label= PreferencesMessages.CodeAssistConfigurationBlock_matchCamelCase_label; addCheckBox(composite, label, PREF_CODEASSIST_CAMEL_CASE_MATCH, enabledDisabled, 0); + label= PreferencesMessages.CodeAssistConfigurationBlock_matchSubstring_label; + addCheckBox(composite, label, PREF_CODEASSIST_SUBSTRING_MATCH, enabledDisabled, 0); + label= PreferencesMessages.JavaEditorPreferencePage_showOnlyProposalsVisibleInTheInvocationContext; addCheckBox(composite, label, PREF_CODEASSIST_SHOW_VISIBLE_PROPOSALS, trueFalse, 0); diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.java index cedc6f0759..4dce36ad43 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.java @@ -13,6 +13,7 @@ * Guven Demir <guven.internet+eclipse@gmail.com> - [package explorer] Alternative package name shortening: abbreviation - https://bugs.eclipse.org/bugs/show_bug.cgi?id=299514 * Thomas Reinhardt <thomas@reinhardt.com> - [build path] user library dialog should allow to select JAR from workspace - http://bugs.eclipse.org/300542 * Stephan Herrmann <stephan@cs.tu-berlin.de> - [compiler][null] inheritance of null annotations as an option - https://bugs.eclipse.org/388281 + * Gábor Kövesdán - Contribution for Bug 350000 - [content assist] Include non-prefix matches in auto-complete suggestions *******************************************************************************/ package org.eclipse.jdt.internal.ui.preferences; @@ -791,6 +792,7 @@ public final class PreferencesMessages extends NLS { public static String JavaBasePreferencePage_do_not_hide_dialog_title; public static String JavaBasePreferencePage_do_not_hide_dialog_message; public static String CodeAssistConfigurationBlock_matchCamelCase_label; + public static String CodeAssistConfigurationBlock_matchSubstring_label; public static String ComplianceConfigurationBlock_version16; public static String ComplianceConfigurationBlock_version17; public static String ComplianceConfigurationBlock_version18; diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.properties b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.properties index f59e3de2bc..8478a6b1d3 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.properties +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/PreferencesMessages.properties @@ -14,6 +14,7 @@ # Thomas Reinhardt <thomas@reinhardt.com> - [build path] user library dialog should allow to select JAR from workspace - http://bugs.eclipse.org/300542 # Stephan Herrmann <stephan@cs.tu-berlin.de> - [compiler][null] inheritance of null annotations as an option - https://bugs.eclipse.org/388281 # Christian Georgi<christian.georgi@sap.com> - Use OS symbol for 'Ctrl' - https://bugs.eclipse.org/462770 +# Gábor Kövesdán - Contribution for Bug 350000 - [content assist] Include non-prefix matches in auto-complete suggestions ############################################################################### BuildPathsPropertyPage_error_message=An error occurred while setting the build path. @@ -878,6 +879,7 @@ SmartTypingConfigurationBlock_annotationReporting_link=Also see the <a href="org CodeAssistConfigurationBlock_insertionSection_title=Insertion CodeAssistConfigurationBlock_sortingSection_title=Sorting and Filtering CodeAssistConfigurationBlock_matchCamelCase_label=Show ca&mel case matches +CodeAssistConfigurationBlock_matchSubstring_label=Show su&bstring matches CodeAssistConfigurationBlock_autoactivationSection_title=Auto Activation # do not translate the href argument (org.eclipse.jdt.ui.preferences.ProblemSeveritiesPreferencePage) TypeFilterPreferencePage_restricted_link=Type references with <a href="org.eclipse.jdt.ui.preferences.ProblemSeveritiesPreferencePage">access restrictions</a>: diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/AbstractJavaCompletionProposal.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/AbstractJavaCompletionProposal.java index 709824c8f4..84e35dae02 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/AbstractJavaCompletionProposal.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/AbstractJavaCompletionProposal.java @@ -8,6 +8,7 @@ * Contributors: * IBM Corporation - initial API and implementation * Christian Georgi<christian.georgi@sap.com> - Bug 462770: Use OS symbol for 'Ctrl' + * Gábor Kövesdán - Contribution for Bug 350000 - [content assist] Include non-prefix matches in auto-complete suggestions *******************************************************************************/ package org.eclipse.jdt.internal.ui.text.java; @@ -881,7 +882,9 @@ public abstract class AbstractJavaCompletionProposal implements IJavaCompletionP if (prefix == null || string ==null || prefix.length() > string.length()) return false; String start= string.substring(0, prefix.length()); - return start.equalsIgnoreCase(prefix) || isCamelCaseMatching() && CharOperation.camelCaseMatch(prefix.toCharArray(), string.toCharArray()); + return start.equalsIgnoreCase(prefix) || + isCamelCaseMatching() && CharOperation.camelCaseMatch(prefix.toCharArray(), string.toCharArray()) || + isSubstringMatching() && CharOperation.substringMatch(prefix.toCharArray(), string.toCharArray()); } /** @@ -931,6 +934,17 @@ public abstract class AbstractJavaCompletionProposal implements IJavaCompletionP return JavaCore.ENABLED.equals(value); } + /** + * Returns true if substring matching is enabled. + * + * @return <code>true</code> if substring matching is enabled + * @since 3.12 + */ + protected boolean isSubstringMatching() { + String value= JavaCore.getOption(JavaCore.CODEASSIST_SUBSTRING_MATCH); + return JavaCore.ENABLED.equals(value); + } + protected static boolean insertCompletion() { IPreferenceStore preference= JavaPlugin.getDefault().getPreferenceStore(); return preference.getBoolean(PreferenceConstants.CODEASSIST_INSERT_COMPLETION); |