Can we add an implementation for method and the one for class will reuse it?Uko
Sent from my iPhoneIndeed. I took again a look at it, and I found two bugs. The method looks like this:��TBehavior>>referencedClasses"Return the set of classes that are directly referenced by my methods"| answer |answer := Set new.self methods do: [ :cm |answer addAll:��( cm literals select: [ :l | l isKindOf: Association ] thenCollect: #value ) ].^ answer1. The last literal of a method because the last literal always points to the class of the method.Object methods collectAsSet: [ : cm | cm literals last value ]==>����"a Set(Object)"So, we need to ignore the last literal2. The literals that are Associations can also point to other global literals that are not classes:(ASTCache class>>#initialize) literals allButLastselect: [ :l | l isKindOf: Association ]��thenCollect: #value==> "{Smalltalk}"So, a better implementation for a method is:(Object>>#actionMap) ��literals allButLastselect: [ :l | l value isKindOf: Class ]��thenCollect: #valueI opened a bug:Cheers,DoruOn Sun, May 17, 2015 at 12:24 PM, Nicolai Hess <nicolaihess@web.de> wrote:2015-05-17 11:34 GMT+02:00 stepharo <stepharo@free.fr>:
Le 17/5/15 11:07, Yuriy Tymchuk a ��crit :
Hi, it want to rewrite the SmallLint rule which checks whether an abstract class is referenced. First question is whether the rule is really important, because sometimes there are abstract classes with some utility class methods, so maybe we should check whether they are ���instantiated��� with #new or #basicNew.
indeed this rule is not really revelant.
Now the real question is how do you get all classes referenced by a method. So instead of performing a rule check on a class, do it on a method and find if any of the accessed classes is abstract.
check the literal frame of the methods. When a method refers to a class the class binding is in the literal frame of the compiled method.There is one method to get all referenced classes by a classMorph referencedClasses -> MorphLostFocus MorphChanged PolygonMorph SystemWindow IdentityTransform GLMUIThemeExtraIcons RGMethodDefinition GTObjectPrinter .....It is defined by TBehavior.��
Uko
--