public void test_unspecifiedReferences() throws Exception {
   this.addNodeById("2906110183022219846");
   this.addNodeById("2906110183022219807");
   this.addNodeById("2906110183022219843");
   this.addNodeById("2906110183022354865");
   this.addNodeById("2906110183022432276");
   // Adding one unspecified reference and checking if it was added properly
   int initialSize =
       Sequence.fromIterable(
               SNodeOperations.getReferences(
                   SNodeOperations.cast(
                       this.getNodeById("2906110183022432277"),
                       "jetbrains.mps.lang.smodelTests.structure.ReferenceContainer")))
           .count();
   String unspecifiedReferenceName =
       this.addUnspecifiedReference(
           SNodeOperations.cast(
               this.getNodeById("2906110183022432277"),
               "jetbrains.mps.lang.smodelTests.structure.ReferenceContainer"),
           SNodeOperations.cast(
               this.getNodeById("2906110183022219849"),
               "jetbrains.mps.lang.smodelTests.structure.GrandChild"));
   Assert.assertEquals(
       initialSize + 1,
       Sequence.fromIterable(
               SNodeOperations.getReferences(
                   SNodeOperations.cast(
                       this.getNodeById("2906110183022432277"),
                       "jetbrains.mps.lang.smodelTests.structure.ReferenceContainer")))
           .count());
   // Checking if unspecified reference is working properly
   Iterable<SReference> unspecifiedReferences =
       Sequence.fromIterable(
               SNodeOperations.getReferences(
                   SNodeOperations.cast(
                       this.getNodeById("2906110183022432277"),
                       "jetbrains.mps.lang.smodelTests.structure.ReferenceContainer")))
           .where(
               new IWhereFilter<SReference>() {
                 public boolean accept(SReference it) {
                   return (SLinkOperations.findLinkDeclaration(it) == null);
                 }
               });
   Assert.assertEquals(1, Sequence.fromIterable(unspecifiedReferences).count());
   SReference theReference = Sequence.fromIterable(unspecifiedReferences).first();
   Assert.assertEquals(unspecifiedReferenceName, SLinkOperations.getRole(theReference));
   Assert.assertEquals(
       SNodeOperations.cast(
           this.getNodeById("2906110183022219849"),
           "jetbrains.mps.lang.smodelTests.structure.GrandChild"),
       SLinkOperations.getTargetNode(theReference));
 }
 public void test_forSpecializedLink() throws Exception {
   this.addNodeById("2906110183022219846");
   this.addNodeById("2906110183022219807");
   this.addNodeById("2906110183022219843");
   this.addNodeById("2906110183022354865");
   this.addNodeById("2906110183022432276");
   TestUtilities.assertEquals(
       Sequence.fromArray(
           new SNode[] {
             SNodeOperations.cast(
                 this.getNodeById("2906110183022311236"),
                 "jetbrains.mps.lang.smodelTests.structure.ChildSubConcept")
           }),
       Sequence.fromIterable(
               SNodeOperations.getReferences(
                   SNodeOperations.cast(
                       this.getNodeById("2906110183022354866"),
                       "jetbrains.mps.lang.smodelTests.structure.ReferenceContainerSubConcept")))
           .where(
               new IWhereFilter<SReference>() {
                 public boolean accept(SReference it) {
                   return SLinkOperations.findLinkDeclaration(it)
                       == SLinkOperations.findLinkDeclaration(
                           "jetbrains.mps.lang.smodelTests.structure.ReferenceContainer",
                           "rightChild");
                 }
               })
           .select(
               new ISelector<SReference, SNode>() {
                 public SNode select(SReference it) {
                   return SLinkOperations.getTargetNode(it);
                 }
               }));
   Assert.assertTrue(
       Sequence.fromIterable(
               SNodeOperations.getReferences(
                   SNodeOperations.cast(
                       this.getNodeById("2906110183022354866"),
                       "jetbrains.mps.lang.smodelTests.structure.ReferenceContainerSubConcept")))
           .where(
               new IWhereFilter<SReference>() {
                 public boolean accept(SReference it) {
                   return SLinkOperations.findLinkDeclaration(it)
                       == SLinkOperations.findLinkDeclaration(
                           "jetbrains.mps.lang.smodelTests.structure.ReferenceContainerSubConcept",
                           "specializedRightChild");
                 }
               })
           .isEmpty());
 }
 private static SReference getCheckingReference_id4IvydoGvimX(@NotNull SNode __thisNode__) {
   if (SLinkOperations.getTarget(
           __thisNode__,
           MetaAdapterFactory.getReferenceLink(
               0x8585453e6bfb4d80L,
               0x98deb16074f1d86cL,
               0x7181d929c720809L,
               0x4b9f88d62c795596L,
               "checkingReference"))
       == null) {
     return ((SNode) SNodeOperations.getParent(__thisNode__)).getReferences().iterator().next();
   }
   for (SReference reference :
       Sequence.fromIterable(
           SNodeOperations.getReferences(SNodeOperations.getParent(__thisNode__)))) {
     if (SLinkOperations.getTargetNode(reference)
         == SLinkOperations.getTarget(
             __thisNode__,
             MetaAdapterFactory.getReferenceLink(
                 0x8585453e6bfb4d80L,
                 0x98deb16074f1d86cL,
                 0x7181d929c720809L,
                 0x4b9f88d62c795596L,
                 "checkingReference"))) {
       return (jetbrains.mps.smodel.SReference) reference;
     }
   }
   return null;
 }
 public void test_roles() throws Exception {
   this.addNodeById("2906110183022219846");
   this.addNodeById("2906110183022219807");
   this.addNodeById("2906110183022219843");
   this.addNodeById("2906110183022354865");
   this.addNodeById("2906110183022432276");
   TestUtilities.assertEquals(
       Sequence.fromArray(
           new String[] {
             SPropertyOperations.getString(
                 SLinkOperations.findLinkDeclaration(
                     "jetbrains.mps.lang.smodelTests.structure.ReferenceContainer", "root"),
                 "role"),
             SPropertyOperations.getString(
                 SLinkOperations.findLinkDeclaration(
                     "jetbrains.mps.lang.smodelTests.structure.ReferenceContainer", "leftChild"),
                 "role"),
             SPropertyOperations.getString(
                 SLinkOperations.findLinkDeclaration(
                     "jetbrains.mps.lang.smodelTests.structure.ReferenceContainer",
                     "rightChild"),
                 "role")
           }),
       Sequence.fromIterable(
               SNodeOperations.getReferences(
                   SNodeOperations.cast(
                       this.getNodeById("2906110183022219844"),
                       "jetbrains.mps.lang.smodelTests.structure.ReferenceContainer")))
           .select(
               new ISelector<SReference, String>() {
                 public String select(SReference it) {
                   return SLinkOperations.getRole(it);
                 }
               }));
 }
 public void test_target() throws Exception {
   this.addNodeById("2906110183022219846");
   this.addNodeById("2906110183022219807");
   this.addNodeById("2906110183022219843");
   this.addNodeById("2906110183022354865");
   this.addNodeById("2906110183022432276");
   TestUtilities.assertEquals(
       Sequence.fromArray(
           new SNode[] {
             SNodeOperations.cast(
                 this.getNodeById("2906110183022219847"),
                 "jetbrains.mps.lang.smodelTests.structure.Root"),
             SNodeOperations.cast(
                 this.getNodeById("2906110183022219848"),
                 "jetbrains.mps.lang.smodelTests.structure.Child"),
             SNodeOperations.cast(
                 this.getNodeById("2906110183022311236"),
                 "jetbrains.mps.lang.smodelTests.structure.ChildSubConcept")
           }),
       Sequence.fromIterable(
               SNodeOperations.getReferences(
                   SNodeOperations.cast(
                       this.getNodeById("2906110183022219844"),
                       "jetbrains.mps.lang.smodelTests.structure.ReferenceContainer")))
           .select(
               new ISelector<SReference, SNode>() {
                 public SNode select(SReference it) {
                   return SLinkOperations.getTargetNode(it);
                 }
               }));
 }
