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; }
@Nullable @Override protected Iterable<? extends SNode> getParameters(SubstituteMenuContext _context) { // TODO: Use link scopes here List<SNode> result = ListSequence.fromList(new ArrayList<SNode>()); Set<SModel> allVisibleModels = SetSequence.fromSetWithValues( new HashSet<SModel>(), (List<SModel>) SModelOperations.allImportedModels(_context.getModel())); SetSequence.fromSet(allVisibleModels).addElement(_context.getModel()); for (SModel nextModel : SetSequence.fromSet(allVisibleModels)) { ListSequence.fromList(result) .addSequence( ListSequence.fromList( jetbrains.mps.lang.smodel.generator.smodelAdapter.SModelOperations.nodes( nextModel, MetaAdapterFactory.getConcept( 0x18bc659203a64e29L, 0xa83a7ff23bde13baL, 0x527faacef50d095eL, "jetbrains.mps.lang.editor.structure.ConceptEditorHintDeclaration")))); } return result; }