5

I'm trying to use IntelliJ 10.5's "structural search" feature to find classes that implement an interface, A but do not implement another interface, B.

By searching first for classes that implement A, and then limiting the search scope to 'previous search results,' it's easy to reduce this to just searching for classes that do not implement B, which is conceptually pretty simple. Unfortunately, I haven't yet managed to pull it off.

If I search for

class $clazz$ implements $B$ {}

and then tick 'invert condition' in the text constraints for variable B, it seems to find 'all classes that implement something other than B' even if they also implement B. I've also tried ticking 'invert condition' on the 'complete match' variable, and its effect is not immediately obvious, but definitely not what I'm looking for.

Inicidentaly, someone else asked a similar question on the IntelliJ forums, but got no love. Help me out, stackoverflow!

4

1 に答える 1

3

InterfaceA を実装しているが InterfaceB を実装していないクラスを見つけるために、次のことを行いました。

  1. 検索 > 構造的に検索
  2. [既存のテンプレートをコピー] をクリックします
  3. インターフェイスの実装者を (階層内で)選択し、[ OK ] をクリックします。
  4. 変数の編集をクリックします
  5. 変数リストでインターフェイスを選択します
  6. テキスト/正規表現にInterfaceAと入力し、[ OK ] をクリックします。
  7. [検索] をクリックします
  8. 検索 > 構造的に検索
  9. 変数の編集をクリックします
  10. 変数リストでインターフェイスを選択します
  11. [テキスト/正規表現] にInterfaceB、 [最小数]に0、 [最大数]に0を入力し、[ OK ] をクリックします。
  12. [範囲] ドロップダウンで[以前の検索結果] を選択します
  13. [検索] をクリックします

手順 8 で [クエリの編集] ボタンを使用しようとしたときに問題が発生したことに注意してください。調査や再試行はしませんでしたが、メニューに戻って [検索] > [構造的に検索] を選択すると、間違いなく機能しました。

于 2011-07-11T23:15:50.027 に答える