Ejemplo n.º 6
0
 public static SReference call_getCheckingReference_5449224527592367549(SNode thisNode) {
   if (SLinkOperations.getTarget(
           thisNode,
           MetaAdapterFactory.getReferenceLink(
               0x8585453e6bfb4d80L,
               0x98deb16074f1d86cL,
               0x7181d929c720809L,
               0x4b9f88d62c795596L,
               "checkingReference"))
       == null) {
     return ((SNode) SNodeOperations.getParent(thisNode)).getReferences().iterator().next();
   }
   for (SReference reference :
       ListSequence.fromList(SNodeOperations.getReferences(SNodeOperations.getParent(thisNode)))) {
     if (SLinkOperations.getTargetNode(reference)
         == SLinkOperations.getTarget(
             thisNode,
             MetaAdapterFactory.getReferenceLink(
                 0x8585453e6bfb4d80L,
                 0x98deb16074f1d86cL,
                 0x7181d929c720809L,
                 0x4b9f88d62c795596L,
                 "checkingReference"))) {
       return (jetbrains.mps.smodel.SReference) reference;
     }
   }
   return null;
 }
Ejemplo n.º 7
0
 public static void fixImportsFromNode(SNode node) {
   for (SNode descendant :
       ListSequence.fromList(
           SNodeOperations.getDescendants(
               node, "jetbrains.mps.lang.core.structure.BaseConcept", false, new String[] {}))) {
     for (SReference reference :
         Sequence.fromIterable(SNodeOperations.getReferences(descendant))) {
       addNodeModelImportIfNeed(node, SLinkOperations.getTargetNode(reference));
     }
   }
 }
 public void test_size() throws Exception {
   this.addNodeById("2906110183022219846");
   this.addNodeById("2906110183022219807");
   this.addNodeById("2906110183022219843");
   this.addNodeById("2906110183022354865");
   this.addNodeById("2906110183022432276");
   Assert.assertTrue(
       Sequence.fromIterable(
               SNodeOperations.getReferences(
                   SNodeOperations.cast(
                       this.getNodeById("2906110183022219808"),
                       "jetbrains.mps.lang.smodelTests.structure.ReferenceContainer")))
           .isEmpty());
   Assert.assertEquals(
       3,
       Sequence.fromIterable(
               SNodeOperations.getReferences(
                   SNodeOperations.cast(
                       this.getNodeById("2906110183022219844"),
                       "jetbrains.mps.lang.smodelTests.structure.ReferenceContainer")))
           .count());
 }
 public void test_forNull() throws Exception {
   this.addNodeById("2906110183022219846");
   this.addNodeById("2906110183022219807");
   this.addNodeById("2906110183022219843");
   this.addNodeById("2906110183022354865");
   this.addNodeById("2906110183022432276");
   SNode nullNode = null;
   Assert.assertTrue(Sequence.fromIterable(SNodeOperations.getReferences(nullNode)).isEmpty());
   SReference nullReference = null;
   Assert.assertNull(SLinkOperations.findLinkDeclaration(nullReference));
   Assert.assertNull(SLinkOperations.getRole(nullReference));
   Assert.assertNull(SLinkOperations.getTargetNode(nullReference));
   Assert.assertNull(SLinkOperations.getResolveInfo(nullReference));
 }
 public void test_resolveInfo() throws Exception {
   this.addNodeById("2906110183022219846");
   this.addNodeById("2906110183022219807");
   this.addNodeById("2906110183022219843");
   this.addNodeById("2906110183022354865");
   this.addNodeById("2906110183022432276");
   // Resolving references by accessing .target node:
   Sequence.fromIterable(
           SNodeOperations.getReferences(
               SNodeOperations.cast(
                   this.getNodeById("2906110183022219844"),
                   "jetbrains.mps.lang.smodelTests.structure.ReferenceContainer")))
       .visitAll(
           new IVisitor<SReference>() {
             public void visit(SReference it) {
               SLinkOperations.getTargetNode(it);
             }
           });
   Sequence.fromIterable(
           SNodeOperations.getReferences(
               SNodeOperations.cast(
                   this.getNodeById("2906110183022219844"),
                   "jetbrains.mps.lang.smodelTests.structure.ReferenceContainer")))
       .select(
           new ISelector<SReference, String>() {
             public String select(SReference it) {
               return SLinkOperations.getResolveInfo(it);
             }
           })
       .visitAll(
           new IVisitor<String>() {
             public void visit(String it) {
               Assert.assertNotNull(it);
             }
           });
 }
