Ejemplo n.º 1
0
  protected void applyTransormMigration(
      SNode origin,
      Computable<SNode> migration,
      _FunctionTypes._void_P2_E0<? super SNode, ? super SNode> postprocess) {
    MigrationScriptBase.SNodePlacePointer pointer = createSNodePlacePointer(origin);
    List<SNode> descendants =
        SNodeOperations.getNodeDescendants(origin, null, true, new SAbstractConcept[] {});

    SNode migrated = migration.compute();

    if (postprocess != null) {
      postprocess.invoke(origin, migrated);
    }

    if (migrated == null) {
      // origin should be removed
      pointer.remove();
    } else {
      if (!(ListSequence.fromList(descendants).contains(migrated))
          && migrated instanceof jetbrains.mps.smodel.SNode) {
        // returned value is new created node
        if (!(ListSequence.fromList(SNodeOperations.getNodeAncestors(origin, null, false))
            .contains(migrated))) {
          // origin is not keeped
          ((jetbrains.mps.smodel.SNode) migrated).setId(origin.getNodeId());
        }
      }
      pointer.insertOrReplace(migrated);
    }
  }
Ejemplo n.º 2
0
 public static SNode topClassifier(@NotNull SNode node) {
   return ListSequence.fromList(
           SNodeOperations.getNodeAncestors(
               node,
               MetaAdapterFactory.getConcept(
                   0xf3061a5392264cc5L,
                   0xa443f952ceaf5816L,
                   0x101d9d3ca30L,
                   "jetbrains.mps.baseLanguage.structure.Classifier"),
               true))
       .last();
 }
Ejemplo n.º 3
0
 public static int virtual_getMetaLevel_3981318653438234726(SNode thisNode) {
   if (jetbrains.mps.util.SNodeOperations.isRoot(thisNode)) {
     return 0;
   }
   int metalevel = 0;
   for (SNode metaLevelChanger :
       SNodeOperations.getNodeAncestors(
           thisNode,
           MetaAdapterFactory.getInterfaceConcept(
               0xceab519525ea4f22L,
               0x9b92103b95ca8c0cL,
               0x2cc012b1584bd3aL,
               "jetbrains.mps.lang.core.structure.IMetaLevelChanger"),
           false)) {
     metalevel +=
         BehaviorReflection.invokeVirtual(
             Integer.TYPE,
             metaLevelChanger,
             "virtual_getMetaLevelChange_201537367881074474",
             new Object[] {});
   }
   return metalevel;
 }
Ejemplo n.º 4
0
 private static boolean isClassifierAccessible(
     @NotNull SNode context, @Nullable SNode classifier) {
   //  check "static" accessibility here
   if ((classifier == null)) {
     return true;
   }
   if (SNodeOperations.isInstanceOf(
       SLinkOperations.getTarget(
           classifier,
           MetaAdapterFactory.getContainmentLink(
               0xf3061a5392264cc5L,
               0xa443f952ceaf5816L,
               0x112670d273fL,
               0x112670d886aL,
               "visibility")),
       MetaAdapterFactory.getConcept(
           0xf3061a5392264cc5L,
           0xa443f952ceaf5816L,
           0x10af9586f0cL,
           "jetbrains.mps.baseLanguage.structure.PrivateVisibility"))) {
     return topClassifier(context) == topClassifier(classifier);
   }
   SNode parent =
       SNodeOperations.getNodeAncestor(
           classifier,
           MetaAdapterFactory.getConcept(
               0xf3061a5392264cc5L,
               0xa443f952ceaf5816L,
               0x101d9d3ca30L,
               "jetbrains.mps.baseLanguage.structure.Classifier"),
           false,
           false);
   if (!(isClassifierAccessible(context, parent))) {
     return false;
   }
   if (SNodeOperations.isInstanceOf(
           SLinkOperations.getTarget(
               classifier,
               MetaAdapterFactory.getContainmentLink(
                   0xf3061a5392264cc5L,
                   0xa443f952ceaf5816L,
                   0x112670d273fL,
                   0x112670d886aL,
                   "visibility")),
           MetaAdapterFactory.getConcept(
               0xf3061a5392264cc5L,
               0xa443f952ceaf5816L,
               0x10af9581ff1L,
               "jetbrains.mps.baseLanguage.structure.PublicVisibility"))
       || packageName(context).equals(packageName(classifier))) {
     return true;
   }
   if (SNodeOperations.isInstanceOf(
       SLinkOperations.getTarget(
           classifier,
           MetaAdapterFactory.getContainmentLink(
               0xf3061a5392264cc5L,
               0xa443f952ceaf5816L,
               0x112670d273fL,
               0x112670d886aL,
               "visibility")),
       MetaAdapterFactory.getConcept(
           0xf3061a5392264cc5L,
           0xa443f952ceaf5816L,
           0x10af958b686L,
           "jetbrains.mps.baseLanguage.structure.ProtectedVisibility"))) {
     // parent cannot be null here
     for (SNode cls :
         ListSequence.fromList(
             SNodeOperations.getNodeAncestors(
                 context,
                 MetaAdapterFactory.getConcept(
                     0xf3061a5392264cc5L,
                     0xa443f952ceaf5816L,
                     0x101d9d3ca30L,
                     "jetbrains.mps.baseLanguage.structure.Classifier"),
                 true))) {
       if (BaseLanguageUtil.isAssignable(cls, parent) && isClassifierAccessible(context, parent)) {
         return true;
       }
     }
   }
   return false;
 }
