[Custom cell provider] Cast BaseConcept to SNode?

Hi all!

I've been trying for a couple of days to create a custom cell for MyConcept which extends BaseConcept.

I have a custom MyCellProvider, extending the AbstractCellProvider. I also have a custom cell in my editor and the Inspector displays a method of type: (editorContext, node)->AbstractCellProvider.

Now I assume I would have to return something like this: return new MyCellProvider(node).

But I get the error "type node<MyConcept> is not a subtype of jetbrains.mps.smodel.SNode".

So how do I tell a custom cell to use my cell provider?

Thank you!

5 comments
Comment actions Permalink

You have to pass in SNode not node<>. SNode is an Open API interface, while node<> is a type declared in the smodel language. SModel is built on top of Open API and sometimes you need to step down on the Java level to manipulate nodes through Java directly. The "downcast" operator (written as "/") serves the purpose.

So your code should look like this: new MyCellProvider(node/);

Note: Typing "node/" straight will not work due to a problem in the editor definition, so type "(node)/" first and then delete the "parentheses". Sorry for this inconvenience.

0
Comment actions Permalink

Hi all,

I have been trying this for many days, But i don't know what to be given in the return function of custom cell.

 

What should i give in this return function of AbstractCellProvider() for custom cell creation ?

0
Comment actions Permalink

Hi all,

 

I had also referred this link https://mps-support.jetbrains.com/hc/en-us/community/posts/205828989-Show-a-list-of-nodes-in-a-read-only-style-in-an-editor.

But i couldn't able to get the static methods of EditorCell_Collection. Is there any dependency to be added ?

0
Comment actions Permalink

Jacquilinedoss, you should act like in other IDE (for example, IntelliJ Idea).

If you would like to use EditorCell_Collection find it with Ctrl + N.

And add this as dependency to your aspect.

0
Comment actions Permalink

Thank you, Slavastap

0

Please sign in to leave a comment.