private static List<INodeSubstituteAction> createPrimaryChildSubstituteActions( SNode parentNode, SNode currentChild, SNode childConcept, IChildNodeSetter childSetter, IOperationContext context) { if (childConcept == null) { return Collections.emptyList(); } final IScope scope = context.getScope(); String childConceptFqName = NameUtil.nodeFQName(childConcept); Set<String> concepts = new HashSet<String>(); for (Language l : SModelOperations.getLanguages(parentNode.getModel(), scope)) { concepts.addAll( LanguageHierarchyCache.getInstance() .getDefaultSubstitutableDescendantsOf(childConceptFqName, l)); } List<INodeSubstituteAction> actions = new ArrayList<INodeSubstituteAction>(); for (String fqName : concepts) { SNode applicableConcept = SModelUtil.findConceptDeclaration(fqName, scope); assert applicableConcept != null : "No concept " + fqName; actions.addAll( createDefaultActions(applicableConcept, parentNode, currentChild, childSetter, context)); } return actions; }
public boolean hasImportedModel(SModelDescriptor modelDescriptor) { if (!myFindUsagesSupported) return false; if (myNeedSearchForStrings && !myModelRootManager.containsString(myModelDescriptor, modelDescriptor.toString())) return false; SModel model = myModelDescriptor.getSModel(); if (model == null) return false; return SModelOperations.getImportElement(model, modelDescriptor.getSModelReference()) != null; }
public boolean hasLanguage(Language language) { if (!myFindUsagesSupported) return false; if (myNeedSearchForStrings && !myModelRootManager.containsString(myModelDescriptor, language.getModuleFqName())) return false; SModel model = myModelDescriptor.getSModel(); if (model == null) return false; return SModelOperations.hasLanguage(model, language.getModuleReference()); }
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; }
private static void assertSameModelImports(SModel expectedModel, SModel actualModel) { assertListsEqual( SModelOperations.getImportedModelUIDs(expectedModel), SModelOperations.getImportedModelUIDs(actualModel), "model import"); }