Reduction of BaseLanguage/BlockStatement-Reference within other Model

Hi,

i created an Extension auf BaseLanguage BL where:

- a new concept "NamedBlockStatement extends BlockStatement" exists and only wraps a BlockStatement (child content)

- NamedBlockStatement has an own editor  with some additional properties (name etc.) and just renders the content: '%content%'

- NamedBlockStatement also has a TextGen that just delegates to the its content: 'append ${node.content} ;'

I can create classes using the NamedBlockStatement without any problems and MPS reduces it to java-files (NamedBlockStatement is "transparent" from that point of view).

Now i created a new language L containing a reference-concept BlockReference referencing the NamedBlockStatement mentioned above. L simply does something completely different from BL but is able to "include" arbitrary code-blocks from a class created with BL.

Now a solution of L can contain BL-classes and "show" snippets (blocks) of BL within its editors (by just doing '(%block%->%content%)'). I can edit in L on both "sides" with sync and can work with code just as it behaves in the corresponding class (which is very nice).

During generation i expect my custom L-stuff to become text (what it does) and i expect the referenced BL-BlockStatement to become the same text what it becomes in the corresponding BL-class. Therefor my generator description just '$COPY_SRC$' the NamedBlockStatment (which defines the TextGen-"delegate" mentioned above) in the place of the reference defined in and for L.

When it comes to generation the problems occours because BL-TextGen of ClassifierType does some magic ('append bl classifier ref ...') which obviously needs the surrounding BL-class to be able to be tranbsformed into Text. Which would be fine if not the last Transient-Model-Step (@29_0) that i can see (@25_1, the one before, the instances still have the same ID), duplicates the BL-Statements into my model (detaching it from the surrounding class-definition) preventing at least the mentioned ClassifierType to become text. Am i doing something wrong or do i miss some kind of generator-configuration or (re)ordering?

 

Thanks for your help,
Mirko

====================================

 

The exception thrown during generation is as follows:

