简体   繁体   English

Pharo和Squeak Smalltalk:在包中列出未实现的方法吗?

[英]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. 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 . 希望至少可以帮助您入门,如果需要进行调整,请查看Behavior类(以了解可以使用的内容,而不是对其进行更改!), CompiledMethodSystemOrganization

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: 显然,该示例使用类别(我假设这就是包的意思?)“ Collections-Arrayed”,但您当然可以对其进行修改以使其成为方法参数,例如:

MyUtilClass unimplementedMessageSendsFor: aCategorySymbol

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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