Status Update
Comments
cc...@google.com <cc...@google.com> #2
Reproduces for me as well on:
Android Studio Ladybug Feature Drop | 2024.2.2 Canary 6
Build #AI-242.23339.11.2422.12480590, built on October 10, 2024
Runtime version: 21.0.4+-12422083-b607.1 amd64
VM: OpenJDK 64-Bit Server VM by JetBrains s.r.o.
Toolkit: sun.awt.X11.XToolkit
Linux 6.9.10-1rodete5-amd64
Kotlin analyzer version: 2.0.20-ij242-38
GC: G1 Young Generation, G1 Concurrent GC, G1 Old Generation
Memory: 8192M
Cores: 20
Registry:
ide.experimental.ui=true
i18n.locale=
profiler.trace.open.mode.web=true
Current Desktop: GNOME
Looks like this is a known intellij issue (
Note that this doesn't affect Room because Room puts sql in annotations like @Query()
which appears to have separate Studio handling.
an...@google.com <an...@google.com> #3
I'm not sure this is the same thing as the YouTrack issue linked above. I can repro this trivially in Android Studio:
fun query(@Language("sql") query: String) { TODO() }
fun callQuery() {
query("SELECT * FROM foo")
}
In the above snippet, there will be a syntax error. The same does not happen in IDEA; that's usually a good clue that it's something we're doing differently in AS code. I'll take a look.
an...@google.com <an...@google.com> #4
This issue is not specifically related to SQL. The language "sql"
is not supported in Android Studio, and the same bug will happen for any unrecognized language:
fun query(@Language("asdcasdcasdcads") query: String) { TODO() }
fun callQuery() {
query("SELECT * FROM foo")
}
The above shows the string as a syntax error, when in reality we should just be displaying it as a normal string without any syntax highlighting. (Note that the language we do support can be annotated with "RoomSql"
.)
This is happening because of DeviceSpecInjector.kt
DeviceSpecLanguage
as a default when the language is unknown. I'm unfamiliar with what that's meant to do, but I've validated that if I remove that default and replace it with a return false
(indicating that injection was not done), then everything works as expected.
DeviceSpecLanguage
seems to be intended for use only with the @Preview
parameter, if I'm reading it correctly; but I may have misinterpreted the intent of the class. Either way, I'm redirecting this bug to the team that owns it, so that they can scope the logic more appropriately.
di...@google.com <di...@google.com>
le...@google.com <le...@google.com>
cc...@google.com <cc...@google.com> #5
This appears to have regressed in Iguana.
We added the @Language("sql") API functionality in macrobench in this change:
So as of March 6 last year, it was working as I developed that change. I tried a few versions of Studio to narrow this regression down:
- Electric eel (not working, presumably not supported yet)
- Flamingo (works in basic way, see 1st screenshot) - I expect AndroidX would have been on a Flamingo canary when I added the annotation
- Giraffe (works)
- Hedgehog (works better, see 2nd screenshot which now highlights the table name as a standard identifier)
- Iguana (broken in current way, see 3rd screenshot)
I tested by creating a trivial empty project, and adding the following to the example unit test:
fun sql(@Language("sql") param: String) {}
@Test
fun foo() {
sql("select * from whatever")
}
Paste containing exact versions I tested on (these are just the initial stable versions of each release):
Description
Component used: androidx.benchmark.macro Version used: Version 1.4.0-alpha04
Calling
PerfettoTraceProcessor.Session#query
withSELECT slice.name, ...
shows the following error in the IDE:id, name or spec expected, got 'SELECT s...'