├── .gitattributes
├── .github
├── dependabot.yml
└── workflows
│ ├── build.yaml
│ └── to-wiki.yaml
├── .gitignore
├── .idea
├── .gitignore
├── .name
├── artifacts
│ └── DclareMps_jar.xml
├── aws.xml
├── codeStyles
│ └── codeStyleConfig.xml
├── encodings.xml
├── inspectionProfiles
│ └── Project_Default.xml
├── misc.xml
└── vcs.xml
├── .mps
├── .gitignore
├── bashsupport_project.xml
├── codeStyleSettings.xml
├── compiler.xml
├── migration.xml
├── misc.xml
├── modules.xml
└── vcs.xml
├── LICENSE
├── README.md
├── bootstrap.gradle.kts
├── build.gradle.kts
├── documentation
├── DclareForMPS.md
├── GUI.md
├── copy-to-wiki.sh
└── images
│ ├── DclareEngineOnAtProjectOpen.png
│ ├── checker-tool.png
│ ├── plugin.png
│ ├── rules-aspect.png
│ ├── status-tool.png
│ └── use-dclareMPS-language.png
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
├── languages
├── DclareGui
│ ├── DclareGui.mpl
│ └── models
│ │ ├── DclareGui.editor.mps
│ │ ├── DclareGui.rules.mps
│ │ └── DclareGui.structure.mps
├── DclareMPS
│ ├── DclareMPS.mpl
│ ├── generator
│ │ └── template
│ │ │ └── main@generator.mps
│ ├── icons
│ │ └── Dclare.png
│ ├── models
│ │ ├── DclareMPS.dataFlow.mps
│ │ ├── DclareMPS.findUsages.mps
│ │ ├── DclareMPS.migration.mps
│ │ ├── behavior.mps
│ │ ├── constraints.mps
│ │ ├── editor.mps
│ │ ├── intentions.mps
│ │ ├── plugin.mps
│ │ ├── refactorings.mps
│ │ ├── structure.mps
│ │ └── typesystem.mps
│ ├── plugin
│ │ └── Dclare.png
│ └── structure
│ │ └── Dclare.png
└── DclareMessages
│ ├── DclareMessages.mpl
│ ├── icons
│ ├── down-arrow.png
│ └── right-arrow.png
│ └── models
│ ├── behavior.mps
│ ├── constraints.mps
│ ├── editor.mps
│ ├── structure.mps
│ └── typesystem.mps
├── mps_build.xml
├── release-notes.md
├── runtime
├── .idea
│ ├── .gitignore
│ ├── compiler.xml
│ ├── encodings.xml
│ ├── gradle.xml
│ ├── misc.xml
│ ├── uiDesigner.xml
│ └── vcs.xml
├── build.gradle.kts
└── src
│ └── main
│ └── java
│ ├── CopyToWiki.java
│ └── org
│ └── modelingvalue
│ └── dclare
│ └── mps
│ ├── ActualArguments.java
│ ├── BulkRenameCommand.java
│ ├── BulkRenameDialog.form
│ ├── BulkRenameDialog.java
│ ├── DAttribute.java
│ ├── DClareMPS.java
│ ├── DCopy.java
│ ├── DDependency.java
│ ├── DDerive.java
│ ├── DFeature.java
│ ├── DFromOriginalObject.java
│ ├── DIdentifiedObject.java
│ ├── DIssue.java
│ ├── DIssueModelReportItem.java
│ ├── DIssueModuleReportItem.java
│ ├── DIssueNodeReportItem.java
│ ├── DIssueType.java
│ ├── DMessage.java
│ ├── DMessageType.java
│ ├── DMethod.java
│ ├── DModel.java
│ ├── DModelListener.java
│ ├── DModelType.java
│ ├── DModule.java
│ ├── DModuleListener.java
│ ├── DModuleReference.java
│ ├── DModuleType.java
│ ├── DNewableObject.java
│ ├── DNode.java
│ ├── DNodeType.java
│ ├── DObject.java
│ ├── DObjectType.java
│ ├── DObserved.java
│ ├── DQuotation.java
│ ├── DRead.java
│ ├── DRepository.java
│ ├── DRepositoryListener.java
│ ├── DRepositoryType.java
│ ├── DRule.java
│ ├── DServerMetaData.java
│ ├── DServerMetaDataType.java
│ ├── DStructClass.java
│ ├── DStructObject.java
│ ├── DTempModel.java
│ ├── DclareForMPSEngine.java
│ ├── DclareForMpsConfig.java
│ ├── DclareForMpsStatus.java
│ ├── DclareModelCheckerBuilder.java
│ ├── DummySModule.java
│ ├── EngineStatusHandler.java
│ ├── IAspect.java
│ ├── IChangeHandler.java
│ ├── INative.java
│ ├── INativeGroup.java
│ ├── INativeRunner.java
│ ├── IRuleAspect.java
│ ├── IRuleSet.java
│ ├── MPSDeltaAdapter.java
│ ├── MPSSerializationHelper.java
│ ├── SStructClass.java
│ ├── SStructObject.java
│ ├── Signature.java
│ └── UnidentifiedException.java
├── settings.gradle.kts
├── solutions
├── DclareForMPS.build
│ ├── DclareForMPS.build.msd
│ └── models
│ │ └── DclareForMPS.build.mps
├── DclareMPSPlugin
│ ├── DclareMPSPlugin.msd
│ ├── icons
│ │ └── Dclare.png
│ ├── models
│ │ └── plugin.mps
│ └── plugin
│ │ └── Dclare.png
├── DclareMPSRuntime
│ ├── DclareMPSRuntime.msd
│ └── models
│ │ └── DclareMPSRuntime.util.mps
└── DclareRuntime
│ └── DclareRuntime.msd
└── usageHints.adoc
/.gitattributes:
--------------------------------------------------------------------------------
1 | trace.info text merge=mps
2 | generated text merge=mps
3 | dependencies text merge=mps
4 | *.mpl text merge=mps
5 | *.msd text merge=mps
6 | *.devkit text merge=mps
7 | *.mpr text merge=mps
8 | *.mpsr text merge=mps
9 | *.model text merge=mps
10 | *.mps text merge=mps
11 |
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | ##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 | ## (C) Copyright 2018-2023 Modeling Value Group B.V. (http://modelingvalue.org) ~
3 | ## ~
4 | ## Licensed under the GNU Lesser General Public License v3.0 (the 'License'). You may not use this file except in ~
5 | ## compliance with the License. You may obtain a copy of the License at: https://choosealicense.com/licenses/lgpl-3.0 ~
6 | ## Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on ~
7 | ## an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the ~
8 | ## specific language governing permissions and limitations under the License. ~
9 | ## ~
10 | ## Maintainers: ~
11 | ## Wim Bast, Tom Brus, Ronald Krijgsheld ~
12 | ## Contributors: ~
13 | ## Arjan Kok, Carel Bast ~
14 | ##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 |
16 | version: 2
17 | updates:
18 | - package-ecosystem: "gradle"
19 | directory: "/"
20 | target-branch: "develop"
21 | schedule:
22 | interval: "daily"
23 | - package-ecosystem: "github-actions"
24 | directory: "/"
25 | target-branch: "develop"
26 | schedule:
27 | interval: "daily"
28 |
--------------------------------------------------------------------------------
/.github/workflows/build.yaml:
--------------------------------------------------------------------------------
1 | ##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 | ## (C) Copyright 2018-2022 Modeling Value Group B.V. (http://modelingvalue.org) ~
3 | ## ~
4 | ## Licensed under the GNU Lesser General Public License v3.0 (the 'License'). You may not use this file except in ~
5 | ## compliance with the License. You may obtain a copy of the License at: https://choosealicense.com/licenses/lgpl-3.0 ~
6 | ## Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on ~
7 | ## an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the ~
8 | ## specific language governing permissions and limitations under the License. ~
9 | ## ~
10 | ## Maintainers: ~
11 | ## Wim Bast, Tom Brus, Ronald Krijgsheld ~
12 | ## Contributors: ~
13 | ## Arjan Kok, Carel Bast ~
14 | ##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 |
16 | name: build
17 |
18 | on: [ push, workflow_dispatch ]
19 |
20 | jobs:
21 | build:
22 | runs-on: ubuntu-20.04
23 | if: "!contains(github.event.head_commit.message, '[no-ci]')"
24 | env:
25 | ALLREP_TOKEN: "${{secrets.ALLREP_TOKEN}}"
26 | TOKEN: "${{secrets.ALLREP_TOKEN}}"
27 | JETBRAINS_PUBLISH_TOKEN: "${{secrets.JETBRAINS_PUBLISH_TOKEN}}"
28 | CI: "true"
29 | steps:
30 | - uses: actions/checkout@v4
31 | with:
32 | fetch-depth: 0
33 |
34 | - uses: actions/setup-java@v3
35 | with:
36 | java-version: 17
37 | distribution: temurin
38 |
39 | ################################################################################
40 | - name: "bootstrap"
41 | run: ./gradlew --build-file bootstrap.gradle.kts
42 |
43 | - name: "build"
44 | run: ./gradlew --info --scan
45 |
46 | - name: "upload zip"
47 | uses: actions/upload-artifact@v3
48 | with:
49 | name: "DclareForMPS.zip"
50 | path: build/artifacts/DclareForMPS/DclareForMPS.zip
51 |
--------------------------------------------------------------------------------
/.github/workflows/to-wiki.yaml:
--------------------------------------------------------------------------------
1 | ##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 | ## (C) Copyright 2018-2023 Modeling Value Group B.V. (http://modelingvalue.org) ~
3 | ## ~
4 | ## Licensed under the GNU Lesser General Public License v3.0 (the 'License'). You may not use this file except in ~
5 | ## compliance with the License. You may obtain a copy of the License at: https://choosealicense.com/licenses/lgpl-3.0 ~
6 | ## Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on ~
7 | ## an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the ~
8 | ## specific language governing permissions and limitations under the License. ~
9 | ## ~
10 | ## Maintainers: ~
11 | ## Wim Bast, Tom Brus, Ronald Krijgsheld ~
12 | ## Contributors: ~
13 | ## Arjan Kok, Carel Bast ~
14 | ##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 |
16 | name: copy-to-wiki
17 |
18 | on: [ push, workflow_dispatch ]
19 |
20 | jobs:
21 | copy-to-wiki:
22 | runs-on: ubuntu-20.04
23 | if: "!contains(github.event.head_commit.message, '[no-ci]')"
24 | env:
25 | ALLREP_TOKEN: "${{secrets.ALLREP_TOKEN}}"
26 | TOKEN: "${{secrets.ALLREP_TOKEN}}"
27 | CI: "true"
28 | steps:
29 | - uses: actions/checkout@v4
30 | with:
31 | path: 'source'
32 |
33 | - uses: actions/checkout@v4
34 | with:
35 | repository: "${{github.repository}}.wiki"
36 | ref: master
37 | path: 'wiki'
38 |
39 | - name: "copy to wiki"
40 | env:
41 | OWNER: ${{github.repository_owner}}
42 | REPO: ${{github.event.repository.name}}
43 | HASH: ${{github.sha}}
44 | run: . source/documentation/copy-to-wiki.sh
45 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | #### Intellij (https://github.com/github/gitignore/blob/master/Global/JetBrains.gitignore)
2 | *.iml
3 | *.ipr
4 | *.iws
5 | .idea/**/contentModel.xml
6 | .idea/**/dataSources.ids
7 | .idea/**/dataSources.local.xml
8 | .idea/**/dataSources/
9 | .idea/**/dbnavigator.xml
10 | .idea/**/dictionaries
11 | .idea/**/dynamic.xml
12 | .idea/**/gradle.xml
13 | .idea/**/libraries
14 | .idea/**/mongoSettings.xml
15 | .idea/**/shelf
16 | .idea/**/sqlDataSources.xml
17 | .idea/**/tasks.xml
18 | .idea/**/uiDesigner.xml
19 | .idea/**/usage.statistics.xml
20 | .idea/**/workspace.xml
21 | .idea/**/xtextAutoBuilderState.xml
22 | .idea/*.iml
23 | .idea/compiler.xml
24 | .idea/jarRepositories.xml
25 | .idea/modules
26 | .idea/modules.xml
27 | atlassian-ide-plugin.xml
28 | out/
29 |
30 | #### eclipse (https://github.com/github/gitignore/blob/master/Global/Eclipse.gitignore & https://gist.github.com/billygoo/2b0dfe020bac550c7bfe)
31 | !gradle-wrapper.jar
32 | !src/**/*target*/
33 | *.bak
34 | *.class
35 | *.ear
36 | *.jar
37 | *.launch
38 | *.swp
39 | *.tmp
40 | *.war
41 | *target*
42 | *~.nib
43 | .apt_generated/
44 | .apt_generated_test/
45 | .classpath
46 | .externalToolBuilders/
47 | .factorypath
48 | .gradle
49 | .loadpath
50 | .metadata
51 | .project
52 | .recommenders
53 | .recommenders/
54 | .settings/
55 | .springBeans
56 | .target
57 | bin/
58 | bin/**
59 | build/
60 | gradle-app.setting
61 | local.properties
62 | tmp/
63 | tmp/**
64 | tmp/**/*
65 |
66 | #### java (https://github.com/github/gitignore/blob/master/Java.gitignore)
67 | *.class
68 | *.ear
69 | *.jar
70 | *.log
71 | *.nar
72 | *.rar
73 | *.tar.gz
74 | *.war
75 | *.zip
76 | hs_err_pid*
77 |
78 | # Gradle (https://github.com/github/gitignore/blob/master/Gradle.gitignore)
79 | !gradle-wrapper.jar
80 | !src/**/build/
81 | **/build/
82 | .gradle
83 | .gradletasknamecache
84 | gradle-app.setting
85 |
86 | # MVG
87 | /TEST-*.txt
88 | /TEST-*.xml
89 | **/*_gen
90 | **/*_gen.caches
91 | .mps/workspace.xml
92 | /.mps-caches/**
93 |
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 | # Editor-based HTTP Client requests
5 | /httpRequests/
6 |
--------------------------------------------------------------------------------
/.idea/.name:
--------------------------------------------------------------------------------
1 | dclareForMPS
--------------------------------------------------------------------------------
/.idea/artifacts/DclareMps_jar.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | $PROJECT_DIR$/solutions/DclareMPSRuntime/lib
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/.idea/aws.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/.idea/codeStyles/codeStyleConfig.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
--------------------------------------------------------------------------------
/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.idea/inspectionProfiles/Project_Default.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 | false
53 |
54 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/.mps/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 |
--------------------------------------------------------------------------------
/.mps/bashsupport_project.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.mps/codeStyleSettings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.mps/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.mps/migration.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/.mps/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/.mps/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/.mps/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | DclareForMPS [](https://www.gnu.org/licenses/lgpl-3.0) [](https://github.com/ModelingValueGroup/DclareForMPS/actions)
2 | ================================
3 | DclareForMPS adds a language aspect named '_rules_' to MPS.
4 | A rule typically derives some part of a model.
5 | Rules can trigger other rules.
6 | A rule runs when something changes in the models that is read by this rule (reactive).
7 | The system terminates on a fixpoint (if no changes occure anymore).
8 | The regular MPS base-languages can be used to specify the rules.
9 | Rules definitions typically use quotations (light or not) to define the derivations.
10 | The rules are executed incrementally, meaning they perform a minimal amount of changes to derive the defined patterns (
11 | expressed in quotations).
12 |
13 | ## MPS plugin
14 |
15 | DclareForMPS is in constant progress.
16 | It is available as a plugin in MPS through the plugin marketplace.
17 |
18 | All feedback, functional or technical, is appreciated.
19 |
20 | ## dclare
21 |
22 | DclareForMPS uses the dclare engine of the Modeling Value Group.
23 | The dclare project can be found here: [dclare](https://github.com/ModelingValueGroup/dclare)
24 |
25 | ## Installation
26 |
27 | 1. install JetBrains MPS (2020.1 or higher)
28 | 2. start MPS
29 | 3. go to the plugins preferences section and install DclareForMPS from the Marketplace
30 | 4. open one of the example projects (see below)
31 | 5. verify that the 'On' setting is enabled (Settings > Other Settings > Dclare):
32 |
33 | 
34 |
35 | 4. rebuild the example project
36 | 5. play with the sandbox-models in the example-project
37 |
38 | ## Examples
39 |
40 | Multiple examples can be found on GitHub:
41 |
42 | - [Sudoku](https://github.com/ModelingValueGroup/ex-Sudoku)
43 | - [EntityClassJava](https://github.com/ModelingValueGroup/ex-EntityClassJava)
44 | - [NiamToOO](https://github.com/ModelingValueGroup/ex-NiamToOO)
45 | - [FlattenAndCopy](https://github.com/ModelingValueGroup/ex-FlattenAndCopy)
46 | - [StateMachines](https://github.com/ModelingValueGroup/statemachines)
47 |
48 | For more info, please read the _README.md_ files that are part of these examples.
49 |
--------------------------------------------------------------------------------
/bootstrap.gradle.kts:
--------------------------------------------------------------------------------
1 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 | // (C) Copyright 2018-2023 Modeling Value Group B.V. (http://modelingvalue.org) ~
3 | // ~
4 | // Licensed under the GNU Lesser General Public License v3.0 (the 'License'). You may not use this file except in ~
5 | // compliance with the License. You may obtain a copy of the License at: https://choosealicense.com/licenses/lgpl-3.0 ~
6 | // Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on ~
7 | // an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the ~
8 | // specific language governing permissions and limitations under the License. ~
9 | // ~
10 | // Maintainers: ~
11 | // Wim Bast, Tom Brus, Ronald Krijgsheld ~
12 | // Contributors: ~
13 | // Arjan Kok, Carel Bast ~
14 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 |
16 | defaultTasks(
17 | "download-MPS",
18 | )
19 | plugins {
20 | id("org.modelingvalue.gradle.mvgplugin") version "1.1.3"
21 | }
22 | tasks.register("download-MPS") {
23 | group = "modelingvaluegroup"
24 | doLast {
25 | org.modelingvalue.gradle.mvgplugin.MvgPlugin.singleton.resolveMpsDependency("mps-boot")
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/build.gradle.kts:
--------------------------------------------------------------------------------
1 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 | // (C) Copyright 2018-2023 Modeling Value Group B.V. (http://modelingvalue.org) ~
3 | // ~
4 | // Licensed under the GNU Lesser General Public License v3.0 (the 'License'). You may not use this file except in ~
5 | // compliance with the License. You may obtain a copy of the License at: https://choosealicense.com/licenses/lgpl-3.0 ~
6 | // Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on ~
7 | // an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the ~
8 | // specific language governing permissions and limitations under the License. ~
9 | // ~
10 | // Maintainers: ~
11 | // Wim Bast, Tom Brus, Ronald Krijgsheld ~
12 | // Contributors: ~
13 | // Arjan Kok, Carel Bast ~
14 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 |
16 | defaultTasks(
17 | "mvgcorrector",
18 | "build",
19 | "mvgtagger",
20 | "mvguploader",
21 | )
22 | plugins {
23 | id("org.modelingvalue.gradle.mvgplugin") version "1.1.3"
24 | }
25 |
26 | ///////////////////////////////////////////////////////////////////////////////////////////////
27 | // import ant file:
28 | try {
29 | val version_mps: String by project
30 | if (!mvgmps.mpsInstallDir.isDirectory)
31 | throw GradleException("You need to first run './gradlew --build-file bootstrap.gradle.kts' to download MPS")
32 |
33 | ant.lifecycleLogLevel = AntBuilder.AntMessagePriority.INFO
34 | ant.setProperty("mps_home", mvgmps.mpsInstallDir.toString())
35 | ant.setProperty("version", version)
36 | ant.setProperty("versionExtra", mvgmps.versionExtra)
37 | ant.setProperty("versionStamp", mvgmps.versionStamp)
38 | ant.setProperty("version_mps", version_mps)
39 | // WORKAROUND START (see https://youtrack.jetbrains.com/issue/MPS-34059)
40 | // for UTF-8 chars used in MPS: add file.encoding to jvmargs, crude but works for now
41 | val antScript = resources.text.fromString(gradle.rootProject.projectDir.resolve("mps_build.xml").readLines().joinToString(separator = System.lineSeparator()) {
42 | it + if (it.matches(Regex(".*$"))) "" else ""
43 | })
44 | // WORKAROUND END
45 | @Suppress("UnstableApiUsage")
46 | ant.importBuild(antScript, gradle.rootProject.projectDir.absolutePath) {
47 | "mpsant-$it"
48 | }
49 | tasks.filter {
50 | it.name.startsWith("mpsant-")
51 | }.forEach {
52 | it.group = "mpsant"
53 | if (it.name == "mpsant-fetchDependencies") {
54 | // the runtime jars should be build and gathered first:
55 | it.dependsOn(":runtime:gatherRuntimeJars")
56 | }
57 | if (it.name.startsWith("mpsant-java.compile")) {
58 | // generation should be triggered before any compilation can take place:
59 | it.dependsOn("mpsant-generate")
60 | }
61 | // always set the properties first:
62 | it.doFirst {
63 | ant.setProperty("mps_home", mvgmps.mpsInstallDir.toString())
64 | ant.setProperty("version", version)
65 | ant.setProperty("versionExtra", mvgmps.versionExtra)
66 | ant.setProperty("versionStamp", mvgmps.versionStamp)
67 | }
68 | }
69 | val clean_gen_dirs = tasks.create("clean_gen_dirs") {
70 | group = "build"
71 | doLast {
72 | listOf("languages", "solutions").forEach {
73 | val d = project.projectDir.resolve(it)
74 | println("INFO: cleaning all _gen dirs from: $d")
75 | d.walkTopDown().filter {
76 | it.name.contains("_gen")
77 | }.forEach {
78 | it.deleteRecursively()
79 | }
80 | }
81 | val buildDir = project.projectDir.resolve("build")
82 | listOf("tmp", "artifacts").forEach {
83 | val d = buildDir.resolve(it)
84 | println("INFO: cleaning from build dir: $d")
85 | d.deleteRecursively()
86 | }
87 | }
88 | }
89 | tasks.create("build") {
90 | group = "build"
91 | dependsOn(tasks.named("mpsant-build"))
92 | }
93 | tasks.create("clean") {
94 | group = "build"
95 | dependsOn(clean_gen_dirs)
96 | }
97 | tasks.create("publish") {
98 | group = "publishing"
99 | dependsOn(tasks.named("mpsant-assemble"))
100 | }
101 | } catch (e: Exception) {
102 | println("problem with import of ant file mps_build.xml: " + e)
103 | }
104 | ///////////////////////////////////////////////////////////////////////////////////////////////
105 | // upload plugin to jetbrains
106 | mvguploader {
107 | pluginId = "13797"
108 | }
109 | tasks.mvguploader {
110 | dependsOn("mpsant-assemble")
111 | }
112 |
--------------------------------------------------------------------------------
/documentation/DclareForMPS.md:
--------------------------------------------------------------------------------
1 | # Getting started
2 |
3 | ### Plugin Installation
4 |
5 | You can install the plugin from the Jetbrains plugin Marketplace:
6 |
7 | 
8 |
9 | ### Where to find the various parts of the plugin
10 |
11 | When installed you can find the plugin in various places.
12 |
13 | - create a language and add _DclareMPS_ as a used language or add the _DclareMPS_ plugin to an existing language:
14 |
15 | 
16 |
17 | - you will see a new MPS aspect has added called _Rules_. Under this aspect you will create and edit your rules.
18 |
19 | 
20 |
21 | - you will see that a preference pane with the name _Dclare_ has been added:
22 |
23 | 
24 |
25 | - you will see that a new tool has been added called _Status_:
26 |
27 | 
28 |
29 | - you will see that a new tool has been added called _Checker_:
30 |
31 | 
32 |
33 | ### Helloworld
34 |
35 | # Syntax
36 |
37 | ### Rule
38 |
39 | ### Attribute
40 |
41 | ### Method
42 |
43 | ### Node/Model/Module/Repository
44 |
45 | ### Struct
46 |
47 | ### Equation
48 |
49 | ### Rule Aspect
50 |
51 | ### Ruleset
52 |
53 | ### Node Construction
54 |
55 | ### Model Construction
56 |
57 | ### Error/Warning/Info Construction
58 |
59 | ### Reference Opposite
60 |
61 | ### Quotation Label
62 |
63 | ### List Literal
64 |
65 | ### Native Block
66 |
67 | ### Checked Dot Expression with Else
68 |
69 | ### Expression Tracing
70 |
71 | # Settings
72 |
73 | ### Developer Mode
74 |
75 | ### Engine Auto On
76 |
77 | ### Thresholds
78 |
79 | ### Synchronisation
80 |
81 | ### Tracing
82 |
83 | # Status Tool
84 |
85 | ### Messages
86 |
87 | ### Status
88 |
89 | ### Aspects
90 |
91 | ### Debugging
92 |
93 | ### Hotspot analyse
94 |
95 | # Auto Checking
96 |
97 | ### Checking Settings
98 |
99 | ### Checking Tool
100 |
101 | # Semantics
102 |
103 | ### Declarative
104 |
105 | ### Fixpoint
106 |
107 | ### Reactive
108 |
109 | ### Ripple Out
110 |
111 | ### Incremental
112 |
113 | ### Identity Matching
114 |
115 | ### Update Granularity
116 |
117 | ### Null Handling
118 |
119 | ### Exception Handling
120 |
121 | ### Orphan Handling
122 |
123 | ### Containment
124 |
125 | ### Optionality
126 |
127 | ### Constant Functionality
128 |
129 | # Gui Library
130 |
131 | The GUI library is an MPS language that allows you to create Swing GUIs in a declarative way.
132 | The library is documented [here](GUI).
133 |
--------------------------------------------------------------------------------
/documentation/GUI.md:
--------------------------------------------------------------------------------
1 | # Gui Library
2 |
3 | ### Diagrams
4 |
5 | ### Declarative Swing
6 |
7 | ### Shapes
8 |
--------------------------------------------------------------------------------
/documentation/copy-to-wiki.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | ##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3 | ## (C) Copyright 2018-2023 Modeling Value Group B.V. (http://modelingvalue.org) ~
4 | ## ~
5 | ## Licensed under the GNU Lesser General Public License v3.0 (the 'License'). You may not use this file except in ~
6 | ## compliance with the License. You may obtain a copy of the License at: https://choosealicense.com/licenses/lgpl-3.0 ~
7 | ## Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on ~
8 | ## an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the ~
9 | ## specific language governing permissions and limitations under the License. ~
10 | ## ~
11 | ## Maintainers: ~
12 | ## Wim Bast, Tom Brus, Ronald Krijgsheld ~
13 | ## Contributors: ~
14 | ## Arjan Kok, Carel Bast ~
15 | ##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
16 |
17 | set -euo pipefail
18 |
19 | main() {
20 | prepare
21 | copyToWiki
22 | pushToWiki
23 | }
24 | prepare() {
25 | SOURCE_DIR="source"
26 | DOCU_DIR="$SOURCE_DIR/documentation"
27 | WIKI_DIR="wiki"
28 | version="$(getVersion)"
29 | branch="${GITHUB_REF#refs/heads/}"
30 | owner="$OWNER"
31 | repo="$REPO"
32 | hash="$HASH"
33 | }
34 | copyToWiki() {
35 | java "$SOURCE_DIR/runtime/src/main/java/CopyToWiki.java" \
36 | "$DOCU_DIR" \
37 | "$WIKI_DIR" \
38 | "$owner" \
39 | "$repo" \
40 | "$version" \
41 | "$branch" \
42 | "$hash"
43 | }
44 | pushToWiki() {
45 | if ! hasWikiChanges; then
46 | echo "no changes to push to wiki repo"
47 | else
48 | ( cd $WIKI_DIR
49 | echo "push changes to wiki repo..."
50 | git config --global user.email "auto-wiki-updater@modelingvalue.nl"
51 | git config --global user.name "auto WIKI updater"
52 | git add -A
53 | git commit -m "update wiki from version '$version' in branch '$branch'"
54 | git push
55 | )
56 | fi
57 | }
58 | getVersion() {
59 | cat "$SOURCE_DIR/gradle.properties" | sed 's/ //g' | egrep '^version=' | sed 's/version=//'
60 | }
61 | hasWikiChanges() {
62 | ( cd "$WIKI_DIR"
63 | [[ $(git status --porcelain) ]]
64 | )
65 | }
66 |
67 |
68 | main "$@"
69 |
--------------------------------------------------------------------------------
/documentation/images/DclareEngineOnAtProjectOpen.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ModelingValueGroup/dclareForMPS/3fd9debbc3ecf7e031c77b51a9a48227547ac7ef/documentation/images/DclareEngineOnAtProjectOpen.png
--------------------------------------------------------------------------------
/documentation/images/checker-tool.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ModelingValueGroup/dclareForMPS/3fd9debbc3ecf7e031c77b51a9a48227547ac7ef/documentation/images/checker-tool.png
--------------------------------------------------------------------------------
/documentation/images/plugin.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ModelingValueGroup/dclareForMPS/3fd9debbc3ecf7e031c77b51a9a48227547ac7ef/documentation/images/plugin.png
--------------------------------------------------------------------------------
/documentation/images/rules-aspect.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ModelingValueGroup/dclareForMPS/3fd9debbc3ecf7e031c77b51a9a48227547ac7ef/documentation/images/rules-aspect.png
--------------------------------------------------------------------------------
/documentation/images/status-tool.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ModelingValueGroup/dclareForMPS/3fd9debbc3ecf7e031c77b51a9a48227547ac7ef/documentation/images/status-tool.png
--------------------------------------------------------------------------------
/documentation/images/use-dclareMPS-language.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ModelingValueGroup/dclareForMPS/3fd9debbc3ecf7e031c77b51a9a48227547ac7ef/documentation/images/use-dclareMPS-language.png
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | ##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 | ## (C) Copyright 2018-2023 Modeling Value Group B.V. (http://modelingvalue.org) ~
3 | ## ~
4 | ## Licensed under the GNU Lesser General Public License v3.0 (the 'License'). You may not use this file except in ~
5 | ## compliance with the License. You may obtain a copy of the License at: https://choosealicense.com/licenses/lgpl-3.0 ~
6 | ## Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on ~
7 | ## an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the ~
8 | ## specific language governing permissions and limitations under the License. ~
9 | ## ~
10 | ## Maintainers: ~
11 | ## Wim Bast, Tom Brus, Ronald Krijgsheld ~
12 | ## Contributors: ~
13 | ## Arjan Kok, Carel Bast ~
14 | ##~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 |
16 | # suppress inspection "UnusedProperty" for whole file
17 | group = org.modelingvalue
18 | artifact = DclareForMPS
19 | version = 4.0.0
20 | version_java = 17
21 | version_mps = 2022.3
22 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ModelingValueGroup/dclareForMPS/3fd9debbc3ecf7e031c77b51a9a48227547ac7ef/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-7.6-bin.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @rem
2 | @rem Copyright 2015 the original author or authors.
3 | @rem
4 | @rem Licensed under the Apache License, Version 2.0 (the "License");
5 | @rem you may not use this file except in compliance with the License.
6 | @rem You may obtain a copy of the License at
7 | @rem
8 | @rem https://www.apache.org/licenses/LICENSE-2.0
9 | @rem
10 | @rem Unless required by applicable law or agreed to in writing, software
11 | @rem distributed under the License is distributed on an "AS IS" BASIS,
12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | @rem See the License for the specific language governing permissions and
14 | @rem limitations under the License.
15 | @rem
16 |
17 | @if "%DEBUG%"=="" @echo off
18 | @rem ##########################################################################
19 | @rem
20 | @rem Gradle startup script for Windows
21 | @rem
22 | @rem ##########################################################################
23 |
24 | @rem Set local scope for the variables with windows NT shell
25 | if "%OS%"=="Windows_NT" setlocal
26 |
27 | set DIRNAME=%~dp0
28 | if "%DIRNAME%"=="" set DIRNAME=.
29 | set APP_BASE_NAME=%~n0
30 | set APP_HOME=%DIRNAME%
31 |
32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter.
33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
34 |
35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
37 |
38 | @rem Find java.exe
39 | if defined JAVA_HOME goto findJavaFromJavaHome
40 |
41 | set JAVA_EXE=java.exe
42 | %JAVA_EXE% -version >NUL 2>&1
43 | if %ERRORLEVEL% equ 0 goto execute
44 |
45 | echo.
46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
47 | echo.
48 | echo Please set the JAVA_HOME variable in your environment to match the
49 | echo location of your Java installation.
50 |
51 | goto fail
52 |
53 | :findJavaFromJavaHome
54 | set JAVA_HOME=%JAVA_HOME:"=%
55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
56 |
57 | if exist "%JAVA_EXE%" goto execute
58 |
59 | echo.
60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
61 | echo.
62 | echo Please set the JAVA_HOME variable in your environment to match the
63 | echo location of your Java installation.
64 |
65 | goto fail
66 |
67 | :execute
68 | @rem Setup the command line
69 |
70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
71 |
72 |
73 | @rem Execute Gradle
74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
75 |
76 | :end
77 | @rem End local scope for the variables with windows NT shell
78 | if %ERRORLEVEL% equ 0 goto mainEnd
79 |
80 | :fail
81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
82 | rem the _cmd.exe /c_ return code!
83 | set EXIT_CODE=%ERRORLEVEL%
84 | if %EXIT_CODE% equ 0 set EXIT_CODE=1
85 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE%
86 | exit /b %EXIT_CODE%
87 |
88 | :mainEnd
89 | if "%OS%"=="Windows_NT" endlocal
90 |
91 | :omega
92 |
--------------------------------------------------------------------------------
/languages/DclareGui/DclareGui.mpl:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 | e584ff77-930e-4637-8df0-b4c8d3b6de91(DclareRuntime)
17 | 55d6b6f5-8095-4cd0-a39b-779da8d12940(DclareMPSRuntime)
18 | 6354ebe7-c22a-4a0f-ac54-50b52ab9b065(JDK)
19 | 1ed103c3-3aa6-49b7-9c21-6765ee11f224(MPS.Editor)
20 | 8865b7a8-5271-43d3-884c-6fd1d9cfdd34(MPS.OpenAPI)
21 | c72da2b9-7cce-4447-8389-f407dc1158b7(jetbrains.mps.lang.structure)
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
--------------------------------------------------------------------------------
/languages/DclareMPS/icons/Dclare.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ModelingValueGroup/dclareForMPS/3fd9debbc3ecf7e031c77b51a9a48227547ac7ef/languages/DclareMPS/icons/Dclare.png
--------------------------------------------------------------------------------
/languages/DclareMPS/models/plugin.mps:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
--------------------------------------------------------------------------------
/languages/DclareMPS/plugin/Dclare.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ModelingValueGroup/dclareForMPS/3fd9debbc3ecf7e031c77b51a9a48227547ac7ef/languages/DclareMPS/plugin/Dclare.png
--------------------------------------------------------------------------------
/languages/DclareMPS/structure/Dclare.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ModelingValueGroup/dclareForMPS/3fd9debbc3ecf7e031c77b51a9a48227547ac7ef/languages/DclareMPS/structure/Dclare.png
--------------------------------------------------------------------------------
/languages/DclareMessages/icons/down-arrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ModelingValueGroup/dclareForMPS/3fd9debbc3ecf7e031c77b51a9a48227547ac7ef/languages/DclareMessages/icons/down-arrow.png
--------------------------------------------------------------------------------
/languages/DclareMessages/icons/right-arrow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ModelingValueGroup/dclareForMPS/3fd9debbc3ecf7e031c77b51a9a48227547ac7ef/languages/DclareMessages/icons/right-arrow.png
--------------------------------------------------------------------------------
/languages/DclareMessages/models/constraints.mps:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/languages/DclareMessages/models/typesystem.mps:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/release-notes.md:
--------------------------------------------------------------------------------
1 | # v1.6.1
2 |
3 | - release with new gradle base infra (no functional differences)
4 |
5 | # v1.6.0
6 |
7 | - update to latest MPS version (2021.1)
8 | - a lot of work is done on bidirectional transformations
9 | - some corner cases in bidi transformations can still cause problems, these will be addressed in a later update
10 |
11 | # v1.5.0
12 |
13 | - various bugfixes
14 | - update to MPS 2020.2
15 |
16 | # v1.4.1
17 |
18 | - update to latest MPS version
19 |
20 | # v1.4.0
21 |
22 | - update to latest MPS version
23 |
24 | # v1.2.4
25 |
26 | - several bugfixes
27 |
28 | # v1.2.0
29 |
30 | - based on MPS 2019.3.4
31 | - declarative model creation/deletion/renaming/matching
32 | - improved ruleset syntax
33 | - multi MPS projects support
34 | # v1.1.1
35 | - based on MPS 2019.3.2
36 | - dclare dashboard now shows engine activity as run/changes counts
37 | # v1.1.0
38 | - based on MPS 2019.3.1
39 | - first release via github actions
40 |
--------------------------------------------------------------------------------
/runtime/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 | # Editor-based HTTP Client requests
5 | /httpRequests/
6 |
--------------------------------------------------------------------------------
/runtime/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/runtime/.idea/encodings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/runtime/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/runtime/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 | false
58 |
59 |
60 |
--------------------------------------------------------------------------------
/runtime/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/runtime/src/main/java/org/modelingvalue/dclare/mps/ActualArguments.java:
--------------------------------------------------------------------------------
1 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 | // (C) Copyright 2018-2023 Modeling Value Group B.V. (http://modelingvalue.org) ~
3 | // ~
4 | // Licensed under the GNU Lesser General Public License v3.0 (the 'License'). You may not use this file except in ~
5 | // compliance with the License. You may obtain a copy of the License at: https://choosealicense.com/licenses/lgpl-3.0 ~
6 | // Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on ~
7 | // an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the ~
8 | // specific language governing permissions and limitations under the License. ~
9 | // ~
10 | // Maintainers: ~
11 | // Wim Bast, Tom Brus, Ronald Krijgsheld ~
12 | // Contributors: ~
13 | // Arjan Kok, Carel Bast ~
14 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 |
16 | package org.modelingvalue.dclare.mps;
17 |
18 | import java.util.Arrays;
19 |
20 | import org.modelingvalue.collections.util.IdentifiedByArray;
21 |
22 | public class ActualArguments extends IdentifiedByArray {
23 |
24 | public static ActualArguments of(Object[] args) {
25 | return new ActualArguments(args);
26 | }
27 |
28 | private ActualArguments(Object[] id) {
29 | super(id);
30 | }
31 |
32 | @Override
33 | public String toString() {
34 | return Arrays.toString(identity()).replace('[', '(').replace(']', ')');
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/runtime/src/main/java/org/modelingvalue/dclare/mps/BulkRenameCommand.java:
--------------------------------------------------------------------------------
1 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 | // (C) Copyright 2018-2023 Modeling Value Group B.V. (http://modelingvalue.org) ~
3 | // ~
4 | // Licensed under the GNU Lesser General Public License v3.0 (the 'License'). You may not use this file except in ~
5 | // compliance with the License. You may obtain a copy of the License at: https://choosealicense.com/licenses/lgpl-3.0 ~
6 | // Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on ~
7 | // an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the ~
8 | // specific language governing permissions and limitations under the License. ~
9 | // ~
10 | // Maintainers: ~
11 | // Wim Bast, Tom Brus, Ronald Krijgsheld ~
12 | // Contributors: ~
13 | // Arjan Kok, Carel Bast ~
14 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 |
16 | package org.modelingvalue.dclare.mps;
17 |
18 | import org.modelingvalue.collections.List;
19 | import org.modelingvalue.collections.util.Pair;
20 |
21 | import java.util.function.Consumer;
22 |
23 | public class BulkRenameCommand {
24 | public final boolean dry;
25 | public final boolean inamedConcepts;
26 | public final boolean allProperties;
27 | public final boolean stringLiterals;
28 | public final List> renames;
29 | public final Consumer resultHandler;
30 |
31 | public static class RenameResult {
32 | public final List rows;
33 | public final String type;
34 | public final String from;
35 | public final String to;
36 | public final String modelName;
37 | public final String nodeName;
38 |
39 | public RenameResult(List rows, String type, String from, String to, String modelName, String nodeName) {
40 | this.rows = rows;
41 | this.type = type;
42 | this.from = from;
43 | this.to = to;
44 | this.modelName = modelName;
45 | this.nodeName = nodeName;
46 | }
47 | }
48 |
49 | public static class Rename {
50 | public boolean enabled;
51 | public boolean regexp;
52 | public String from;
53 | public String to;
54 |
55 | @SuppressWarnings("unused")
56 | public Rename() {
57 | this(false, false, "", "");
58 | }
59 |
60 | public Rename(boolean enabled, boolean regexp, String from, String to) {
61 | this.enabled = enabled;
62 | this.regexp = regexp;
63 | this.from = from;
64 | this.to = to;
65 | }
66 |
67 | @SuppressWarnings("FieldMayBeFinal")
68 | private static java.util.List dummy = null;
69 |
70 | public static java.lang.reflect.Type getListType() {
71 | try {
72 | return Rename.class.getDeclaredField("dummy").getGenericType();
73 | } catch (NoSuchFieldException e) {
74 | throw new RuntimeException(e);
75 | }
76 | }
77 | }
78 |
79 | public BulkRenameCommand(boolean dry, boolean inamedConcepts, boolean allProperties, boolean stringLiterals, List> renames, Consumer resultHandler) {
80 | this.dry = dry;
81 | this.inamedConcepts = inamedConcepts;
82 | this.allProperties = allProperties;
83 | this.stringLiterals = stringLiterals;
84 | this.renames = renames;
85 | this.resultHandler = resultHandler;
86 | }
87 |
88 | @SuppressWarnings("unused")
89 | public void change(List rows, String type, String from, String to, String modelName, String nodeName) {
90 | resultHandler.accept(new RenameResult(rows, type, from, to, modelName, nodeName));
91 | System.err.printf(" - %32s: %-20s: %-32s -> %-32s [%s - %s]\n", rows, type, from, to, modelName, nodeName);
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/runtime/src/main/java/org/modelingvalue/dclare/mps/DCopy.java:
--------------------------------------------------------------------------------
1 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 | // (C) Copyright 2018-2023 Modeling Value Group B.V. (http://modelingvalue.org) ~
3 | // ~
4 | // Licensed under the GNU Lesser General Public License v3.0 (the 'License'). You may not use this file except in ~
5 | // compliance with the License. You may obtain a copy of the License at: https://choosealicense.com/licenses/lgpl-3.0 ~
6 | // Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on ~
7 | // an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the ~
8 | // specific language governing permissions and limitations under the License. ~
9 | // ~
10 | // Maintainers: ~
11 | // Wim Bast, Tom Brus, Ronald Krijgsheld ~
12 | // Contributors: ~
13 | // Arjan Kok, Carel Bast ~
14 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 |
16 | package org.modelingvalue.dclare.mps;
17 |
18 | import java.util.Arrays;
19 |
20 | import org.modelingvalue.dclare.Construction.Reason;
21 | import org.modelingvalue.dclare.Mutable;
22 |
23 | public class DCopy extends DDerive {
24 |
25 | protected DCopy(Mutable thiz, DNode copiedRoot, IRuleSet ruleSet, String anonymousType, Object[] ctx) {
26 | this(thiz, init(ctx, copiedRoot, ruleSet, anonymousType));
27 | }
28 |
29 | private static Object[] init(Object[] ctx, DNode copiedRoot, IRuleSet ruleSet, String anonymousType) {
30 | Object[] array = Arrays.copyOf(ctx, ctx.length + 3);
31 | array[array.length - 3] = copiedRoot;
32 | array[array.length - 2] = ruleSet;
33 | array[array.length - 1] = anonymousType;
34 | return array;
35 | }
36 |
37 | protected DCopy(DNode copiedChild, DCopy root) {
38 | this(null, new Object[]{copiedChild, root});
39 | }
40 |
41 | private DCopy(Mutable thiz, Object[] identity) {
42 | super(thiz, identity);
43 | }
44 |
45 | public DCopy root() {
46 | Object e = get(null, 1);
47 | return e instanceof DCopy ? (DCopy) e : this;
48 | }
49 |
50 | public DNode copied() {
51 | DCopy root = root();
52 | return root == this ? (DNode) get(null, root.size() - 3) : (DNode) get(null, 0);
53 | }
54 |
55 | @Override
56 | public IRuleSet ruleSet() {
57 | DCopy root = root();
58 | return (IRuleSet) root.get(null, root.size() - 2);
59 | }
60 |
61 | @Override
62 | public String anonymousType() {
63 | DCopy root = root();
64 | return (String) root.get(null, root.size() - 1);
65 | }
66 |
67 | @Override
68 | protected Reason clone(Mutable thiz, Object[] identity) {
69 | return new DCopy(thiz, identity);
70 | }
71 |
72 | }
73 |
--------------------------------------------------------------------------------
/runtime/src/main/java/org/modelingvalue/dclare/mps/DDependency.java:
--------------------------------------------------------------------------------
1 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 | // (C) Copyright 2018-2023 Modeling Value Group B.V. (http://modelingvalue.org) ~
3 | // ~
4 | // Licensed under the GNU Lesser General Public License v3.0 (the 'License'). You may not use this file except in ~
5 | // compliance with the License. You may obtain a copy of the License at: https://choosealicense.com/licenses/lgpl-3.0 ~
6 | // Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on ~
7 | // an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the ~
8 | // specific language governing permissions and limitations under the License. ~
9 | // ~
10 | // Maintainers: ~
11 | // Wim Bast, Tom Brus, Ronald Krijgsheld ~
12 | // Contributors: ~
13 | // Arjan Kok, Carel Bast ~
14 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 |
16 | package org.modelingvalue.dclare.mps;
17 |
18 | import org.jetbrains.mps.openapi.module.SDependency;
19 | import org.jetbrains.mps.openapi.module.SDependencyScope;
20 | import org.jetbrains.mps.openapi.module.SModule;
21 | import org.jetbrains.mps.openapi.module.SModuleReference;
22 | import org.modelingvalue.collections.util.IdentifiedBy;
23 |
24 | public class DDependency extends IdentifiedBy implements SDependency {
25 |
26 | public DDependency(SDependency original) {
27 | super(original);
28 | }
29 |
30 | @Override
31 | public SDependencyScope getScope() {
32 | return id().getScope();
33 | }
34 |
35 | @Override
36 | public boolean isReexport() {
37 | return id().isReexport();
38 | }
39 |
40 | @Override
41 | public SModuleReference getTargetModule() {
42 | return new DModuleReference(id().getTargetModule());
43 | }
44 |
45 | @Override
46 | public DModule getTarget() {
47 | SModule target = DClareMPS.instance().read(() -> id().getTarget());
48 | return target != null ? DModule.of(target) : null;
49 | }
50 |
51 | }
52 |
--------------------------------------------------------------------------------
/runtime/src/main/java/org/modelingvalue/dclare/mps/DDerive.java:
--------------------------------------------------------------------------------
1 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 | // (C) Copyright 2018-2023 Modeling Value Group B.V. (http://modelingvalue.org) ~
3 | // ~
4 | // Licensed under the GNU Lesser General Public License v3.0 (the 'License'). You may not use this file except in ~
5 | // compliance with the License. You may obtain a copy of the License at: https://choosealicense.com/licenses/lgpl-3.0 ~
6 | // Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on ~
7 | // an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the ~
8 | // specific language governing permissions and limitations under the License. ~
9 | // ~
10 | // Maintainers: ~
11 | // Wim Bast, Tom Brus, Ronald Krijgsheld ~
12 | // Contributors: ~
13 | // Arjan Kok, Carel Bast ~
14 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 |
16 | package org.modelingvalue.dclare.mps;
17 |
18 | import org.jetbrains.mps.openapi.language.SLanguage;
19 | import org.modelingvalue.dclare.Construction;
20 | import org.modelingvalue.dclare.Direction;
21 | import org.modelingvalue.dclare.Mutable;
22 |
23 | public abstract class DDerive extends Construction.Reason {
24 |
25 | protected DDerive(Mutable thiz, Object[] identity) {
26 | super(thiz, identity);
27 | }
28 |
29 | public abstract String anonymousType();
30 |
31 | public abstract IRuleSet ruleSet();
32 |
33 | @Override
34 | public Direction direction() {
35 | return IAspect.DIRECTION.get(ruleSet().getAspect());
36 | }
37 |
38 | public SLanguage language() {
39 | return ruleSet().getLanguage();
40 | }
41 |
42 | public IAspect aspect() {
43 | return ruleSet().getAspect();
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/runtime/src/main/java/org/modelingvalue/dclare/mps/DFeature.java:
--------------------------------------------------------------------------------
1 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 | // (C) Copyright 2018-2023 Modeling Value Group B.V. (http://modelingvalue.org) ~
3 | // ~
4 | // Licensed under the GNU Lesser General Public License v3.0 (the 'License'). You may not use this file except in ~
5 | // compliance with the License. You may obtain a copy of the License at: https://choosealicense.com/licenses/lgpl-3.0 ~
6 | // Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on ~
7 | // an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the ~
8 | // specific language governing permissions and limitations under the License. ~
9 | // ~
10 | // Maintainers: ~
11 | // Wim Bast, Tom Brus, Ronald Krijgsheld ~
12 | // Contributors: ~
13 | // Arjan Kok, Carel Bast ~
14 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 |
16 | package org.modelingvalue.dclare.mps;
17 |
18 | import org.jetbrains.mps.openapi.model.SNodeReference;
19 | import org.modelingvalue.collections.util.Internable;
20 |
21 | public interface DFeature extends Internable {
22 |
23 | SNodeReference getSource();
24 |
25 | boolean isSynthetic();
26 |
27 | IRuleSet ruleSet();
28 |
29 | boolean isConstant();
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/runtime/src/main/java/org/modelingvalue/dclare/mps/DFromOriginalObject.java:
--------------------------------------------------------------------------------
1 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 | // (C) Copyright 2018-2023 Modeling Value Group B.V. (http://modelingvalue.org) ~
3 | // ~
4 | // Licensed under the GNU Lesser General Public License v3.0 (the 'License'). You may not use this file except in ~
5 | // compliance with the License. You may obtain a copy of the License at: https://choosealicense.com/licenses/lgpl-3.0 ~
6 | // Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on ~
7 | // an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the ~
8 | // specific language governing permissions and limitations under the License. ~
9 | // ~
10 | // Maintainers: ~
11 | // Wim Bast, Tom Brus, Ronald Krijgsheld ~
12 | // Contributors: ~
13 | // Arjan Kok, Carel Bast ~
14 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 |
16 | package org.modelingvalue.dclare.mps;
17 |
18 | public abstract class DFromOriginalObject extends DObject {
19 |
20 | private final O original;
21 |
22 | protected DFromOriginalObject(O original) {
23 | this.original = original;
24 | }
25 |
26 | public O original() {
27 | return original;
28 | }
29 |
30 | @Override
31 | public int hashCode() {
32 | return original.hashCode();
33 | }
34 |
35 | @Override
36 | public boolean equals(Object obj) {
37 | if (obj == this) {
38 | return true;
39 | } else if (obj instanceof DFromOriginalObject) {
40 | DFromOriginalObject> other = (DFromOriginalObject>) obj;
41 | return original.equals(other.original);
42 | } else {
43 | return false;
44 | }
45 | }
46 |
47 | @Override
48 | public String toString() {
49 | return original.toString();
50 | }
51 |
52 | @Override
53 | protected boolean isRead() {
54 | return true;
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/runtime/src/main/java/org/modelingvalue/dclare/mps/DIssueModelReportItem.java:
--------------------------------------------------------------------------------
1 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 | // (C) Copyright 2018-2023 Modeling Value Group B.V. (http://modelingvalue.org) ~
3 | // ~
4 | // Licensed under the GNU Lesser General Public License v3.0 (the 'License'). You may not use this file except in ~
5 | // compliance with the License. You may obtain a copy of the License at: https://choosealicense.com/licenses/lgpl-3.0 ~
6 | // Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on ~
7 | // an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the ~
8 | // specific language governing permissions and limitations under the License. ~
9 | // ~
10 | // Maintainers: ~
11 | // Wim Bast, Tom Brus, Ronald Krijgsheld ~
12 | // Contributors: ~
13 | // Arjan Kok, Carel Bast ~
14 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 |
16 | package org.modelingvalue.dclare.mps;
17 |
18 | import java.util.Arrays;
19 | import java.util.Collection;
20 | import java.util.Collections;
21 | import java.util.HashSet;
22 | import java.util.Objects;
23 | import java.util.Set;
24 |
25 | import org.jetbrains.mps.openapi.model.SModel;
26 |
27 | import jetbrains.mps.errors.MessageStatus;
28 | import jetbrains.mps.errors.item.ModelReportItemBase;
29 | import jetbrains.mps.errors.item.RuleIdFlavouredItem;
30 |
31 | public class DIssueModelReportItem extends ModelReportItemBase implements RuleIdFlavouredItem {
32 |
33 | private static final HashSet> FLAVOURS = new HashSet<>(Arrays.asList(FLAVOUR_ISSUE_KIND, FLAVOUR_MODEL, FLAVOUR_RULE_ID));
34 |
35 | private final TypesystemRuleId ruleId;
36 |
37 | public DIssueModelReportItem(MessageStatus severity, SModel model, String message, TypesystemRuleId ruleId) {
38 | super(severity, model.getReference(), severity.getPresentation() + ": " + message);
39 | this.ruleId = ruleId;
40 | }
41 |
42 | @Override
43 | public int hashCode() {
44 | return Objects.hash(ruleId, getSeverity(), getModel(), getMessage());
45 | }
46 |
47 | @Override
48 | public boolean equals(Object obj) {
49 | if (this == obj)
50 | return true;
51 | if (obj == null)
52 | return false;
53 | if (getClass() != obj.getClass())
54 | return false;
55 | DIssueModelReportItem other = (DIssueModelReportItem) obj;
56 | return Objects.equals(ruleId, other.ruleId) //
57 | && Objects.equals(getSeverity(), other.getSeverity()) //
58 | && Objects.equals(getModel(), other.getModel())//
59 | && Objects.equals(getMessage(), other.getMessage());
60 | }
61 |
62 | @Override
63 | public Set> getIdFlavours() {
64 | return FLAVOURS;
65 | }
66 |
67 | @Override
68 | public ItemKind getIssueKind() {
69 | return DIssue.ITEM_KIND;
70 | }
71 |
72 | @Override
73 | public Collection getRuleId() {
74 | return Collections.singleton(ruleId);
75 | }
76 |
77 | }
78 |
--------------------------------------------------------------------------------
/runtime/src/main/java/org/modelingvalue/dclare/mps/DIssueModuleReportItem.java:
--------------------------------------------------------------------------------
1 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 | // (C) Copyright 2018-2023 Modeling Value Group B.V. (http://modelingvalue.org) ~
3 | // ~
4 | // Licensed under the GNU Lesser General Public License v3.0 (the 'License'). You may not use this file except in ~
5 | // compliance with the License. You may obtain a copy of the License at: https://choosealicense.com/licenses/lgpl-3.0 ~
6 | // Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on ~
7 | // an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the ~
8 | // specific language governing permissions and limitations under the License. ~
9 | // ~
10 | // Maintainers: ~
11 | // Wim Bast, Tom Brus, Ronald Krijgsheld ~
12 | // Contributors: ~
13 | // Arjan Kok, Carel Bast ~
14 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 |
16 | package org.modelingvalue.dclare.mps;
17 |
18 | import java.util.Arrays;
19 | import java.util.Collection;
20 | import java.util.Collections;
21 | import java.util.HashSet;
22 | import java.util.Objects;
23 | import java.util.Set;
24 |
25 | import org.jetbrains.mps.openapi.module.SModule;
26 | import org.jetbrains.mps.openapi.module.SModuleReference;
27 |
28 | import jetbrains.mps.errors.MessageStatus;
29 | import jetbrains.mps.errors.item.ModuleReportItem;
30 | import jetbrains.mps.errors.item.RuleIdFlavouredItem;
31 |
32 | public class DIssueModuleReportItem implements ModuleReportItem, RuleIdFlavouredItem {
33 |
34 | private static final HashSet> FLAVOURS = new HashSet<>(Arrays.asList(FLAVOUR_ISSUE_KIND, FLAVOUR_MODULE, FLAVOUR_RULE_ID));
35 |
36 | private final MessageStatus severity;
37 | private final SModuleReference module;
38 | private final String message;
39 | private final TypesystemRuleId ruleId;
40 |
41 | public DIssueModuleReportItem(MessageStatus severity, SModule module, String message, TypesystemRuleId ruleId) {
42 | this.severity = severity;
43 | this.module = module.getModuleReference();
44 | this.message = severity.getPresentation() + ": " + message;
45 | this.ruleId = ruleId;
46 | }
47 |
48 | @Override
49 | public int hashCode() {
50 | return Objects.hash(message, module, ruleId, severity);
51 | }
52 |
53 | @Override
54 | public boolean equals(Object obj) {
55 | if (this == obj)
56 | return true;
57 | if (obj == null)
58 | return false;
59 | if (getClass() != obj.getClass())
60 | return false;
61 | DIssueModuleReportItem other = (DIssueModuleReportItem) obj;
62 | return Objects.equals(message, other.message) //
63 | && Objects.equals(module, other.module) //
64 | && Objects.equals(ruleId, other.ruleId) //
65 | && severity == other.severity;
66 | }
67 |
68 | @Override
69 | public Set> getIdFlavours() {
70 | return FLAVOURS;
71 | }
72 |
73 | @Override
74 | public ItemKind getIssueKind() {
75 | return DIssue.ITEM_KIND;
76 | }
77 |
78 | @Override
79 | public SModuleReference getModule() {
80 | return module;
81 | }
82 |
83 | @Override
84 | public String getMessage() {
85 | return message;
86 | }
87 |
88 | @Override
89 | public MessageStatus getSeverity() {
90 | return severity;
91 | }
92 |
93 | @Override
94 | public Collection getRuleId() {
95 | return Collections.singleton(ruleId);
96 | }
97 |
98 | }
99 |
--------------------------------------------------------------------------------
/runtime/src/main/java/org/modelingvalue/dclare/mps/DIssueNodeReportItem.java:
--------------------------------------------------------------------------------
1 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 | // (C) Copyright 2018-2023 Modeling Value Group B.V. (http://modelingvalue.org) ~
3 | // ~
4 | // Licensed under the GNU Lesser General Public License v3.0 (the 'License'). You may not use this file except in ~
5 | // compliance with the License. You may obtain a copy of the License at: https://choosealicense.com/licenses/lgpl-3.0 ~
6 | // Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on ~
7 | // an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the ~
8 | // specific language governing permissions and limitations under the License. ~
9 | // ~
10 | // Maintainers: ~
11 | // Wim Bast, Tom Brus, Ronald Krijgsheld ~
12 | // Contributors: ~
13 | // Arjan Kok, Carel Bast ~
14 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 |
16 | package org.modelingvalue.dclare.mps;
17 |
18 | import java.util.Arrays;
19 | import java.util.Collection;
20 | import java.util.Collections;
21 | import java.util.HashSet;
22 | import java.util.Objects;
23 | import java.util.Set;
24 |
25 | import org.jetbrains.mps.openapi.model.SNode;
26 |
27 | import jetbrains.mps.errors.MessageStatus;
28 | import jetbrains.mps.errors.item.NodeReportItemBase;
29 | import jetbrains.mps.errors.item.RuleIdFlavouredItem;
30 | import jetbrains.mps.errors.messageTargets.MessageTarget;
31 | import jetbrains.mps.errors.messageTargets.NodeMessageTarget;
32 |
33 | public class DIssueNodeReportItem extends NodeReportItemBase implements RuleIdFlavouredItem {
34 |
35 | private static final NodeMessageTarget NODE_MESSAGE_TARGET = new NodeMessageTarget();
36 |
37 | private static final HashSet> FLAVOURS = new HashSet<>(Arrays.asList(FLAVOUR_ISSUE_KIND, FLAVOUR_NODE, FLAVOUR_RULE_ID));
38 |
39 | private final MessageTarget messageTarget;
40 | private final TypesystemRuleId ruleId;
41 |
42 | public DIssueNodeReportItem(MessageStatus severity, SNode node, MessageTarget messageTarget, String message, TypesystemRuleId ruleId) {
43 | super(severity, node.getReference(), message);
44 | this.messageTarget = messageTarget != null ? messageTarget : NODE_MESSAGE_TARGET;
45 | this.ruleId = ruleId;
46 | }
47 |
48 | @Override
49 | public int hashCode() {
50 | return Objects.hash(messageTarget, ruleId, getSeverity(), getNode(), getMessage());
51 | }
52 |
53 | @Override
54 | public boolean equals(Object obj) {
55 | if (this == obj)
56 | return true;
57 | if (obj == null)
58 | return false;
59 | if (getClass() != obj.getClass())
60 | return false;
61 | DIssueNodeReportItem other = (DIssueNodeReportItem) obj;
62 | return Objects.equals(messageTarget, other.messageTarget)//
63 | && Objects.equals(ruleId, other.ruleId) //
64 | && Objects.equals(getSeverity(), other.getSeverity()) //
65 | && Objects.equals(getNode(), other.getNode())//
66 | && Objects.equals(getMessage(), other.getMessage());
67 | }
68 |
69 | @Override
70 | public Set> getIdFlavours() {
71 | return FLAVOURS;
72 | }
73 |
74 | @Override
75 | public MessageTarget getMessageTarget() {
76 | return messageTarget;
77 | }
78 |
79 | @Override
80 | public ItemKind getIssueKind() {
81 | return DIssue.ITEM_KIND;
82 | }
83 |
84 | @Override
85 | public Collection getRuleId() {
86 | return Collections.singleton(ruleId);
87 | }
88 | }
89 |
--------------------------------------------------------------------------------
/runtime/src/main/java/org/modelingvalue/dclare/mps/DIssueType.java:
--------------------------------------------------------------------------------
1 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 | // (C) Copyright 2018-2023 Modeling Value Group B.V. (http://modelingvalue.org) ~
3 | // ~
4 | // Licensed under the GNU Lesser General Public License v3.0 (the 'License'). You may not use this file except in ~
5 | // compliance with the License. You may obtain a copy of the License at: https://choosealicense.com/licenses/lgpl-3.0 ~
6 | // Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on ~
7 | // an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the ~
8 | // specific language governing permissions and limitations under the License. ~
9 | // ~
10 | // Maintainers: ~
11 | // Wim Bast, Tom Brus, Ronald Krijgsheld ~
12 | // Contributors: ~
13 | // Arjan Kok, Carel Bast ~
14 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 |
16 | package org.modelingvalue.dclare.mps;
17 |
18 | import org.jetbrains.mps.openapi.language.SLanguage;
19 | import org.modelingvalue.collections.Collection;
20 | import org.modelingvalue.collections.Set;
21 | import org.modelingvalue.dclare.Observer;
22 | import org.modelingvalue.dclare.Setable;
23 |
24 | import jetbrains.mps.errors.MessageStatus;
25 |
26 | public class DIssueType extends DObjectType {
27 |
28 | public DIssueType(MessageStatus type) {
29 | super(type);
30 | }
31 |
32 | @SuppressWarnings("rawtypes")
33 | @Override
34 | public Set getRules(Set ruleSets) {
35 | return Set.of();
36 | }
37 |
38 | @SuppressWarnings("rawtypes")
39 | @Override
40 | public Set getAttributes(Set ruleSets) {
41 | return Set.of();
42 | }
43 |
44 | @SuppressWarnings("rawtypes")
45 | @Override
46 | public Set getNatives(Set ruleSets) {
47 | return Set.of();
48 | }
49 |
50 | @Override
51 | public Set getLanguages() {
52 | return Set.of();
53 | }
54 |
55 | @SuppressWarnings("rawtypes")
56 | @Override
57 | protected Collection observers() {
58 | return DIssue.OBSERVERS;
59 | }
60 |
61 | @SuppressWarnings("rawtypes")
62 | @Override
63 | protected Collection setables() {
64 | return DIssue.SETABLES;
65 | }
66 |
67 | }
68 |
--------------------------------------------------------------------------------
/runtime/src/main/java/org/modelingvalue/dclare/mps/DMessage.java:
--------------------------------------------------------------------------------
1 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 | // (C) Copyright 2018-2023 Modeling Value Group B.V. (http://modelingvalue.org) ~
3 | // ~
4 | // Licensed under the GNU Lesser General Public License v3.0 (the 'License'). You may not use this file except in ~
5 | // compliance with the License. You may obtain a copy of the License at: https://choosealicense.com/licenses/lgpl-3.0 ~
6 | // Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on ~
7 | // an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the ~
8 | // specific language governing permissions and limitations under the License. ~
9 | // ~
10 | // Maintainers: ~
11 | // Wim Bast, Tom Brus, Ronald Krijgsheld ~
12 | // Contributors: ~
13 | // Arjan Kok, Carel Bast ~
14 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 |
16 | package org.modelingvalue.dclare.mps;
17 |
18 | import org.jetbrains.mps.openapi.model.SNodeReference;
19 | import org.modelingvalue.collections.List;
20 |
21 | public class DMessage {
22 | private static final long serialVersionUID = -303368640776089669L;
23 |
24 | private final Object content;
25 | private final DMessageType type;
26 | private final DObject context;
27 | private final DFeature feature;
28 | private List subMessages = List.of();
29 |
30 | public DMessage(DObject context, DFeature feature, DMessageType type, Object content) {
31 | this.context = context;
32 | this.feature = feature;
33 | this.type = type;
34 | this.content = content;
35 | }
36 |
37 | public DObject context() {
38 | return context;
39 | }
40 |
41 | public DFeature feature() {
42 | return feature;
43 | }
44 |
45 | public DMessageType type() {
46 | return type;
47 | }
48 |
49 | public Object content() {
50 | return content;
51 | }
52 |
53 | public SNodeReference source() {
54 | return feature().getSource();
55 | }
56 |
57 | public List subMessages() {
58 | return subMessages;
59 | }
60 |
61 | public void addSubMessage(DMessage subMessage) {
62 | subMessages = subMessages.add(subMessage);
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/runtime/src/main/java/org/modelingvalue/dclare/mps/DMessageType.java:
--------------------------------------------------------------------------------
1 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 | // (C) Copyright 2018-2023 Modeling Value Group B.V. (http://modelingvalue.org) ~
3 | // ~
4 | // Licensed under the GNU Lesser General Public License v3.0 (the 'License'). You may not use this file except in ~
5 | // compliance with the License. You may obtain a copy of the License at: https://choosealicense.com/licenses/lgpl-3.0 ~
6 | // Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on ~
7 | // an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the ~
8 | // specific language governing permissions and limitations under the License. ~
9 | // ~
10 | // Maintainers: ~
11 | // Wim Bast, Tom Brus, Ronald Krijgsheld ~
12 | // Contributors: ~
13 | // Arjan Kok, Carel Bast ~
14 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 |
16 | package org.modelingvalue.dclare.mps;
17 |
18 | public enum DMessageType {
19 | error,
20 | warning,
21 | info,
22 | debug
23 | }
24 |
--------------------------------------------------------------------------------
/runtime/src/main/java/org/modelingvalue/dclare/mps/DMethod.java:
--------------------------------------------------------------------------------
1 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 | // (C) Copyright 2018-2023 Modeling Value Group B.V. (http://modelingvalue.org) ~
3 | // ~
4 | // Licensed under the GNU Lesser General Public License v3.0 (the 'License'). You may not use this file except in ~
5 | // compliance with the License. You may obtain a copy of the License at: https://choosealicense.com/licenses/lgpl-3.0 ~
6 | // Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on ~
7 | // an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the ~
8 | // specific language governing permissions and limitations under the License. ~
9 | // ~
10 | // Maintainers: ~
11 | // Wim Bast, Tom Brus, Ronald Krijgsheld ~
12 | // Contributors: ~
13 | // Arjan Kok, Carel Bast ~
14 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 |
16 | package org.modelingvalue.dclare.mps;
17 |
18 | import org.jetbrains.mps.openapi.language.SLanguage;
19 | import org.modelingvalue.collections.Set;
20 | import org.modelingvalue.collections.util.Pair;
21 | import org.modelingvalue.dclare.Constant;
22 |
23 | public abstract class DMethod implements DFeature {
24 |
25 | @SuppressWarnings("unchecked")
26 | public static DMethod of(SLanguage language, String id) {
27 | return (DMethod) DClareMPS.ALL_METHODS_MAP.get(language).get(id);
28 | }
29 |
30 | @SuppressWarnings("rawtypes")
31 | private static final Constant, DMethod> D_METHOD = Constant.of("D_METHOD", p -> {
32 | Set langs = DRepository.ALL_LANGUAGES_WITH_RULES.get(DClareMPS.instance().getRepository());
33 | for (DMethod method : DClareMPS.METHOD_MAP.get(langs).get(Pair.of(p.a(), p.b().size()))) {
34 | if (p.b().isSubOf(method.signature(), true)) {
35 | return method;
36 | }
37 | }
38 | throw new UnsupportedOperationException(p.a() + p.b());
39 | });
40 |
41 | private final Constant METHOD_CONSTANT = Constant.of(Pair.of(this, "D_METHOD_CONSTANT"), null, args -> call(args.identity()));
42 |
43 | @SuppressWarnings({"unchecked", "rawtypes"})
44 | public R invoke(Object[] args) {
45 | DMethod dMethod = DMethod.D_METHOD.get(Pair.of(name(), Signature.of(signature(), args)));
46 | if (dMethod.isConstant()) {
47 | return (R) dMethod.METHOD_CONSTANT.get(ActualArguments.of(args));
48 | } else {
49 | return (R) dMethod.call(args);
50 | }
51 | }
52 |
53 | public abstract String name();
54 |
55 | @SuppressWarnings("rawtypes")
56 | public abstract Signature signature();
57 |
58 | public abstract R call(Object[] arguments);
59 |
60 | public abstract String id();
61 |
62 | }
63 |
--------------------------------------------------------------------------------
/runtime/src/main/java/org/modelingvalue/dclare/mps/DModelType.java:
--------------------------------------------------------------------------------
1 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 | // (C) Copyright 2018-2023 Modeling Value Group B.V. (http://modelingvalue.org) ~
3 | // ~
4 | // Licensed under the GNU Lesser General Public License v3.0 (the 'License'). You may not use this file except in ~
5 | // compliance with the License. You may obtain a copy of the License at: https://choosealicense.com/licenses/lgpl-3.0 ~
6 | // Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on ~
7 | // an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the ~
8 | // specific language governing permissions and limitations under the License. ~
9 | // ~
10 | // Maintainers: ~
11 | // Wim Bast, Tom Brus, Ronald Krijgsheld ~
12 | // Contributors: ~
13 | // Arjan Kok, Carel Bast ~
14 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 |
16 | package org.modelingvalue.dclare.mps;
17 |
18 | import org.jetbrains.mps.openapi.language.SLanguage;
19 | import org.modelingvalue.collections.Collection;
20 | import org.modelingvalue.collections.Set;
21 | import org.modelingvalue.collections.util.Pair;
22 | import org.modelingvalue.dclare.Observer;
23 | import org.modelingvalue.dclare.Setable;
24 |
25 | public class DModelType extends DObjectType, Set>> {
26 |
27 | public DModelType(Pair, Set> identity) {
28 | super(identity);
29 | }
30 |
31 | @SuppressWarnings({"unchecked", "rawtypes"})
32 | @Override
33 | public Set getRules(Set ruleSets) {
34 | return (Set) ruleSets.flatMap(rs -> Collection.of(rs.getModelRules(getAnonymousTypes()))).asSet();
35 | }
36 |
37 | @SuppressWarnings({"rawtypes", "unchecked"})
38 | @Override
39 | public Set getAttributes(Set ruleSets) {
40 | return (Set) ruleSets.flatMap(rs -> Collection.of(rs.getModelAttributes(getAnonymousTypes()))).asSet();
41 | }
42 |
43 | @SuppressWarnings({"rawtypes", "unchecked"})
44 | @Override
45 | public Set getNatives(Set ruleSets) {
46 | return (Set) ruleSets.flatMap(rs -> Collection.of(rs.getModelNatives(getAnonymousTypes()))).asSet();
47 | }
48 |
49 | @Override
50 | public Set getLanguages() {
51 | return id().a();
52 | }
53 |
54 | public Set getAnonymousTypes() {
55 | return id().b();
56 | }
57 |
58 | @SuppressWarnings("rawtypes")
59 | @Override
60 | public Collection setables() {
61 | return DModel.SETABLES;
62 | }
63 |
64 | @SuppressWarnings("rawtypes")
65 | @Override
66 | protected Collection observers() {
67 | return DModel.OBSERVERS;
68 | }
69 | }
70 |
--------------------------------------------------------------------------------
/runtime/src/main/java/org/modelingvalue/dclare/mps/DModuleListener.java:
--------------------------------------------------------------------------------
1 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 | // (C) Copyright 2018-2023 Modeling Value Group B.V. (http://modelingvalue.org) ~
3 | // ~
4 | // Licensed under the GNU Lesser General Public License v3.0 (the 'License'). You may not use this file except in ~
5 | // compliance with the License. You may obtain a copy of the License at: https://choosealicense.com/licenses/lgpl-3.0 ~
6 | // Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on ~
7 | // an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the ~
8 | // specific language governing permissions and limitations under the License. ~
9 | // ~
10 | // Maintainers: ~
11 | // Wim Bast, Tom Brus, Ronald Krijgsheld ~
12 | // Contributors: ~
13 | // Arjan Kok, Carel Bast ~
14 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 |
16 | package org.modelingvalue.dclare.mps;
17 |
18 | import org.jetbrains.mps.openapi.language.SLanguage;
19 | import org.jetbrains.mps.openapi.model.SModel;
20 | import org.jetbrains.mps.openapi.model.SModelReference;
21 | import org.jetbrains.mps.openapi.module.SDependency;
22 | import org.jetbrains.mps.openapi.module.SModule;
23 | import org.jetbrains.mps.openapi.module.SModuleListener;
24 | import org.modelingvalue.collections.Set;
25 | import org.modelingvalue.collections.util.Pair;
26 |
27 | public class DModuleListener extends Pair implements SModuleListener {
28 |
29 | private static final long serialVersionUID = -6842951912074996409L;
30 |
31 | public DModuleListener(DModule dModule, DClareMPS dClareMPS) {
32 | super(dModule, dClareMPS);
33 | }
34 |
35 | @Override
36 | public void modelAdded(SModule module, SModel sModel) {
37 | b().handleMPSChange(() -> {
38 | if (!a().isExternal() && !DModel.EXTERNAL.get(sModel)) {
39 | DModel dModel = DModel.of(sModel);
40 | DModule.MODELS.set(a(), Set::add, dModel);
41 | }
42 | });
43 |
44 | }
45 |
46 | @Override
47 | public void beforeModelRemoved(SModule module, SModel sModel) {
48 | b().handleMPSChange(() -> {
49 | if (!a().isExternal() && !DModel.EXTERNAL.get(sModel)) {
50 | DModel dModel = DModel.of(sModel);
51 | DModule.MODELS.set(a(), Set::remove, dModel);
52 | }
53 | });
54 | }
55 |
56 | @Override
57 | public void dependencyAdded(SModule module, SDependency dep) {
58 | b().handleMPSChange(() -> {
59 | DModule.DEPENDENCIES.set(a(), Set::add, new DDependency(dep));
60 | });
61 | }
62 |
63 | @Override
64 | public void dependencyRemoved(SModule module, SDependency dep) {
65 | b().handleMPSChange(() -> {
66 | DModule.DEPENDENCIES.set(a(), Set::remove, new DDependency(dep));
67 | });
68 | }
69 |
70 | @Override
71 | public void modelRemoved(SModule module, SModelReference ref) {
72 | }
73 |
74 | @Override
75 | public void beforeModelRenamed(SModule module, SModel model, SModelReference newRef) {
76 | }
77 |
78 | @Override
79 | public void modelRenamed(SModule module, SModel model, SModelReference oldRef) {
80 | b().handleMPSChange(() -> {
81 | if (!a().isExternal() && !DModel.EXTERNAL.get(model)) {
82 | DModel.NAME.set(DModel.of(model), model.getName().getLongName());
83 | }
84 | });
85 | }
86 |
87 | @Override
88 | public void languageAdded(SModule module, SLanguage lang) {
89 | b().handleMPSChange(() -> {
90 | DModule.LANGUAGES.set(a(), Set::add, lang);
91 | DRepository repository = DClareMPS.instance().getRepository();
92 | if (!DClareMPS.ACTIVE_RULE_SETS.get(lang).isEmpty() && !DRepository.ALL_LANGUAGES_WITH_RULES.get(repository).contains(lang)) {
93 | DClareMPS.instance().engine().restart();
94 | }
95 | });
96 | }
97 |
98 | @Override
99 | public void languageRemoved(SModule module, SLanguage lang) {
100 | b().handleMPSChange(() -> {
101 | DModule.LANGUAGES.set(a(), Set::remove, lang);
102 | DRepository repository = DClareMPS.instance().getRepository();
103 | if (!DClareMPS.ACTIVE_RULE_SETS.get(lang).isEmpty() && DRepository.ALL_LANGUAGES_WITH_RULES.get(repository).contains(lang)) {
104 | DClareMPS.instance().engine().restart();
105 | }
106 | });
107 | }
108 |
109 | @Override
110 | public void moduleChanged(SModule module) {
111 | }
112 |
113 | }
114 |
--------------------------------------------------------------------------------
/runtime/src/main/java/org/modelingvalue/dclare/mps/DModuleReference.java:
--------------------------------------------------------------------------------
1 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 | // (C) Copyright 2018-2023 Modeling Value Group B.V. (http://modelingvalue.org) ~
3 | // ~
4 | // Licensed under the GNU Lesser General Public License v3.0 (the 'License'). You may not use this file except in ~
5 | // compliance with the License. You may obtain a copy of the License at: https://choosealicense.com/licenses/lgpl-3.0 ~
6 | // Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on ~
7 | // an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the ~
8 | // specific language governing permissions and limitations under the License. ~
9 | // ~
10 | // Maintainers: ~
11 | // Wim Bast, Tom Brus, Ronald Krijgsheld ~
12 | // Contributors: ~
13 | // Arjan Kok, Carel Bast ~
14 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 |
16 | package org.modelingvalue.dclare.mps;
17 |
18 | import org.jetbrains.mps.openapi.module.SModule;
19 | import org.jetbrains.mps.openapi.module.SModuleId;
20 | import org.jetbrains.mps.openapi.module.SModuleReference;
21 | import org.jetbrains.mps.openapi.module.SRepository;
22 | import org.modelingvalue.collections.util.IdentifiedBy;
23 |
24 | public class DModuleReference extends IdentifiedBy implements SModuleReference {
25 |
26 | public DModuleReference(SModuleReference id) {
27 | super(id);
28 | }
29 |
30 | @Override
31 | public SModuleId getModuleId() {
32 | return id().getModuleId();
33 | }
34 |
35 | @Override
36 | public String getModuleName() {
37 | return id().getModuleName();
38 | }
39 |
40 | @Override
41 | public SModule resolve(SRepository repo) {
42 | SModule resolved = DClareMPS.instance().read(() -> id().resolve(repo));
43 | return resolved != null ? DModule.of(resolved) : null;
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/runtime/src/main/java/org/modelingvalue/dclare/mps/DModuleType.java:
--------------------------------------------------------------------------------
1 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 | // (C) Copyright 2018-2023 Modeling Value Group B.V. (http://modelingvalue.org) ~
3 | // ~
4 | // Licensed under the GNU Lesser General Public License v3.0 (the 'License'). You may not use this file except in ~
5 | // compliance with the License. You may obtain a copy of the License at: https://choosealicense.com/licenses/lgpl-3.0 ~
6 | // Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on ~
7 | // an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the ~
8 | // specific language governing permissions and limitations under the License. ~
9 | // ~
10 | // Maintainers: ~
11 | // Wim Bast, Tom Brus, Ronald Krijgsheld ~
12 | // Contributors: ~
13 | // Arjan Kok, Carel Bast ~
14 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 |
16 | package org.modelingvalue.dclare.mps;
17 |
18 | import org.jetbrains.mps.openapi.language.SLanguage;
19 | import org.modelingvalue.collections.Collection;
20 | import org.modelingvalue.collections.Set;
21 | import org.modelingvalue.dclare.Observer;
22 | import org.modelingvalue.dclare.Setable;
23 |
24 | public class DModuleType extends DObjectType> {
25 |
26 | public DModuleType(Set identity) {
27 | super(identity);
28 | }
29 |
30 | @SuppressWarnings({"unchecked", "rawtypes"})
31 | @Override
32 | public Set getRules(Set ruleSets) {
33 | return (Set) ruleSets.flatMap(rs -> Collection.of(rs.getModuleRules())).asSet();
34 | }
35 |
36 | @SuppressWarnings({"rawtypes", "unchecked"})
37 | @Override
38 | public Set getAttributes(Set ruleSets) {
39 | return (Set) ruleSets.flatMap(rs -> Collection.of(rs.getModuleAttributes())).asSet();
40 | }
41 |
42 | @SuppressWarnings({"rawtypes", "unchecked"})
43 | @Override
44 | public Set getNatives(Set ruleSets) {
45 | return (Set) ruleSets.flatMap(rs -> Collection.of(rs.getModuleNatives())).asSet();
46 | }
47 |
48 | @Override
49 | public Set getLanguages() {
50 | return id();
51 | }
52 |
53 | @SuppressWarnings("rawtypes")
54 | @Override
55 | protected Collection observers() {
56 | return DModule.OBSERVERS;
57 | }
58 |
59 | @SuppressWarnings("rawtypes")
60 | @Override
61 | public Collection setables() {
62 | return DModule.SETABLES;
63 | }
64 |
65 | }
66 |
--------------------------------------------------------------------------------
/runtime/src/main/java/org/modelingvalue/dclare/mps/DNodeType.java:
--------------------------------------------------------------------------------
1 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 | // (C) Copyright 2018-2023 Modeling Value Group B.V. (http://modelingvalue.org) ~
3 | // ~
4 | // Licensed under the GNU Lesser General Public License v3.0 (the 'License'). You may not use this file except in ~
5 | // compliance with the License. You may obtain a copy of the License at: https://choosealicense.com/licenses/lgpl-3.0 ~
6 | // Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on ~
7 | // an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the ~
8 | // specific language governing permissions and limitations under the License. ~
9 | // ~
10 | // Maintainers: ~
11 | // Wim Bast, Tom Brus, Ronald Krijgsheld ~
12 | // Contributors: ~
13 | // Arjan Kok, Carel Bast ~
14 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 |
16 | package org.modelingvalue.dclare.mps;
17 |
18 | import org.jetbrains.mps.openapi.language.SConcept;
19 | import org.jetbrains.mps.openapi.language.SLanguage;
20 | import org.modelingvalue.collections.Collection;
21 | import org.modelingvalue.collections.Set;
22 | import org.modelingvalue.collections.util.Pair;
23 | import org.modelingvalue.collections.util.Quadruple;
24 | import org.modelingvalue.dclare.Observer;
25 | import org.modelingvalue.dclare.Setable;
26 |
27 | @SuppressWarnings("unused")
28 | public class DNodeType extends DObjectType, SConcept, Set, Set>> {
29 |
30 | public DNodeType(Quadruple, SConcept, Set, Set> q) {
31 | super(q);
32 | }
33 |
34 | @SuppressWarnings({"unchecked", "rawtypes"})
35 | @Override
36 | public Set getRules(Set ruleSets) {
37 | return (Set) ruleSets.flatMap(rs -> Collection.of(rs.getNodeRules(getConcept(), getAnonymousTypes()))).asSet();
38 | }
39 |
40 | @SuppressWarnings({"unchecked", "rawtypes"})
41 | @Override
42 | public Set getAttributes(Set ruleSets) {
43 | return (Set) ruleSets.flatMap(rs -> Collection.of(rs.getNodeAttributes(getConcept(), getAnonymousTypes()))).asSet();
44 | }
45 |
46 | @SuppressWarnings({"rawtypes", "unchecked"})
47 | @Override
48 | public Set getNatives(Set ruleSets) {
49 | return (Set) ruleSets.flatMap(rs -> Collection.of(rs.getNodeNatives(getConcept(), getAnonymousTypes()))).asSet();
50 | }
51 |
52 | @Override
53 | public Set getLanguages() {
54 | return id().a();
55 | }
56 |
57 | public SConcept getConcept() {
58 | return id().b();
59 | }
60 |
61 | public Set getAnonymousTypes() {
62 | return id().c();
63 | }
64 |
65 | public Set copyAspects() {
66 | return id().d();
67 | }
68 |
69 | @SuppressWarnings("rawtypes")
70 | @Override
71 | public Collection setables() {
72 | return Collection.concat(DNode.SETABLES, DNode.CONCEPT_DOBSERVEDS.get(getConcept()));
73 | }
74 |
75 | @SuppressWarnings("rawtypes")
76 | @Override
77 | protected Collection observers() {
78 | Set conceptObservers = DNode.OBSERVERS.addAll(DNode.CONCEPT_OBSERVERS.get(getConcept()));
79 | for (IAspect aspect : copyAspects()) {
80 | conceptObservers = conceptObservers.addAll(DNode.COPY_CONCEPT_OBSERVERS.get(Pair.of(getConcept(), aspect)));
81 | }
82 | return conceptObservers;
83 | }
84 |
85 | }
86 |
--------------------------------------------------------------------------------
/runtime/src/main/java/org/modelingvalue/dclare/mps/DQuotation.java:
--------------------------------------------------------------------------------
1 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 | // (C) Copyright 2018-2023 Modeling Value Group B.V. (http://modelingvalue.org) ~
3 | // ~
4 | // Licensed under the GNU Lesser General Public License v3.0 (the 'License'). You may not use this file except in ~
5 | // compliance with the License. You may obtain a copy of the License at: https://choosealicense.com/licenses/lgpl-3.0 ~
6 | // Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on ~
7 | // an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the ~
8 | // specific language governing permissions and limitations under the License. ~
9 | // ~
10 | // Maintainers: ~
11 | // Wim Bast, Tom Brus, Ronald Krijgsheld ~
12 | // Contributors: ~
13 | // Arjan Kok, Carel Bast ~
14 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 |
16 | package org.modelingvalue.dclare.mps;
17 |
18 | import java.util.Arrays;
19 |
20 | import org.modelingvalue.dclare.Construction.Reason;
21 | import org.modelingvalue.dclare.Mutable;
22 |
23 | public class DQuotation extends DDerive {
24 |
25 | protected DQuotation(Mutable thiz, IRuleSet ruleSet, String anonymousType, Object[] ctx) {
26 | super(thiz, init(ctx, ruleSet, anonymousType));
27 | }
28 |
29 | private DQuotation(Mutable thiz, Object[] identity) {
30 | super(thiz, identity);
31 | }
32 |
33 | private static Object[] init(Object[] ctx, IRuleSet ruleSet, String anonymousType) {
34 | Object[] array = Arrays.copyOf(ctx, ctx.length + 2);
35 | array[array.length - 2] = ruleSet;
36 | array[array.length - 1] = anonymousType;
37 | return array;
38 | }
39 |
40 | @Override
41 | public IRuleSet ruleSet() {
42 | return (IRuleSet) get(null, size() - 2);
43 | }
44 |
45 | @Override
46 | public String anonymousType() {
47 | return (String) get(null, size() - 1);
48 | }
49 |
50 | @Override
51 | protected Reason clone(Mutable thiz, Object[] identity) {
52 | return new DQuotation(thiz, identity);
53 | }
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/runtime/src/main/java/org/modelingvalue/dclare/mps/DRead.java:
--------------------------------------------------------------------------------
1 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 | // (C) Copyright 2018-2023 Modeling Value Group B.V. (http://modelingvalue.org) ~
3 | // ~
4 | // Licensed under the GNU Lesser General Public License v3.0 (the 'License'). You may not use this file except in ~
5 | // compliance with the License. You may obtain a copy of the License at: https://choosealicense.com/licenses/lgpl-3.0 ~
6 | // Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on ~
7 | // an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the ~
8 | // specific language governing permissions and limitations under the License. ~
9 | // ~
10 | // Maintainers: ~
11 | // Wim Bast, Tom Brus, Ronald Krijgsheld ~
12 | // Contributors: ~
13 | // Arjan Kok, Carel Bast ~
14 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 |
16 | package org.modelingvalue.dclare.mps;
17 |
18 | import org.modelingvalue.dclare.Construction;
19 | import org.modelingvalue.dclare.Construction.Reason;
20 | import org.modelingvalue.dclare.Direction;
21 | import org.modelingvalue.dclare.Mutable;
22 |
23 | public class DRead extends Construction.Reason {
24 |
25 | private static final Direction DIRECTION = Direction.of(DRead.class);
26 |
27 | protected DRead(R ref) {
28 | super(null, new Object[]{ref});
29 | }
30 |
31 | @SuppressWarnings("unchecked")
32 | public R reference() {
33 | return (R) get(null, 0);
34 | }
35 |
36 | @Override
37 | public Direction direction() {
38 | return DIRECTION;
39 | }
40 |
41 | @Override
42 | protected Reason clone(Mutable thiz, Object[] identity) {
43 | throw new UnsupportedOperationException();
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/runtime/src/main/java/org/modelingvalue/dclare/mps/DRepositoryListener.java:
--------------------------------------------------------------------------------
1 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 | // (C) Copyright 2018-2023 Modeling Value Group B.V. (http://modelingvalue.org) ~
3 | // ~
4 | // Licensed under the GNU Lesser General Public License v3.0 (the 'License'). You may not use this file except in ~
5 | // compliance with the License. You may obtain a copy of the License at: https://choosealicense.com/licenses/lgpl-3.0 ~
6 | // Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on ~
7 | // an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the ~
8 | // specific language governing permissions and limitations under the License. ~
9 | // ~
10 | // Maintainers: ~
11 | // Wim Bast, Tom Brus, Ronald Krijgsheld ~
12 | // Contributors: ~
13 | // Arjan Kok, Carel Bast ~
14 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 |
16 | package org.modelingvalue.dclare.mps;
17 |
18 | import org.jetbrains.mps.openapi.module.SModule;
19 | import org.jetbrains.mps.openapi.module.SModuleReference;
20 | import org.jetbrains.mps.openapi.module.SRepository;
21 | import org.jetbrains.mps.openapi.module.SRepositoryListener;
22 | import org.modelingvalue.collections.Set;
23 | import org.modelingvalue.collections.util.Pair;
24 |
25 | public class DRepositoryListener extends Pair implements SRepositoryListener {
26 |
27 | private static final long serialVersionUID = -8833673849931733478L;
28 |
29 | public DRepositoryListener(DRepository dRepository, DClareMPS dClareMPS) {
30 | super(dRepository, dClareMPS);
31 | }
32 |
33 | @Override
34 | public void moduleAdded(SModule sModule) {
35 | b().handleMPSChange(() -> {
36 | DModule dModule = DModule.of(sModule);
37 | if (!dModule.isExternal()) {
38 | DRepository.MODULES.set(a(), Set::add, dModule);
39 | if (DModule.LANGUAGES_WITH_RULES.get(dModule).anyMatch(l -> !DRepository.ALL_LANGUAGES_WITH_RULES.get(a()).contains(l))) {
40 | DClareMPS.instance().engine().restart();
41 | }
42 | }
43 | });
44 | }
45 |
46 | @Override
47 | public void beforeModuleRemoved(SModule sModule) {
48 | b().handleMPSChange(() -> {
49 | DModule dModule = DModule.of(sModule);
50 | if (!dModule.isExternal()) {
51 | DRepository.MODULES.set(a(), Set::remove, dModule);
52 | if (DModule.LANGUAGES_WITH_RULES.get(dModule).anyMatch(l -> DRepository.ALL_LANGUAGES_WITH_RULES.get(a()).contains(l))) {
53 | DClareMPS.instance().engine().restart();
54 | }
55 | }
56 | });
57 | }
58 |
59 | @Override
60 | public void moduleRemoved(SModuleReference module) {
61 | }
62 |
63 | @Override
64 | public void commandStarted(SRepository repository) {
65 | }
66 |
67 | @Override
68 | public void commandFinished(SRepository repository) {
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/runtime/src/main/java/org/modelingvalue/dclare/mps/DRepositoryType.java:
--------------------------------------------------------------------------------
1 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 | // (C) Copyright 2018-2023 Modeling Value Group B.V. (http://modelingvalue.org) ~
3 | // ~
4 | // Licensed under the GNU Lesser General Public License v3.0 (the 'License'). You may not use this file except in ~
5 | // compliance with the License. You may obtain a copy of the License at: https://choosealicense.com/licenses/lgpl-3.0 ~
6 | // Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on ~
7 | // an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the ~
8 | // specific language governing permissions and limitations under the License. ~
9 | // ~
10 | // Maintainers: ~
11 | // Wim Bast, Tom Brus, Ronald Krijgsheld ~
12 | // Contributors: ~
13 | // Arjan Kok, Carel Bast ~
14 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 |
16 | package org.modelingvalue.dclare.mps;
17 |
18 | import org.jetbrains.mps.openapi.language.SLanguage;
19 | import org.modelingvalue.collections.Collection;
20 | import org.modelingvalue.collections.Set;
21 | import org.modelingvalue.dclare.Observer;
22 | import org.modelingvalue.dclare.Setable;
23 |
24 | public class DRepositoryType extends DObjectType> {
25 |
26 | public DRepositoryType(Set identity) {
27 | super(identity);
28 | }
29 |
30 | @SuppressWarnings({"rawtypes", "unchecked"})
31 | @Override
32 | public Set getRules(Set ruleSets) {
33 | return (Set) ruleSets.flatMap(rs -> Collection.of(rs.getRepositoryRules())).asSet();
34 | }
35 |
36 | @SuppressWarnings({"rawtypes", "unchecked"})
37 | @Override
38 | public Set getAttributes(Set ruleSets) {
39 | return (Set) ruleSets.flatMap(rs -> Collection.of(rs.getRepositoryAttributes())).asSet();
40 | }
41 |
42 | @SuppressWarnings({"rawtypes", "unchecked"})
43 | @Override
44 | public Set getNatives(Set ruleSets) {
45 | return (Set) ruleSets.flatMap(rs -> Collection.of(rs.getRepositoryNatives())).asSet();
46 | }
47 |
48 | @Override
49 | public Set getLanguages() {
50 | return id();
51 | }
52 |
53 | @SuppressWarnings("rawtypes")
54 | @Override
55 | protected Collection observers() {
56 | return DRepository.OBSERVERS;
57 | }
58 |
59 | @SuppressWarnings("rawtypes")
60 | @Override
61 | public Collection setables() {
62 | return DRepository.SETABLES;
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/runtime/src/main/java/org/modelingvalue/dclare/mps/DRule.java:
--------------------------------------------------------------------------------
1 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 | // (C) Copyright 2018-2023 Modeling Value Group B.V. (http://modelingvalue.org) ~
3 | // ~
4 | // Licensed under the GNU Lesser General Public License v3.0 (the 'License'). You may not use this file except in ~
5 | // compliance with the License. You may obtain a copy of the License at: https://choosealicense.com/licenses/lgpl-3.0 ~
6 | // Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on ~
7 | // an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the ~
8 | // specific language governing permissions and limitations under the License. ~
9 | // ~
10 | // Maintainers: ~
11 | // Wim Bast, Tom Brus, Ronald Krijgsheld ~
12 | // Contributors: ~
13 | // Arjan Kok, Carel Bast ~
14 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 |
16 | package org.modelingvalue.dclare.mps;
17 |
18 | import org.modelingvalue.collections.Collection;
19 | import org.modelingvalue.collections.Set;
20 | import org.modelingvalue.collections.util.Concurrent;
21 | import org.modelingvalue.dclare.*;
22 |
23 | @SuppressWarnings("rawtypes")
24 | public interface DRule extends DFeature {
25 |
26 | Constant OBSERVER = Constant.of("OBSERVER", DObserver::new);
27 |
28 | class DObserver extends Observer {
29 |
30 | @SuppressWarnings("unchecked")
31 | private DObserver(DRule rule) {
32 | super(rule, rule::run, Collection.of(rule.targets()).asSet(), //
33 | rule.initialLowPriority() ? Priority.OUTER : Priority.one, //
34 | IAspect.DIRECTION.get(rule.ruleSet().getAspect()), //
35 | LeafModifier.anonymous.iff(rule.ruleSet().getAnonymousType() != null), //
36 | LeafModifier.atomic.iff(rule.atomic()));
37 | }
38 |
39 | public DRule rule() {
40 | return (DRule) id();
41 | }
42 |
43 | @Override
44 | public DRule.DObserverTransaction openTransaction(MutableTransaction parent) {
45 | return ((DClareMPS) parent.universeTransaction().mutable()).dObserverTransactions.get().open(this, parent);
46 | }
47 |
48 | @Override
49 | public void closeTransaction(Transaction tx) {
50 | ((DClareMPS) tx.universeTransaction().mutable()).dObserverTransactions.get().close((DRule.DObserverTransaction) tx);
51 | }
52 |
53 | @Override
54 | public DRule.DObserverTransaction newTransaction(UniverseTransaction universeTransaction) {
55 | return new DRule.DObserverTransaction(universeTransaction);
56 | }
57 |
58 | }
59 |
60 | class DObserverTransaction extends ObserverTransaction {
61 |
62 | final Concurrent> issues = Concurrent.of();
63 |
64 | private DObserverTransaction(UniverseTransaction root) {
65 | super(root);
66 | }
67 |
68 | @Override
69 | protected final void doRun(State pre, UniverseTransaction universeTransaction) {
70 | DObject dObject = mutable();
71 | issues.init(Set.of());
72 | try {
73 | if (!dObject.isObsolete(rule().ruleSet().getAnonymousType())) {
74 | super.doRun(pre, universeTransaction);
75 | }
76 | } finally {
77 | DObject.CONTAINED_DCLARE_ISSUES.set(dObject, (b, a) -> a.addAll(b.exclude(i -> i.getRule().equals(rule()))), issues.result());
78 | }
79 | }
80 |
81 | @Override
82 | public DObject mutable() {
83 | return (DObject) super.mutable();
84 | }
85 |
86 | @Override
87 | public DObserver> observer() {
88 | return (DObserver) super.observer();
89 | }
90 |
91 | public DRule rule() {
92 | return observer().rule();
93 | }
94 |
95 | }
96 |
97 | void run(O object);
98 |
99 | boolean initialLowPriority();
100 |
101 | java.util.List targets();
102 |
103 | boolean atomic();
104 |
105 | @Override
106 | default boolean isConstant() {
107 | return false;
108 | }
109 |
110 | }
111 |
--------------------------------------------------------------------------------
/runtime/src/main/java/org/modelingvalue/dclare/mps/DServerMetaData.java:
--------------------------------------------------------------------------------
1 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 | // (C) Copyright 2018-2023 Modeling Value Group B.V. (http://modelingvalue.org) ~
3 | // ~
4 | // Licensed under the GNU Lesser General Public License v3.0 (the 'License'). You may not use this file except in ~
5 | // compliance with the License. You may obtain a copy of the License at: https://choosealicense.com/licenses/lgpl-3.0 ~
6 | // Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on ~
7 | // an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the ~
8 | // specific language governing permissions and limitations under the License. ~
9 | // ~
10 | // Maintainers: ~
11 | // Wim Bast, Tom Brus, Ronald Krijgsheld ~
12 | // Contributors: ~
13 | // Arjan Kok, Carel Bast ~
14 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 |
16 | package org.modelingvalue.dclare.mps;
17 |
18 | import static org.modelingvalue.dclare.CoreSetableModifier.plumbing;
19 |
20 | import org.modelingvalue.collections.Set;
21 | import org.modelingvalue.collections.util.Pair;
22 | import org.modelingvalue.dclare.Observer;
23 | import org.modelingvalue.dclare.Setable;
24 |
25 | public class DServerMetaData extends DObject {
26 |
27 | protected static final DServerMetaDataType SERVER_METADATA_TYPE = new DServerMetaDataType();
28 |
29 | protected static final DObserved> SHARED_MODELS = DObserved.of("SHARED_MODELS", Set.of(), null, (m, pre, post) -> {
30 | }, plumbing);
31 |
32 | @SuppressWarnings("rawtypes")
33 | protected static final Set OBSERVERS = DObject.OBSERVERS;
34 |
35 | @SuppressWarnings("rawtypes")
36 | protected static final Set SETABLES = DObject.SETABLES.add(SHARED_MODELS);
37 |
38 | public DServerMetaData() {
39 | }
40 |
41 | @Override
42 | protected void read(DClareMPS dClareMPS) {
43 | }
44 |
45 | @Override
46 | protected DServerMetaDataType getType() {
47 | return SERVER_METADATA_TYPE;
48 | }
49 |
50 | @Override
51 | protected DServerMetaDataType getBootstrapType() {
52 | return SERVER_METADATA_TYPE;
53 | }
54 |
55 | @Override
56 | public boolean isExternal() {
57 | return false;
58 | }
59 |
60 | @Override
61 | protected boolean isRead() {
62 | return false;
63 | }
64 |
65 | @Override
66 | protected Pair> readParent() {
67 | throw new UnsupportedOperationException();
68 | }
69 |
70 | }
71 |
--------------------------------------------------------------------------------
/runtime/src/main/java/org/modelingvalue/dclare/mps/DServerMetaDataType.java:
--------------------------------------------------------------------------------
1 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 | // (C) Copyright 2018-2023 Modeling Value Group B.V. (http://modelingvalue.org) ~
3 | // ~
4 | // Licensed under the GNU Lesser General Public License v3.0 (the 'License'). You may not use this file except in ~
5 | // compliance with the License. You may obtain a copy of the License at: https://choosealicense.com/licenses/lgpl-3.0 ~
6 | // Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on ~
7 | // an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the ~
8 | // specific language governing permissions and limitations under the License. ~
9 | // ~
10 | // Maintainers: ~
11 | // Wim Bast, Tom Brus, Ronald Krijgsheld ~
12 | // Contributors: ~
13 | // Arjan Kok, Carel Bast ~
14 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 |
16 | package org.modelingvalue.dclare.mps;
17 |
18 | import org.jetbrains.mps.openapi.language.SLanguage;
19 | import org.modelingvalue.collections.Collection;
20 | import org.modelingvalue.collections.Set;
21 | import org.modelingvalue.dclare.Observer;
22 | import org.modelingvalue.dclare.Setable;
23 |
24 | public class DServerMetaDataType extends DObjectType {
25 |
26 | protected DServerMetaDataType() {
27 | super("SERVER_METADATA_TYPE");
28 | }
29 |
30 | @SuppressWarnings("rawtypes")
31 | @Override
32 | public Set getRules(Set ruleSets) {
33 | return Set.of();
34 | }
35 |
36 | @SuppressWarnings("rawtypes")
37 | @Override
38 | public Set getAttributes(Set ruleSets) {
39 | return Set.of();
40 | }
41 |
42 | @SuppressWarnings("rawtypes")
43 | @Override
44 | public Set getNatives(Set ruleSets) {
45 | return Set.of();
46 | }
47 |
48 | @Override
49 | public Set getLanguages() {
50 | return Set.of();
51 | }
52 |
53 | @SuppressWarnings("rawtypes")
54 | @Override
55 | protected Collection observers() {
56 | return DServerMetaData.OBSERVERS;
57 | }
58 |
59 | @SuppressWarnings("rawtypes")
60 | @Override
61 | public Collection setables() {
62 | return DServerMetaData.SETABLES;
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/runtime/src/main/java/org/modelingvalue/dclare/mps/DStructClass.java:
--------------------------------------------------------------------------------
1 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 | // (C) Copyright 2018-2023 Modeling Value Group B.V. (http://modelingvalue.org) ~
3 | // ~
4 | // Licensed under the GNU Lesser General Public License v3.0 (the 'License'). You may not use this file except in ~
5 | // compliance with the License. You may obtain a copy of the License at: https://choosealicense.com/licenses/lgpl-3.0 ~
6 | // Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on ~
7 | // an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the ~
8 | // specific language governing permissions and limitations under the License. ~
9 | // ~
10 | // Maintainers: ~
11 | // Wim Bast, Tom Brus, Ronald Krijgsheld ~
12 | // Contributors: ~
13 | // Arjan Kok, Carel Bast ~
14 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 |
16 | package org.modelingvalue.dclare.mps;
17 |
18 | import org.jetbrains.mps.openapi.language.SLanguage;
19 | import org.modelingvalue.collections.Collection;
20 | import org.modelingvalue.collections.Set;
21 | import org.modelingvalue.collections.util.Triple;
22 |
23 | public class DStructClass extends DObjectType, Set, SStructClass>> {
24 |
25 | public DStructClass(Triple, Set, SStructClass> identity) {
26 | super(identity);
27 | }
28 |
29 | @SuppressWarnings({"rawtypes", "unchecked"})
30 | @Override
31 | public Set getRules(Set ruleSets) {
32 | return (Set) ruleSets.flatMap(rs -> Collection.of(rs.getStructRules(getSStructClass(), getAnonymousTypes()))).asSet();
33 | }
34 |
35 | @SuppressWarnings({"rawtypes", "unchecked"})
36 | @Override
37 | public Set getAttributes(Set ruleSets) {
38 | return (Set) Collection.concat(getSStructClass().getIdentity(), ruleSets.flatMap(rs -> Collection.of(rs.getStructAttributes(getSStructClass(), getAnonymousTypes())))).asSet();
39 | }
40 |
41 | @SuppressWarnings({"rawtypes", "unchecked"})
42 | @Override
43 | public Set getNatives(Set ruleSets) {
44 | return (Set) ruleSets.flatMap(rs -> Collection.of(rs.getStructNatives(getSStructClass(), getAnonymousTypes()))).asSet();
45 | }
46 |
47 | @Override
48 | public Set getLanguages() {
49 | return id().a();
50 | }
51 |
52 | public Set getAnonymousTypes() {
53 | return id().b();
54 | }
55 |
56 | public SStructClass getSStructClass() {
57 | return id().c();
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/runtime/src/main/java/org/modelingvalue/dclare/mps/DStructObject.java:
--------------------------------------------------------------------------------
1 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 | // (C) Copyright 2018-2023 Modeling Value Group B.V. (http://modelingvalue.org) ~
3 | // ~
4 | // Licensed under the GNU Lesser General Public License v3.0 (the 'License'). You may not use this file except in ~
5 | // compliance with the License. You may obtain a copy of the License at: https://choosealicense.com/licenses/lgpl-3.0 ~
6 | // Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on ~
7 | // an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the ~
8 | // specific language governing permissions and limitations under the License. ~
9 | // ~
10 | // Maintainers: ~
11 | // Wim Bast, Tom Brus, Ronald Krijgsheld ~
12 | // Contributors: ~
13 | // Arjan Kok, Carel Bast ~
14 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 |
16 | package org.modelingvalue.dclare.mps;
17 |
18 | import java.util.Arrays;
19 | import java.util.Objects;
20 |
21 | import org.jetbrains.mps.openapi.language.SLanguage;
22 | import org.modelingvalue.collections.Set;
23 | import org.modelingvalue.collections.util.Pair;
24 | import org.modelingvalue.collections.util.Triple;
25 | import org.modelingvalue.dclare.Constant;
26 | import org.modelingvalue.dclare.State;
27 |
28 | @SuppressWarnings("unused")
29 | public class DStructObject extends DIdentifiedObject implements SStructObject {
30 |
31 | private static final Constant, Set, SStructClass>, DStructClass> CLASS_OBJECT_TYPE = Constant.of("CLASS_OBJECT_TYPE", DStructClass::new);
32 |
33 | public static DStructObject of(SStructClass cls, Object[] identity) {
34 | for (int i = 0; i < identity.length; i++) {
35 | Objects.requireNonNull(identity[i]);
36 | }
37 | identity = Arrays.copyOf(identity, identity.length + 1);
38 | identity[identity.length - 1] = cls;
39 | return new DStructObject(identity);
40 | }
41 |
42 | public static DStructObject of(IRuleSet ruleSet, String anonymousType, Object[] ctx, SStructClass cls, Object[] identity) {
43 | return quotationConstruct(ruleSet, anonymousType, ctx, () -> of(cls, identity));
44 | }
45 |
46 | protected DStructObject(Object[] identity) {
47 | super(identity);
48 | }
49 |
50 | @Override
51 | public boolean isExternal() {
52 | return getSClass().isValueClass();
53 | }
54 |
55 | @SuppressWarnings("rawtypes")
56 | @Override
57 | public boolean dIsOrphan(State state) {
58 | return !isExternal() && super.dIsOrphan(state);
59 | }
60 |
61 | @Override
62 | public String toString() {
63 | return getSClass() + Arrays.toString(Arrays.copyOf(identity, identity.length - 1));
64 | }
65 |
66 | @Override
67 | protected DStructClass getType() {
68 | DObject dParent = dObjectParent();
69 | Set ls = (dParent != null && !dParent.isExternal() ? dParent : getContextObject()).dClass().getLanguages();
70 | SLanguage lang = getSClass().getLanguage();
71 | if (!DClareMPS.ACTIVE_RULE_SETS.get(lang).isEmpty()) {
72 | ls = ls.add(lang);
73 | }
74 | ls = ls.addAll(getAnonymousLanguages());
75 | return CLASS_OBJECT_TYPE.get(Triple.of(ls, getAnonymousTypes(), getSClass()));
76 | }
77 |
78 | @Override
79 | protected DStructClass getBootstrapType() {
80 | return CLASS_OBJECT_TYPE.get(Triple.of(Set.of(), Set.of(), getSClass()));
81 | }
82 |
83 | @SuppressWarnings({"unchecked", "rawtypes"})
84 | @Override
85 | public void dActivate() {
86 | super.dActivate();
87 | for (DAttribute id : getSClass().getIdentity()) {
88 | if (id.isComposite()) {
89 | id.activate(this);
90 | }
91 | }
92 | }
93 |
94 | @Override
95 | public SStructClass getSClass() {
96 | return (SStructClass) identity[identity.length - 1];
97 | }
98 |
99 | @Override
100 | public Object[] getIdentity() {
101 | return identity;
102 | }
103 |
104 | @Override
105 | protected void read(DClareMPS dClareMPS) {
106 | }
107 |
108 | @Override
109 | public boolean isDclareOnly() {
110 | return true;
111 | }
112 |
113 | @Override
114 | protected boolean isRead() {
115 | return false;
116 | }
117 |
118 | @Override
119 | protected Pair> readParent() {
120 | throw new UnsupportedOperationException();
121 | }
122 |
123 | }
124 |
--------------------------------------------------------------------------------
/runtime/src/main/java/org/modelingvalue/dclare/mps/DTempModel.java:
--------------------------------------------------------------------------------
1 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 | // (C) Copyright 2018-2023 Modeling Value Group B.V. (http://modelingvalue.org) ~
3 | // ~
4 | // Licensed under the GNU Lesser General Public License v3.0 (the 'License'). You may not use this file except in ~
5 | // compliance with the License. You may obtain a copy of the License at: https://choosealicense.com/licenses/lgpl-3.0 ~
6 | // Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on ~
7 | // an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the ~
8 | // specific language governing permissions and limitations under the License. ~
9 | // ~
10 | // Maintainers: ~
11 | // Wim Bast, Tom Brus, Ronald Krijgsheld ~
12 | // Contributors: ~
13 | // Arjan Kok, Carel Bast ~
14 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 |
16 | package org.modelingvalue.dclare.mps;
17 |
18 | import org.jetbrains.mps.openapi.model.EditableSModel;
19 | import org.jetbrains.mps.openapi.model.SModelReference;
20 | import org.jetbrains.mps.openapi.module.SModuleReference;
21 | import org.jetbrains.mps.openapi.persistence.NullDataSource;
22 | import org.jetbrains.mps.openapi.persistence.PersistenceFacade;
23 |
24 | import jetbrains.mps.extapi.module.SModuleBase;
25 | import jetbrains.mps.smodel.EditableModelDescriptor;
26 | import jetbrains.mps.smodel.ModelLoadResult;
27 | import jetbrains.mps.smodel.SModelId;
28 | import jetbrains.mps.smodel.SNodeUndoableAction;
29 | import jetbrains.mps.smodel.event.SModelRenamedEvent;
30 | import jetbrains.mps.smodel.loading.ModelLoadingState;
31 |
32 | @SuppressWarnings("unused")
33 | public class DTempModel extends EditableModelDescriptor implements EditableSModel {
34 |
35 | public DTempModel(String name, SModuleBase module) {
36 | this(createModelRef(name, module.getModuleReference()));
37 | }
38 |
39 | protected DTempModel(String name) {
40 | this(createModelRef(name, null));
41 | }
42 |
43 | public DTempModel(SModelReference ref) {
44 | super(ref, new NullDataSource());
45 | }
46 |
47 | @Override
48 | @Deprecated
49 | public void updateTimestamp() {
50 | }
51 |
52 | @Override
53 | public boolean needsReloading() {
54 | return false;
55 | }
56 |
57 | @Override
58 | protected ModelLoadResult createModel() {
59 | jetbrains.mps.smodel.SModel smodel = new jetbrains.mps.smodel.SModel(getReference()) {
60 | @Override
61 | protected void performUndoableAction(SNodeUndoableAction action) {
62 | super.performUndoableAction(action);
63 | }
64 |
65 | @Override
66 | public boolean canFireEvent() {
67 | return true;
68 | }
69 | };
70 | return new ModelLoadResult<>(smodel, ModelLoadingState.FULLY_LOADED);
71 | }
72 |
73 | @Override
74 | public boolean isChanged() {
75 | return false;
76 | }
77 |
78 | @Override
79 | public void save() {
80 | }
81 |
82 | @SuppressWarnings("deprecation")
83 | @Override
84 | public void rename(String newModelName, boolean changeFile) {
85 | assertCanChange();
86 | SModelReference oldName = getReference();
87 | fireBeforeModelRenamed(new SModelRenamedEvent(this, oldName.getModelName(), newModelName));
88 | SModelReference newModelReference = PersistenceFacade.getInstance().createModelReference(getReference().getModuleReference(), getReference().getModelId(), newModelName);
89 | fireBeforeModelRenamed(newModelReference);
90 | changeModelReference(newModelReference);
91 | setChanged(true);
92 | fireModelRenamed(new SModelRenamedEvent(this, oldName.getModelName(), newModelName));
93 | fireModelRenamed(oldName);
94 | }
95 |
96 | @Override
97 | public boolean isReadOnly() {
98 | return false;
99 | }
100 |
101 | @Override
102 | public void reloadFromSource() {
103 | throw new UnsupportedOperationException();
104 | }
105 |
106 | private static SModelReference createModelRef(String modelName, SModuleReference moduleReference) {
107 | SModelId id = SModelId.generate();
108 | return PersistenceFacade.getInstance().createModelReference(moduleReference, id, modelName);
109 | }
110 | }
111 |
--------------------------------------------------------------------------------
/runtime/src/main/java/org/modelingvalue/dclare/mps/DclareForMpsStatus.java:
--------------------------------------------------------------------------------
1 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 | // (C) Copyright 2018-2023 Modeling Value Group B.V. (http://modelingvalue.org) ~
3 | // ~
4 | // Licensed under the GNU Lesser General Public License v3.0 (the 'License'). You may not use this file except in ~
5 | // compliance with the License. You may obtain a copy of the License at: https://choosealicense.com/licenses/lgpl-3.0 ~
6 | // Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on ~
7 | // an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the ~
8 | // specific language governing permissions and limitations under the License. ~
9 | // ~
10 | // Maintainers: ~
11 | // Wim Bast, Tom Brus, Ronald Krijgsheld ~
12 | // Contributors: ~
13 | // Arjan Kok, Carel Bast ~
14 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 |
16 | package org.modelingvalue.dclare.mps;
17 |
18 | import org.modelingvalue.dclare.ImperativeTransaction;
19 | import org.modelingvalue.dclare.UniverseStatistics;
20 | import org.modelingvalue.dclare.UniverseTransaction.Status;
21 |
22 | import java.util.function.Supplier;
23 |
24 | import static org.modelingvalue.dclare.UniverseTransaction.Mood.*;
25 |
26 | public class DclareForMpsStatus {
27 | private final Status status;
28 | private final DClareMPS dClareMPS;
29 |
30 | public DclareForMpsStatus(Status status, DClareMPS dClareMPS) {
31 | this.status = status;
32 | this.dClareMPS = dClareMPS;
33 | }
34 |
35 | public boolean isChecking() {
36 | return status.mood == idle && status.active.anyMatch(a -> a instanceof String);
37 | }
38 |
39 | public boolean isCommitting() {
40 | return status.mood == idle && status.active.anyMatch(a -> a instanceof ImperativeTransaction);
41 | }
42 |
43 | public boolean isIdle() {
44 | return status.mood == idle || status.mood == starting;
45 | }
46 |
47 | public boolean isActive() {
48 | return status.mood == busy;
49 | }
50 |
51 | public boolean isStopped() {
52 | return status.mood == stopped;
53 | }
54 |
55 | public R get(Supplier supplier) {
56 | return status.state.get(supplier);
57 | }
58 |
59 | public void run(Runnable r) {
60 | status.state.run(r);
61 | }
62 |
63 | public UniverseStatistics stats() {
64 | return status.stats;
65 | }
66 |
67 | public DClareMPS dClareMPS() {
68 | return dClareMPS;
69 | }
70 |
71 | }
72 |
--------------------------------------------------------------------------------
/runtime/src/main/java/org/modelingvalue/dclare/mps/DummySModule.java:
--------------------------------------------------------------------------------
1 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 | // (C) Copyright 2018-2023 Modeling Value Group B.V. (http://modelingvalue.org) ~
3 | // ~
4 | // Licensed under the GNU Lesser General Public License v3.0 (the 'License'). You may not use this file except in ~
5 | // compliance with the License. You may obtain a copy of the License at: https://choosealicense.com/licenses/lgpl-3.0 ~
6 | // Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on ~
7 | // an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the ~
8 | // specific language governing permissions and limitations under the License. ~
9 | // ~
10 | // Maintainers: ~
11 | // Wim Bast, Tom Brus, Ronald Krijgsheld ~
12 | // Contributors: ~
13 | // Arjan Kok, Carel Bast ~
14 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 |
16 | package org.modelingvalue.dclare.mps;
17 |
18 | import java.util.Set;
19 |
20 | import org.jetbrains.mps.openapi.language.SLanguage;
21 | import org.jetbrains.mps.openapi.model.SModel;
22 | import org.jetbrains.mps.openapi.model.SModelId;
23 | import org.jetbrains.mps.openapi.module.SDependency;
24 | import org.jetbrains.mps.openapi.module.SModule;
25 | import org.jetbrains.mps.openapi.module.SModuleFacet;
26 | import org.jetbrains.mps.openapi.module.SModuleId;
27 | import org.jetbrains.mps.openapi.module.SModuleListener;
28 | import org.jetbrains.mps.openapi.module.SModuleReference;
29 | import org.jetbrains.mps.openapi.module.SRepository;
30 | import org.jetbrains.mps.openapi.persistence.ModelRoot;
31 |
32 | final class DummySModule implements SModule {
33 |
34 | private final SModuleReference ref;
35 |
36 | DummySModule(SModuleReference ref) {
37 | this.ref = ref;
38 | }
39 |
40 | @Override
41 | public SModuleReference getModuleReference() {
42 | return ref;
43 | }
44 |
45 | @Override
46 | public SModuleId getModuleId() {
47 | return ref.getModuleId();
48 | }
49 |
50 | @Override
51 | public String getModuleName() {
52 | return ref.getModuleName();
53 | }
54 |
55 | @Override
56 | public boolean isReadOnly() {
57 | return false;
58 | }
59 |
60 | @Override
61 | public boolean isPackaged() {
62 | return false;
63 | }
64 |
65 | @Override
66 | public SRepository getRepository() {
67 | return null;
68 | }
69 |
70 | @Override
71 | public Iterable getDeclaredDependencies() {
72 | return null;
73 | }
74 |
75 | @Override
76 | public Set getUsedLanguages() {
77 | return null;
78 | }
79 |
80 | @Override
81 | public int getUsedLanguageVersion(SLanguage usedLanguage) {
82 | return 0;
83 | }
84 |
85 | @Override
86 | public SModel getModel(SModelId id) {
87 | return null;
88 | }
89 |
90 | @Override
91 | public Iterable getModels() {
92 | return null;
93 | }
94 |
95 | @Override
96 | public Iterable getFacets() {
97 | return null;
98 | }
99 |
100 | @Override
101 | public T getFacet(Class clazz) {
102 | return null;
103 | }
104 |
105 | @Override
106 | public Iterable getModelRoots() {
107 | return null;
108 | }
109 |
110 | @Override
111 | public void addModuleListener(SModuleListener listener) {
112 | }
113 |
114 | @Override
115 | public void removeModuleListener(SModuleListener listener) {
116 | }
117 |
118 | }
119 |
--------------------------------------------------------------------------------
/runtime/src/main/java/org/modelingvalue/dclare/mps/EngineStatusHandler.java:
--------------------------------------------------------------------------------
1 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 | // (C) Copyright 2018-2023 Modeling Value Group B.V. (http://modelingvalue.org) ~
3 | // ~
4 | // Licensed under the GNU Lesser General Public License v3.0 (the 'License'). You may not use this file except in ~
5 | // compliance with the License. You may obtain a copy of the License at: https://choosealicense.com/licenses/lgpl-3.0 ~
6 | // Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on ~
7 | // an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the ~
8 | // specific language governing permissions and limitations under the License. ~
9 | // ~
10 | // Maintainers: ~
11 | // Wim Bast, Tom Brus, Ronald Krijgsheld ~
12 | // Contributors: ~
13 | // Arjan Kok, Carel Bast ~
14 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 |
16 | package org.modelingvalue.dclare.mps;
17 |
18 | import org.modelingvalue.collections.DefaultMap;
19 | import org.modelingvalue.collections.List;
20 |
21 | public interface EngineStatusHandler {
22 |
23 | void status(DclareForMpsStatus status);
24 |
25 | void aspects(List apects, DclareForMpsStatus status);
26 |
27 | void messages(DefaultMap> messages, DclareForMpsStatus status);
28 |
29 | void start(DclareForMpsStatus status);
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/runtime/src/main/java/org/modelingvalue/dclare/mps/IAspect.java:
--------------------------------------------------------------------------------
1 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 | // (C) Copyright 2018-2023 Modeling Value Group B.V. (http://modelingvalue.org) ~
3 | // ~
4 | // Licensed under the GNU Lesser General Public License v3.0 (the 'License'). You may not use this file except in ~
5 | // compliance with the License. You may obtain a copy of the License at: https://choosealicense.com/licenses/lgpl-3.0 ~
6 | // Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on ~
7 | // an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the ~
8 | // specific language governing permissions and limitations under the License. ~
9 | // ~
10 | // Maintainers: ~
11 | // Wim Bast, Tom Brus, Ronald Krijgsheld ~
12 | // Contributors: ~
13 | // Arjan Kok, Carel Bast ~
14 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 |
16 | package org.modelingvalue.dclare.mps;
17 |
18 | import java.util.List;
19 |
20 | import org.jetbrains.mps.openapi.language.SLanguage;
21 | import org.modelingvalue.collections.Collection;
22 | import org.modelingvalue.collections.Set;
23 | import org.modelingvalue.dclare.Constant;
24 | import org.modelingvalue.dclare.Direction;
25 |
26 | public interface IAspect {
27 |
28 | @SuppressWarnings("unchecked")
29 | static IAspect of(SLanguage language, String id) {
30 | return DClareMPS.ASPECT_MAP.get(language).get(id);
31 | }
32 |
33 | Constant DIRECTION = Constant.of("DIRECTION", a -> Direction.of(a, a.isOnDemand(), () -> {
34 | return Collection.of(a.getOpposites()).sequential().map(o -> IAspect.DIRECTION.get(o)).asSet();
35 | }));
36 |
37 | Constant> ALL_DEPENDENCIES = Constant.of("ALL_DEPENDENCIES", a -> {
38 | return Collection.of(a.getDependencies()).flatMap(d -> IAspect.ALL_DEPENDENCIES.get(d)).asSet().add(a);
39 | });
40 |
41 | String getId();
42 |
43 | String getName();
44 |
45 | List getDependencies();
46 |
47 | List getOpposites();
48 |
49 | SLanguage getLanguage();
50 |
51 | boolean isAllwaysOn();
52 |
53 | boolean isOnDemand();
54 |
55 | }
56 |
--------------------------------------------------------------------------------
/runtime/src/main/java/org/modelingvalue/dclare/mps/IChangeHandler.java:
--------------------------------------------------------------------------------
1 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 | // (C) Copyright 2018-2023 Modeling Value Group B.V. (http://modelingvalue.org) ~
3 | // ~
4 | // Licensed under the GNU Lesser General Public License v3.0 (the 'License'). You may not use this file except in ~
5 | // compliance with the License. You may obtain a copy of the License at: https://choosealicense.com/licenses/lgpl-3.0 ~
6 | // Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on ~
7 | // an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the ~
8 | // specific language governing permissions and limitations under the License. ~
9 | // ~
10 | // Maintainers: ~
11 | // Wim Bast, Tom Brus, Ronald Krijgsheld ~
12 | // Contributors: ~
13 | // Arjan Kok, Carel Bast ~
14 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 |
16 | package org.modelingvalue.dclare.mps;
17 |
18 | public interface IChangeHandler {
19 |
20 | DAttribute attribute();
21 |
22 | void handle(O context, T pre, T post);
23 |
24 | boolean deferred();
25 |
26 | INative iNative();
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/runtime/src/main/java/org/modelingvalue/dclare/mps/INative.java:
--------------------------------------------------------------------------------
1 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 | // (C) Copyright 2018-2023 Modeling Value Group B.V. (http://modelingvalue.org) ~
3 | // ~
4 | // Licensed under the GNU Lesser General Public License v3.0 (the 'License'). You may not use this file except in ~
5 | // compliance with the License. You may obtain a copy of the License at: https://choosealicense.com/licenses/lgpl-3.0 ~
6 | // Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on ~
7 | // an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the ~
8 | // specific language governing permissions and limitations under the License. ~
9 | // ~
10 | // Maintainers: ~
11 | // Wim Bast, Tom Brus, Ronald Krijgsheld ~
12 | // Contributors: ~
13 | // Arjan Kok, Carel Bast ~
14 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 |
16 | package org.modelingvalue.dclare.mps;
17 |
18 | import org.jetbrains.mps.openapi.language.SAbstractConcept;
19 | import org.modelingvalue.collections.List;
20 | import org.modelingvalue.dclare.Constant;
21 |
22 | public interface INative extends DFeature {
23 |
24 | @SuppressWarnings({"rawtypes", "unchecked"})
25 | static final Constant> ALL_HANDLERS = Constant.of("ALL_HANDLERS", List.of(), n -> {
26 | return List.of(n.getChangeHandlers());
27 | });
28 |
29 | void init(O context, DObject parent, INativeRunner nativeRunner);
30 |
31 | void exit(O context, DObject parent, INativeRunner nativeRunner);
32 |
33 | @SuppressWarnings("rawtypes")
34 | java.util.List getChangeHandlers();
35 |
36 | Object type();
37 |
38 | INativeGroup group();
39 |
40 | @SuppressWarnings({"rawtypes", "unchecked"})
41 | static int compare(INative a, INative b) {
42 | if (a.equals(b)) {
43 | return 0;
44 | } else {
45 | Object at = a.type();
46 | Object bt = b.type();
47 | if (at instanceof SAbstractConcept && bt instanceof SAbstractConcept) {
48 | SAbstractConcept ac = (SAbstractConcept) at;
49 | SAbstractConcept bc = (SAbstractConcept) bt;
50 | if (ac.isSubConceptOf(bc)) {
51 | return -1;
52 | } else if (bc.isSubConceptOf(ac)) {
53 | return 1;
54 | }
55 | } else if (at instanceof SStructClass && bt instanceof SStructClass) {
56 | SStructClass ac = (SStructClass) at;
57 | SStructClass bc = (SStructClass) bt;
58 | if (ac.isAssignableFrom(bc)) {
59 | return 1;
60 | } else if (bc.isAssignableFrom(ac)) {
61 | return -1;
62 | }
63 | } else if (at instanceof Class && bt instanceof Class) {
64 | Class ac = (Class) at;
65 | Class bc = (Class) bt;
66 | if (ac.isAssignableFrom(bc)) {
67 | return 1;
68 | } else if (bc.isAssignableFrom(ac)) {
69 | return -1;
70 | }
71 | }
72 | return Integer.compare(a.hashCode(), b.hashCode());
73 | }
74 | }
75 |
76 | }
77 |
--------------------------------------------------------------------------------
/runtime/src/main/java/org/modelingvalue/dclare/mps/INativeGroup.java:
--------------------------------------------------------------------------------
1 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 | // (C) Copyright 2018-2023 Modeling Value Group B.V. (http://modelingvalue.org) ~
3 | // ~
4 | // Licensed under the GNU Lesser General Public License v3.0 (the 'License'). You may not use this file except in ~
5 | // compliance with the License. You may obtain a copy of the License at: https://choosealicense.com/licenses/lgpl-3.0 ~
6 | // Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on ~
7 | // an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the ~
8 | // specific language governing permissions and limitations under the License. ~
9 | // ~
10 | // Maintainers: ~
11 | // Wim Bast, Tom Brus, Ronald Krijgsheld ~
12 | // Contributors: ~
13 | // Arjan Kok, Carel Bast ~
14 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 |
16 | package org.modelingvalue.dclare.mps;
17 |
18 | import java.util.function.Consumer;
19 |
20 | import org.jetbrains.mps.openapi.language.SLanguage;
21 |
22 | public interface INativeGroup {
23 |
24 | @SuppressWarnings("unchecked")
25 | static INativeGroup of(SLanguage language, String id) {
26 | return DClareMPS.NATIVE_GROUP_MAP.get(language).get(id);
27 | }
28 |
29 | String getId();
30 |
31 | String getName();
32 |
33 | Consumer getScheduler(DClareMPS dclare);
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/runtime/src/main/java/org/modelingvalue/dclare/mps/INativeRunner.java:
--------------------------------------------------------------------------------
1 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 | // (C) Copyright 2018-2023 Modeling Value Group B.V. (http://modelingvalue.org) ~
3 | // ~
4 | // Licensed under the GNU Lesser General Public License v3.0 (the 'License'). You may not use this file except in ~
5 | // compliance with the License. You may obtain a copy of the License at: https://choosealicense.com/licenses/lgpl-3.0 ~
6 | // Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on ~
7 | // an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the ~
8 | // specific language governing permissions and limitations under the License. ~
9 | // ~
10 | // Maintainers: ~
11 | // Wim Bast, Tom Brus, Ronald Krijgsheld ~
12 | // Contributors: ~
13 | // Arjan Kok, Carel Bast ~
14 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 |
16 | package org.modelingvalue.dclare.mps;
17 |
18 | import jetbrains.mps.project.ProjectBase;
19 |
20 | public interface INativeRunner {
21 |
22 | void run(Runnable runable);
23 |
24 | void runNow(Runnable runable);
25 |
26 | ProjectBase project();
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/runtime/src/main/java/org/modelingvalue/dclare/mps/IRuleAspect.java:
--------------------------------------------------------------------------------
1 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 | // (C) Copyright 2018-2023 Modeling Value Group B.V. (http://modelingvalue.org) ~
3 | // ~
4 | // Licensed under the GNU Lesser General Public License v3.0 (the 'License'). You may not use this file except in ~
5 | // compliance with the License. You may obtain a copy of the License at: https://choosealicense.com/licenses/lgpl-3.0 ~
6 | // Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on ~
7 | // an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the ~
8 | // specific language governing permissions and limitations under the License. ~
9 | // ~
10 | // Maintainers: ~
11 | // Wim Bast, Tom Brus, Ronald Krijgsheld ~
12 | // Contributors: ~
13 | // Arjan Kok, Carel Bast ~
14 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 |
16 | package org.modelingvalue.dclare.mps;
17 |
18 | import java.util.List;
19 |
20 | import org.jetbrains.mps.openapi.language.SReferenceLink;
21 |
22 | import jetbrains.mps.smodel.runtime.ILanguageAspect;
23 |
24 | public interface IRuleAspect extends ILanguageAspect {
25 | List getRuleSets();
26 |
27 | List getAspects();
28 |
29 | List getNativeGroups();
30 |
31 | List getStructClasses();
32 |
33 | List getReferencesWithOpposite();
34 | }
35 |
--------------------------------------------------------------------------------
/runtime/src/main/java/org/modelingvalue/dclare/mps/IRuleSet.java:
--------------------------------------------------------------------------------
1 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 | // (C) Copyright 2018-2023 Modeling Value Group B.V. (http://modelingvalue.org) ~
3 | // ~
4 | // Licensed under the GNU Lesser General Public License v3.0 (the 'License'). You may not use this file except in ~
5 | // compliance with the License. You may obtain a copy of the License at: https://choosealicense.com/licenses/lgpl-3.0 ~
6 | // Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on ~
7 | // an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the ~
8 | // specific language governing permissions and limitations under the License. ~
9 | // ~
10 | // Maintainers: ~
11 | // Wim Bast, Tom Brus, Ronald Krijgsheld ~
12 | // Contributors: ~
13 | // Arjan Kok, Carel Bast ~
14 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 |
16 | package org.modelingvalue.dclare.mps;
17 |
18 | import java.util.List;
19 |
20 | import org.jetbrains.mps.openapi.language.SAbstractConcept;
21 | import org.jetbrains.mps.openapi.language.SLanguage;
22 | import org.jetbrains.mps.openapi.model.SModel;
23 | import org.jetbrains.mps.openapi.model.SNode;
24 | import org.modelingvalue.collections.Set;
25 |
26 | public interface IRuleSet {
27 |
28 | List> getNodeAttributes(SAbstractConcept concept, Set anonymousTypes);
29 |
30 | List> getModelAttributes(Set anonymousTypes);
31 |
32 | List> getModuleAttributes();
33 |
34 | List> getRepositoryAttributes();
35 |
36 | List> getStructAttributes(SStructClass cls, Set anonymousTypes);
37 |
38 | List> getNodeRules(SAbstractConcept concept, Set anonymousTypes);
39 |
40 | List> getModelRules(Set anonymousTypes);
41 |
42 | List> getModuleRules();
43 |
44 | List> getRepositoryRules();
45 |
46 | List> getStructRules(SStructClass cls, Set anonymousTypes);
47 |
48 | List> getNodeNatives(SAbstractConcept concept, Set anonymousTypes);
49 |
50 | List> getModelNatives(Set anonymousTypes);
51 |
52 | List> getModuleNatives();
53 |
54 | List> getRepositoryNatives();
55 |
56 | List> getStructNatives(SStructClass cls, Set anonymousTypes);
57 |
58 | List> getAllMethods();
59 |
60 | List> getAllAttributes();
61 |
62 | List> getAllRules();
63 |
64 | List> getAllNatives();
65 |
66 | IAspect getAspect();
67 |
68 | String getAnonymousType();
69 |
70 | SLanguage getLanguage();
71 |
72 | }
73 |
--------------------------------------------------------------------------------
/runtime/src/main/java/org/modelingvalue/dclare/mps/MPSDeltaAdapter.java:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ModelingValueGroup/dclareForMPS/3fd9debbc3ecf7e031c77b51a9a48227547ac7ef/runtime/src/main/java/org/modelingvalue/dclare/mps/MPSDeltaAdapter.java
--------------------------------------------------------------------------------
/runtime/src/main/java/org/modelingvalue/dclare/mps/SStructClass.java:
--------------------------------------------------------------------------------
1 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 | // (C) Copyright 2018-2023 Modeling Value Group B.V. (http://modelingvalue.org) ~
3 | // ~
4 | // Licensed under the GNU Lesser General Public License v3.0 (the 'License'). You may not use this file except in ~
5 | // compliance with the License. You may obtain a copy of the License at: https://choosealicense.com/licenses/lgpl-3.0 ~
6 | // Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on ~
7 | // an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the ~
8 | // specific language governing permissions and limitations under the License. ~
9 | // ~
10 | // Maintainers: ~
11 | // Wim Bast, Tom Brus, Ronald Krijgsheld ~
12 | // Contributors: ~
13 | // Arjan Kok, Carel Bast ~
14 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 |
16 | package org.modelingvalue.dclare.mps;
17 |
18 | import org.jetbrains.mps.openapi.language.SLanguage;
19 | import org.modelingvalue.collections.List;
20 | import org.modelingvalue.collections.Set;
21 |
22 | @SuppressWarnings("unused")
23 | public class SStructClass {
24 |
25 | @SuppressWarnings("rawtypes")
26 | public static SStructClass of(String id, String name, SLanguage language, DAttribute[] identity, SStructClass[] supers, boolean isValueClass) {
27 | return new SStructClass(id, name, language, List.of(identity), Set.of(supers), isValueClass);
28 | }
29 |
30 | public static SStructClass of(SLanguage language, String id) {
31 | return DClareMPS.STRUCT_CLASS_MAP.get(language).get(id);
32 | }
33 |
34 | private final String id;
35 | private final String name;
36 | private final List> identity;
37 | private final Set supers;
38 | private final SLanguage language;
39 | private final boolean isValueClass;
40 |
41 | private SStructClass(String id, String name, SLanguage language, List> identity, Set supers, boolean isValueClass) {
42 | super();
43 | this.id = id;
44 | this.name = name;
45 | this.language = language;
46 | this.supers = supers;
47 | this.identity = identity;
48 | this.isValueClass = isValueClass;
49 | }
50 |
51 | @Override
52 | public int hashCode() {
53 | return id.hashCode();
54 | }
55 |
56 | public String id() {
57 | return id;
58 | }
59 |
60 | @Override
61 | public boolean equals(Object obj) {
62 | if (this == obj) {
63 | return true;
64 | } else if (obj == null) {
65 | return false;
66 | } else if (getClass() != obj.getClass()) {
67 | return false;
68 | } else {
69 | SStructClass other = (SStructClass) obj;
70 | return id.equals(other.id);
71 | }
72 | }
73 |
74 | public boolean isAssignableFrom(SStructClass sub) {
75 | return equals(sub) || sub.supers.anyMatch(this::isAssignableFrom);
76 | }
77 |
78 | @Override
79 | public String toString() {
80 | return name;
81 | }
82 |
83 | public SLanguage getLanguage() {
84 | return language;
85 | }
86 |
87 | public List> getIdentity() {
88 | return identity;
89 | }
90 |
91 | public Set getSupers() {
92 | return supers;
93 | }
94 |
95 | public boolean isValueClass() {
96 | return isValueClass;
97 | }
98 |
99 | }
100 |
--------------------------------------------------------------------------------
/runtime/src/main/java/org/modelingvalue/dclare/mps/SStructObject.java:
--------------------------------------------------------------------------------
1 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 | // (C) Copyright 2018-2023 Modeling Value Group B.V. (http://modelingvalue.org) ~
3 | // ~
4 | // Licensed under the GNU Lesser General Public License v3.0 (the 'License'). You may not use this file except in ~
5 | // compliance with the License. You may obtain a copy of the License at: https://choosealicense.com/licenses/lgpl-3.0 ~
6 | // Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on ~
7 | // an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the ~
8 | // specific language governing permissions and limitations under the License. ~
9 | // ~
10 | // Maintainers: ~
11 | // Wim Bast, Tom Brus, Ronald Krijgsheld ~
12 | // Contributors: ~
13 | // Arjan Kok, Carel Bast ~
14 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 |
16 | package org.modelingvalue.dclare.mps;
17 |
18 | public interface SStructObject {
19 |
20 | SStructClass getSClass();
21 |
22 | Object[] getIdentity();
23 |
24 | }
25 |
--------------------------------------------------------------------------------
/runtime/src/main/java/org/modelingvalue/dclare/mps/Signature.java:
--------------------------------------------------------------------------------
1 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 | // (C) Copyright 2018-2023 Modeling Value Group B.V. (http://modelingvalue.org) ~
3 | // ~
4 | // Licensed under the GNU Lesser General Public License v3.0 (the 'License'). You may not use this file except in ~
5 | // compliance with the License. You may obtain a copy of the License at: https://choosealicense.com/licenses/lgpl-3.0 ~
6 | // Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on ~
7 | // an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the ~
8 | // specific language governing permissions and limitations under the License. ~
9 | // ~
10 | // Maintainers: ~
11 | // Wim Bast, Tom Brus, Ronald Krijgsheld ~
12 | // Contributors: ~
13 | // Arjan Kok, Carel Bast ~
14 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 |
16 | package org.modelingvalue.dclare.mps;
17 |
18 | import java.util.Arrays;
19 |
20 | import org.jetbrains.mps.openapi.language.SAbstractConcept;
21 | import org.jetbrains.mps.openapi.model.SNode;
22 | import org.modelingvalue.collections.util.IdentifiedByArray;
23 |
24 | public class Signature extends IdentifiedByArray implements Comparable {
25 |
26 | public static Signature of(Signature def, Object[] args) {
27 | Object[] id = new Object[args.length + 2];
28 | for (int i = 0; i < args.length; i++) {
29 | if (args[i] == null) {
30 | id[i] = def.get(i);
31 | } else if (args[i] instanceof SNode) {
32 | id[i] = ((SNode) args[i]).getConcept();
33 | } else if (args[i] instanceof SStructObject) {
34 | id[i] = ((SStructObject) args[i]).getSClass();
35 | } else {
36 | id[i] = args[i].getClass();
37 | }
38 | }
39 | id[args.length] = def.get(args.length);
40 | id[args.length + 1] = def.get(args.length + 1);
41 | return of(id);
42 | }
43 |
44 | public static Signature of(Object[] types) {
45 | return new Signature(types);
46 | }
47 |
48 | private Signature(Object[] id) {
49 | super(id);
50 | }
51 |
52 | @Override
53 | public String toString() {
54 | return Arrays.toString(identity()).replace('[', '(').replace(']', ')');
55 | }
56 |
57 | @SuppressWarnings({"unchecked", "rawtypes"})
58 | public boolean isSubOf(Signature sup, boolean flipLast2) {
59 | if (size() != sup.size()) {
60 | return false;
61 | } else {
62 | int flipIndex = flipLast2 ? size() - 2 : size();
63 | for (int i = 0; i < size(); i++) {
64 | Object subType = i >= flipIndex ? sup.get(i) : get(i);
65 | Object supType = i >= flipIndex ? get(i) : sup.get(i);
66 | if (subType instanceof SAbstractConcept && supType instanceof SAbstractConcept) {
67 | if (!((SAbstractConcept) subType).isSubConceptOf((SAbstractConcept) supType)) {
68 | return false;
69 | }
70 | } else if (subType instanceof SStructClass && supType instanceof SStructClass) {
71 | if (!((SStructClass) supType).isAssignableFrom((SStructClass) subType)) {
72 | return false;
73 | }
74 | } else if (subType instanceof IAspect && supType instanceof IAspect) {
75 | if (!IAspect.ALL_DEPENDENCIES.get((IAspect) subType).contains((IAspect) supType)) {
76 | return false;
77 | }
78 | } else if (subType instanceof Class && supType instanceof Class) {
79 | if (!((Class) supType).isAssignableFrom((Class) subType)) {
80 | return false;
81 | }
82 | } else if ((subType instanceof SAbstractConcept || subType instanceof SStructClass || subType instanceof IAspect) && supType instanceof Class) {
83 | if (supType != Object.class) {
84 | return false;
85 | }
86 | } else {
87 | return false;
88 | }
89 | }
90 | return true;
91 | }
92 | }
93 |
94 | @Override
95 | public int compareTo(Signature o) {
96 | if (equals(o)) {
97 | return 0;
98 | } else if (isSubOf(o, false)) {
99 | return -1;
100 | } else if (o.isSubOf(this, false)) {
101 | return 1;
102 | } else {
103 | return Integer.compare(hashCode(), o.hashCode());
104 | }
105 | }
106 |
107 | }
108 |
--------------------------------------------------------------------------------
/runtime/src/main/java/org/modelingvalue/dclare/mps/UnidentifiedException.java:
--------------------------------------------------------------------------------
1 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 | // (C) Copyright 2018-2023 Modeling Value Group B.V. (http://modelingvalue.org) ~
3 | // ~
4 | // Licensed under the GNU Lesser General Public License v3.0 (the 'License'). You may not use this file except in ~
5 | // compliance with the License. You may obtain a copy of the License at: https://choosealicense.com/licenses/lgpl-3.0 ~
6 | // Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on ~
7 | // an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the ~
8 | // specific language governing permissions and limitations under the License. ~
9 | // ~
10 | // Maintainers: ~
11 | // Wim Bast, Tom Brus, Ronald Krijgsheld ~
12 | // Contributors: ~
13 | // Arjan Kok, Carel Bast ~
14 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 |
16 | package org.modelingvalue.dclare.mps;
17 |
18 | import org.modelingvalue.dclare.Setable;
19 | import org.modelingvalue.dclare.ex.ConsistencyError;
20 |
21 | @SuppressWarnings("unused")
22 | public final class UnidentifiedException extends ConsistencyError {
23 |
24 | private static final long serialVersionUID = 5442977255041372354L;
25 |
26 | @SuppressWarnings("rawtypes")
27 | public UnidentifiedException(Object object, DRule.DObserver observer, Object value) {
28 | super(object, observer, 4, "Rule '" + observer.rule() + "' in object '" + object + "' assigns unidentified objects '" + value + "'");
29 | }
30 |
31 | @SuppressWarnings("rawtypes")
32 | public UnidentifiedException(Object object, Setable setable, Object value) {
33 | super(object, setable, 4, "Property '" + setable + "' of object '" + object + "' is assigned with unidentified objects '" + value + "'");
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/settings.gradle.kts:
--------------------------------------------------------------------------------
1 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 | // (C) Copyright 2018-2023 Modeling Value Group B.V. (http://modelingvalue.org) ~
3 | // ~
4 | // Licensed under the GNU Lesser General Public License v3.0 (the 'License'). You may not use this file except in ~
5 | // compliance with the License. You may obtain a copy of the License at: https://choosealicense.com/licenses/lgpl-3.0 ~
6 | // Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on ~
7 | // an 'AS IS' BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the ~
8 | // specific language governing permissions and limitations under the License. ~
9 | // ~
10 | // Maintainers: ~
11 | // Wim Bast, Tom Brus, Ronald Krijgsheld ~
12 | // Contributors: ~
13 | // Arjan Kok, Carel Bast ~
14 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
15 |
16 | rootProject.name = "dclareForMPS"
17 |
18 | include("runtime")
19 |
20 | plugins {
21 | id("com.gradle.enterprise") version ("3.5")
22 | }
23 |
--------------------------------------------------------------------------------
/solutions/DclareForMPS.build/DclareForMPS.build.msd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 | 422c2909-59d6-41a9-b318-40e6256b250f(jetbrains.mps.ide.build)
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/solutions/DclareMPSPlugin/icons/Dclare.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ModelingValueGroup/dclareForMPS/3fd9debbc3ecf7e031c77b51a9a48227547ac7ef/solutions/DclareMPSPlugin/icons/Dclare.png
--------------------------------------------------------------------------------
/solutions/DclareMPSPlugin/plugin/Dclare.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/ModelingValueGroup/dclareForMPS/3fd9debbc3ecf7e031c77b51a9a48227547ac7ef/solutions/DclareMPSPlugin/plugin/Dclare.png
--------------------------------------------------------------------------------
/solutions/DclareMPSRuntime/DclareMPSRuntime.msd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 | 8865b7a8-5271-43d3-884c-6fd1d9cfdd34(MPS.OpenAPI)
22 | 6ed54515-acc8-4d1e-a16c-9fd6cfe951ea(MPS.Core)
23 | 498d89d2-c2e9-11e2-ad49-6cf049e62fe5(MPS.IDEA)
24 | 1ed103c3-3aa6-49b7-9c21-6765ee11f224(MPS.Editor)
25 | c72da2b9-7cce-4447-8389-f407dc1158b7(jetbrains.mps.lang.structure)
26 | 9a4afe51-f114-4595-b5df-048ce3c596be(jetbrains.mps.runtime)
27 | e584ff77-930e-4637-8df0-b4c8d3b6de91(DclareRuntime)
28 | cc7da2f6-419f-4133-a811-31fcd3295a85(jetbrains.mps.debugger.api.api)
29 | 34e84b8f-afa8-4364-abcd-a279fddddbe7(jetbrains.mps.editor.runtime)
30 | 6354ebe7-c22a-4a0f-ac54-50b52ab9b065(JDK)
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
--------------------------------------------------------------------------------
/solutions/DclareRuntime/DclareRuntime.msd:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 | 6354ebe7-c22a-4a0f-ac54-50b52ab9b065(JDK)
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/usageHints.adoc:
--------------------------------------------------------------------------------
1 | :experimental:
2 | = Hints on using DclareForMPS
3 |
4 | == General
5 | * We have to switch on the engine at menu:File[Settings > Other Settings > Dclare > Engine on].
6 | * Attribute inheritance works, i.e. attributes for concept `SuperConcept` can be referred to in concept `SubConcept extends SuperConcept`.
7 | * We can have circular change rules, as long as they don't conflict.
8 | +
9 | Example: In model `A`, we have a named node of concept `X`.
10 | A rule creates model `B` and within it a named node of concept `Y`.
11 | We can propagate name changes from `X` to `Y` **and** from `Y` to `X`.
12 |
13 | == Model change / write access
14 | * Inside Dclare, we can only write to the model with the `:=` operator or by calling `concat()` on a collection.
15 |
16 | == Syntax
17 | * We can use variables in the _Rules_ section by nesting them into curly braces:
18 | +
19 | [source, java]
20 | ----
21 | {
22 | node = this.someRefOfTypeSomething;
23 | }
24 | ----
25 |
26 | * We can find opposites of references with the `~` operator:
27 | +
28 | [source, java]
29 | ----
30 | nlist inhabitants := this.address.~Inhabitant::home;
31 | ----
32 |
33 | * We can set an attribute to optional, if it might be `null`.
34 | Prefix the attribute with `optional`, or use the intention menu.
35 |
36 | == UI
37 | * The menu:Context Menu[Refactoring > Extract Attribute] works as expected.
38 |
--------------------------------------------------------------------------------