Ejemplo n.º 11
0
 public static boolean call_isApplicable_5449224527592368025(
     SAbstractConcept thisConcept, SNode node) {
   return ListSequence.fromList(SNodeOperations.getReferences(node)).isNotEmpty()
       && (AttributeOperations.getAttribute(
               node,
               new IAttributeDescriptor.NodeAttribute(
                   MetaAdapterFactory.getConcept(
                       0x8585453e6bfb4d80L,
                       0x98deb16074f1d86cL,
                       0x7181d929c720809L,
                       "jetbrains.mps.lang.test.structure.ScopesTest")))
           == null)
       && !(SNodeOperations.isInstanceOf(
           node,
           MetaAdapterFactory.getConcept(
               0x8585453e6bfb4d80L,
               0x98deb16074f1d86cL,
               0x7181d929c720809L,
               "jetbrains.mps.lang.test.structure.ScopesTest")));
 }
Ejemplo n.º 12
0
 public ModelLinkMap build() {
   // build map based on already loaded model
   for (SNode node : myModel.nodes()) {
     addRoleLocation(ptr(node.getRoleLink()), node);
     addTypeLocation(ptr(SNodeOperations.getConceptDeclaration(node)), node);
     for (String prop : SetSequence.fromSet(node.getPropertyNames())) {
       addNameLocation(ptr(node.getPropertyDeclaration(prop)), node, prop);
     }
     for (SReference ref : Sequence.fromIterable(SNodeOperations.getReferences(node))) {
       addRoleLocation(ptr(SLinkOperations.findLinkDeclaration(ref)), ref);
       if ((SReference) ref instanceof StaticReference) {
         addTargetLocation(
             ptr(SLinkOperations.getTargetNode(ref)), (StaticReference) (SReference) ref);
       } else {
         addDynamicReference(ref.getTargetSModelReference(), (DynamicReference) (SReference) ref);
       }
     }
   }
   return this;
 }
 private static Boolean isApplicable_id4IvydoGviup(
     @NotNull SAbstractConcept __thisConcept__, SNode node) {
   return Sequence.fromIterable(SNodeOperations.getReferences(node)).isNotEmpty()
       && (AttributeOperations.getAttribute(
               node,
               new IAttributeDescriptor.NodeAttribute(
                   MetaAdapterFactory.getConcept(
                       0x8585453e6bfb4d80L,
                       0x98deb16074f1d86cL,
                       0x7181d929c720809L,
                       "jetbrains.mps.lang.test.structure.ScopesTest")))
           == null)
       && !(SNodeOperations.isInstanceOf(
           node,
           MetaAdapterFactory.getConcept(
               0x8585453e6bfb4d80L,
               0x98deb16074f1d86cL,
               0x7181d929c720809L,
               "jetbrains.mps.lang.test.structure.ScopesTest")));
 }
