Bug 482119 - [search] New SearchPattern.R_SUBSTRING_MATCH
Summary: [search] New SearchPattern.R_SUBSTRING_MATCH
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.6   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 4.6 M5   Edit
Assignee: Manoj N Palat CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 470203
  Show dependency tree
 
Reported: 2015-11-13 09:55 EST by Noopur Gupta CLA
Modified: 2016-01-27 06:21 EST (History)
5 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Noopur Gupta CLA 2015-11-13 09:55:33 EST
In order to style tokens in substring proposals (bug 470203), a new search pattern R_SUBSTRING_MATCH is required along with the corresponding support in SearchPattern.getMatchingRegions(String pattern, String name, int matchRule).
Comment 1 Eclipse Genie CLA 2015-12-16 07:10:00 EST
New Gerrit change created: https://git.eclipse.org/r/62814
Comment 2 Noopur Gupta CLA 2015-12-16 16:52:28 EST
(In reply to Eclipse Genie from comment #1)
> New Gerrit change created: https://git.eclipse.org/r/62814

With this patch, if the pattern is "eq" and name is "contentEquals(CharSequence cs)" for a method proposal, the matching region contains the range for the "eq" in parameter type "CharSequence" as well, which is not required. 
Another example - pattern "k" and name "checkBackground" - returns ranges for both the "k"s in name.

I think it should be in sync with CharOperation#checkSubstringMatch, so just using String#indexOf should be good for now. 

If CharOperation#checkSubstringMatch is changed later to include non-consecutive occurrence of pattern characters then we will have to update the same in #getMatchingRegions also.
Comment 3 Manoj N Palat CLA 2015-12-18 04:44:59 EST
(In reply to Noopur Gupta from comment #2)
> (In reply to Eclipse Genie from comment #1)
> > New Gerrit change created: https://git.eclipse.org/r/62814
> 
> With this patch, if the pattern is "eq" and name is
> "contentEquals(CharSequence cs)" for a method proposal, the matching region
> contains the range for the "eq" in parameter type "CharSequence" as well,
> which is not required. 
> Another example - pattern "k" and name "checkBackground" - returns ranges
> for both the "k"s in name.
> 
> I think it should be in sync with CharOperation#checkSubstringMatch, so just
> using String#indexOf should be good for now. 
> 
> If CharOperation#checkSubstringMatch is changed later to include
> non-consecutive occurrence of pattern characters then we will have to update
> the same in #getMatchingRegions also.

Noopur: The assumption was that only the method name will be given for getMatchingRegions and not with parameters. In the case mentioned by you, it includes the parameters as well. Ideal case will be for the jdt.ui to pass the method name. If that is not possible can you enumerate the list of terminal tokens which I should be looking at - in the case its "(". What else should I expect and process, say '<' for eg?
Comment 4 Noopur Gupta CLA 2015-12-18 06:06:07 EST
(In reply to Manoj Palat from comment #3)
> (In reply to Noopur Gupta from comment #2)
> > (In reply to Eclipse Genie from comment #1)
> > > New Gerrit change created: https://git.eclipse.org/r/62814
> > 
> > With this patch, if the pattern is "eq" and name is
> > "contentEquals(CharSequence cs)" for a method proposal, the matching region
> > contains the range for the "eq" in parameter type "CharSequence" as well,
> > which is not required. 
> > Another example - pattern "k" and name "checkBackground" - returns ranges
> > for both the "k"s in name.
> > 
> > I think it should be in sync with CharOperation#checkSubstringMatch, so just
> > using String#indexOf should be good for now. 
> > 
> > If CharOperation#checkSubstringMatch is changed later to include
> > non-consecutive occurrence of pattern characters then we will have to update
> > the same in #getMatchingRegions also.
> 
> Noopur: The assumption was that only the method name will be given for
> getMatchingRegions and not with parameters. In the case mentioned by you, it
> includes the parameters as well. Ideal case will be for the jdt.ui to pass
> the method name. If that is not possible can you enumerate the list of
> terminal tokens which I should be looking at - in the case its "(". What
> else should I expect and process, say '<' for eg?

As of now, SearchPattern#getMatchingRegions was invoked only for Open Type dialog from jdt.ui which directly passed the type name or package string as the search string because we could easily split the qualified type name based on '-' in the display string.

With content assist, the search string being passed (from AbstractJavaCompletionProposal) is the display string of a proposal, which can be any proposal like a method, field, type, package, keyword etc. 

> can you enumerate the list of terminal tokens
Looking at the display strings of the proposals, I can see '-' for types, '(' for methods and ':' for fields.

Instead of passing the entire display string from AbstractJavaCompletionProposal in jdt.ui, we can pass only the substring upto '(', ':' or '-', whichever is found first in this order in the display string. Let me know if this is required.

> > Another example - pattern "k" and name "checkBackground" - returns 
> > ranges for both the "k"s in name.

For this case, the result should still contain only the first 'k'.
Comment 5 Manoj N Palat CLA 2015-12-28 01:53:06 EST
(In reply to Noopur Gupta from comment #4)
> 
> As of now, SearchPattern#getMatchingRegions was invoked only for Open Type
> dialog from jdt.ui which directly passed the type name or package string as
> the search string because we could easily split the qualified type name
> based on '-' in the display string.

ok.

> Instead of passing the entire display string from
> AbstractJavaCompletionProposal in jdt.ui, we can pass only the substring
> upto '(', ':' or '-', whichever is found first in this order in the display
> string. Let me know if this is required.

Yes. Let the jdt.ui pass only the substring upto the terminal char

> 
> > > Another example - pattern "k" and name "checkBackground" - returns 
> > > ranges for both the "k"s in name.
> 
> For this case, the result should still contain only the first 'k'.
ok.
Comment 6 Noopur Gupta CLA 2016-01-04 06:47:14 EST
(In reply to Manoj Palat from comment #5)
> (In reply to Noopur Gupta from comment #4)
> > Instead of passing the entire display string from
> > AbstractJavaCompletionProposal in jdt.ui, we can pass only the substring
> > upto '(', ':' or '-', whichever is found first in this order in the display
> > string. Let me know if this is required.
> 
> Yes. Let the jdt.ui pass only the substring upto the terminal char

Updated https://git.eclipse.org/r/#/c/60936/ accordingly.
Comment 7 Manoj N Palat CLA 2016-01-05 03:18:00 EST
(In reply to Noopur Gupta from comment #6)
> 
> Updated https://git.eclipse.org/r/#/c/60936/ accordingly.
Thanks Noopur. Resolving this jdt.core bug.
Comment 8 Noopur Gupta CLA 2016-01-05 09:06:07 EST
(In reply to Manoj Palat from comment #7)
> (In reply to Noopur Gupta from comment #6)
> > 
> > Updated https://git.eclipse.org/r/#/c/60936/ accordingly.
> Thanks Noopur. Resolving this jdt.core bug.

I don't see the fix in master branch of jdt.core repo yet.
Comment 9 Dani Megert CLA 2016-01-05 09:23:33 EST
.
Comment 10 Lars Vogel CLA 2016-01-05 09:44:49 EST
(In reply to Dani Megert from comment #9)
> .

Is this "." an old habit or still necessary after Bug 481803? If yes, we should open a new bug to make this not necessary.
Comment 11 Dani Megert CLA 2016-01-05 10:46:49 EST
(In reply to Lars Vogel from comment #10)
> (In reply to Dani Megert from comment #9)
> > .
> 
> Is this "." an old habit

No, not an old habit and not affected by the bug you cited. That bug was about closing bugs and not about reopening. Feel free to file a new bug.
Comment 12 Lars Vogel CLA 2016-01-05 11:01:53 EST
(In reply to Dani Megert from comment #11)
> No, not an old habit and not affected by the bug you cited. That bug was
> about closing bugs and not about reopening. Feel free to file a new bug.

Bug 485222.
Comment 14 Dusi Sarath Chandra CLA 2016-01-27 04:15:40 EST
Verified for 4.6 M5 using Version: Neon (4.6)
Build id: I20160119-0800