Android Studio 尋找宣告

尋找符號的宣告。

用量

android studio find-declaration [-h] [--context-file=PARAM] [--pid=PARAM] [--project=PARAM] [--short] <symbol>

選項

  • --context-file=PARAM - 檔案的選用路徑,內含符號的參照,相對於目前目錄或絕對路徑。
  • -h,--help:顯示指定指令的說明訊息。
  • --pid=PARAM:要連線的 Android Studio 執行個體 PID。
  • --project=PARAM - 在 Android Studio 中開啟要查詢的專案名稱或路徑。使用 android studio check 取得可用專案的名稱。
  • --short:只顯示檔案中相符的位置。

android 選項:

  • --sdk=PARAM - Android SDK 的路徑。
  • -v,--verbose - 啟用詳細輸出功能以利疑難排解。
  • -V,--version - 列印版本資訊並結束。

位置引數

  • <symbol> - 要尋找宣告的符號。

說明

android studio find-declaration 會使用 Android Studio 的語意索引,在開啟的專案中找出符號 (類別、方法、函式、屬性、欄位、常數或 Android 資源) 的確切宣告位置。

須使用 Android Studio Quail 2 以上版本。

如果多個符號在模組或套件中共用相同名稱,請傳遞 --context-file=<path>,指向參照符號的來源檔案,讓 Android Studio 可以使用該檔案的匯入項目和範圍解析符號。傳遞 --short,只輸出相符的檔案路徑和行號。

範例

以精簡格式找出 HotelDetailScreen 的聲明:

android studio find-declaration --short HotelDetailScreen

使用結構定義檔案找出宣告,消除匯入項目的歧義:

android studio find-declaration --context-file=app/src/main/java/com/example/myapp/MainActivity.kt HotelDetailScreen