Ejemplo n.º 14
0
 protected void addNodeImports(SNode node) {
   final SModelInternal modelInternal = (SModelInternal) myModel;
   final AbstractModule module = ((AbstractModule) myModel.getModule());
   final Collection<SLanguage> importedLanguages = modelInternal.importedLanguageIds();
   for (SNode subNode :
       ListSequence.fromList(
           SNodeOperations.getNodeDescendants(node, null, true, new SAbstractConcept[] {}))) {
     SLanguage usedLanguage = subNode.getConcept().getLanguage();
     if (!(importedLanguages.contains(usedLanguage))) {
       modelInternal.addLanguage(usedLanguage);
     }
     for (SReference ref : ListSequence.fromList(SNodeOperations.getReferences(subNode))) {
       SModel usedModel = SNodeOperations.getModel(SLinkOperations.getTargetNode(ref));
       if (usedModel != null && !(modelInternal.importedModels().contains(usedModel))) {
         modelInternal.addModelImport(usedModel.getReference(), false);
         module.addDependency(
             SNodeOperations.getModel(SLinkOperations.getTargetNode(ref))
                 .getModule()
                 .getModuleReference(),
             false);
       }
     }
   }
 }
Ejemplo n.º 15
0
    @Override
    public List<SearchResult<ModelCheckerIssue>> checkModel(
        SModel model, ProgressMonitor monitor, SRepository repository) {
      List<SearchResult<ModelCheckerIssue>> results =
          ListSequence.fromList(new ArrayList<SearchResult<ModelCheckerIssue>>());

      monitor.start("adapter usages", 1);
      for (SNode node : ListSequence.fromList(SModelOperations.getNodes(model, null))) {
        if (monitor.isCanceled()) {
          break;
        }
        // Check for adapter references
        for (SReference ref : Sequence.fromIterable(SNodeOperations.getReferences(node))) {
          SModelReference targetSModelReference = ref.getTargetSModelReference();
          if (targetSModelReference != null
              && SModelStereotype.getStereotype(targetSModelReference.getModelName())
                  .equals("java_stub")) {
            SNode target = SLinkOperations.getTargetNode(ref);
            if ((target != null)
                && SNodeOperations.isInstanceOf(
                    target, "jetbrains.mps.baseLanguage.structure.ClassConcept")) {
              String qualifiedName =
                  BehaviorReflection.invokeVirtual(
                      String.class,
                      SNodeOperations.cast(
                          target, "jetbrains.mps.baseLanguage.structure.ClassConcept"),
                      "virtual_getFqName_1213877404258",
                      new Object[] {});
              if ("jetbrains.mps.smodel.INodeAdapter".equals(qualifiedName)
                  || "jetbrains.mps.smodel.BaseAdapter".equals(qualifiedName)) {
                SpecificChecker.addIssue(
                    results,
                    node,
                    "Reference to "
                        + qualifiedName
                        + " in role `"
                        + SLinkOperations.getRole(ref)
                        + "'",
                    ModelChecker.SEVERITY_ERROR,
                    "adapter class usage",
                    null);
              }

              if (SModelStereotype.withoutStereotype(targetSModelReference.getModelName())
                      .endsWith(".structure")
                  && SModelUtil.findConceptDeclaration(qualifiedName) != null) {
                SpecificChecker.addIssue(
                    results,
                    node,
                    "Using adapter of "
                        + qualifiedName
                        + " concept in role `"
                        + SLinkOperations.getRole(ref)
                        + "'",
                    ModelChecker.SEVERITY_ERROR,
                    "adapter class usage",
                    null);
              }
            }
          }
        }
      }
      monitor.done();
      return results;
    }
