1

How do I list all unimplemented methods in a package? Given that the method should be implemented in that package and not in other (for example in a superclass outside the package or in Object).

Edit: Yes, I'd like to know "messages sent that are not implemented" but to limit the analysis to one specific given package, for ex:

FooPackage unimplementedMessageSends.

user1000565
  • 927
  • 4
  • 12
  • 1
    I read the question carefully several times and have no idea what you're asking. Maybe adding a concrete example would help – Sean DeNigris Jan 05 '12 at 19:21
  • 2
    I don't understand the question either. Maybe the author would like to know the _messages sent that are not implemented_? Or maybe he would like to know the methods that have _undefined subclass responsabilities_? Both issues can be found with CodeCritics that is part of the refactoring engine. – Lukas Renggli Jan 05 '12 at 19:28

1 Answers1

1

I haven't fully tested this so you might need to tweak it a bit to suit your requirements, but from how I understand your question, you might be after something like this:

| allMethodsSent allMethodsImplemented |
allMethodsSent := IdentitySet new.
allMethodsImplemented := IdentitySet new.
(SystemOrganization listAtCategoryNamed: #'Collections-Arrayed')
    do: [:eachClassName |
        (Smalltalk at: eachClassName) methodDictionary valuesDo: [:eachMethod |
            allMethodsSent addAll: eachMethod messages.
            ].
        allMethodsImplemented addAll: (Smalltalk at: eachClassName) selectors
        ].
^allMethodsSent
    removeAllFoundIn: allMethodsImplemented;
    yourself

Hopefully that'll help you get started at least, if you need to tweak it, have a look at the classes Behavior (to see what you can use, not to change it!), CompiledMethod, and SystemOrganization.

Obviously this example uses the category (I'm assuming that's what you mean by package?) "Collections-Arrayed", but you could of course adapt it to make that a method parameter, something like:

MyUtilClass unimplementedMessageSendsFor: aCategorySymbol
Amos M. Carpenter
  • 4,848
  • 4
  • 42
  • 72