public static Collection<SModel> getModifiedModels(Collection<? extends SModel> models) { Set<SModel> result = new LinkedHashSet<SModel>(); ModelGenerationStatusManager statusManager = ModelGenerationStatusManager.getInstance(); for (SModel sm : models) { if (statusManager.generationRequired(sm)) { result.add(sm); continue; } // TODO regenerating all dependant models can be slow, option? if (!(SModelStereotype.DESCRIPTOR.equals(SModelStereotype.getStereotype(sm)) || LanguageAspect.BEHAVIOR.is(sm) || LanguageAspect.CONSTRAINTS.is(sm))) { // temporary solution: only descriptor/behavior/constraints models continue; } final SRepository repository = sm.getRepository(); if (repository == null) { // no idea how to treat a model which hands in the air; expect it to be editable and tell // isChanged if desires re-generation continue; } GenerationDependencies oldDependencies = GenerationDependenciesCache.getInstance().get(sm); // FIXME use SRepository to pick proper GenerationDependenciesCache instance if (oldDependencies == null) { // TODO turn on when generated file will be mandatory // result.add(sm); continue; } Map<String, String> externalHashes = oldDependencies.getExternalHashes(); for (Entry<String, String> entry : externalHashes.entrySet()) { String modelReference = entry.getKey(); SModel rmd = PersistenceFacade.getInstance() .createModelReference(modelReference) .resolve(repository); if (rmd == null) { result.add(sm); break; } String oldHash = entry.getValue(); if (oldHash == null) { continue; } String newHash = statusManager.currentHash(rmd); if (newHash == null || !oldHash.equals(newHash)) { result.add(sm); break; } } } return result; }
public Condition<SModelReference> getImportedModelsRemoveCondition() { Set<SModelReference> models = new ModelAccessHelper(myModelDescriptor.getRepository()) .runReadAction( new Computable<Set<SModelReference>>() { public Set<SModelReference> compute() { return SModelOperations.getUsedImportedModels(myModelDescriptor); } }); return new ModelProperties.ModelsCondition(models); }
public static SNode getModuleStub(SModel model) { final SModule module = model.getModule(); SRepository repo = model.getRepository(); if (repo == null || ProjectStructureModule.getInstance(repo) == null) { return null; } if (module instanceof Generator) { Language lang = ((Generator) module).getSourceLanguage(); SModel m = ProjectStructureModule.getInstance(repo).getModelByModule(lang); if (m == null) { return null; } SNode l = ListSequence.fromList( SModelOperations.roots( m, MetaAdapterFactory.getConcept( 0x86ef829012bb4ca7L, 0x947f093788f263a9L, 0x5869770da61dfe1fL, "jetbrains.mps.lang.project.structure.Language"))) .first(); return (l == null ? null : ListSequence.fromList( SLinkOperations.getChildren( l, MetaAdapterFactory.getContainmentLink( 0x86ef829012bb4ca7L, 0x947f093788f263a9L, 0x5869770da61dfe1fL, 0x5869770da61dfe37L, "generator"))) .findFirst( new IWhereFilter<SNode>() { public boolean accept(SNode it) { return eq_kkj9n5_a0a0a0a0a0a4a3a11( SPropertyOperations.getString( it, MetaAdapterFactory.getProperty( 0x86ef829012bb4ca7L, 0x947f093788f263a9L, 0x5869770da61dfe1eL, 0x5869770da61dfe22L, "uuid")), module.getModuleReference().getModuleId().toString()); } })); } else { SModel m = ProjectStructureModule.getInstance(repo).getModelByModule(module); return (m == null ? null : ListSequence.fromList( SModelOperations.roots( m, MetaAdapterFactory.getConcept( 0x86ef829012bb4ca7L, 0x947f093788f263a9L, 0x5869770da61dfe1eL, "jetbrains.mps.lang.project.structure.Module"))) .first()); } }