diff --git a/mps-cli-gradle-plugin/plugin/src/main/groovy/org/mps_cli/model/SRepository.groovy b/mps-cli-gradle-plugin/plugin/src/main/groovy/org/mps_cli/model/SRepository.groovy index 92f2180..6030497 100644 --- a/mps-cli-gradle-plugin/plugin/src/main/groovy/org/mps_cli/model/SRepository.groovy +++ b/mps-cli-gradle-plugin/plugin/src/main/groovy/org/mps_cli/model/SRepository.groovy @@ -2,16 +2,6 @@ package org.mps_cli.model class SRepository { - SRepository(List modules, List languages) { - this.modules = modules.asImmutable() - this.languages = languages.asImmutable() - - this.models = modules.collectMany { it.models }.asImmutable() - this.nodes = models.collectMany { it.allNodes }.asImmutable() - this.id2modelsCache = models.collectEntries {[it.modelId, it] }.asImmutable() - this.id2ModulesCache = modules.collectEntries {[it.moduleId, it] }.asImmutable() - } - private List modules; private List languages; @@ -20,13 +10,26 @@ class SRepository { private Map id2modelsCache; private Map id2ModulesCache; + SRepository(List modules, List languages) { + this.modules = modules.asImmutable() + this.languages = languages.asImmutable() + + this.models = modules.collectMany { it.models }.asImmutable() + this.nodes = models.collectMany { it.allNodes }.asImmutable() + this.id2modelsCache = models.collectEntries { [it.modelId, it] }.asImmutable() + this.id2ModulesCache = modules.collectEntries { [it.moduleId, it] }.asImmutable() + } + List getModules() { modules } + List getLanguages() { languages } List allModels() { models } + List allNodes() { nodes } Map id2models() { id2modelsCache } + Map id2modules() { id2ModulesCache } List findModelByName(String modelName) { @@ -44,7 +47,7 @@ class SRepository { } List nodesOfConcept(String fullyQualifiedConceptName) { - allNodes().findAll { it.concept.name == fullyQualifiedConceptName} + allNodes().findAll { it.concept.name == fullyQualifiedConceptName } } List nodesOfShortConceptName(String shortConceptName) { @@ -61,15 +64,15 @@ class SRepository { } Set conceptsOfLanguage(String langName) { - languages.find {it.name == langName}?.concepts + languages.find { it.name == langName }?.concepts } SConcept findConceptByShortName(String conceptShortName) { def ending = "." + conceptShortName - languages.collectMany {it.concepts }.find { it.name.endsWith(ending) } + languages.collectMany { it.concepts }.find { it.name.endsWith(ending) } } SModuleBase findModuleByName(String moduleName) { - modules.find {it.name.equals(moduleName) } + modules.find { it.name.equals(moduleName) } } }