コード例 #1
0
ファイル: RuleMethodCall.java プロジェクト: lilongthinker/MPS
 public void performActions(Program o, SNode node) {
   SNode m = node;
   SNode targetNode = node;
   while (SNodeOperations.isInstanceOf(
           SNodeOperations.getParent(targetNode),
           "jetbrains.mps.baseLanguage.structure.DotExpression")
       && SLinkOperations.getTarget(
               SNodeOperations.cast(
                   SNodeOperations.getParent(targetNode),
                   "jetbrains.mps.baseLanguage.structure.DotExpression"),
               "operation",
               true)
           == targetNode) {
     targetNode = SNodeOperations.getParent(targetNode);
   }
   if (SLinkOperations.getTargets(
           SLinkOperations.getTarget(m, "baseMethodDeclaration", false), "annotation", true)
       != null) {
     for (SNode annotation :
         SLinkOperations.getTargets(
             SLinkOperations.getTarget(m, "baseMethodDeclaration", false), "annotation", true)) {
       if (SLinkOperations.getTarget(annotation, "annotation", false)
           == SNodeOperations.getNode(
               "f:java_stub#3f233e7f-b8a6-46d2-a57f-795d56775243#org.jetbrains.annotations(Annotations/org.jetbrains.annotations@java_stub)",
               "~Nullable")) {
         {
           Object object = node;
           if (((Program) o).contains(object)) {
             boolean before = false;
             int position = ((Program) (o)).getEnd(object);
             Instruction instruction = new nullableInstruction(targetNode);
             instruction.setSource(node);
             ((Program) (o)).insert(instruction, position, true, before);
           }
         }
       }
       if (SLinkOperations.getTarget(annotation, "annotation", false)
           == SNodeOperations.getNode(
               "f:java_stub#3f233e7f-b8a6-46d2-a57f-795d56775243#org.jetbrains.annotations(Annotations/org.jetbrains.annotations@java_stub)",
               "~NotNull")) {
         {
           Object object = node;
           if (((Program) o).contains(object)) {
             boolean before = false;
             int position = ((Program) (o)).getEnd(object);
             Instruction instruction = new notNullInstruction(targetNode);
             instruction.setSource(node);
             ((Program) (o)).insert(instruction, position, true, before);
           }
         }
       }
     }
   }
 }
コード例 #2
0
 public void performActions(Object o) {
   {
     Object object = getFieldValue("patternVar_action_var_5730083271929373007");
     if (((Program) o).contains(object)) {
       boolean before = false;
       int position;
       if (before) {
         position = ((Program) (o)).getStart(object);
       } else {
         position = ((Program) (o)).getEnd(object);
       }
       Instruction instruction = new notNullInstruction((SNode) getFieldValue("patternVar_p"));
       instruction.setRuleReference(
           "r:00000000-0000-4000-0000-011c895902c2(jetbrains.mps.baseLanguage.dataFlow)/1490803006783710006");
       instruction.setSource(getFieldValue("patternVar_action_var_5730083271929373007"));
       ((Program) (o)).insert(instruction, position, true, before);
     }
   }
 }