IntelliJのStructural Replaceでfor文をforEachに置き換えてみた。 メニューのEdit -> Find -> Replace Structurally...で、「Structural Replace」を開く。 置き換え前、置き換え後のテンプレートには以下を設定する。 Search template for ($type$ $var$ : $collection$) { $body$; } Edit Variablesから以下の設定を行う。 $collection$ Text/regexp for java expression typeに「java.lang.Iterable」を設定する。 Apply constraint within type hierarchyのチェックをオンにする。 $body$ Minimum countに「0」を設定する。 unl