How to find all the visible methods of a class as high-level node<>

Hi,

i need to find all the methods visible within a class (only the overwritten one, if so) preferably as high-level node<>. I digged a bit around within the MPS code and found two promising classes that could give me the answer:

  • InstanceMethodCall_InstanceMethodScope
  • ClassifierVisibleMembersScope


but i can get the nodes only as low-level SNode from there...

And all the available Finders defined within MPS seem not to do what i need, so:

1) is there a way to somehow upcast SNode?

2) did i overlook something to or do i have to write an own finder?

Thx,

Mirko

5 comments
Comment actions Permalink

Hi!

ClassifierVisibleMembersScope contains

@NotNull() public List<node<>> getNodes(Condition<SNode> condition) {

   ...

}

method, so looks like you can get node<> instances from there (this class is written in MPS, so you need to write client code using it in MPS too).
In addition SNode can be automatically casted to node<>, so you can write following expression in MPS:

List<SNode> sNodes = this.getSNodes();
nlist<> nodes = sNodes;
0
Comment actions Permalink

ah, ok,

it seems i was a little confused by the two existing implementations of ClassifierVisibleMembersScope. Both in the same package but one as STUB. What is that for?

The STUB's signature is:

@NotNull()
public List<SNode> getNodes(Condition<SNode> condition) {
  <no body>
}

and the other one is

@NotNull()
public List<node<>> getNodes(Condition<SNode> condition) {
  some BaseLang Code
}

Is the STUB-one on the way TO-BE-REMOVED soon?

Thx,

Mirko

0
Comment actions Permalink

Mirko,

The "@java_stub" models are not regular MPS models. They are the counterpart for java classes and are needed just to reference existing java code (e.g. you can reference JDK just because such a fake models are built for it). These models contain only public entities (those which can be accessed from outside), that's why you don't see the body of the methods.

So, we have a ClassifierVisibleMembersScope written in MPS (that is not in java_stub model). When it is generated and compiled, we get the result - a classfile. This classfile is collected by the java stub loader and its counterpart is built in MPS (the ClassifierVisibleMembersScope in java_stub model). So, you need to just use the class from non-stub model.

If you have any further questions, feel free to ask.

Regards,

Mihail

0
Comment actions Permalink

Mihail,

but why is it necessary to have both versions being accessible from within MPS? Couldn't the low-level one not be completely "overwritten" by the high-level one? Obviously both have the same full qualified name (except @java_stub).

Regards,

Mirko

0
Comment actions Permalink

Mirko,

You say right things - this stub model is better not to be visible at all. But the solution you propose can't be used generally for now because we need some classes generated from language models together with those language models. About your case - this model can be made non-visible as classes generated from it are not required to be used directly from MPS.

On the other hand, the presence of stub models is not a big problem since you know what they are.

We are now getting rid of the usages I've said before. After this refactoring your solution could be applied, I think.

I've created an issue in our bugtracker pointing to this discussion: http://youtrack.jetbrains.net/issue/MPS-9831. It does not have a great priority, but I think it will be fixed in some time.

Regards,

Mihail

0

Please sign in to leave a comment.