Path-like navigation Follow
Hi,
my small sample-application has a simple tree-like structure where i want to build a behaviour very similar to the "."-Operator in Base-Language (f.e. class.method or class.field). I searched within the code for base-language to find the place where these restrictions to the possible (sub)elements occurr (monkey see, monkey do ;-)) . Not very successful. Can you give me hint, where to look for the implementation of such a sample?
Thx, Mirko
Please sign in to leave a comment.
Hi, Mirko,
If you want to add new after dot constructs, you have to implement IOperation concept interface. Take a look, for example at the ArrayLengthOperation concept.
Regards,
Konstantin
Thanks Konstantin!
It's amazing how fast you answer my questions! Pretty good Forum here at JetBrains!!
Hi Konstantin,
i created such an IOperation-Implementation and defined the Constraints as follows (similar to ArrayLengthOperation):
can be child (Strong Subtype): coerceStrong(parentNode:DotExpression.operand.type :<< concept = MyType as mytype) != null;
--- assuming a the left operand of the Dot-Operation must be of strong (sub)type MyType (am i right?)
i also created an editor (same as ArrayLengthOperation) and a TypeSystem for that operation:
typeof(operation) :==: <node<MyTargetType>>;
anyway... i do not get an intention or any other behavior when i write a "." behind some Element typed as MyType. Did i forget something? do i have to define an intention or do i have to say somewhere "This Operation is to be used in my models"?
Are IOperation-Types always be taken automatically into account when typing "."?
Thanks in advance,
Mirko
Hello, Mirko,
What is available in completion menu after you pressed dot? You can tune representation of your concept with alias and short_description concept properties.
If you want, you can send me your project at the email Konstantin.Solomatov@jetbrains.com and I will take a look and figure out what's wrong with your project.
Regards,
Konstantin.
Hi Konstantin,
the completion-menu doesn't appear automatically after typing ".". When i then hit Ctrl-Space after the "." i get the Context-menu with the text 'No variants for "roleToken."'.
do you have a totally simplified sample that defines an extension for DotExpression?
Thanks,
Mirko
Hi, Mirko,
In order for . be available, your expression should have type. Make sure that it does by pressing ctrl+shfit+T. If it doesn't, create a type system rule which sets type.
Konstantin.
Hi Konstantin,
ahhh, ok.... when i hit ctrl+shift+T in my sandbox-model i get "no type". So i will have to define Type...
is it right, that i have no type until i spefically define one, even if there is no ambiguity?
Thx,
Mirko
Right, you have to define a type in order for dot to be applicable to your node.
It isn't completely right. Type can be set by a parent of your node, etc. We have type inference.
Hi Konstantin,
i tried to define the typesystem-rule but after a while i got following exceptions on the MPS Messages console:
[jetbrains-mps.generator.GenerationController] java.lang.RuntimeException : Access Denied
[GenerationController] java.lang.RuntimeException: Access Denied
The IDE internal error says:
java.lang.RuntimeException : Access Denied: Access Denied
java.lang.RuntimeException: Access Denied
at jetbrains.mps.plugin.RMIHandler$MyMPSPlugin.checkAccess(RMIHandler.java:71)
at jetbrains.mps.plugin.RMIHandler$MyMPSPlugin.getProjectCreator(RMIHandler.java:97)
at sun.reflect.GeneratedMethodAccessor15.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:305)
at sun.rmi.transport.Transport$1.run(Transport.java:159)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Transport.java:155)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:535)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:790)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:649)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:619)
at sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(Unknown Source)
at sun.rmi.transport.StreamRemoteCall.executeCall(Unknown Source)
at sun.rmi.server.UnicastRef.invoke(Unknown Source)
at java.rmi.server.RemoteObjectInvocationHandler.invokeRemoteMethod(Unknown Source)
at java.rmi.server.RemoteObjectInvocationHandler.invoke(Unknown Source)
at $Proxy46.getProjectCreator(Unknown Source)
at jetbrains.mps.plugin.MPSPlugin.getPlugin(MPSPlugin.java:52)
at jetbrains.mps.plugin.MPSPlugin.getProjectHandler(MPSPlugin.java:73)
at jetbrains.mps.project.MPSProject.getProjectHandler(MPSProject.java:274)
at jetbrains.mps.generator.GenerationController.getProjectHandler(GenerationController.java:372)
at jetbrains.mps.generator.GenerationController.isIDEAPresent(GenerationController.java:364)
at jetbrains.mps.generator.GenerationController.compileModule(GenerationController.java:301)
at jetbrains.mps.generator.GenerationController.generate(GenerationController.java:128)
at jetbrains.mps.generator.GeneratorManager$4.run(GeneratorManager.java:322)
at jetbrains.mps.smodel.ModelAccess$2.compute(ModelAccess.java:83)
at jetbrains.mps.smodel.ModelAccess$4.compute(ModelAccess.java:107)
at com.intellij.openapi.application.impl.ApplicationImpl$11.run(ApplicationImpl.java:706)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:676)
at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:704)
at jetbrains.mps.smodel.ModelAccess.runWriteAction(ModelAccess.java:116)
at jetbrains.mps.smodel.ModelAccess.runWriteAction(ModelAccess.java:81)
at jetbrains.mps.generator.GeneratorManager.generateModels(GeneratorManager.java:313)
at jetbrains.mps.generator.GeneratorManager.access$100(GeneratorManager.java:58)
at jetbrains.mps.generator.GeneratorManager$3.run(GeneratorManager.java:256)
at com.intellij.openapi.progress.impl.ProgressManagerImpl$TaskRunnable.run(ProgressManagerImpl.java:341)
at com.intellij.openapi.progress.impl.ProgressManagerImpl$4.run(ProgressManagerImpl.java:185)
at com.intellij.openapi.progress.impl.ProgressManagerImpl$2.run(ProgressManagerImpl.java:130)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.executeProcessUnderProgress(ProgressManagerImpl.java:154)
at com.intellij.openapi.progress.impl.ProgressManagerImpl.runProcess(ProgressManagerImpl.java:121)
at com.intellij.openapi.application.impl.ApplicationImpl$7$1.run(ApplicationImpl.java:474)
at com.intellij.openapi.application.impl.ApplicationImpl$5.run(ApplicationImpl.java:303)
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
at java.util.concurrent.FutureTask$Sync.innerRun(Unknown Source)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
at com.intellij.openapi.application.impl.ApplicationImpl$1$1.run(ApplicationImpl.java:107)
a few days ago i had the problem that changes to the editor-components were only reflected to the according model after a restart of MPS....
Do you have an idea, what happens here?
Thx, Mirko
Mirko,
This exception has nothing to do with your code. It happened because you have installed a plugin (it's a security check that allows a plugin to use MPS only from local machine. You IP was changed so it was thrown). I recommend you to uninstall plugin and use MPS without it. If you need the plugin's functionality, you can restart MPS and IDEA.
Konstantin