3
4

More than 1 year has passed since last update.

Android Studio Electric EelとRoom 2.5.0でSQLのハイライトが適用されないのを回避する

Last updated at Posted at 2023-01-25

Android Studio Electric Eel と Room 2.5.0 の組み合わせで @Query に書いている SQL のハイライトがなくなり、コードジャンプも使えない現象が発生します。

ハイライトが適用されていない Query

この問題の回避策を書いておきます。

回避策

「Android Studio」 → 「Settings」 を開き、「Editor」 → 「Language Injections」 を開く

スクリーンショット 2023-01-25 11.05.58.png

+ ボタンから 「Generic Kotlin」 を選択し、「Name」 には任意の名前、「ID」 には 「RoomSql」、「Places Patterns」 には以下の内容を入力する。

+ kotlinParameter().ofFunction(0, kotlinFunction().withName("Query").definedInClass("androidx.room.Query"))
+ kotlinParameter().ofFunction(0, kotlinFunction().withName("DatabaseView").definedInClass("androidx.room.DatabaseView"))

スクリーンショット 2023-01-25 11.09.05.png

最後に追加した内容を適用すると Room の @Query に書かれている SQL にハイライトやコードジャンプが復活する。

スクリーンショット 2023-01-25 11.11.23.png


別の回避策として Android Studio Flamingo を使うという手もあります。
(Electric Eel に修正パッチが来るかは不明)

参考

3
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
4