Example #1
0
 protected void validateImports() {
   SModelInternal modelInternal = (SModelInternal) myModel;
   for (SModuleReference devKit :
       ListSequence.fromListWithValues(
           new ArrayList<SModuleReference>(), modelInternal.importedDevkits())) {
     modelInternal.deleteDevKit(devKit);
   }
   for (SLanguage language :
       ListSequence.fromListWithValues(
           new ArrayList<SLanguage>(), modelInternal.importedLanguageIds())) {
     modelInternal.deleteLanguageId(language);
   }
   for (jetbrains.mps.smodel.SModel.ImportElement model :
       ListSequence.fromListWithValues(
           new ArrayList<jetbrains.mps.smodel.SModel.ImportElement>(),
           modelInternal.importedModels())) {
     modelInternal.deleteModelImport(model.getModelReference());
   }
   addBuiltInImports();
   TemporaryModels.getInstance().addMissingImports(myModel);
 }
 /*package*/ void updateImportVersions(
     EditableSModelDescriptor model, final Map<String, Object> _params) {
   jetbrains.mps.smodel.SModel m = model.getSModel();
   for (jetbrains.mps.smodel.SModel.ImportElement importElement :
       ListSequence.fromList(SModelOperations.getAllImportElements(model.getSModel()))) {
     RefactorableSModelDescriptor usedModel =
         as_hexye9_a0a0a1a7(
             SModelRepository.getInstance().getModelDescriptor(importElement.getModelReference()),
             RefactorableSModelDescriptor.class);
     if (usedModel == null) {
       continue;
     }
     if (importElement.getUsedVersion() < usedModel.getVersion()) {
       LOG.info(
           model
               + ": updating used version of "
               + importElement.getModelReference()
               + " from "
               + importElement.getUsedVersion()
               + " to "
               + usedModel.getVersion());
       m.updateImportedModelUsedVersion(importElement.getModelReference(), usedModel.getVersion());
       model.setChanged(true);
     } else if (importElement.getUsedVersion() > usedModel.getVersion()) {
       LOG.error(
           model
               + ": used version of "
               + importElement.getModelReference()
               + " is greater than model version: "
               + importElement.getUsedVersion()
               + ">"
               + usedModel.getVersion());
       m.updateImportedModelUsedVersion(importElement.getModelReference(), usedModel.getVersion());
       model.setChanged(true);
     }
   }
 }
 @Override
 public void modelVersionRead(SModel.ImportElement element) {
   storeAndCheckConsistency(
       myModelVersions, element.getModelReference(), element.getUsedVersion());
 }
Example #4
0
 public boolean updateModelReference(SModelReference model, final SModelReference newModel) {
   boolean res = false;
   // update imports
   for (SModel.ImportElement element : ListSequence.fromList(myModel.importedModels())) {
     if (model.equals(element.getModelReference())) {
       res = true;
       element.setModelReference(newModel);
     }
   }
   for (SModel.ImportElement element :
       ListSequence.fromList(myModel.getAdditionalModelVersions())) {
     if (model.equals(element.getModelReference())) {
       element.setModelReference(newModel);
     }
   }
   // update references
   List<DynamicReference> list = myDynRefMap.remove(model);
   if (list != null) {
     res = true;
     ListSequence.fromList(list)
         .visitAll(
             new IVisitor<DynamicReference>() {
               public void visit(DynamicReference it) {
                 it.setTargetSModelReference(newModel);
               }
             });
     MapSequence.fromMap(myDynRefMap).put(newModel, list);
   }
   for (SNodePointer ptr : SetSequence.fromSet(MapSequence.fromMap(myTargetMap).keySet())) {
     if (model.equals(ptr.getModelReference())) {
       res = true;
       ListSequence.fromList(MapSequence.fromMap(myTargetMap).get(ptr))
           .visitAll(
               new IVisitor<StaticReference>() {
                 public void visit(StaticReference it) {
                   it.setTargetSModelReference(newModel);
                 }
               });
     }
   }
   // update conceptFqNames (if it was structure model)
   for (SNodePointer ptr : SetSequence.fromSet(MapSequence.fromMap(myNodeTypeMap).keySet())) {
     if (model.equals(ptr.getModelReference())) {
       res = true;
       ListSequence.fromList(MapSequence.fromMap(myNodeTypeMap).get(ptr))
           .visitAll(
               new IVisitor<SNode>() {
                 public void visit(SNode node) {
                   String name = NameUtil.shortNameFromLongName(node.getConceptFqName());
                   HackSNodeUtil.setConceptFqName(
                       node,
                       NameUtil.longNameFromNamespaceAndShortName(newModel.getLongName(), name));
                 }
               });
     }
   }
   // update maps themselves
   updatePtrMap(myNodeRoleMap, model, newModel);
   updatePtrMap(myNodeTypeMap, model, newModel);
   updatePtrMap(myPropNameMap, model, newModel);
   updatePtrMap(myRefRoleMap, model, newModel);
   updatePtrMap(myTargetMap, model, newModel);
   return res;
 }