-
Notifications
You must be signed in to change notification settings - Fork 516
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Test against 2023.2 * Update dependency mkdocs-material-extensions to v1.3.1 (#4832) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Update dependency com.squareup:kotlinpoet to v1.15.2 (#4855) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Bump sql-psi to 0.5.0 (#4794) * Bump sql-psi to 0.5.0-SNAPSHOT * Use published loadFolderFromResources function * Expose HSQL test-fixtures * Expose MySql test-fixtures * Move timber from sql-psi to sqldelight * Expose Sqlite Json test-fixtures * Expose Sqlite 3.18 test-fixtures * Expose Sqlite 3.24 test-fixtures * Expose Sqlite 3.25 test-fixtures * Expose Sqlite 3.30 test-fixtures * Expose Sqlite 3.33 test-fixtures * Expose Sqlite 3.35 test-fixtures * Expose Sqlite 3.38 test-fixtures * Spotless * Adopt changed sql-psi api * Add snapshot repo to test snapshot * Fix Infer between * Add missing snapshot repo * Add missing snapshot repo * Switch to the release version * Use new loadFolderFromResources shortcut --------- Co-authored-by: hfhbd <hfhbd@users.noreply.github.com> * Add TRUNCATE to postgres dialect (#4817) Co-authored-by: Alec Kazakova <1675456+AlecKazakova@users.noreply.github.com> * feat: add initialOffset for OffsetQueryPagingSource (#4802) * feat: add initialOffset for OffsetQueryPagingSource * apply spotless check * binary compatibility overload * typo * add @jvmoverloads for ABI compatibility * add @jvmoverloads for ABI compatibility * Update agp to v8.2.0 (#4861) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Update plugin intellij to v1.16.1 (#4862) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Fix compatibility issues --------- Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Philip Wedemann <22521688+hfhbd@users.noreply.github.com> Co-authored-by: hfhbd <hfhbd@users.noreply.github.com> Co-authored-by: Bastien de Luca <de-luca@users.noreply.github.com> Co-authored-by: Mohamad Jaara <jaara.moh@gmail.com>
- Loading branch information
1 parent
882d47e
commit 471afc4
Showing
8 changed files
with
69 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
...dea-plugin/src/main/kotlin/app/cash/sqldelight/intellij/util/StubIndexKeyCompatibility.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package app.cash.sqldelight.intellij.util | ||
|
||
import com.intellij.psi.PsiElement | ||
import com.intellij.psi.stubs.AbstractStubIndex | ||
import com.intellij.psi.stubs.StubIndexKey | ||
import kotlin.reflect.KClass | ||
import kotlin.reflect.full.companionObject | ||
import kotlin.reflect.full.companionObjectInstance | ||
|
||
internal inline fun <P : PsiElement, reified T : AbstractStubIndex<String, P>> KClass<T>.compatibleKey(): StubIndexKey<String, P> { | ||
// read the HELPER variable reflectively (2023.2) | ||
try { | ||
val helperField = this.java.getField("Helper") | ||
val helper = helperField.get(null) | ||
if (helper != null) { | ||
val keyMethod = helper.javaClass.getMethod("getIndexKey") | ||
val key = keyMethod.invoke(helper) | ||
@Suppress("UNCHECKED_CAST") // Reflection that will go away when our minimum version is >= 2023.2 | ||
if (key != null) return key as StubIndexKey<String, P> | ||
} | ||
} catch (e: Exception) { | ||
/* intentionally empty, fall back to getInstance() call in case of errors */ | ||
} | ||
|
||
// read the INSTANCE variable reflectively first (newer Kotlin plugins) | ||
try { | ||
val instanceField = this.java.getField("INSTANCE") | ||
val instance = instanceField.get(null) | ||
if (instance is T) { | ||
val keyMethod = instance.javaClass.getMethod("getKey") | ||
val key = keyMethod.invoke(instance) | ||
@Suppress("UNCHECKED_CAST") // Reflection that will go away when our minimum version is >= 2023.2 | ||
if (key != null) return key as StubIndexKey<String, P> | ||
} | ||
} catch (e: Exception) { | ||
/* intentionally empty, fall back to getInstance() call in case of errors */ | ||
} | ||
|
||
// Call the method getInstance on the companion type. | ||
val companionMethod = | ||
this.companionObject!!.java.getMethod("getInstance") | ||
val instance = companionMethod.invoke(this.companionObjectInstance!!) | ||
as T | ||
val keyMethod = instance.javaClass.getMethod("getKey") | ||
val key = keyMethod.invoke(instance) | ||
@Suppress("UNCHECKED_CAST") // Reflection that will go away when our minimum version is >= 2023.2 | ||
return key as StubIndexKey<String, P> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters