Exemplo n.º 1
0
 @Override
 public jetbrains.mps.smodel.SModel createModel() {
   if (!myToCopy.isLoaded()) {
     // we are going to access internal/implementation model which might be in a partially-loaded
     // state (only public API guarantees proper loading). With partial model, we could face odd
     // issues (e.g. incomplete set of implicit imports as implementation node's concepts are not
     // considered)
     myToCopy.load();
   }
   Document document = ModelPersistence.saveModel(((SModelBase) myToCopy).getSModel());
   Element rootElement = document.getRootElement();
   rootElement.setAttribute(ModelPersistence.REF, getReference().toString());
   String modelContent = JDOMUtil.asString(document);
   try {
     return ModelPersistence.readModel(modelContent, false);
   } catch (ModelReadException e) {
     return new StubModel(PersistenceFacade.getInstance().createModelReference(myLongName), e);
   }
 }