private SModelDescriptor findModel(SModelReference reference) { if (reference.equals(myModel.getSModelReference())) { return myModel.getModelDescriptor(); } List<IScope> scopes = ListSequence.fromList(new ArrayList<IScope>()); IScope ps = myProject.getScope(); if (ps != null) { ListSequence.fromList(scopes).addElement(ps); } ListSequence.fromList(scopes).addElement(GlobalScope.getInstance()); for (IScope scope : ListSequence.fromList(scopes)) { SModelDescriptor md = scope.getModelDescriptor(reference); if (md != null) { return md; } } // if we can't find model using full reference, try to find by fq-name // this is needed for viewing diff on models saved before MPS 2.0 M5 for (IScope scope : ListSequence.fromList(scopes)) { SModelDescriptor md = scope.getModelDescriptor(reference.getSModelFqName()); if (md != null) { return md; } } return null; }
public static Language getLanguage(Project project, String languageName) { return project.getScope().getLanguage(languageName); }
public static SModelDescriptor getModel(Project project, String modelName) { return project.getScope().getModelDescriptor(SModelReference.fromString(modelName)); }