| Summary: | Documentation about use of "SearchPattern.R_REGEXP_MATCH" is wrong | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | joerg <joerg.domaschka> | ||||||
| Component: | Core | Assignee: | Satyam Kandula <satyam.kandula> | ||||||
| Status: | VERIFIED FIXED | QA Contact: | |||||||
| Severity: | major | ||||||||
| Priority: | P3 | CC: | amj87.iitr, joerg.domaschka, satyam.kandula, srikanth_sankaran, stephan.herrmann | ||||||
| Version: | 3.5.1 | Flags: | stephan.herrmann:
review+
|
||||||
| Target Milestone: | 3.8 M7 | ||||||||
| Hardware: | PC | ||||||||
| OS: | Linux | ||||||||
| Whiteboard: | |||||||||
| Attachments: |
|
||||||||
Fixed the comment and released using commit 6a31f7b894cb57eee0afe92309b5b578eca7edb4 OK, the docs for R_REGEXP_MATCH and createPattern(..) (two versions) are updated. But what about validateMatchRule(..)? That still looks wrong to me, as per comment 0: > The JavaDoc of SearchPattern.validateMatchRule(String stringPattern, int matchRule) says: "when the R_REGEXP_MATCH flag is set, then the pattern is rejected as this kind of match is not supported yet and-1 is returned". This is not the way it is implemented. The implementation checks whether R_REGEXP_MATCH is set *together with* one of the other flags. Perhaps in this place the implementation should be adjusted to the spec? Created attachment 214902 [details]
code patch
Fix to validateMatchRule to return -1 if this expression is set. Thanks Stephan for catching this. Can you also review the change?
Patch looks good. Thanks Stephan. Released the patch via commit 20fa95b73616c543b99afd6d679821c3656bc2c0 Created attachment 214973 [details]
plugin to verify
Verified using attached plugin and build I20120502-1800.
|
Build Identifier: M20090917-0800 Obviously support for SearchPattern.R_REGEXP_MATCH is not implemented. Yet, the documentation of SearchPatter.createPattern(String stringPattern, int searchFor, int limitTo, int matchRule) does not mention it. Worse, createPattern() does not return null, but treats the regular expression as a normal pattern which leads to very unexpected behaviour. The JavaDoc of SearchPattern.validateMatchRule(String stringPattern, int matchRule) says: "when the R_REGEXP_MATCH flag is set, then the pattern is rejected as this kind of match is not supported yet and-1 is returned". This is not the way it is implemented. This is very confusing as well. I am not requesting that this feature be implemented (even thought that would be nice), but a hint in the API that R_REGEXP_MATCH is not ready for use would have saved me some hours. Reproducible: Always Steps to Reproduce: 1. Create a file Test.java: class Test { private void a(){ Object o = new Object(); String s = o.toString(); } } 2. In your search implementation: String regex = "java\\.lang\\.((String)|(Object)); SearchPattern pattern = SearchPattern.createPattern(regex, IJavaSearchConstants.REFERENCES,IJavaSearchConstants.TYPE, SearchPattern.R_REGEXP_MATCH); ... SearchEngine se = new SearchEngine(); se.search(pattern, ..., ..., ..., null); you will notice that the respective SearchRequestor is never called.