Actions

Actions are then used to be able to make automated changes to the code that was matched by the search.

applyIf

Provides a way to only execute this fix action if a condition passes. Whole fix declarations may also have conditions using availableIf.

Warning

If none of the actions in a single fix pass their condition, the fix will still be available in the context menu, but it won't do anything when applied. To hide a fix completely, use availableIf.

markedElement

With markedElement, the condition will be checked against the element that matched the search part of the recipe.

 search:
   methodcall:
     type: SerializerA
     name: doSerialize
 availableFixes:
 - name: Use SerializerB instead
   actions:
   - rewrite:
       to: new SerializerB({{{arguments.0}}}).includeNulls().serialize()
       applyIf:
         markedElement:
           is:
             methodcall:
               args:
                 2:
                   value:
                     stringified: "true"
   - rewrite:
       to: new SerializerB({{{arguments.0}}}).serialize()
       applyIf:
         markedElement:
           is:
             methodcall:
               args:
                 2:
                   value:
                     stringified: "false"
-     SerializerA.doSerialize(object, false);
+     new SerializerB(object).serialize();

-     SerializerA.doSerialize(object, true);
+     new SerializerB(object).includeNulls().serialize();

followedByElement

Similar to markedElement, but here the condition is checked against the "followed by" element.

label

Similar to markedElement, but here the condition is checked against the element with the associated label.