-
Notifications
You must be signed in to change notification settings - Fork 20
ADFA-3731: add cancellation support for Kotlin diagnostics #1211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
65 commits
Select commit
Hold shift + click to select a range
1b069cb
fix: add ability to re-write class name references in desugar plugin
itsaky-adfa a70fd66
feat: integrate Kotlin analysis API
itsaky-adfa 4ca1e97
Merge branch 'stage' into fix/ADFA-3366-include-analysis-api-as-depen…
itsaky-adfa 43286a6
fix: update kotlin-android to latest version
itsaky-adfa f1fe62f
fix: remove UnsafeImpl
itsaky-adfa 6e6d8b3
fix: update kotlin-android to latest version
itsaky-adfa b208658
fix: replace usages of Unsafe with UnsafeImpl
itsaky-adfa c844ad2
fix: make Kotlin LSP no-op
itsaky-adfa 58db2cb
feat: configure K2 standalone session when setting up LSP
itsaky-adfa bf7acd1
fix: JvmTarget resolution fails for input "21"
itsaky-adfa dc62a51
fix: do not early-init VirtualFileSystem
itsaky-adfa 4b1c8e4
fix: remove replaceClass desugar instruction for Unsafe
itsaky-adfa b14f6ee
fix: ensure boot class path is added as dependency to Android modules
itsaky-adfa 54ca7a9
feat: add diagnostic provider for Kotlin
itsaky-adfa 6e4d458
fix: remove unnecessary log statement
itsaky-adfa 5d841a3
fix: update to latest kotlin-android release
itsaky-adfa 4b7b0f2
fix: always re-initialize K2 session on setupWithProject
itsaky-adfa e2f137a
fix: diagnostics are always collected from the on-disk file
itsaky-adfa 09fc9ea
feat: add the ability to incrementally invalidate source roots on pro…
itsaky-adfa dd3d519
fix: dispatch build-related events from GradleBuildService
itsaky-adfa d6defa6
feat: introduct KtFileManager
itsaky-adfa 4666893
fix: add initial K2-backed scope code completions
itsaky-adfa 2f982a7
feat: add member completions backed by K2
itsaky-adfa 4129a47
feat: suggest local and imported extension functions
itsaky-adfa 7d736fa
fix: do not suggest extension functions for scope completions
itsaky-adfa 87234f8
feat: add scope-sensitive keyword completions
itsaky-adfa 7d78db1
feat: add indexing api and service implementation
itsaky-adfa c35aa9f
fix: metadata version is sometimes not parsed
itsaky-adfa bede4db
fix: make JvmSymbolIndex exclusive to external libraries
itsaky-adfa 9eb4ffe
feat: add module resolver to resolve library modules from source path
itsaky-adfa 1fdd5b3
feat: add support for completing non-imported symbols
itsaky-adfa c78d5ab
fix: use Kotlin context receivers feature
itsaky-adfa 47d1738
fix: auto-import un-imported classes
itsaky-adfa eed2d03
fix: use internal name repr for library index
itsaky-adfa e6fcf6e
fix: filter-out ext syms with inapplicable receivers
itsaky-adfa 9fa3d4a
feat: add Kotlin source file index
itsaky-adfa ab5c7d9
fix: infinite loop when converting type names to display names
itsaky-adfa 0ec7b4b
fix: update ModuleResolver to resolve KaSourceModule from file path
itsaky-adfa bf9b2da
fix: update KotlinSourceScanner to use internal names in index
itsaky-adfa 49e7efe
feat: add custom implementations of analysis API services
itsaky-adfa a33427d
fix: use StandaloneProjectFactory to create MockProject
itsaky-adfa 51d0686
feat: add support for indexing classes using VirtualFile
itsaky-adfa e77df48
feat: create in-memory KtFile instances for modified files
itsaky-adfa 340b08b
fix: IndexWorker always re-index libraries
itsaky-adfa a1d999e
feat: add KtFile.backingFilePath for better resolution of declaring m…
itsaky-adfa 49542ad
fix: remove library indexing logic for kt index worker
itsaky-adfa 888193f
feat: add index for generated JARs
itsaky-adfa f3997a5
fix: java source files are not recognized by analysis API
itsaky-adfa a0e3075
fix: remove unused kotlin lsp modules
itsaky-adfa fbab307
fix: add basic test cases for indexing and keyword completions
itsaky-adfa ea6c1ca
feat: add snippets for Kotlin sources
itsaky-adfa f29e83a
feat: make comment/uncomment line actions generic to LSP implementations
itsaky-adfa 9e18834
fix: register comment/uncomment line actions in Kotlin LSP
itsaky-adfa c569cb6
fix: comment/uncomment actions are overridden by language servers
itsaky-adfa 429e500
fix: invalid label for uncomment line action
itsaky-adfa ffd785e
fix: collect and report Kotlin syntax errors
itsaky-adfa 7a9b0e9
feat: add 'Add import' action for kotlin source files
itsaky-adfa 3fdbe67
fix: un-imported extension symbols are not shown in completion items
itsaky-adfa 4889377
feat: add cancellation support for Kotlin diagnostics
itsaky-adfa a7c76ce
fix: cancel completion when partial candidate is empty
itsaky-adfa 759d6cc
fix: inline Collection.ifNotEmpty ext func
itsaky-adfa b6fd00a
Merge branch 'stage' into fix/ADFA-3727
itsaky-adfa c255c52
fix: remove unused class
itsaky-adfa 43dc186
Merge branch 'fix/ADFA-3727' into fix/ADFA-3731
itsaky-adfa df37a6e
Merge branch 'stage' into fix/ADFA-3731
itsaky-adfa File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
5 changes: 5 additions & 0 deletions
5
common/src/main/java/com/itsaky/androidide/utils/CollectionExts.kt
This file contains hidden or 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,5 @@ | ||
| package com.itsaky.androidide.utils | ||
|
|
||
| inline fun <E, T: Collection<E>> T.ifNotEmpty(crossinline action: T.() -> Unit) { | ||
| if (isNotEmpty()) action() | ||
| } | ||
69 changes: 69 additions & 0 deletions
69
common/src/main/java/com/itsaky/androidide/utils/KeyedDebouncingAction.kt
This file contains hidden or 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,69 @@ | ||
| package com.itsaky.androidide.utils | ||
|
|
||
| import com.itsaky.androidide.progress.ICancelChecker | ||
| import com.itsaky.androidide.tasks.JobCancelChecker | ||
| import kotlinx.coroutines.CoroutineScope | ||
| import kotlinx.coroutines.Dispatchers | ||
| import kotlinx.coroutines.Job | ||
| import kotlinx.coroutines.channels.Channel | ||
| import kotlinx.coroutines.currentCoroutineContext | ||
| import kotlinx.coroutines.delay | ||
| import kotlinx.coroutines.ensureActive | ||
| import kotlinx.coroutines.launch | ||
| import java.util.concurrent.ConcurrentHashMap | ||
| import kotlin.coroutines.CoroutineContext | ||
| import kotlin.time.Duration | ||
| import kotlin.time.Duration.Companion.milliseconds | ||
|
|
||
| class KeyedDebouncingAction<T: Any>( | ||
| private val scope: CoroutineScope, | ||
| private val debounceDuration: Duration = DEBOUNCE_DURATION_DEFAULT, | ||
| private val actionContext: CoroutineContext = Dispatchers.Default, | ||
| private val action: suspend (T, ICancelChecker) -> Unit, | ||
| ) { | ||
|
|
||
| private data class ActionEntry<T>( | ||
| val channel: Channel<T>, | ||
| val job: Job, | ||
| ) { | ||
| fun cancel() { | ||
| channel.close() | ||
| job.cancel() | ||
| } | ||
| } | ||
|
|
||
| private val pending = ConcurrentHashMap<T, ActionEntry<T>>() | ||
|
|
||
| companion object { | ||
| val DEBOUNCE_DURATION_DEFAULT = 400.milliseconds | ||
| } | ||
|
|
||
| fun cancelPending(key: T) { | ||
| pending.remove(key)?.cancel() | ||
| } | ||
|
|
||
| fun schedule(key: T) { | ||
| val entry = pending.computeIfAbsent(key) { createEntry() } | ||
| entry.channel.trySend(key) | ||
| } | ||
|
|
||
| private fun createEntry(): ActionEntry<T> { | ||
| val channel = Channel<T>(Channel.CONFLATED) | ||
| val job = scope.launch(actionContext) { | ||
| for (latestKey in channel) { | ||
| delay(debounceDuration) | ||
| ensureActive() | ||
|
|
||
| val cancelChecker = JobCancelChecker(currentCoroutineContext()[Job]) | ||
| action(latestKey, cancelChecker) | ||
| } | ||
| } | ||
|
|
||
| return ActionEntry(channel, job) | ||
| } | ||
|
|
||
| fun cancelAll() { | ||
| pending.values.forEach { it.cancel() } | ||
| pending.clear() | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.