From 49f2c2dc6f0c07ba162b18b18f5b5a8e53e361cb Mon Sep 17 00:00:00 2001 From: jannisCode Date: Tue, 26 Nov 2024 15:04:19 +0100 Subject: [PATCH] New Option in the preferences where one can change if one parameter should be displayed when using the code minings --- .../codemining/CalleeJavaMethodParameterVisitor.java | 6 ++++++ .../JavaEditorCodeMiningConfigurationBlock.java | 11 ++++++++++- .../ui/org/eclipse/jdt/ui/PreferenceConstants.java | 8 ++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/codemining/CalleeJavaMethodParameterVisitor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/codemining/CalleeJavaMethodParameterVisitor.java index 11f14a89ef0..209b86d5cf6 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/codemining/CalleeJavaMethodParameterVisitor.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/codemining/CalleeJavaMethodParameterVisitor.java @@ -165,7 +165,13 @@ private boolean skipParameterNameCodeMining(String[] parameterNames, List arg } private boolean skipParameterNamesCodeMinings(IMethod method) { + IPreferenceStore store= JavaPlugin.getDefault().getPreferenceStore(); + boolean showFromOneParameter = store.getBoolean(PreferenceConstants.EDITOR_JAVA_SHOW_ONE_PARAMETER); + if(showFromOneParameter) { + return false; + } return method.getNumberOfParameters() <= 1; + } private boolean skipParameterNamesCodeMinings(IMethod method, String[] parameterNames) { diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/JavaEditorCodeMiningConfigurationBlock.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/JavaEditorCodeMiningConfigurationBlock.java index 06c4ebfd659..65f422731f1 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/JavaEditorCodeMiningConfigurationBlock.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/preferences/JavaEditorCodeMiningConfigurationBlock.java @@ -81,6 +81,9 @@ public class JavaEditorCodeMiningConfigurationBlock extends OptionsConfiguration private static final Key PREF_DEFAULT_FILTER_FOR_PARAMETER_NAMES= getJDTUIKey( PreferenceConstants.EDITOR_JAVA_CODEMINING_DEFAULT_FILTER_FOR_PARAMETER_NAMES); + private static final Key PREF_SHOW_ONE_PARAMETER= getJDTUIKey( + PreferenceConstants.EDITOR_JAVA_SHOW_ONE_PARAMETER); + private static final String SETTINGS_SECTION_NAME= "JavaEditorCodeMiningConfigurationBlock"; //$NON-NLS-1$ private static final String[] TRUE_FALSE= new String[] { "true", "false" }; //$NON-NLS-1$ //$NON-NLS-2$ @@ -101,7 +104,7 @@ public JavaEditorCodeMiningConfigurationBlock(IStatusChangeListener context, public static Key[] getAllKeys() { return new Key[] { PREF_CODEMINING_ENABLED, PREF_SHOW_CODEMINING_AT_LEAST_ONE, PREF_SHOW_REFERENCES, PREF_SHOW_REFERENCES_ON_TYPES, PREF_SHOW_REFERENCES_ON_FIELDS, PREF_SHOW_REFERENCES_ON_METHODS, - PREF_SHOW_IMPLEMENTATIONS, PREF_SHOW_PARAMETER_NAMES, PREF_IGNORE_INEXACT_MATCHES, PREF_FILTER_IMPLIED_PARAMETER_NAMES, PREF_DEFAULT_FILTER_FOR_PARAMETER_NAMES }; + PREF_SHOW_IMPLEMENTATIONS, PREF_SHOW_PARAMETER_NAMES, PREF_IGNORE_INEXACT_MATCHES, PREF_FILTER_IMPLIED_PARAMETER_NAMES, PREF_DEFAULT_FILTER_FOR_PARAMETER_NAMES, PREF_SHOW_ONE_PARAMETER }; } @Override @@ -227,6 +230,9 @@ private void createGeneralSection(int nColumns, Composite parent) { PreferencesMessages.JavaEditorCodeMiningConfigurationBlock_defaultFilterForParameterNames_label, PREF_DEFAULT_FILTER_FOR_PARAMETER_NAMES, TRUE_FALSE, extraIndent, section); + fFilteredPrefTree.addCheckBox(inner, + "Show one Parameter", //$NON-NLS-1$ + PREF_SHOW_ONE_PARAMETER, TRUE_FALSE, extraIndent, section); } private void updateEnableStates() { @@ -244,8 +250,11 @@ private void updateEnableStates() { // Show implementations checkboxes getCheckBox(PREF_SHOW_IMPLEMENTATIONS).getSelection(); boolean showParameterNames= getCheckBox(PREF_SHOW_PARAMETER_NAMES).getSelection(); + getCheckBox(PREF_FILTER_IMPLIED_PARAMETER_NAMES).setEnabled(showParameterNames); getCheckBox(PREF_DEFAULT_FILTER_FOR_PARAMETER_NAMES).setEnabled(showParameterNames); + getCheckBox(PREF_SHOW_ONE_PARAMETER).setEnabled(showParameterNames); + } else { atLeastOneCheckBox.setEnabled(false); ignoreInexactReferenceMatches.setEnabled(false); diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/PreferenceConstants.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/PreferenceConstants.java index 5b2fd619e15..a1fe0bc8e31 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/PreferenceConstants.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/ui/PreferenceConstants.java @@ -3939,6 +3939,12 @@ private PreferenceConstants() { */ public static final String EDITOR_JAVA_CODEMINING_DEFAULT_FILTER_FOR_PARAMETER_NAMES = "java.codemining.defalt.filter.for.parameterNames"; //$NON-NLS-1$ + /** + * @since 3.33 + */ + public static final String EDITOR_JAVA_SHOW_ONE_PARAMETER = "java.codemining.show.one.parameter"; //$NON-NLS-1$ + + /** * A named preference that stores the value for "Filter matching parameter names" when showing parameter names * in codemining. This will filter out parameter names when the passed parameter name implies the parameter name. @@ -4374,6 +4380,8 @@ public static void initializeDefaultValues(IPreferenceStore store) { store.setDefault(EDITOR_JAVA_CODEMINING_SHOW_PARAMETER_NAMES, false); store.setDefault(EDITOR_JAVA_CODEMINING_FILTER_IMPLIED_PARAMETER_NAMES, true); store.setDefault(EDITOR_JAVA_CODEMINING_DEFAULT_FILTER_FOR_PARAMETER_NAMES, true); + store.setDefault(EDITOR_JAVA_SHOW_ONE_PARAMETER, true); + // Javadoc hover & view JavaElementLinks.initDefaultPreferences(store);