Skip to content

Commit

Permalink
New Option in the preferences where one can change if one parameter
Browse files Browse the repository at this point in the history
should be displayed when using the code minings
  • Loading branch information
jannisCode committed Dec 10, 2024
1 parent 324bdfd commit 49f2c2d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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$
Expand All @@ -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
Expand Down Expand Up @@ -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() {
Expand All @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 49f2c2d

Please sign in to comment.