Actions ======= .. include:: /ref/actions_summary.txt .. toctree:: :titlesonly: actions/addfield actions/addmethod actions/changeannotation actions/changemodifiers actions/changename actions/findandreplace actions/goto actions/insertstatement actions/modifyassignedvariable actions/parameterize actions/rewrite .. contents:: .. _actions_applyIf: applyIf ------- Provides a way to only execute this fix action if a condition passes. Whole fix declarations may also have conditions using :ref:`fixes_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 :ref:`fixes_availableIf`. markedElement ~~~~~~~~~~~~~ With ``markedElement``, the condition will be checked against the element that matched the search part of the recipe. .. code-block:: yaml :emphasize-lines: 9,10,18,19 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" .. code-block:: diff - 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.