ah looks very nice, indeed much more powerful than my hack. If you have time, switch to real regular expressions, because things like
add: (MethodCategorizationRule whenSelectorMatches: 'as*' categorizeIn: #converting); will easily produce false positives. For instance #assert: will end up in converting, which is not what you want ;) => /as[A-Z][a-zA-Z]*/ for instance does a much better job
On 2013-08-14, at 15:24, Stéphane Ducasse <stephane.ducasse@inria.fr> wrote:
Ok I checked and I prefer the one I used because you can express nice rules :) My next step will be to check the tests again, hack/replace the methodClassifier and code with the hacked version for a while and push everything in the system. Now I will look to see how to make them polymorphic because the classifier is simpler
Here is the default rules list (I added bench from the other list).
What is nice is that - we can express that the superclass should be used in last resort - I filtered the extensions for now.
defaultCategorizationRules
"The order is relevant, the categorizer uses the first rule matching - DF"
^OrderedCollection new add: MethodCategorizationRule forAccessors;
"initialize" add: (MethodCategorizationRule whenSelectorMatches: 'initialize*' categorizeIn: #initialization); add: (MethodCategorizationRule whenSelectorMatches: 'init*' categorizeIn: #initialization); add: (MethodCategorizationRule whenSelectorMatches: 'default*' categorizeIn: #defaults);
add: (MethodCategorizationRule whenSelectorMatches: 'as*' categorizeIn: #converting); add: (MethodCategorizationRule whenSelectorMatches: 'hash' categorizeIn: #comparing); "order is important"
"testing" add: (MethodCategorizationRule whenSelectorMatches: 'is*' categorizeIn: #testing); add: (MethodCategorizationRule whenSelectorMatches: 'has*' categorizeIn: #testing);
add: (MethodCategorizationRule whenSelectorMatches: '=' categorizeIn: #comparing);
add: (MethodCategorizationRule whenSelectorMatches: 'new' categorizeIn: #'instance creation'); add: (MethodCategorizationRule whenSelectorMatches: 'setting' categorizeIn: #'settings');
add: (MethodCategorizationRule whenSelectorMatches: 'printOn:' categorizeIn: #printing); add: (MethodCategorizationRule whenSelectorMatches: 'storeOn:' categorizeIn: #printing);
add: (MethodCategorizationRule whenSelectorMatches: '*copy*' categorizeIn: #copying);
add: (MethodCategorizationRule whenSelectorMatches: 'draw*' categorizeIn: #drawing); add: (MethodCategorizationRule whenSelectorMatches: 'bench*' categorizeIn: #benchmarking); add: (MethodCategorizationRule whenSelectorMatches: 'signal*' categorizeIn: #signalling); add: (MethodCategorizationRule whenSelectorMatches: 'add*' categorizeIn: #adding); add: (MethodCategorizationRule whenSelectorMatches: 'remove*' categorizeIn: #adding);
add: (MethodCategorizationRule whenSelectorMatches: 'open*' categorizeIn: #opening); add: (MethodCategorizationRule whenSelectorMatches: 'update*' categorizeIn: #updating); add: (MethodCategorizationRule whenSelectorMatches: 'change*' categorizeIn: #updating);
add: (MethodCategorizationRule whenSelectorMatches: 'accept*' categorizeIn: #'visitor accepting'); add: (MethodCategorizationRule whenSelectorMatches: 'visit*' categorizeIn: #visiting);
add: (MethodCategorizationRule whenSelectorMatches: 'menu*' categorizeIn: #menus);
add: (MethodCategorizationRule whenSelectorMatches: 'value' categorizeIn: #value);
"test cases" add: (MethodCategorizationRule whenSelectorMatches: 'test*' andClassInheritsFrom: TestCase categorizeIn: #tests);
add: (MethodCategorizationRule whenSelectorMatches: 'setUp' andClassInheritsFrom: TestCase categorizeIn: #'setup'); add: (MethodCategorizationRule whenSelectorMatches: 'tearDown' andClassInheritsFrom: TestCase categorizeIn: #'setup');
"baselines, versions..." add: (MethodCategorizationRule whenSelectorMatches: 'version*' andClassMatches: 'ConfigurationOf*' categorizeIn: #'versions'); add: (MethodCategorizationRule whenSelectorMatches: 'baseline*' andClassMatches: 'ConfigurationOf*' categorizeIn: #'baselines'); add: (MethodCategorizationRule whenSelectorMatches: 'development*' andClassMatches: 'ConfigurationOf*' categorizeIn: #'symbolic'); add: (MethodCategorizationRule whenSelectorMatches: 'stable*' andClassMatches: 'ConfigurationOf*' categorizeIn: #'symbolic');
add: MethodCategorizationRule usingMostUsedCategoryInSuperClasses; add: MethodCategorizationRule usingMostUsedCategoryInImage; yourself
Did you use the method categorizer that is already in the image?
=> MethodClassifier
it implements already a lot of rules, so you should plug in your tool there or remove MethodClassifier and make it work with nautilus. otherwise we have a lot of duplicated functionality.
I was not aware of it I will look at it. In fact there was a method categorizer in a nice package with tests and I took this one and adapted it. I will check the rules.
Stef