Find methods with return type String

115 Views Asked by At

I try to create a query to get all methods with a specific return type. Looking at the definitions of FAMIXMethod and FAMIXBehavioralEntity I think the declaredType: is the correct method for this query on FAMIXMethodGroup.

I've tried to use the query:

self select: [ :each | each declaredType: String ]

But this stops with an

error: "MessageNotUnderstood"

1

There are 1 best solutions below

1
On

declaredType: is a setter, so you are trying to change the declaredType, which is expected to be a FAMIXType. Thus the MessageNotUnderstood.

A possible approach is to get the declaredType (which is a (sub)instance of FAMIXType) and ask for the smalltalkClass. Note that declaredType may not exist.

self select: [ :each |
    each hasDeclaredType and: [
        each declaredType smalltalkClass isKindOf: String class ] ].

Maybe a simpler approach can be devised with Moose Query, but I am not familiar with that.