Ejemplo n.º 16
0
 public void checkNode(
     final SNode node,
     LanguageErrorsComponent component,
     final IOperationContext operationContext,
     IScope scope) {
   if (operationContext == null) {
     return;
   }
   if (SNodeUtil.getMetaLevel(node) != 0) {
     return;
   }
   SNode concept = SNodeOperations.getConceptDeclaration(node);
   for (SReference ref : SNodeOperations.getReferences(node)) {
     SNode target = SLinkOperations.getTargetNode(ref);
     SNode ld = SLinkOperations.findLinkDeclaration(ref);
     // don't check unresolved and broken references, they should already have an error message
     if ((target == null) || ld == null) {
       continue;
     }
     component.addDependency(target);
     component.addDependency(ld);
     component.addDependency(node);
     component.addDependency(SNodeOperations.getParent(node));
     for (SNode c : SNodeOperations.getChildren(node)) {
       component.addDependency(c);
     }
     String linkRole = SModelUtil.getGenuineLinkRole(ld);
     final SNode linkTarget = SLinkOperations.getTarget(ld, "target", false);
     final INodeReferentSearchScopeProvider scopeProvider =
         ModelConstraintsUtil.getSearchScopeProvider(concept, linkRole);
     SearchScopeStatus searchScopeStatus =
         component.runCheckingAction(
             new _FunctionTypes._return_P0_E0<SearchScopeStatus>() {
               public SearchScopeStatus invoke() {
                 return ModelConstraintsUtil.createSearchScope(
                     scopeProvider,
                     SNodeOperations.getModel(node),
                     SNodeOperations.getParent(node),
                     node,
                     linkTarget,
                     operationContext);
               }
             });
     if (searchScopeStatus.isError()) {
       component.addError(
           node,
           searchScopeStatus.getMessage(),
           (SNode) null,
           new ReferenceMessageTarget(SLinkOperations.getRole(ref)));
     } else if (!(searchScopeStatus.isDefault()
         || searchScopeStatus.getSearchScope().isInScope(target))) {
       String name = target.getName();
       component.addError(
           node,
           "reference"
               + ((name == null ? "" : " " + name))
               + " ("
               + SLinkOperations.getRole(ref)
               + ") is out of search scope",
           searchScopeStatus.getReferenceValidatorNode(),
           new ReferenceMessageTarget(SLinkOperations.getRole(ref)));
     }
   }
 }
