Repository navigation
ADFA-6858: Kotlin declaration lookups without whole-package parses #2214
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
20 commits
Select commit
Hold shift + click to select a range
165b23f
ADFA-6858: style: spotless reformat, no functional change
itsaky-adfa 8c81a26
ADFA-6858: Move file add/remove handling into AbstractCompilationEnvi…
itsaky-adfa 85decbf
ADFA-6858: Notify listeners after KtFileMetadataIndex writes
itsaky-adfa cffd946
ADFA-6858: Read only top-level declarations in the declaration provider
itsaky-adfa 1a02671
ADFA-6858: Add a bounded package-to-files cache invalidated by index …
itsaky-adfa b7d4fab
Merge branch 'feat/ADFA-6858-t1' into feat/ADFA-6858-declaration-prov…
itsaky-adfa 791d408
ADFA-6858: Cache package file lists in KtSymbolIndex
itsaky-adfa 6dd6613
ADFA-6858: Return lazy sequences from top-level declaration helpers
itsaky-adfa 84a3d97
ADFA-6858: Let deletes and renames remove Kotlin files from the index
itsaky-adfa 8c2aaf9
Merge branch 'feat/ADFA-6858-t1' into feat/ADFA-6858-declaration-prov…
itsaky-adfa 884808e
Merge branch 'feat/ADFA-6858-t5' into feat/ADFA-6858-declaration-prov…
itsaky-adfa 2cdfa79
ADFA-6858: Use a block comment for the cache generation field
itsaky-adfa 872939e
ADFA-6858: Harden package cache paths and read-lock the remaining pro…
itsaky-adfa 7914cf0
Merge branch 'stage' into feat/ADFA-6858-declaration-provider
itsaky-adfa 18651d4
ADFA-6858: Keep the edited package cached and match writes against st…
itsaky-adfa 75fcfef
ADFA-6858: Skip session invalidation for paths in no module
itsaky-adfa 858dd7a
ADFA-6858: Drop the old path's in-memory copy on every IDE rename
itsaky-adfa e1eabd3
ADFA-6858: Reuse toVirtualFileOrNull in findSourceFiles
itsaky-adfa 8440a55
ADFA-6858: Find a class-like declaration in one walk of the package
itsaky-adfa 099b2f3
Merge branch 'stage' into feat/ADFA-6858-declaration-provider
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
78 changes: 78 additions & 0 deletions
78
.../kotlin/org/appdevforall/codeonthego/indexing/jvm/KtFileMetadataIndexWriteListenerTest.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,78 @@ | ||
| package org.appdevforall.codeonthego.indexing.jvm | ||
|
|
||
| import com.google.common.truth.Truth.assertThat | ||
| import kotlinx.coroutines.test.runTest | ||
| import org.appdevforall.codeonthego.indexing.InMemoryIndex | ||
| import org.junit.Test | ||
| import org.junit.runner.RunWith | ||
| import org.junit.runners.JUnit4 | ||
| import java.time.Instant | ||
|
|
||
| @RunWith(JUnit4::class) | ||
| class KtFileMetadataIndexWriteListenerTest { | ||
| private val index = KtFileMetadataIndex(InMemoryIndex(KtFileMetadataDescriptor)) | ||
| private val writes = mutableListOf<KtFileMetadataWrite>() | ||
|
|
||
| private fun metadata( | ||
| path: String, | ||
| pkg: String, | ||
| ) = KtFileMetadata(path, pkg, Instant.EPOCH, 1L) | ||
|
|
||
| @Test | ||
| fun upsertReportsPathAndPackage() = | ||
| runTest { | ||
| index.addWriteListener { writes += it } | ||
|
|
||
| index.upsert(metadata("/a/A.kt", "com.a")) | ||
|
|
||
| assertThat(writes).containsExactly(KtFileMetadataWrite.Upserted("/a/A.kt", "com.a")) | ||
| } | ||
|
|
||
| @Test | ||
| fun removeAndRemoveAllReportPaths() = | ||
| runTest { | ||
| index.addWriteListener { writes += it } | ||
|
|
||
| index.remove("/a/A.kt") | ||
| index.removeAll(listOf("/a/B.kt", "/a/C.kt")) | ||
|
|
||
| assertThat(writes) | ||
| .containsExactly( | ||
| KtFileMetadataWrite.Removed(listOf("/a/A.kt")), | ||
| KtFileMetadataWrite.Removed(listOf("/a/B.kt", "/a/C.kt")), | ||
| ).inOrder() | ||
| } | ||
|
|
||
| @Test | ||
| fun clearReportsCleared() = | ||
| runTest { | ||
| index.addWriteListener { writes += it } | ||
|
|
||
| index.clear() | ||
|
|
||
| assertThat(writes).containsExactly(KtFileMetadataWrite.Cleared) | ||
| } | ||
|
|
||
| @Test | ||
| fun listenerSeesTheWriteAlreadyApplied() = | ||
| runTest { | ||
| var pathsSeenInListener: List<String>? = null | ||
| index.addWriteListener { | ||
| pathsSeenInListener = index.getFilePathsForPackage("com.a").toList() | ||
| } | ||
|
|
||
| index.upsert(metadata("/a/A.kt", "com.a")) | ||
|
|
||
| assertThat(pathsSeenInListener).containsExactly("/a/A.kt") | ||
| } | ||
|
|
||
| @Test | ||
| fun closedRegistrationIsNotCalled() = | ||
| runTest { | ||
| index.addWriteListener { writes += it }.close() | ||
|
|
||
| index.upsert(metadata("/a/A.kt", "com.a")) | ||
|
|
||
| assertThat(writes).isEmpty() | ||
| } | ||
| } |
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.