Ejemplo n.º 1
0
  public static boolean nodeSubstituteActionsBuilder_Precondition_Statement_7750890258733139493(
      final IOperationContext operationContext, final NodeSubstitutePreconditionContext _context) {
    if ((SNodeOperations.getAncestor(
            _context.getParentNode(),
            "jetbrains.mps.lang.typesystem.structure.InferenceRule",
            false,
            false)
        != null)) {
      return true;
    }

    SNode method =
        SNodeOperations.getAncestor(
            _context.getParentNode(),
            "jetbrains.mps.baseLanguage.structure.BaseMethodDeclaration",
            false,
            false);
    if ((method != null)
        && BaseMethodDeclaration_Behavior.call_hasAnnotation_5499146221535822693(
            method,
            SNodeOperations.getNode(
                "r:00000000-0000-4000-0000-011c895902b5(jetbrains.mps.lang.typesystem.dependencies)",
                "1196177069451"))) {
      return true;
    }
    return false;
  }
 public void applyRule(
     final SNode method,
     final TypeCheckingContext typeCheckingContext,
     IsApplicableStatus status) {
   SNode superMethod =
       BehaviorReflection.invokeVirtual(
           (Class<SNode>) ((Class) Object.class),
           method,
           "virtual_getNearestOverriddenMethod_5358895268254685434",
           new Object[] {});
   if ((superMethod == null)) {
     return;
   }
   if (BaseMethodDeclaration_Behavior.call_hasAnnotation_5499146221535822693(
       superMethod,
       SNodeOperations.getNode(
           "3f233e7f-b8a6-46d2-a57f-795d56775243/java:org.jetbrains.annotations(Annotations/)",
           "~NotNull"))) {
     if (!(BaseMethodDeclaration_Behavior.call_hasAnnotation_5499146221535822693(
         method,
         SNodeOperations.getNode(
             "3f233e7f-b8a6-46d2-a57f-795d56775243/java:org.jetbrains.annotations(Annotations/)",
             "~NotNull")))) {
       {
         MessageTarget errorTarget = new NodeMessageTarget();
         IErrorReporter _reporter_2309309498 =
             typeCheckingContext.reportTypeError(
                 method,
                 "This method must have @NotNull annotation",
                 "r:00000000-0000-4000-0000-011c895902c5(jetbrains.mps.baseLanguage.typesystem)",
                 "5499146221535829680",
                 null,
                 errorTarget);
         {
           BaseQuickFixProvider intentionProvider =
               new BaseQuickFixProvider(
                   "jetbrains.mps.baseLanguage.typesystem.Add_NotNullAnnotation_QuickFix", false);
           intentionProvider.putArgument("method", method);
           _reporter_2309309498.addIntentionProvider(intentionProvider);
         }
       }
     }
   }
   for (int i = 0;
       i
           < ListSequence.fromList(
                   SLinkOperations.getChildren(
                       superMethod,
                       MetaAdapterFactory.getContainmentLink(
                           0xf3061a5392264cc5L,
                           0xa443f952ceaf5816L,
                           0xf8cc56b1fcL,
                           0xf8cc56b1feL,
                           "parameter")))
               .count();
       i++) {
     if (ParameterDeclaration_Behavior.call_hasAnnotation_5499146221535981742(
         ListSequence.fromList(
                 SLinkOperations.getChildren(
                     superMethod,
                     MetaAdapterFactory.getContainmentLink(
                         0xf3061a5392264cc5L,
                         0xa443f952ceaf5816L,
                         0xf8cc56b1fcL,
                         0xf8cc56b1feL,
                         "parameter")))
             .getElement(i),
         SNodeOperations.getNode(
             "3f233e7f-b8a6-46d2-a57f-795d56775243/java:org.jetbrains.annotations(Annotations/)",
             "~Nullable"))) {
       SNode param =
           ListSequence.fromList(
                   SLinkOperations.getChildren(
                       method,
                       MetaAdapterFactory.getContainmentLink(
                           0xf3061a5392264cc5L,
                           0xa443f952ceaf5816L,
                           0xf8cc56b1fcL,
                           0xf8cc56b1feL,
                           "parameter")))
               .getElement(i);
       if (param != null
           && !(ParameterDeclaration_Behavior.call_hasAnnotation_5499146221535981742(
               param,
               SNodeOperations.getNode(
                   "3f233e7f-b8a6-46d2-a57f-795d56775243/java:org.jetbrains.annotations(Annotations/)",
                   "~Nullable")))) {
         {
           MessageTarget errorTarget = new NodeMessageTarget();
           IErrorReporter _reporter_2309309498 =
               typeCheckingContext.reportTypeError(
                   param,
                   "This parameter must have @Nullable annotation",
                   "r:00000000-0000-4000-0000-011c895902c5(jetbrains.mps.baseLanguage.typesystem)",
                   "5499146221535981784",
                   null,
                   errorTarget);
           {
             BaseQuickFixProvider intentionProvider =
                 new BaseQuickFixProvider(
                     "jetbrains.mps.baseLanguage.typesystem.Add_NullableAnnotationToParameter_QuickFix",
                     false);
             intentionProvider.putArgument("parameter", param);
             _reporter_2309309498.addIntentionProvider(intentionProvider);
           }
         }
       }
     }
   }
 }