Example #1
0
  private void processReference(String prefix, SReference ref, Consumer<SReference> consumer) {
    if (!(ref instanceof StaticReference)) return;
    SNodeId target = ref.getTargetNodeId();
    if (!(target instanceof Foreign)) return;

    String targetNodeIdStr = target.toString();

    boolean found = false;
    int idx = targetNodeIdStr.indexOf(prefix);

    while (idx >= 0) {
      if (idx == 0) {
        found = true;
        break;
      }

      char c = targetNodeIdStr.charAt(idx - 1);
      if (c == '.' || Character.isLetterOrDigit(c)) {
        idx = targetNodeIdStr.indexOf(prefix, idx + 1);
        continue;
      }

      found = true;
      break;
    }

    if (found) {
      consumer.consume(ref);
    }
  }
Example #2
0
  private static void assertReferenceEquals(
      String errorString, SReference expectedReference, SReference actualReference) {
    if (expectedReference == null) {
      assertNull(errorString, actualReference);
      return;
    }
    assertNotNull(errorString, actualReference);

    //    assertIdEqualsOrBothNull(errorString, expectedReference.getTargetNode(),
    // actualReference.getTargetNode());
    assertEquals(
        errorString,
        ((jetbrains.mps.smodel.SReference) expectedReference).getResolveInfo(),
        ((jetbrains.mps.smodel.SReference) actualReference).getResolveInfo());
    assertEquals(errorString, expectedReference.getRole(), actualReference.getRole());
    assertEquals(
        errorString, expectedReference.getTargetNodeId(), actualReference.getTargetNodeId());
  }