コード例 #1
0
  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;
  }
コード例 #2
0
  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;
  }
コード例 #3
0
  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());
  }
コード例 #4
0
  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;
  }
コード例 #5
0
ファイル: ModelAssert.java プロジェクト: CloudMetal/MPS
 private static void assertSameModelImports(SModel expectedModel, SModel actualModel) {
   assertListsEqual(
       SModelOperations.getImportedModelUIDs(expectedModel),
       SModelOperations.getImportedModelUIDs(actualModel),
       "model import");
 }