简体   繁体   中英

Pharo and Squeak Smalltalk: Listing unimplemented methods in a package?

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM