Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 349773 - FQNPrefixMatcher uses "wrong" LastSegmentFinder
Summary: FQNPrefixMatcher uses "wrong" LastSegmentFinder
Status: CLOSED FIXED
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: 2.0.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: SR1   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-19 13:38 EDT by Alexander Nittka CLA
Modified: 2017-09-19 17:33 EDT (History)
1 user (show)

See Also:
sebastian.zarnekow: indigo+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Nittka CLA 2011-06-19 13:38:27 EDT
The tests for the FQNPrefixMatcher (FQNPrefixMatcherTest) use a different LastSegmentFinder than the default implementation.

The former (in the tests) returns the complete string after the last delimieter (baz from foo.bar.baz). Hence "b" is a matching candidate for "foo.bar.baz".
The latter (default implementation) returns null as "baz" does not contain a upper case letter. That is, in a setting that is not customised "b" is not a matching candidate.

For simple names starting with an upper case letter this is no problem, as both LastSegmentFinders yield the same result. However for lower case names the default implementation might be unsatisfactory.
Comment 1 Sebastian Zarnekow CLA 2011-06-19 13:45:29 EDT
Scheduled for SR1.

A patch is very welcome ;-)
Comment 2 Alexander Nittka CLA 2011-06-19 14:03:53 EDT
Well, I can't decide what's actually wrong. Is it the tests using the wrong LastSegmentFinder. Is it the wrong default implementation of the LastSegmentFinder. Or is it my requirement that b should be a matching candidate for foo.bar.baz...

One option would be to rename DefaultLastSegmentFinder to something else (from some tests, I see what it is doing, but I can't quite understand why that should be the default behaviour) and use a different implementation instead. How about

public String getLastSegment(String fqn, char delimiter) {
  try{
    int index = fqn.lastIndexOf(delimiter)+1;
    return fqn.substring(index);
  }catch(Exception e){
  }
  return fqn;
}

or the implementation used in FQNPrefixMatcherTest
Comment 3 Sebastian Zarnekow CLA 2011-07-30 15:37:55 EDT
Pushed to master.
Comment 4 Karsten Thoms CLA 2017-09-19 17:21:45 EDT
Closing all bugs that were set to RESOLVED before Neon.0
Comment 5 Karsten Thoms CLA 2017-09-19 17:33:08 EDT
Closing all bugs that were set to RESOLVED before Neon.0