Ejemplo n.º 17
0
 public static boolean isReference(SNode node) {
   return ListSequence.fromList(SNodeOperations.getChildren(node)).isEmpty()
       && Sequence.fromIterable(SNodeOperations.getReferences(node)).count() == 1;
 }
Ejemplo n.º 18
0
  @Override
  public List<SearchResult<ModelCheckerIssue>> checkModel(
      SModel model, ProgressMonitor monitor, final IOperationContext operationContext) {
    List<SearchResult<ModelCheckerIssue>> results =
        ListSequence.fromList(new ArrayList<SearchResult<ModelCheckerIssue>>());
    String title =
        "Checking " + SModelOperations.getModelName(model) + " for wrong aspect dependencies...";
    monitor.start(title, 1);

    int modelKind = getModelKind(model, null);
    if (modelKind == OTHER) {
      monitor.done();
      return results;
    }

    for (SNode node : ListSequence.fromList(SModelOperations.getNodes(model, null))) {
      if (monitor.isCanceled()) {
        break;
      }
      // Check for unresolved references
      for (final SReference ref : Sequence.fromIterable(SNodeOperations.getReferences(node))) {
        if ((AttributeOperations.getAttribute(
                node,
                new IAttributeDescriptor.LinkAttribute(
                    SConceptOperations.findConceptDeclaration(
                        "jetbrains.mps.lang.generator.structure.ReferenceMacro"),
                    SLinkOperations.getRole(ref)))
            != null)) {
          continue;
        }
        SNode targetNode = jetbrains.mps.util.SNodeOperations.getTargetNodeSilently(ref);
        if (targetNode == null) {
          addIssue(
              results,
              node,
              "Unresolved reference: " + SLinkOperations.getResolveInfo(ref),
              ModelChecker.SEVERITY_ERROR,
              "unresolved reference",
              new IModelCheckerFix() {
                public boolean doFix() {
                  return ResolverComponent.getInstance().resolve(ref, operationContext);
                }
              });
          continue;
        }

        SModel targetModel = SNodeOperations.getModel(targetNode);
        int targetKind = getModelKind(targetModel, ref);
        if (targetKind > modelKind) {
          addIssue(
              results,
              node,
              "Wrong reference: "
                  + SLinkOperations.getResolveInfo(ref)
                  + ", reference from "
                  + kindToString(modelKind)
                  + " to "
                  + kindToString(targetKind),
              ModelChecker.SEVERITY_ERROR,
              "wrong aspect dependency (" + kindToString(modelKind) + ")",
              null);
        }
      }
    }
    monitor.done();
    return results;
  }
 private static Boolean isSimple_id4IvydoGvpbr(
     @NotNull SAbstractConcept __thisConcept__, SNode node) {
   return Sequence.fromIterable(SNodeOperations.getReferences(node)).count() == 1;
 }
