Since my last build upgrade, the syntax highlighting in my DAOs is not working anymore.
My expectation (and experience) is, that there is syntax highlighting in the queries and once the database inspector is running, there is also a button on the left side, which executes the SQL statement on the running database. I don't know, why this happened. The only thing I did, was run recommended upgrades for my build gradles. Also, reverting these changes did not improve the situation.
At least in regards to syntax highlighting I found a solution:
However, that still does not resolve the problem of "Quick running" the sql statement in the database inspector.
Also to note here, I tried already this: How to highlight SQL syntax of Room Dao in Android Studio, which did not work. In my case, there is no listing for "Android Room SQL", but only "Room SQL".
Any ideas?
Auto highlighting still doesn't work with:
Android Studio Electric Eel | 2022.1.1 Build #AI-221.6008.13.2211.9477386, built on January 11, 2023
and
room: 2.5.0
in kotlin @Dao class.
So, as said here, you should:
Go to Settings > Editor > Language Injections
Add a new injection of type "Generic Kotlin"
Choose "RoomSQL" as the ID for the injection.
Add the following for the "Places Patterns":
+ kotlinParameter().ofFunction(0, kotlinFunction().withName("Query").definedInClass("androidx.room.Query"))
+ kotlinParameter().ofFunction(0, kotlinFunction().withName("DatabaseView").definedInClass("androidx.room.DatabaseView"))
And injection works fine!