moosetechnology / ClassNameAnalyser

MIT License
5 stars 2 forks source link

Error: #superclass was sent to nil #14

Closed olekscode closed 5 years ago

olekscode commented 5 years ago

Code to reproduce it:

featureSelector := DMFeatureSelector new.
featureSelector 
  stemming: true;
  filterAllDigits: true; 
  filterSpecialChars: true;
  selectLastSymbol: true.

aCollectionOfPackageNames := #('AST-Core' 'Athens-Cairo').

conceptualModel := featureSelector applyFeaturesOn: aCollectionOfPackageNames.
olekscode commented 5 years ago

One possible way to fix it is to treat Traits separately. You can rewrite DMFeatureSelector >> extractRootClassFrom: as

DMFeatureSelector >> extractRootClassFrom: aClass

    ({ Object . ProtoObject } includes: aClass)
        ifTrue: [ ^ aClass ].

    aClass isTrait
        ifTrue: [ ^ aClass ].

    (aClass superclass == Object)
        ifTrue: [ ^ aClass  ].

    ^ self extractRootClassFrom: (aClass superclass).