public Set<SReference> findUsages(Set<SNode> nodes) { if (!myFindUsagesSupported) return Collections.emptySet(); if (myNeedSearchForStrings) { Set<String> strings = new HashSet<String>(); for (SNode node : nodes) { strings.add(quoteSpecialXMLCharacters(node.getId())); } if (!myModelRootManager.containsSomeString(myModelDescriptor, strings)) return Collections.emptySet(); } SModel model = myModelDescriptor.getSModel(); if (model == null) return Collections.emptySet(); Set<SReference> result = new HashSet<SReference>(); for (SNode root : model.roots()) { addUsages(root, nodes, result); } return result; }
public boolean hasUsages(Set<SModelReference> models) { if (!myFindUsagesSupported) return false; if (myNeedSearchForStrings) { Set<String> strings = new HashSet<String>(); for (SModelReference model : models) { strings.add(quoteSpecialXMLCharacters(model.toString())); } if (!myModelRootManager.containsSomeString(myModelDescriptor, strings)) return false; } SModel model = myModelDescriptor.getSModel(); if (model == null) return false; for (SModelDescriptor modelDescriptor : SModelOperations.allImportedModels(model, GlobalScope.getInstance())) { if (models.contains(modelDescriptor.getSModelReference())) { return true; } } return false; }