-
Notifications
You must be signed in to change notification settings - Fork 189
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
Bug 531785 - Auto infix search in Open Resource #12
Bug 531785 - Auto infix search in Open Resource #12
Conversation
5702845
to
8e68049
Compare
For consistency, couldn't it be a |
Possibly yes, I will have to look at how it could be incorporated into the existing code base, but also how to make it easy to use for the client code. Maybe a related question to be sure: We want to keep the behavior backwards compatible for existing clients (so that they won't have to change their code in order to keep the old behavior), don't we? |
As much as possible yes. If some important feature does require to break some behavior, this needs to be discussed with the PMC for a decision. |
c95f8c7
to
b0fc7cd
Compare
So, as can be seen from the commits, I have implemented some other points from the todo-list in the description. The next big thing in the list is this one:
After this, I would probably move on to the last:
Plus of course, some documentation pages should be updated... BTW The Jenkins build is currently failing on some error I don't quite understand. It is possible that the error is quite unrelated to commits in this PR, but I don't know really... A final thought, after digging into this search topic more, I think that replacing the current "wildcards / camelCase / etc.-based searches" with a brand-new "fuzzy search" as known from the other IDEs out there (i. e. when writing simply & easily "illexc" finds "IllegalArgumentException") is the way to go. Yet, even finishing this one (which is rather an extension of the existing searches) could be a good start before moving on to a more "radical" change like that? As usual, feedback and hints are welcome. :) |
bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/dialogs/SearchPattern.java
Outdated
Show resolved
Hide resolved
bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/dialogs/SearchPattern.java
Outdated
Show resolved
Hide resolved
@@ -436,6 +441,21 @@ protected Comparator getItemsComparator() { | |||
return 1; | |||
} | |||
} | |||
// Prioritize names starting with the pattern |
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 could be hopefully sufficient?
The existing comparator code is written in a way which doesn't seem to let us cover the code with corresponding unit tests easily. But hopefully it doesn't matter that much in this case.
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.
No one protested, so assuming this sorting implementation is sufficient and closing this thread.
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.
Maybe reopen for a while with a question...
The current comparator implementation part:
// Prioritize names starting with the pattern
char patternFirstChar = getFirstFileNameChar(pattern);
if (patternFirstChar != 0) {
patternFirstChar = Character.toLowerCase(patternFirstChar);
m1 = patternFirstChar == Character.toLowerCase(s1.charAt(0));
m2 = patternFirstChar == Character.toLowerCase(s2.charAt(0));
if (!m1 || !m2) {
if (m1) {
return -1;
}
if (m2) {
return 1;
}
}
}
... is simple, but because of checking just the first letters, it wrongly evaluates for example name "Aabc" as a "name starting with the pattern" if the pattern is "ab". IMO the only 100% working solution would be either to de-facto re-implement the matching here (which is somewhat already done in the matches highlighting code) or to change the whole searching solution to keep metadata for every successful match. Until then, can we say that the solution above is "good enough" for now and maybe add some inline warning comment about it not being perfect?
Status update: I've tried some real-world manual testing, finding I need to fix handling of some edge cases in / with the new code. Approximately these:
|
Wow, it looks like everything is fine again :), I guess the previous build failures were given by the June release / freeze period somehow. Anyway, as can be seen, I have (hopefully) coped with the 3 points described above - by the 3 follow-up commits. So if someone could review and give a feedback, it would be great. Mainly the 3rd point was quite challenging, as I had to drill through many historical tickets to find out what is going on there in the I'm also not sure if I have correctly selected to merge the master branch into mine, or if I should do a rebase instead. So please let me know, provided I should do this differently. |
A rebase is perfectly fine. We try to avoid merge commits. |
ab825db
to
70ef7f4
Compare
@HannesWell, thanks for your quick info. So while still probably quite far from being a fully implemented PR, I have at least master-rebased, reorganized & squashed the 8 commits into 3 relatively "self-contained" ones, which I believe can somewhat simplify the reviews. |
27585f1
to
14b25b8
Compare
OK, so I have finished some smaller amendments and the code is ready for review & testing now (except for the 2 remaining tasks from PR description). I think I will take a small break from this one. ;) So @mickaelistria, @vogella or whoever is watching this issue, can you please have a look? It would be great to have some concrete suggestions before moving on, so that we avoid a major rework after everything is implemented. Thanks in advance. :) |
I'm quite busy with a handful of high priority tasks. I'll try to review it next week if no other committer does look at it in the meantime (but having someone else to review would be very welcome!) |
I will be soon on vacation for a few weeks so I cannot review at the moment. I suggest to squash the commits into one commit using interfactive rebase and force push to your branch. Also I would suggest to remove the WIP from the PR, WIP is usually something committers ignore as WIP indicates that the change is not yet complete but to me it looks (on a quick glance) that this change is actually ready for review and that you expecting feedback on it. Thanks @pbodnar for working on this, it is really nice to see an issue being worked on that makes IntelliJ better than Eclipse |
@pbodnar this one needs manual rebase. |
14b25b8
to
3dba2df
Compare
OK, freshly rebased on the latest master, squashed into 1 commit, updated the description and removed prefix "WIP". All ready for a review, hopefully. :) |
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 should really be a MatchRule like others. Keeping this consistencyy would reduce the amount of new API to be created.
Also, I've looked a bit on the web to find a formal definiton of |
OK, I can see we could remove those 2 new constructors and (currently unused)
Regarding the |
JDT's SearchPattern calls it SUBSTRING_MATCH if I understand correctly. That's a good term to reuse. |
OK, I will try to refactor the code - to introduce a new flag |
@pbodnar did you update your API baseline? I downloaded https://download.eclipse.org/eclipse/downloads/drops4/S-4.26RC2-202211231800/ and set my workspace to use this a API baseline in which I did not get the error you described. Lets see what CI thinks of this change. |
@pbodnar unfortunately this change now conflicts with your Javadoc changes. Can you rebase your change onto master? |
This covers changes implemented here: eclipse-platform/eclipse.platform.ui#12. In short, automatic prefix ("starts with") search got replaced with automatic infix ("contains") search. Also, a new wildcard character '>' was introduced to enforce the original prefix search. To improve the docs at the same time: * mention explicitly that the search is case-insensitive * unify the way example searches are formulated
978152a
to
5fda965
Compare
@vogella, thanks for your assistance. :) So I have rebased, squashed and moved version /
Can you please help once again? |
The version of org.eclipse.ui.ide in the MANIFEST.MF should be increased by +0.0.100 to signify some changes have happened compare to last release. Also, by the way, its requirement on org.eclipse.ui.workbench should set 3.128.0 as minimal version as it uses the new APIs there. |
5fda965
to
beb720c
Compare
bundles/org.eclipse.ui.navigator.resources/META-INF/MANIFEST.MF
Outdated
Show resolved
Hide resolved
beb720c
to
ce1c3e8
Compare
No, because it doesn't consume new API methods or fields. It's still compatible with the older one.
You got it ;)
Hopefully yes.
Some of those checks can already be seen in the IDE if you configure a PDE baseline referencing latest release. |
A new match rule `RULE_SUBSTRING_MATCH` is introduced in the `SearchPattern`. The constant itself is copied as-is from JDT's variant of `SearchPattern`, yet its usage and purpose differs. When used and prefix search is not enforced, then: * search is done as if "*" was specified at the pattern start * CamelCase search doesn't require the 1st pattern char to be the very 1st char of the matched string Use this in Resource search dialogs for the default and file name pattern, while also list "prefix matches" firstly and extend the matched characters highlighting to still work correctly. Path (container) and extension searches should not be affected by this. Further changes: * users can start a search pattern with ">" to enforce the old prefix-only search Necessary refactoring: * unify how `stringPattern` gets prepared in `SearchPattern.initializePatternAndMatchRule()` * this also implies refactoring of camelCaseMatch() * use `SearchPattern.initialPattern` for creating the extra patterns in the dialog class * this fixes scenarios when the newly introduced ">" is used together with "." (changes in pattern didn't get recognized) * this also means that most of the lines made by 2ff4063 are removed as they are no longer necessary Improve unit tests of `SearchPattern`: * remove duplicated examples from javadocs * newly cover basic edge cases * use better examples for starts-vs-contains-like tests * add sanity check that at least 1 testing resource matches some pattern
ce1c3e8
to
831ed83
Compare
@mickaelistria, thanks for the tips. So I have done the 2 changes in manifests as proposed + another forced rebase. And finally "All checks have passed". :) |
Thank you! |
@pbodnar the new funcationality is super nice and easy to use, thanks a bunch for this. One of my clients mentioned that it would also be very nice if the * in the middle of a work could be avoid, e.g. in the following example: the match for TaskColumnPropertyAccessor continues if:
but not if I write taskproperti have to add an * to match this one, e.g. task*propert Would you be interested in also implementing the automatic * in the middle of the search term? According to my client this is standard behavior in VSCode and IntelliJ. |
@vogella, thanks for your feedback. I have actually kinda proposed this kind of change at https://bugs.eclipse.org/bugs/show_bug.cgi?id=531785#c13 - I called it "fuzzy search" there. :) Anyway, yes, it seems doable (with matching algorithm itself being quite trivial?), with some major refactorings (API and UI changes would have to be consulted?), given I already somewhat understand the searching code behind. I'm just not sure if it still pays off when Eclipse Theia is on its way, and it is also harder for me to find some extra time for Eclipse contributions these days... Maybe when there will be more votes on this? ;) |
If the matching algorithm can be adjusted easily why not change it without any API changes? I think it would be OK for our search to become better without offering API to go back to the "not so nice" behavior. |
@vogella, good point, just extending the behavior could probably be the simplest way, provided it would by widely accepted. Question is, what with all those existing Besides that, matching, sorting and highlighting of the matches are currently done independently of each other. As seen already within this MR, this has got some limits (mainly in regards to sorting and coping with duplicated executions of +- the same stuff). I can imagine a major redesign where output from matching wouldn't be just a |
Basic feature description
A new match rule
RULE_SUBSTRING_MATCH
is introduced in theSearchPattern
. The constant itself is copied as-is from JDT's variantof
SearchPattern
, yet its usage and purpose differs.When used and prefix search is not enforced, then:
1st char of the matched string
Use this in Resource search dialogs for the default and file name
pattern, while also list "prefix matches" firstly and extend the matched
characters highlighting to still work correctly.
Path (container) and extension searches should not be affected by this.
Further changes:
prefix-only search
For seeing how autoInfixSearch differs from the old one, one can compare "SearchPatternAuto.java" with "InfixSearchPatternAuto.java".
Yet to be investigated / implemented
SearchPattern.RULE_SUBSTRING_MATCH
or similar instead ofSearchPattern.autoInfixSearch
Historical issues identified that could / should be solved later on
SearchPattern.RULE_CASE_SENSITIVE
- this flag seems to be ignored by the actual SearchPattern implementationSearchPattern.camelCaseMatch()
could be optimized to check strings' lengths firstly. Something like:Constants like
SearchPattern.END_SYMBOL
are just private and special chars checking is hard-coded in dependent classes likeFilteredResourcesSelectionDialog
Inefficient matches highlighting:
ResourceItemLabelProvider.getMatchPositions()
and related seem to contain some tricky code and logic. -> see Make matches highlighting in Resource dialog more simple and efficient #184