TextGen threw an exception for model bordmittel.deck_js@29_0
java.lang.IllegalStateException
    at jetbrains.mps.baseLanguage.textGen.ImportsContext.getInstance(ImportsContext.java:101)
    at jetbrains.mps.baseLanguage.textGen.BaseLanguageTextGen.getClassName(BaseLanguageTextGen.java:284)
    at jetbrains.mps.baseLanguage.textGen.BaseLanguageTextGen.appendClassName(BaseLanguageTextGen.java:315)
    at jetbrains.mps.baseLanguage.textGen.BaseLanguageTextGen.blClassifierRef(BaseLanguageTextGen.java:217)
    at jetbrains.mps.baseLanguage.textGen.ClassifierType_TextGen.generateText(ClassifierType_TextGen.java:19)
    at jetbrains.mps.text.impl.TextGenTransitionContext.generateText(TextGenTransitionContext.java:63)
    at jetbrains.mps.text.impl.TextGenSupport.doAppendNode(TextGenSupport.java:162)
    at jetbrains.mps.text.impl.TextGenSupport.appendNode(TextGenSupport.java:158)
    at jetbrains.mps.baseLanguage.textGen.BaseLanguageTextGen.variableDeclaration(BaseLanguageTextGen.java:127)
    at jetbrains.mps.baseLanguage.textGen.LocalVariableDeclaration_TextGen.generateText(LocalVariableDeclaration_TextGen.java:14)
    at jetbrains.mps.text.impl.TextGenTransitionContext.generateText(TextGenTransitionContext.java:63)
    at jetbrains.mps.text.impl.TextGenSupport.doAppendNode(TextGenSupport.java:162)
    at jetbrains.mps.text.impl.TextGenSupport.appendNode(TextGenSupport.java:158)
    at jetbrains.mps.baseLanguage.textGen.LocalVariableDeclarationStatement_TextGen.generateText(LocalVariableDeclarationStatement_TextGen.java:20)
    at jetbrains.mps.text.impl.TextGenTransitionContext.generateText(TextGenTransitionContext.java:63)
    at jetbrains.mps.text.impl.TextGenSupport.doAppendNode(TextGenSupport.java:162)
    at jetbrains.mps.text.impl.TextGenSupport.appendNode(TextGenSupport.java:158)
    at jetbrains.mps.baseLanguage.textGen.StatementList_TextGen.generateText(StatementList_TextGen.java:21)
    at jetbrains.mps.text.impl.TextGenTransitionContext.generateText(TextGenTransitionContext.java:63)
    at jetbrains.mps.text.impl.TextGenSupport.doAppendNode(TextGenSupport.java:162)
    at jetbrains.mps.text.impl.TextGenSupport.appendNode(TextGenSupport.java:158)
    at jetbrains.mps.baseLanguage.textGen.BlockStatement_TextGen.generateText(BlockStatement_TextGen.java:27)
    at jetbrains.mps.text.impl.TextGenTransitionContext.generateText(TextGenTransitionContext.java:63)
    at jetbrains.mps.text.impl.TextGenSupport.doAppendNode(TextGenSupport.java:162)
    at jetbrains.mps.text.impl.TextGenSupport.appendNode(TextGenSupport.java:158)
    at bordmittel_baseLanguage_ext.textGen.NamedBlockStatement_TextGen.generateText(NamedBlockStatement_TextGen.java:18)
    at jetbrains.mps.text.impl.TextGenTransitionContext.generateText(TextGenTransitionContext.java:63)
    at jetbrains.mps.text.impl.TextGenSupport.doAppendNode(TextGenSupport.java:162)
    at jetbrains.mps.text.impl.TextGenSupport.appendNode(TextGenSupport.java:158)
    at de.slisson.mps.richtext.textGen.Text_TextGen.generateText(Text_TextGen.java:17)
    at jetbrains.mps.text.impl.TextGenTransitionContext.generateText(TextGenTransitionContext.java:63)
    at jetbrains.mps.text.impl.TextGenSupport.doAppendNode(TextGenSupport.java:162)
    at jetbrains.mps.text.impl.TextGenSupport.appendNode(TextGenSupport.java:158)
    at jetbrains.mps.core.xml.textGen.XmlElement_TextGen.generateText(XmlElement_TextGen.java:61)
    at jetbrains.mps.text.impl.TextGenTransitionContext.generateText(TextGenTransitionContext.java:63)
    at jetbrains.mps.text.impl.TextGenSupport.doAppendNode(TextGenSupport.java:162)
    at jetbrains.mps.text.impl.TextGenSupport.appendNode(TextGenSupport.java:158)
    at jetbrains.mps.core.xml.textGen.XmlElement_TextGen.generateText(XmlElement_TextGen.java:52)
    at jetbrains.mps.text.impl.TextGenTransitionContext.generateText(TextGenTransitionContext.java:63)
    at jetbrains.mps.text.impl.TextGenSupport.doAppendNode(TextGenSupport.java:162)
    at jetbrains.mps.text.impl.TextGenSupport.appendNode(TextGenSupport.java:158)
    at jetbrains.mps.core.xml.textGen.XmlElement_TextGen.generateText(XmlElement_TextGen.java:52)
    at jetbrains.mps.text.impl.TextGenTransitionContext.generateText(TextGenTransitionContext.java:63)
    at jetbrains.mps.text.impl.TextGenSupport.doAppendNode(TextGenSupport.java:162)
    at jetbrains.mps.text.impl.TextGenSupport.appendNode(TextGenSupport.java:158)
    at jetbrains.mps.core.xml.textGen.XmlElement_TextGen.generateText(XmlElement_TextGen.java:52)
    at jetbrains.mps.text.impl.TextGenTransitionContext.generateText(TextGenTransitionContext.java:63)
    at jetbrains.mps.text.impl.TextGenSupport.doAppendNode(TextGenSupport.java:162)
    at jetbrains.mps.text.impl.TextGenSupport.appendNode(TextGenSupport.java:158)
    at jetbrains.mps.core.xml.textGen.XmlDocument_TextGen.generateText(XmlDocument_TextGen.java:18)
    at jetbrains.mps.text.impl.TextGenTransitionContext.generateText(TextGenTransitionContext.java:63)
    at jetbrains.mps.text.impl.TextGenSupport.doAppendNode(TextGenSupport.java:162)
    at jetbrains.mps.text.impl.TextGenSupport.appendNode(TextGenSupport.java:158)
    at jetbrains.mps.core.xml.textGen.XmlFile_TextGen.generateText(XmlFile_TextGen.java:19)
    at jetbrains.mps.text.impl.TextGenTransitionContext.generateText(TextGenTransitionContext.java:63)
    at jetbrains.mps.text.impl.TextGenSupport.doAppendNode(TextGenSupport.java:162)
    at jetbrains.mps.text.impl.TextGenSupport.appendNode(TextGenSupport.java:158)
    at jetbrains.mps.text.impl.RegularTextUnit.doGenerate(RegularTextUnit.java:125)
    at jetbrains.mps.text.impl.RegularTextUnit.generate(RegularTextUnit.java:102)
    at jetbrains.mps.text.TextGeneratorEngine$2.run(TextGeneratorEngine.java:113)
    at jetbrains.mps.smodel.WorkbenchModelAccess$2.run(WorkbenchModelAccess.java:105)
    at com.intellij.openapi.application.impl.ApplicationImpl.runReadAction(ApplicationImpl.java:848)
    at jetbrains.mps.smodel.WorkbenchModelAccess.runReadAction(WorkbenchModelAccess.java:100)
    at jetbrains.mps.smodel.ModelAccessBase.runReadAction(ModelAccessBase.java:53)
    at jetbrains.mps.smodel.ModelReadRunnable.run(ModelReadRunnable.java:40)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)

