public static List<SNode> nodes(SModel model, final SAbstractConcept concept) { if (model == null) { return new ArrayList<SNode>(); } if (concept != null) { return jetbrains.mps.smodel.SModelOperations.getNodes(model, concept); } List<SNode> result = new ArrayList<SNode>(); for (SNode node : SNodeUtil.getDescendants(model)) { result.add(node); } return result; }
private static List<SNode> allNodesIncludingImported( SModel sModel, boolean roots, @Nullable SAbstractConcept concept) { List<SModel> modelsList = new ArrayList<SModel>(); modelsList.add(sModel); List<SModel> modelDescriptors = jetbrains.mps.smodel.SModelOperations.allImportedModels(sModel); for (SModel descriptor : modelDescriptors) { modelsList.add(descriptor); } List<SNode> resultNodes = new ArrayList<SNode>(); final Condition<SNode> instanceCondition = (concept == null ? null : new InstanceOfCondition(concept)); for (SModel aModel : modelsList) { if (concept == null || roots) { ConditionalIterable<SNode> nodes = new ConditionalIterable<SNode>( (roots ? aModel.getRootNodes() : SNodeUtil.getDescendants(aModel)), instanceCondition); resultNodes.addAll(IterableUtil.asList(nodes)); } else { resultNodes.addAll(jetbrains.mps.smodel.SModelOperations.getNodes(aModel, concept)); } } return resultNodes; }