Merl
Merl

Reputation: 13

Find methods with return type String

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"

Upvotes: 1

Views: 108

Answers (1)

Peter Uhnak
Peter Uhnak

Reputation: 10217

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.

Upvotes: 1

Related Questions