Ejemplo n.º 5
0
 public static boolean isVisible(@NotNull SNode context, @NotNull SNode name) {
   // only check visibility of the name, accessibility of qualifier and if the name is member is
   // not checked here
   if (SNodeOperations.isInstanceOf(
       name,
       MetaAdapterFactory.getConcept(
           0xf3061a5392264cc5L,
           0xa443f952ceaf5816L,
           0x101d9d3ca30L,
           "jetbrains.mps.baseLanguage.structure.Classifier"))) {
     return isClassifierAccessible(
         context,
         SNodeOperations.cast(
             name,
             MetaAdapterFactory.getConcept(
                 0xf3061a5392264cc5L,
                 0xa443f952ceaf5816L,
                 0x101d9d3ca30L,
                 "jetbrains.mps.baseLanguage.structure.Classifier")));
   }
   if (SNodeOperations.isInstanceOf(
       SNodeOperations.getParent(name),
       MetaAdapterFactory.getConcept(
           0xf3061a5392264cc5L,
           0xa443f952ceaf5816L,
           0x101edd46144L,
           "jetbrains.mps.baseLanguage.structure.Interface"))) {
     return true;
   }
   if (SNodeOperations.isInstanceOf(
           SLinkOperations.getTarget(
               name,
               MetaAdapterFactory.getContainmentLink(
                   0xf3061a5392264cc5L,
                   0xa443f952ceaf5816L,
                   0x112670d273fL,
                   0x112670d886aL,
                   "visibility")),
           MetaAdapterFactory.getConcept(
               0xf3061a5392264cc5L,
               0xa443f952ceaf5816L,
               0x10af9581ff1L,
               "jetbrains.mps.baseLanguage.structure.PublicVisibility"))
       || SNodeOperations.isInstanceOf(
           name,
           MetaAdapterFactory.getConcept(
               0xf3061a5392264cc5L,
               0xa443f952ceaf5816L,
               0xfc367388b3L,
               "jetbrains.mps.baseLanguage.structure.EnumConstantDeclaration"))) {
     return true;
   }
   if (SNodeOperations.isInstanceOf(
       SLinkOperations.getTarget(
           name,
           MetaAdapterFactory.getContainmentLink(
               0xf3061a5392264cc5L,
               0xa443f952ceaf5816L,
               0x112670d273fL,
               0x112670d886aL,
               "visibility")),
       MetaAdapterFactory.getConcept(
           0xf3061a5392264cc5L,
           0xa443f952ceaf5816L,
           0x10af9586f0cL,
           "jetbrains.mps.baseLanguage.structure.PrivateVisibility"))) {
     return topClassifier(context) == topClassifier(name);
   }
   // package or protected access
   if (packageName(context).equals(packageName(name))) {
     return true;
   }
   if (SNodeOperations.isInstanceOf(
       SLinkOperations.getTarget(
           name,
           MetaAdapterFactory.getContainmentLink(
               0xf3061a5392264cc5L,
               0xa443f952ceaf5816L,
               0x112670d273fL,
               0x112670d886aL,
               "visibility")),
       MetaAdapterFactory.getConcept(
           0xf3061a5392264cc5L,
           0xa443f952ceaf5816L,
           0x10af958b686L,
           "jetbrains.mps.baseLanguage.structure.ProtectedVisibility"))) {
     //  check special cases of protected access
     SNode classifier =
         SNodeOperations.getNodeAncestor(
             name,
             MetaAdapterFactory.getConcept(
                 0xf3061a5392264cc5L,
                 0xa443f952ceaf5816L,
                 0x101d9d3ca30L,
                 "jetbrains.mps.baseLanguage.structure.Classifier"),
             false,
             false);
     for (SNode cls :
         ListSequence.fromList(
             SNodeOperations.getNodeAncestors(
                 context,
                 MetaAdapterFactory.getConcept(
                     0xf3061a5392264cc5L,
                     0xa443f952ceaf5816L,
                     0x101d9d3ca30L,
                     "jetbrains.mps.baseLanguage.structure.Classifier"),
                 true))) {
       if (BaseLanguageUtil.isAssignable(cls, classifier)) {
         if (SNodeOperations.isInstanceOf(
                     name,
                     MetaAdapterFactory.getConcept(
                         0xf3061a5392264cc5L,
                         0xa443f952ceaf5816L,
                         0xf8c108ca68L,
                         "jetbrains.mps.baseLanguage.structure.FieldDeclaration"))
                 && SNodeOperations.isInstanceOf(
                     context,
                     MetaAdapterFactory.getConcept(
                         0xf3061a5392264cc5L,
                         0xa443f952ceaf5816L,
                         0x116b483d77aL,
                         "jetbrains.mps.baseLanguage.structure.FieldReferenceOperation"))
             || SNodeOperations.isInstanceOf(
                     name,
                     MetaAdapterFactory.getConcept(
                         0xf3061a5392264cc5L,
                         0xa443f952ceaf5816L,
                         0xf8cc56b21dL,
                         "jetbrains.mps.baseLanguage.structure.InstanceMethodDeclaration"))
                 && SNodeOperations.isInstanceOf(
                     context,
                     MetaAdapterFactory.getConcept(
                         0xf3061a5392264cc5L,
                         0xa443f952ceaf5816L,
                         0x118154a6332L,
                         "jetbrains.mps.baseLanguage.structure.InstanceMethodCallOperation"))) {
           // check ExpressionName or PrimaryExpression is subclass of cls, works only with right
           // context
           //  will not work in the case: otherClass.method(protectedMethod()) with enclosed node
           // as context
           if (TypeChecker.getInstance()
               .getSubtypingManager()
               .isSubtype(
                   ((SNode)
                       BHReflection.invoke(
                           SNodeOperations.cast(
                               SNodeOperations.getParent(context),
                               MetaAdapterFactory.getConcept(
                                   0xf3061a5392264cc5L,
                                   0xa443f952ceaf5816L,
                                   0x116b46a08c4L,
                                   "jetbrains.mps.baseLanguage.structure.DotExpression")),
                           SMethodTrimmedId.create(
                               "getOperandType",
                               MetaAdapterFactory.getConcept(
                                   0xf3061a5392264cc5L,
                                   0xa443f952ceaf5816L,
                                   0x116b46a08c4L,
                                   "jetbrains.mps.baseLanguage.structure.DotExpression"),
                               "7GulAc9z0dN"))),
                   _quotation_createNode_v8uv56_b0a2a0a0a2a7a1(cls))) {
             return true;
           }
         } else if (SNodeOperations.isInstanceOf(
             name,
             MetaAdapterFactory.getConcept(
                 0xf3061a5392264cc5L,
                 0xa443f952ceaf5816L,
                 0xf8cc56b204L,
                 "jetbrains.mps.baseLanguage.structure.ConstructorDeclaration"))) {
           // check it is superclass constructor invocation or anonymous class instance creation
           return SNodeOperations.isInstanceOf(
                   context,
                   MetaAdapterFactory.getConcept(
                       0xf3061a5392264cc5L,
                       0xa443f952ceaf5816L,
                       0xf93d512e1eL,
                       "jetbrains.mps.baseLanguage.structure.SuperConstructorInvocation"))
               || SNodeOperations.isInstanceOf(
                   context,
                   MetaAdapterFactory.getConcept(
                       0xf3061a5392264cc5L,
                       0xa443f952ceaf5816L,
                       0x1107e0cb103L,
                       "jetbrains.mps.baseLanguage.structure.AnonymousClass"))
               || SNodeOperations.isInstanceOf(
                   context,
                   MetaAdapterFactory.getConcept(
                       0xf3061a5392264cc5L,
                       0xa443f952ceaf5816L,
                       0x1133e3b449aL,
                       "jetbrains.mps.baseLanguage.structure.AnonymousClassCreator"));
         } else {
           return true;
         }
       }
     }
   }
   return false;
 }
Ejemplo n.º 6
0
 public void addError(SNode node, String errorString, @Nullable SNodeReference ruleNode) {
   for (SNode anc : ListSequence.fromList(SNodeOperations.getNodeAncestors(node, null, false))) {
     addDependency(anc);
   }
   addError(node, errorString, ruleNode, new NodeMessageTarget());
 }
Ejemplo n.º 7
0
 protected void adjustMigratedIds(SNode node, SNode migrated) {
   if (!(ListSequence.fromList(SNodeOperations.getNodeAncestors(node, null, false))
       .contains(migrated))) {
     ((jetbrains.mps.smodel.SNode) migrated).setId(node.getNodeId());
   }
 }