ADFA-4059: inconsistent search scope in source modules and project structure provider#1361
Conversation
…e provider Signed-off-by: Akash Yadav <akashyadav@appdevforall.org> # Conflicts: # app/src/main/java/com/itsaky/androidide/app/IDEApplication.kt
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughRelease Notes - ADFA-4059: Fix Inconsistent Search Scope in Source Modules and Project Structure ProviderArchitecture & Infrastructure
Symbol Indexing & Search Scope
Testing Infrastructure
Other Changes
|
| Layer / File(s) | Summary |
|---|---|
Abstract compilation environment and initialization lsp/kotlin/src/main/java/com/itsaky/androidide/lsp/kotlin/compiler/AbstractCompilationEnvironment.kt, lsp/kotlin/src/main/java/com/itsaky/androidide/lsp/kotlin/compiler/CompilationEnvironment.kt |
AbstractCompilationEnvironment centralizes IntelliJ/Kotlin Analysis API setup, compiler configuration, and lifecycle; CompilationEnvironment now extends it, adds coroutine-scoped initialization, diagnostics publishing, and FIR invalidation publishing. |
Service registration abstraction and providers lsp/kotlin/src/main/java/com/itsaky/androidide/lsp/kotlin/compiler/registrar/AnalysisApiServiceProvider.kt, lsp/kotlin/src/main/java/com/itsaky/androidide/lsp/kotlin/compiler/registrar/AnalysisApiServiceProviders.kt, lsp/kotlin/src/main/java/com/itsaky/androidide/lsp/kotlin/compiler/registrar/LspAnalysisApiServiceRegistrar.kt |
Adds AnalysisApiServiceProvider types and builder, a provider registry (AnalysisApiServiceProviders), and LspAnalysisApiServiceRegistrar that applies provider registrations to mock application/project component managers (replacing removed monolithic registrar). |
Compiler configuration and invalidation lsp/kotlin/src/main/java/com/itsaky/androidide/lsp/kotlin/KotlinLanguageServer.kt |
Switches metadata index construction to KtFileMetadataIndex.sqliteBacked(...) and integrates FIR session invalidation publishing in file/module modification flows. |
Module System and Source File Discovery
| Layer / File(s) | Summary |
|---|---|
Abstract module base and scope computation lsp/kotlin/src/main/java/com/itsaky/androidide/lsp/kotlin/compiler/modules/AbstractKtModule.kt, lsp/kotlin/src/main/java/com/itsaky/androidide/lsp/kotlin/compiler/modules/AbstractSourceModule.kt |
Adds computeBaseContentScope() hook and AbstractSourceModule which implements source-file discovery (walk content roots, filter .kt/.java) and a path-based GlobalSearchScope to avoid stale-VFS issues. |
KtSourceModule refactoring and declaration providers lsp/kotlin/src/main/java/com/itsaky/androidide/lsp/kotlin/compiler/modules/KtSourceModule.kt, lsp/kotlin/src/main/java/com/itsaky/androidide/lsp/kotlin/compiler/services/DeclarationsProvider.kt |
KtSourceModule now inherits AbstractSourceModule (removing its own file-walk); DeclarationProvider now extends AbstractDeclarationProvider which centralizes project and defines ktFilesForPackage hook. |
Index System Improvements
| Layer / File(s) | Summary |
|---|---|
FilteredIndex overridability lsp/indexing/src/main/kotlin/org/appdevforall/codeonthego/indexing/FilteredIndex.kt |
Makes active-source management methods open for subclasses and refactors query/get/contains to consistently consult isActive(sourceId). |
InMemoryIndex prefix-match enhancement lsp/indexing/src/main/kotlin/org/appdevforall/codeonthego/indexing/InMemoryIndex.kt |
resolveMatchingKeys now supports bucketed prefix-searchable fields (case-insensitive) and a case-sensitive fallback for non-prefix fields; empty prefix on bucketed fields returns bucket contents. |
JvmSymbolIndex and KtFileMetadataIndex abstractions lsp/jvm-symbol-index/src/main/kotlin/org/appdevforall/codeonthego/indexing/jvm/JvmSymbolIndex.kt, lsp/jvm-symbol-index/src/main/kotlin/org/appdevforall/codeonthego/indexing/jvm/KtFileMetadataIndex.kt |
JvmSymbolIndex is now open; KtFileMetadataIndex depends on Index<KtFileMetadata> rather than a concrete SQLite type and exposes sqliteBacked factory. |
Source file indexer local declaration skip lsp/kotlin/src/main/java/com/itsaky/androidide/lsp/kotlin/compiler/index/SourceFileIndexer.kt |
analyzeFunction and analyzeProperty early-return for local declarations (dcl.isLocal), preventing indexing of locals. |
Test Infrastructure and Fixtures
| Layer / File(s) | Summary |
|---|---|
Test base class and JUnit rule lsp/kotlin/src/test/java/com/itsaky/androidide/lsp/kotlin/fixtures/KtLspTest.kt, lsp/kotlin/src/test/java/com/itsaky/androidide/lsp/kotlin/fixtures/KtLspTestRule.kt |
Adds KtLspTest Robolectric-backed test base with helpers and KtLspTestRule to provision temp source roots and test environment lifecycle. |
Test environment fixture and module implementation lsp/kotlin/src/test/java/com/itsaky/androidide/lsp/kotlin/fixtures/KtLspTestEnvironment.kt, lsp/kotlin/src/test/java/com/itsaky/androidide/lsp/kotlin/fixtures/TestKtSourceModule.kt |
KtLspTestEnvironment extends the new abstract compilation environment to create SDK/stdlib/source/library modules, wire in-memory symbol indexes, and provide createSourceFile + analyze helpers; TestKtSourceModule supplies test module metadata. |
Test cases and regression tests lsp/kotlin/src/test/java/com/itsaky/androidide/lsp/kotlin/compiler/index/SourceFileIndexerTest.kt, lsp/kotlin/src/test/java/com/itsaky/androidide/lsp/kotlin/fixtures/KtLspTestEnvironmentTest.kt, lsp/kotlin/src/test/java/com/itsaky/androidide/lsp/kotlin/compiler/modules/ContentScopeStalenessTest.kt |
Adds tests verifying local-declaration skipping in the index, fixture correctness (source creation and cross-file resolution), and content-scope staleness regression coverage. |
Supporting and Cleanup Changes
| Layer / File(s) | Summary |
|---|---|
Application setup and service cleanup app/src/main/java/com/itsaky/androidide/app/IDEApplication.kt, lsp/kotlin/src/main/java/com/itsaky/androidide/lsp/kotlin/compiler/services/AnalysisPermissionOptions.kt, lsp/kotlin/src/main/java/com/itsaky/androidide/lsp/kotlin/compiler/services/ProjectStructureProvider.kt |
Removes the setupIdeaStandaloneExecution import/call and the java.awt.headless property set from application startup; refactors AnalysisPermissionOptions to constructor-based properties and removes SLF4J logger from ProjectStructureProvider. |
Dependency and API updates subprojects/kotlin-analysis-api/build.gradle.kts, testing/lsp/src/main/java/com/itsaky/androidide/lsp/api/LSPTest.kt, shared/src/main/java/com/itsaky/androidide/utils/Either.kt |
Updates an external Kotlin-Android artifact tag and checksum, switches a test accessor to ILanguageServerRegistry.default, and includes a minor EOF brace edit. |
Estimated code review effort
🎯 4 (Complex) | ⏱️ ~60 minutes
Possibly related PRs
- appdevforall/CodeOnTheGo#1323: Bumps
ktAndroidTagand updates thesha256Checksumfor thekt-androidartifact (same build pin change). - appdevforall/CodeOnTheGo#1142: Related changes touching Kotlin LSP compilation/session lifecycle and incremental invalidation behavior.
- appdevforall/CodeOnTheGo#1214: Overlapping changes around file-change/invalidation flows and CompilationEnvironment indexing logic.
Suggested reviewers
- Daniel-ADFA
- jatezzz
- dara-abijo-adfa
Poem
🐰 I hopped through modules, scopes, and indexes bright,
Built a shared env to make the analyses light,
Providers register, tests spin up in a whirl,
Locals are skipped, and symbols unfurl,
A carrot-coded cheer from your little dev rabbit!
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | Docstring coverage is 16.67% which is insufficient. The required threshold is 80.00%. | Write docstrings for the functions missing them to satisfy the coverage threshold. |
✅ Passed checks (4 passed)
| Check name | Status | Explanation |
|---|---|---|
| Title check | ✅ Passed | The title clearly summarizes the main objective: fixing inconsistent search scope in source modules and project structure provider, which aligns with the primary refactoring across multiple module and indexing files. |
| Description check | ✅ Passed | The description references the Jira issue ADFA-4059 with a link, which is directly related to the changeset's core objective of fixing inconsistent search scope issues. |
| Linked Issues check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
| Out of Scope Changes check | ✅ Passed | Check skipped because no linked issues were found for this pull request. |
✏️ Tip: You can configure your own custom pre-merge checks in the settings.
✨ Finishing Touches
📝 Generate docstrings
- Create stacked PR
- Commit on current branch
🧪 Generate unit tests (beta)
- Create PR with unit tests
- Commit unit tests in branch
fix/ADFA-4059
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
lsp/kotlin/src/test/java/com/itsaky/androidide/lsp/kotlin/fixtures/KtLspTestRule.kt (1)
30-33: 💤 Low valueThe
env.project.write { }block is currently a no-op.With
env.close()commented out, the write block does nothing andenvis never disposed, leaving its resources held for the duration of the suite. This is acknowledged via the TODO, but worth resolving so the environment is torn down between tests.Want me to open an issue to track teardown of
env(investigating whyenv.close()fails under test), or draft a working disposal sequence?🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@lsp/kotlin/src/test/java/com/itsaky/androidide/lsp/kotlin/fixtures/KtLspTestRule.kt` around lines 30 - 33, The env.project.write { } block is a no-op because env.close() is commented out, so ensure the test environment is reliably torn down by calling env.close() from the rule's teardown rather than leaving it inside the write block: move the disposal into a proper tearDown/after method in KtLspTestRule, call env.close() (or Disposer.dispose(env) if close() is unstable) inside a try/catch to swallow/log any exceptions, and null out the env reference after successful disposal so resources are released between tests; reference env, env.close(), env.project.write { }, and the KtLspTestRule teardown method when applying the change.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@lsp/kotlin/src/main/java/com/itsaky/androidide/lsp/kotlin/compiler/modules/AbstractSourceModule.kt`:
- Around line 10-28: The file uses kotlin.io.path.walk which is marked
experimental; add an opt-in for ExperimentalPathApi at the top of the file
(file-level) so the compiler allows use of kotlin.io.path.walk (or alternatively
enable -Xopt-in=kotlin.io.path.ExperimentalPathApi for the module); update
AbstractSourceModule (where computeFiles calls walk) to have
`@OptIn`(kotlin.io.path.ExperimentalPathApi::class) applied file-wide to suppress
the experimental API error.
In
`@lsp/kotlin/src/test/java/com/itsaky/androidide/lsp/kotlin/fixtures/KtLspTestRule.kt`:
- Around line 28-35: The TemporaryFolder created as tempDir is manually created
(tempDir.create()) and not registered as a JUnit rule, so its cleanup never
runs; update the teardown in the finally block of KtLspTestRule to explicitly
delete the tempDir (call tempDir.delete()) before or after env.project.write/
env.close() to ensure the temp src folder and written sources are removed;
reference the tempDir TemporaryFolder instance and the env teardown block (the
finally that currently checks ::env.isInitialized and calls env.project.write)
and add the explicit cleanup call there so temporary files are removed even when
tests fail.
In `@subprojects/kotlin-analysis-api/build.gradle.kts`:
- Around line 12-31: Replace the local absolute-file dependency in the
dependencies { api(files(...)) } block with the original externalAssets {
jarDependency("kt-android") { ... } } wiring: restore the externalAssets block
that uses AssetSource.External(url = uri(...), sha256Checksum = "..."), re-add
the AssetSource import if removed, and remove the hardcoded api(files(...))
entry so the build fetches the shared kt-android JAR via the external asset
mechanism with integrity verification.
---
Nitpick comments:
In
`@lsp/kotlin/src/test/java/com/itsaky/androidide/lsp/kotlin/fixtures/KtLspTestRule.kt`:
- Around line 30-33: The env.project.write { } block is a no-op because
env.close() is commented out, so ensure the test environment is reliably torn
down by calling env.close() from the rule's teardown rather than leaving it
inside the write block: move the disposal into a proper tearDown/after method in
KtLspTestRule, call env.close() (or Disposer.dispose(env) if close() is
unstable) inside a try/catch to swallow/log any exceptions, and null out the env
reference after successful disposal so resources are released between tests;
reference env, env.close(), env.project.write { }, and the KtLspTestRule
teardown method when applying the change.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 1fd0c255-3161-4eb6-b157-b71e6449a3ad
📒 Files selected for processing (29)
app/src/main/java/com/itsaky/androidide/app/IDEApplication.ktlsp/indexing/src/main/kotlin/org/appdevforall/codeonthego/indexing/FilteredIndex.ktlsp/indexing/src/main/kotlin/org/appdevforall/codeonthego/indexing/InMemoryIndex.ktlsp/jvm-symbol-index/src/main/kotlin/org/appdevforall/codeonthego/indexing/jvm/JvmSymbolIndex.ktlsp/jvm-symbol-index/src/main/kotlin/org/appdevforall/codeonthego/indexing/jvm/KtFileMetadataIndex.ktlsp/kotlin/src/main/java/com/itsaky/androidide/lsp/kotlin/KotlinLanguageServer.ktlsp/kotlin/src/main/java/com/itsaky/androidide/lsp/kotlin/compiler/AbstractCompilationEnvironment.ktlsp/kotlin/src/main/java/com/itsaky/androidide/lsp/kotlin/compiler/CompilationEnvironment.ktlsp/kotlin/src/main/java/com/itsaky/androidide/lsp/kotlin/compiler/index/SourceFileIndexer.ktlsp/kotlin/src/main/java/com/itsaky/androidide/lsp/kotlin/compiler/modules/AbstractKtModule.ktlsp/kotlin/src/main/java/com/itsaky/androidide/lsp/kotlin/compiler/modules/AbstractSourceModule.ktlsp/kotlin/src/main/java/com/itsaky/androidide/lsp/kotlin/compiler/modules/KtSourceModule.ktlsp/kotlin/src/main/java/com/itsaky/androidide/lsp/kotlin/compiler/registrar/AnalysisApiServiceProvider.ktlsp/kotlin/src/main/java/com/itsaky/androidide/lsp/kotlin/compiler/registrar/AnalysisApiServiceProviders.ktlsp/kotlin/src/main/java/com/itsaky/androidide/lsp/kotlin/compiler/registrar/LspAnalysisApiServiceRegistrar.ktlsp/kotlin/src/main/java/com/itsaky/androidide/lsp/kotlin/compiler/registrar/LspServiceRegistrar.ktlsp/kotlin/src/main/java/com/itsaky/androidide/lsp/kotlin/compiler/services/AnalysisPermissionOptions.ktlsp/kotlin/src/main/java/com/itsaky/androidide/lsp/kotlin/compiler/services/DeclarationsProvider.ktlsp/kotlin/src/main/java/com/itsaky/androidide/lsp/kotlin/compiler/services/ProjectStructureProvider.ktlsp/kotlin/src/test/java/com/itsaky/androidide/lsp/kotlin/compiler/index/SourceFileIndexerTest.ktlsp/kotlin/src/test/java/com/itsaky/androidide/lsp/kotlin/compiler/modules/ContentScopeStalenessTest.ktlsp/kotlin/src/test/java/com/itsaky/androidide/lsp/kotlin/fixtures/KtLspTest.ktlsp/kotlin/src/test/java/com/itsaky/androidide/lsp/kotlin/fixtures/KtLspTestEnvironment.ktlsp/kotlin/src/test/java/com/itsaky/androidide/lsp/kotlin/fixtures/KtLspTestEnvironmentTest.ktlsp/kotlin/src/test/java/com/itsaky/androidide/lsp/kotlin/fixtures/KtLspTestRule.ktlsp/kotlin/src/test/java/com/itsaky/androidide/lsp/kotlin/fixtures/TestKtSourceModule.ktshared/src/main/java/com/itsaky/androidide/utils/Either.ktsubprojects/kotlin-analysis-api/build.gradle.ktstesting/lsp/src/main/java/com/itsaky/androidide/lsp/api/LSPTest.kt
💤 Files with no reviewable changes (2)
- lsp/kotlin/src/main/java/com/itsaky/androidide/lsp/kotlin/compiler/registrar/LspServiceRegistrar.kt
- app/src/main/java/com/itsaky/androidide/app/IDEApplication.kt
Signed-off-by: Akash Yadav <akashyadav@appdevforall.org>
Signed-off-by: Akash Yadav <akashyadav@appdevforall.org>
See ADFA-4059 for more details.