Ejemplo n.º 1
0
 public static boolean findInModule(SModule module, String modelName, String rootName) {
   for (SModel d : module.getModels()) {
     if (d.getModelName().equals(modelName)) {
       for (SNode _n : d.getRootNodes()) {
         SNode n = (SNode) _n;
         if (SNodeOperations.isInstanceOf(n, "jetbrains.mps.baseLanguage.structure.Classifier")
             && SPropertyOperations.getString(
                     SNodeOperations.cast(n, "jetbrains.mps.baseLanguage.structure.Classifier"),
                     "name")
                 .equals(rootName)) {
           return true;
         }
       }
     }
   }
   return false;
 }
 public void applyRule(
     final SNode buildSolutionRunner,
     final TypeCheckingContext typeCheckingContext,
     IsApplicableStatus status) {
   final String className =
       BehaviorReflection.invokeVirtual(
           String.class,
           buildSolutionRunner,
           "virtual_getClassName_1350734474210951475",
           new Object[] {});
   final String methodName =
       BehaviorReflection.invokeVirtual(
           String.class,
           buildSolutionRunner,
           "virtual_getMethodName_1350734474210955274",
           new Object[] {});
   SModuleReference moduleReference =
       ModuleReference.parseReference(
           BuildMps_AbstractModule_Behavior.call_getModuleReference_4643216374596368935(
               SLinkOperations.getTarget(
                   buildSolutionRunner,
                   MetaAdapterFactory.getReferenceLink(
                       0x427a473d5177432cL,
                       0x9905bcbceb71b996L,
                       0x39ea87a41cc0827eL,
                       0x54b085b5945c6691L,
                       "solution"))));
   SModule module = GlobalScope.getInstance().resolve(moduleReference);
   if (module != null) {
     for (SModel m : module.getModels()) {
       if (SModelOperations.getModelName(m).equals(module.getModuleName())) {
         SNode classToRun =
             ListSequence.fromList(
                     SModelOperations.roots(
                         m,
                         MetaAdapterFactory.getConcept(
                             0xf3061a5392264cc5L,
                             0xa443f952ceaf5816L,
                             0xf8c108ca66L,
                             "jetbrains.mps.baseLanguage.structure.ClassConcept")))
                 .findFirst(
                     new IWhereFilter<SNode>() {
                       public boolean accept(SNode it) {
                         return SPropertyOperations.getString(
                                 it,
                                 MetaAdapterFactory.getProperty(
                                     0xceab519525ea4f22L,
                                     0x9b92103b95ca8c0cL,
                                     0x110396eaaa4L,
                                     0x110396ec041L,
                                     "name"))
                             .equals(className);
                       }
                     });
         if ((classToRun == null)) {
           continue;
         }
         SNode methodToRun =
             Sequence.fromIterable(
                     ClassConcept_Behavior.call_staticMethods_5292274854859435867(classToRun))
                 .findFirst(
                     new IWhereFilter<SNode>() {
                       public boolean accept(SNode it) {
                         return SPropertyOperations.getString(
                                     it,
                                     MetaAdapterFactory.getProperty(
                                         0xceab519525ea4f22L,
                                         0x9b92103b95ca8c0cL,
                                         0x110396eaaa4L,
                                         0x110396ec041L,
                                         "name"))
                                 .equals(methodName)
                             && SNodeOperations.isInstanceOf(
                                 SLinkOperations.getTarget(
                                     it,
                                     MetaAdapterFactory.getContainmentLink(
                                         0xf3061a5392264cc5L,
                                         0xa443f952ceaf5816L,
                                         0x112670d273fL,
                                         0x112670d886aL,
                                         "visibility")),
                                 MetaAdapterFactory.getConcept(
                                     0xf3061a5392264cc5L,
                                     0xa443f952ceaf5816L,
                                     0x10af9581ff1L,
                                     "jetbrains.mps.baseLanguage.structure.PublicVisibility"))
                             && ListSequence.fromList(
                                     SLinkOperations.getChildren(
                                         it,
                                         MetaAdapterFactory.getContainmentLink(
                                             0xf3061a5392264cc5L,
                                             0xa443f952ceaf5816L,
                                             0xf8cc56b1fcL,
                                             0xf8cc56b1feL,
                                             "parameter")))
                                 .isEmpty();
                       }
                     });
         if ((methodToRun != null)) {
           return;
         }
       }
     }
   }
   {
     MessageTarget errorTarget = new NodeMessageTarget();
     errorTarget = new ReferenceMessageTarget("solution");
     IErrorReporter _reporter_2309309498 =
         typeCheckingContext.reportTypeError(
             buildSolutionRunner,
             "Cannot find public static void "
                 + className
                 + "."
                 + methodName
                 + "() in "
                 + SPropertyOperations.getString(
                     SLinkOperations.getTarget(
                         buildSolutionRunner,
                         MetaAdapterFactory.getReferenceLink(
                             0x427a473d5177432cL,
                             0x9905bcbceb71b996L,
                             0x39ea87a41cc0827eL,
                             0x54b085b5945c6691L,
                             "solution")),
                     MetaAdapterFactory.getProperty(
                         0xceab519525ea4f22L,
                         0x9b92103b95ca8c0cL,
                         0x110396eaaa4L,
                         0x110396ec041L,
                         "name")),
             "r:6869e2b7-2b2d-443c-a462-ce5a9004892e(jetbrains.mps.build.mps.runner.typesystem)",
             "7415565752189086936",
             null,
             errorTarget);
   }
 }