-
Notifications
You must be signed in to change notification settings - Fork 93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactoring Filter from call Hierarchy #1730
base: master
Are you sure you want to change the base?
Refactoring Filter from call Hierarchy #1730
Conversation
6f320a6
to
b598a1b
Compare
b598a1b
to
138e939
Compare
138e939
to
12a4eb0
Compare
12a4eb0
to
1d16fb4
Compare
Now it works with an enum rather than an array which is much nicer
1d16fb4
to
05762ad
Compare
Now it works with an enum rather than an array which is much nicer
05762ad
to
de3e1dc
Compare
I used your feedback and used Enums istead of arrays in the latest commit! Everything else is still the same! |
Now it works with an enum rather than an array which is much nicer eclipse-jdt#1730
de3e1dc
to
381b6cd
Compare
Now it works with an enum rather than an array which is much nicer eclipse-jdt#1730
381b6cd
to
405eaa4
Compare
Now it works with an enum rather than an array which is much nicer eclipse-jdt#1730
405eaa4
to
cc0b1e8
Compare
Now it works with an enum rather than an array which is much nicer eclipse-jdt#1730
cc0b1e8
to
b89f05b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Check the formatting, check for unnecessary changes, check the naming of the parameters (use camelCase) and there is also unnecessary if
-else
blocks (you can inline the content of the if
)
b89f05b
to
cc0b1e8
Compare
Now it works with an enum rather than an array which is much nicer eclipse-jdt#1730
cc0b1e8
to
e002f0d
Compare
Now it works with an enum rather than an array which is much nicer eclipse-jdt#1730
e002f0d
to
ac35cdf
Compare
Now it works with an enum rather than an array which is much nicer eclipse-jdt#1730
ac35cdf
to
fcdbf21
Compare
Now it works with an enum rather than an array which is much nicer eclipse-jdt#1730
60d5494
to
8f206b7
Compare
@@ -43,6 +44,7 @@ class FiltersDialog extends StatusDialog { | |||
private Button fShowAll; | |||
private Button fHideTest; | |||
private Button fShowTest; | |||
private Button[] buttons = {fShowAll, fHideTest, fShowTest}; //important what comes when |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't make too much sense, here the buttons
is initialized with 3 nulls, in a complicated way.
You can remove the fShowAll,fHideTest,fShowTest
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
public enum CallHierarchyFilterOptions { | ||
SHOW_ALL_CODE("PREF_SHOW_ALL_CODE", "Show All Code"), //$NON-NLS-1$ //$NON-NLS-2$ | ||
HIDE_TEST_CODE("PREF_HIDE_TEST_CODE", "Hide Test Code"), //$NON-NLS-1$ //$NON-NLS-2$ | ||
SHOW_TEST_CODE_ONLY("PREF_SHOW_TEST_CODE_ONLY", "Test Code only"); //$NON-NLS-1$ //$NON-NLS-2$ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should use the proper CallHierarchyMessages.FiltersDialog_ShowAllCode variables to return the labels.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Now it works with an enum rather than an array which is much nicer eclipse-jdt#1730
8f206b7
to
323ece0
Compare
Now it works with an enum rather than an array which is much nicer eclipse-jdt#1730
323ece0
to
1814d0a
Compare
Now it works with an enum rather than an array which is much nicer eclipse-jdt#1730
1814d0a
to
5952983
Compare
Now it works with an enum rather than an array which is much nicer eclipse-jdt#1730
5952983
to
4be571a
Compare
This pull request changes some projects for the first time in this development cycle.
An additional commit containing all the necessary changes was pushed to the top of this PR's branch. To obtain these changes (for example if you want to push more changes) either fetch from your fork or apply the git patch. Git patch
Further information are available in Common Build Issues - Missing version increments. |
Now it works with an enum rather than an array which is much nicer eclipse-jdt#1730
962d7f2
to
d0d0eda
Compare
if(Boolean.parseBoolean(JavaManipulation.getPreference(option.getId(), null))) { | ||
return option; | ||
} | ||
} return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
} return null; | |
} | |
return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
IPreferenceStore settings = JavaPlugin.getDefault().getPreferenceStore(); | ||
settings.setValue(PREF_HIDE_TEST_CODE, value); | ||
for(CallHierarchyFilterOptions option : CallHierarchyFilterOptions.values()) { | ||
settings.setValue(option.getId(), option == filter ? true : false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
settings.setValue(option.getId(), option == filter ? true : false); | |
settings.setValue(option.getId(), option == filter); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
} | ||
|
||
public CallHierarchyFilterOptions getActiveFilter() { | ||
for (CallHierarchyFilterOptions option: CallHierarchyFilterOptions.values()) { //must be one of the threee |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for (CallHierarchyFilterOptions option: CallHierarchyFilterOptions.values()) { //must be one of the threee | |
for (CallHierarchyFilterOptions option: CallHierarchyFilterOptions.values()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
updateEnabledState(); | ||
} | ||
|
||
private CallHierarchyFilterOptions getFilterOptions(Button B) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private CallHierarchyFilterOptions getFilterOptions(Button B) { | |
private CallHierarchyFilterOptions getFilterOptions(Button b) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
private Button fShowAll; | ||
private Button fHideTest; | ||
private Button fShowTest; | ||
private Button[] buttons = new Button[CallHierarchyFilterOptions.values().length]; //important what comes when |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
private Button[] buttons = new Button[CallHierarchyFilterOptions.values().length]; //important what comes when | |
private List<Button> buttons = new ArrayList<>(CallHierarchyFilterOptions.values().length); //important what comes when | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
for (int i = 0; i < buttons.length; i++) { | ||
buttons[i] = new Button(radioGroup, SWT.RADIO); | ||
buttons[i].setText(getFilterOptions(buttons[i]).getText()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is odd that you end up calling getFilterOptions
to know what should go into the text. Also, if you add a new value to CallHierarchyFilterOptions
then you need to adapt the method getFilterOptions
. How about you:
a) Get the text by querying the current CallHierarchyFilterOptions
and
b) Put the corresponding option into the data
of the button so you can query it later in the getFilterOptions
for (int i = 0; i < buttons.length; i++) { | |
buttons[i] = new Button(radioGroup, SWT.RADIO); | |
buttons[i].setText(getFilterOptions(buttons[i]).getText()); | |
} | |
for (CallHierarchyFilterOptions op : CallHierarchyFilterOptions.values()) { | |
Button b = new Button(radioGroup, SWT.RADIO); | |
b.setText(op.getText()); | |
b.setData(KEY_CALL_HIERARCHY_FILTER_OPTION, op); | |
buttons.add(b); | |
} |
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the help! I implemented it the way you suggestend!
if(B == buttons[0]) { | ||
return CallHierarchyFilterOptions.SHOW_ALL_CODE; | ||
} else if (B == buttons[1]) { | ||
return CallHierarchyFilterOptions.HIDE_TEST_CODE; | ||
} else { | ||
return CallHierarchyFilterOptions.SHOW_TEST_CODE_ONLY; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you have the corresponding option in the data
then you can simply query it.
if(B == buttons[0]) { | |
return CallHierarchyFilterOptions.SHOW_ALL_CODE; | |
} else if (B == buttons[1]) { | |
return CallHierarchyFilterOptions.HIDE_TEST_CODE; | |
} else { | |
return CallHierarchyFilterOptions.SHOW_TEST_CODE_ONLY; | |
} | |
return (CallHierarchyFilterOptions) b.getData(KEY_CALL_HIERARCHY_FILTER_OPTION); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
@@ -40,9 +41,7 @@ class FiltersDialog extends StatusDialog { | |||
private Button fFilterOnNames; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You need this one if you follow my advice below:
private Button fFilterOnNames; | |
private static final String KEY_CALL_HIERARCHY_FILTER_OPTION= "callHierarchyFilterOption"; //$NON-NLS-1$ | |
private Button fFilterOnNames; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Now it works with an enum rather than an array which is much nicer eclipse-jdt#1730
d0d0eda
to
5737c4c
Compare
Now it works with an enum rather than an array which is much nicer eclipse-jdt#1730
5737c4c
to
4664372
Compare
IPreferenceStore settings = JavaPlugin.getDefault().getPreferenceStore(); | ||
settings.setValue(PREF_HIDE_TEST_CODE, value); | ||
for(CallHierarchyFilterOptions option : CallHierarchyFilterOptions.values()) { | ||
settings.setValue(option.getId(), option == filter); } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
settings.setValue(option.getId(), option == filter); } | |
settings.setValue(option.getId(), option == filter); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Now it works with an enum rather than an array which is much nicer eclipse-jdt#1730
4664372
to
cf7200f
Compare
Now it works with an enum rather than an array which is much nicer eclipse-jdt#1730
cf7200f
to
e66345f
Compare
Now it works with an enum rather than an array which is much nicer eclipse-jdt#1730
e66345f
to
b48d2c4
Compare
@gzsombor is this PR good to go? Maybe some committer would like to (review and) merge? |
|
||
for (Button button : buttons) { | ||
button.setLayoutData(gridData); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rewrite this function to this:
} | |
private void createTestCodeArea(Composite parent) { | |
Composite radioGroup= new Composite(parent, SWT.NONE); | |
radioGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); | |
GridLayout layout= new GridLayout(); | |
layout.numColumns= 1; | |
radioGroup.setLayout(layout); | |
GridData gridData= new GridData(GridData.FILL_HORIZONTAL); | |
gridData.horizontalIndent= 0; | |
for (CallHierarchyFilterOptions op : CallHierarchyFilterOptions.values()) { | |
Button b= new Button(radioGroup, SWT.RADIO); | |
b.setText(op.getText()); | |
b.setData(KEY_CALL_HIERARCHY_FILTER_OPTION, op); | |
b.setLayoutData(gridData); | |
buttons.add(b); | |
} | |
setSelection(); | |
} |
That would fix the trimming of the labels too.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not a refactoring, it adds/changes the following lines:
radioGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
GridData gridData= new GridData(GridData.FILL_HORIZONTAL);
b.setLayoutData(gridData);
This should be done in another PR.
What it does
This PR is a refactoring of the code for the filters in the Call Hierarchy.
It makes the code more modifiable and versatile
Author checklist