Skip to content

fix(daemon): give a new model the devkits and used languages MPS gives it - #230

Open
sergej-koscejev wants to merge 2 commits into
mainfrom
fix/225-aspect-devkit
Open

sergej-koscejev wants to merge 2 commits into
mainfrom
fix/225-aspect-devkit

Conversation

@sergej-koscejev

Copy link
Copy Markdown
Member

Summary

mops create model and Code Mode's SModule.createModel now give a new model the devkits and used languages that MPS gives it. Both go through ModelCreator, which now calls MPS's ModelsAutoImportsManager.performImports, the same step the MPS New Model dialog and the "new aspect" actions run after creating a model.

 ModelCreator.create(preparation)
   modelRoot.createModel(name, …)
+  ModelsAutoImportsManager.performImports(module, model)
   model.save()

What a new model gets now (from the MPS core contributors, observed on MPS 2024.1.6):

Module Model Gets
Language aspect with a default devkit (structure, constraints, typesystem, dataFlow, textGen, migration, …) its aspect devkit, e.g. jetbrains.mps.devkit.aspect.structure
Language other aspect (editor, behavior, intentions, …) or non-aspect model jetbrains.mps.devkit.general-purpose plus the aspect's main languages, e.g. jetbrains.mps.lang.editor and jetbrains.mps.lang.actions for editor
Generator any jetbrains.mps.devkit.templates, plus an import of the source language's structure model for a template model
Solution any nothing (no change)

The create model help, the SModule.createModel Code Mode catalog entry, and the bundled creation examples say so. The MPS behavior was checked in the 2024.1 and 2026.1 sources (ModelsAutoImportsManager, Language.LanguageModelsAutoImports, Generator.GeneratorModelsAutoImports, ModelCreateHelper, LanguageAspectDescriptorBase.create).

Left for later:

  • Code Mode LanguageAspect.<ASPECT>.createNew(language) is MPS's own API and still gives a plain model. mops cannot change it; module.createModel('.structure') is the path that gets the devkit.
  • The MPS New Model dialog also runs MissingDependenciesFixer, which adds module dependencies for imported models. mops does not. Only the generator template-model import of the source language's structure model is affected; aspect models get no model imports.
  • create model output and --dry-run do not list the devkits and used languages that were added (docs/VISION.md principle 3).

Fixes #225

Evidence

  • Before: the issue's steps on a copy of the MPS 2024.1.6 sample _theSimplestLanguage:

    mops create language repro.lang
    mops create model repro.lang.structure --module repro.lang   # <languages /> empty
    mops code run add-concept.groovy                            # adds a ConceptDeclaration
    mops make module repro.lang
    error  <identifier> expected (…/source_gen/repro/lang/Language.java:43)
    made 1 module(s): FAILED (9 error(s))
    

    After: the same steps:

    <languages>
      <devkit ref="78434eb8-b0e5-444b-850d-e7c4ad2da9ab(jetbrains.mps.devkit.aspect.structure)" />
    </languages>
    …
    made 1 module(s): success
    
  • New tests, each seen failing before the fix:

    • ModelCreationSemanticsTest: create model example.lang.structure in a new language gets jetbrains.mps.devkit.aspect.structure; Code Mode createModel('.dataFlow') gets jetbrains.mps.devkit.aspect.dataflow. Pass on MPS 2024.1.6, 2025.1.4, 2026.1.1.
    • MakeIntegrationTest: create language → create structure model → add a concept → make module succeeds (was FAILED with the Language.java compile errors). Passes on MPS 2024.1.6.
  • ./gradlew check on ec10323: exit 0; daemon tests (456 each on 2024.1.6, 2025.1.4, 2026.1.1, prerelease) and CLI integration tests (82 each, 6 skipped) have no failures. After the review fix-up commit: ModelCreationSemanticsTest on 2024.1.6 and 2026.1.1, :cli:test, detektMain, checkReference pass.

Merge Danger

Blast Radius: Model creation

Every model that mops creates in a language or generator now starts with devkits and used languages, where it used to start empty. Solution models are unchanged.

…s it

mops create model and Code Mode's SModule.createModel now run MPS's
ModelsAutoImportsManager on the new model, as the MPS New Model dialog
does. An aspect model of a language gets its aspect devkit, for example
jetbrains.mps.devkit.aspect.structure, so the language makes.

Fixes #225
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

create model: aspect models of a language get no aspect devkit, so the language does not build

1 participant