Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 349773

Summary: FQNPrefixMatcher uses "wrong" LastSegmentFinder
Product: [Modeling] TMF Reporter: Alexander Nittka <alex>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: sebastian.zarnekow
Version: 2.0.0Flags: sebastian.zarnekow: indigo+
Target Milestone: SR1   
Hardware: All   
OS: All   
Whiteboard:

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