Ejemplo n.º 20
0
 public static boolean call_isSimple_5449224527592395483(
     SAbstractConcept thisConcept, SNode node) {
   return ListSequence.fromList(SNodeOperations.getReferences(node)).count() == 1;
 }
    public void test_unresolvedReference() throws Exception {
      this.addNodeById("2906110183022219846");
      this.addNodeById("2906110183022219807");
      this.addNodeById("2906110183022219843");
      this.addNodeById("2906110183022354865");
      this.addNodeById("2906110183022432276");
      SLinkOperations.getTarget(
          SNodeOperations.cast(
              this.getNodeById("2906110183022219844"),
              "jetbrains.mps.lang.smodelTests.structure.ReferenceContainer"),
          "root",
          false);
      SLinkOperations.getTarget(
          SNodeOperations.cast(
              this.getNodeById("2906110183022219844"),
              "jetbrains.mps.lang.smodelTests.structure.ReferenceContainer"),
          "leftChild",
          false);
      SLinkOperations.getTarget(
          SNodeOperations.cast(
              this.getNodeById("2906110183022219844"),
              "jetbrains.mps.lang.smodelTests.structure.ReferenceContainer"),
          "rightChild",
          false);

      SLinkOperations.getTarget(
          SNodeOperations.cast(
              this.getNodeById("2906110183022354866"),
              "jetbrains.mps.lang.smodelTests.structure.ReferenceContainerSubConcept"),
          "root",
          false);
      SLinkOperations.getTarget(
          SNodeOperations.cast(
              this.getNodeById("2906110183022354866"),
              "jetbrains.mps.lang.smodelTests.structure.ReferenceContainerSubConcept"),
          "leftChild",
          false);
      SLinkOperations.getTarget(
          SNodeOperations.cast(
              this.getNodeById("2906110183022354866"),
              "jetbrains.mps.lang.smodelTests.structure.ReferenceContainerSubConcept"),
          "rightChild",
          false);

      int initialSize =
          Sequence.fromIterable(
                  SNodeOperations.getReferences(
                      SNodeOperations.cast(
                          this.getNodeById("2906110183022432277"),
                          "jetbrains.mps.lang.smodelTests.structure.ReferenceContainer")))
              .count();
      Assert.assertTrue(
          Sequence.fromIterable(
                  SNodeOperations.getReferences(
                      SNodeOperations.cast(
                          this.getNodeById("2906110183022432277"),
                          "jetbrains.mps.lang.smodelTests.structure.ReferenceContainer")))
              .where(
                  new IWhereFilter<SReference>() {
                    public boolean accept(SReference it) {
                      return (SLinkOperations.getTargetNode(it) == null);
                    }
                  })
              .isEmpty());
      SLinkOperations.getTarget(
              SNodeOperations.cast(
                  this.getNodeById("2906110183022432277"),
                  "jetbrains.mps.lang.smodelTests.structure.ReferenceContainer"),
              "root",
              false)
          .delete();
      UnregisteredNodes.instance().clear();
      Assert.assertEquals(
          initialSize,
          Sequence.fromIterable(
                  SNodeOperations.getReferences(
                      SNodeOperations.cast(
                          this.getNodeById("2906110183022432277"),
                          "jetbrains.mps.lang.smodelTests.structure.ReferenceContainer")))
              .count());
      Iterable<SReference> brokenReferences =
          Sequence.fromIterable(
                  SNodeOperations.getReferences(
                      SNodeOperations.cast(
                          this.getNodeById("2906110183022432277"),
                          "jetbrains.mps.lang.smodelTests.structure.ReferenceContainer")))
              .where(
                  new IWhereFilter<SReference>() {
                    public boolean accept(SReference it) {
                      return jetbrains.mps.util.SNodeOperations.getTargetNodeSilently(it) == null;
                    }
                  });
      Assert.assertEquals(1, Sequence.fromIterable(brokenReferences).count());
      SReference theReference = Sequence.fromIterable(brokenReferences).first();
      Assert.assertEquals(
          SPropertyOperations.getString(
              SLinkOperations.findLinkDeclaration(
                  "jetbrains.mps.lang.smodelTests.structure.ReferenceContainer", "root"),
              "role"),
          SLinkOperations.getRole(theReference));
      Assert.assertEquals(
          SLinkOperations.findLinkDeclaration(
              "jetbrains.mps.lang.smodelTests.structure.ReferenceContainer", "root"),
          SLinkOperations.findLinkDeclaration(theReference));
      Assert.assertNotNull(SLinkOperations.getResolveInfo(theReference));
    }