0
9 comments
Avatar
Permanently deleted user

Hi,

at https://www.dropbox.com/s/il5m43eijf2lqp3/test.zip?dl=0 i created a minimal test-Language for the problem described above (i'm using MPS 3.4.3).

Within the contained sandbox-solution i expect the Text-outcome to be:

  • the java-file MyClass (works)
  • the file map_Document.xml looking like this:

    <TEXT>text text<%% THE CODE OF THE REFERENCED BL-BlockStatement%%>text text</TEXT>

The Exception mentioned above is also thrown, when building the solution.

Thanks in advance,
Mirko

0

Could you please also share the project files (the .mps folder)?

0
Avatar
Permanently deleted user

Hi Vaclav,

can i send it somehow private to you (there are some meta-infos about the whole WS inside that i do not want to share publicly)?

Thanks,
Mirko

0
Avatar
Permanently deleted user

Hi Vaclav,

i sent the .mps-folder to you via e-mail. Did you receive it? Any news regarding this question?

Thanks,
Mirko

0
Avatar
Permanently deleted user

Hi,

i do not want to be too pushy, but actually i think this should be a standard ability of MPS, isn't it? Currently i'm trying to push MPS within our organisation, but there is a minimum-requirement that i need or i lose (and combination of languages is one of the most usefull things in a cell-based editor in my opinion).

I think (and hope) this is an easy issue originating in my brain by not knowing MPS deep enough. However i would appreciate a solution in the near future for the provided test-language or i will have to stop my MPS-initiative (wouldn't love that either)...

Or any other information would help too.

Thx,
Mirko

0

Hi Mirko,

BaseLanguage's TextGen currently does not support statements being embedded in anything other than BaseLanguage classes. This dependency stems from the need to resolve fully-qualified class names and imports used in these statements.

We'll look into the possibility to make this step configurable in the next version, so that you could provide your own resolver for fully-qualified names and imports. Until then, you still have the (non-trivial) option to convert your statements into a textual model using your own generator. You will have to provide a Language that models text and lines and that is doing the final TextGen.

Vaclav

 

0
Avatar
Permanently deleted user

Hi Vaclav,

thanks for your answer!

I just found out, that when i hold my BL-class (from the example above) within another model and reference it "cross model" (just via "normal" dependency), the referenced code-snippet gets converted to text within my custom output without any complains.

This will help me in my current situation (for now - don't know what's coming up) but it would be a great feature to generally support Cross-Model-Generation without that limitation. Technically in my case it would be to "just" label the generated text (that came out of the referenced BL-Snippet) and copy it over to the referencing output (sounds not that hard to me to implement, but i'm no MPS-"insider" ;) ).

Regards,
Mirko

 

0
Avatar
Permanently deleted user

Hi,

on question/problem remains in my case: i need to control indentation -> can i influence somehow the indention-depth of the generated BL-Text?

Thanks,
Mirko

0

Yse, use the indent buffer, increate/decrease depth or with indent TextGen language statements. This should do the trick.

0

Please sign in to leave a comment.