Skip to content

ADFA-7115: Give Kotlin test sources their own modules - #2268

Merged
itsaky-adfa merged 2 commits into
stagefrom
fix/ADFA-7115-kotlin-scopes
Nov 20, 2026
Merged

itsaky-adfa merged 2 commits into
stagefrom
fix/ADFA-7115-kotlin-scopes

Conversation

@itsaky-adfa

@itsaky-adfa itsaky-adfa commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

ADFA-7115

Stack 3/5. First commit is a Spotless reformat.

Kotlin test sources become their own analysis modules over main, with access to main's internal declarations.

Tested: unit tests, spotlessCheck.

@itsaky-adfa itsaky-adfa self-assigned this Nov 16, 2026
@atlassian

atlassian Bot commented Nov 16, 2026

Copy link
Copy Markdown

To enable Code Reviewer, link your GitHub account to your Atlassian account.

This is a one-time task that takes less than a minute. Once your account is linked, resubmit the pull request to trigger a code review.

@itsaky-adfa
itsaky-adfa added this pull request to stack #2276 November 17, 2026 13:58
@itsaky-adfa
itsaky-adfa marked this pull request as ready for review November 17, 2026 13:59

@claude claude Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review for a one-time review, or @claude review always to subscribe this PR to a review on every future push.

Tip: disable this comment in your organization's Code Review settings.

@coderabbitai

coderabbitai Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Important

Review skipped

Review was skipped as selected files did not have any reviewable changes.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: 44f2db57-47fc-4ab6-9092-32fa6405f6f9
Commits

Reviewing files that changed from the base of the PR and between 26c82db and 3c7474d.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

No actionable comments were generated in the recent review.

Summary

Release notes

  • Kotlin test sources now load as separate analysis modules.
    • unitTest and androidTest source sets each become a module.
    • Each test module depends on the main module as a regular dependency and as a friend.
    • Test modules inherit main-module dependencies.
    • Test-only project dependencies apply only to their own test scope.
    • Unit tests depend on test fixtures. The fixtures do not depend on unit tests.
  • Test modules can use main declarations, including internal declarations.
  • Find-usages changes:
    • internal targets search their own module, the modules that contain the match set, and source modules whose direct friend dependencies include those modules.
    • File-confined targets still search only their file when a path is available. Otherwise they search only their module.
    • Other visibility levels still search dependent modules. Test scopes are now included in this search.
  • Visibility checks:
    • For INTERNAL declarations, SymbolVisibilityChecker accepts a use site when the declaring module is a direct friend dependency of the use-site module. Previously only same-module access passed.
  • API changes (internal to the Kotlin LSP module):
    • KtSourceModule constructor adds a directFriendDependencies parameter.
    • KtSourceModule.Builder.addFriend(friend: KtModule) is added.
    • TestKtSourceModule constructor adds directFriendDependencies before languageVersion.
    • TestSourceModuleSpec adds a friends list. Each friend must also appear in dependsOn.
  • Documentation:
    • The find-usages scope documentation covers test source sets.
    • The non-goals list no longer excludes test-source usages.

Risks and best-practice concerns

  • Test results are not verified. The PR description reports unit tests and spotlessCheck as run by the author. No completed check on the current head was available to confirm them.
  • Positional constructor changes can break callers.
    • KtSourceModule gains a required parameter in the middle of its list.
    • TestKtSourceModule gains a default parameter before languageVersion and jvmTarget. Any positional caller that passes those arguments now binds to the wrong parameter without a compile error if types align.
    • Use named arguments or add new parameters at the end.
  • Widened INTERNAL visibility changes semantics.
    • Access now depends on the correct population of directFriendDependencies.
    • An incorrect friend list can grant or deny access silently.
  • Friend setup depends on ordering.
    • Friends are added after dependencies are added.
    • A friend that is absent from dependsOn fails only in the test fixture path. Production paths do not check this rule.
  • The change set mixes a Spotless reformat with logic changes.
    • SymbolVisibilityCheckerTest shows +182/-166 lines, mostly from formatting.
    • Reviewers must separate formatting from behavior when they review the logic commit.
  • Scope growth increases analysis cost.
    • Each non-main scope with sources becomes a module.
    • Find-usages now searches more modules for dependent-scope targets.
  • This PR depends on its stacked base branch (fix/ADFA-7115-java-scopes). Merge it only after the base branch is merged or rebased.

The Kotlin LSP now represents test source sets as separate modules with scoped classpaths, dependencies, and friend relationships. Internal visibility and find-usages searches account for friend modules. Tests and feature documentation cover the updated module and search scopes.

Changes: Test-Source Module Visibility

Layer / File(s) Summary
Build scoped modules and friend relationships
lsp/kotlin/src/main/java/com/itsaky/androidide/lsp/kotlin/compiler/*, lsp/kotlin/src/main/java/com/itsaky/androidide/lsp/kotlin/compiler/modules/KtSourceModule.kt, lsp/kotlin/src/test/java/com/itsaky/androidide/lsp/kotlin/compiler/*, lsp/kotlin/src/test/java/com/itsaky/androidide/lsp/kotlin/fixtures/*
Kotlin module layouts now include non-main source scopes with scope-specific roots and classpaths. Module construction records regular and friend dependencies. Compiler tests and fixtures cover source-set modules, dependencies, and friend relationships.
Apply friend visibility to search scopes
lsp/kotlin/src/main/java/com/itsaky/androidide/lsp/kotlin/navigation/FindUsages.kt, lsp/kotlin/src/main/java/com/itsaky/androidide/lsp/kotlin/utils/SymbolVisibilityChecker.kt, lsp/kotlin/src/test/java/com/itsaky/androidide/lsp/kotlin/navigation/TestSourceScopesTest.kt, lsp/kotlin/src/test/java/com/itsaky/androidide/lsp/kotlin/utils/SymbolVisibilityCheckerTest.kt, docs/features/kotlin-find-usages.md
Internal declarations are visible from friend modules. Internal find-usages searches include friend modules. Tests and documentation cover test-source search and visibility scopes.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Suggested reviewers: hal-eisen-adfa, daniel-adfa

Merge Risk: Minimal · previous review f1972

Kotlin test source sets become separate analysis modules that can see their main module's internal declarations, and find-usages now reaches those test modules. I found no concrete defect in the supplied changes. Test results were author-reported, but nothing indicates a merge-blocking problem.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: Kotlin test sources become their own analysis modules. The raw summary confirms this, covering unitTest and androidTest source-set modules, friend dependencies on main…
Description check Passed The description states that Kotlin test sources become their own analysis modules over main, with access to main's internal declarations. This matches the changeset, which adds test source-set modules…
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.
Full details: Title check

Explanation

The title names the main change: Kotlin test sources become their own analysis modules. The raw summary confirms this, covering unitTest and androidTest source-set modules, friend dependencies on main, and test-module visibility tests. The title is concise and specific, and it does not use vague terms.

Full details: Description check

Explanation

The description states that Kotlin test sources become their own analysis modules over main, with access to main's internal declarations. This matches the changeset, which adds test source-set modules, friend dependencies, and internal visibility changes. It also notes the Spotless reformat commit. The description is brief but relevant.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

I hop through source sets, neat and bright
Main and tests now share the light
Friends can see what internals say
Find-usages follows paths their way
I tuck the docs beneath the hay

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: 10034d36-9504-4d8f-ad91-38786cc48ed1
Commits

Reviewing files that changed from the base of the PR and between e0e0ca5 and f197210.

Files selected for processing: 14

  • docs/features/kotlin-find-usages.md
  • lsp/kotlin/src/main/java/com/itsaky/androidide/lsp/kotlin/compiler/KotlinModuleLayout.kt
  • lsp/kotlin/src/main/java/com/itsaky/androidide/lsp/kotlin/compiler/WorkspaceExts.kt
  • lsp/kotlin/src/main/java/com/itsaky/androidide/lsp/kotlin/compiler/modules/KtSourceModule.kt
  • lsp/kotlin/src/main/java/com/itsaky/androidide/lsp/kotlin/navigation/FindUsages.kt
  • lsp/kotlin/src/main/java/com/itsaky/androidide/lsp/kotlin/utils/SymbolVisibilityChecker.kt
  • lsp/kotlin/src/test/java/com/itsaky/androidide/lsp/kotlin/compiler/CollectKtModulesTest.kt
  • lsp/kotlin/src/test/java/com/itsaky/androidide/lsp/kotlin/compiler/KotlinModuleLayoutTest.kt
  • lsp/kotlin/src/test/java/com/itsaky/androidide/lsp/kotlin/fixtures/GradleProjectFixtures.kt
  • 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
  • lsp/kotlin/src/test/java/com/itsaky/androidide/lsp/kotlin/fixtures/TestSourceModuleSpec.kt
  • lsp/kotlin/src/test/java/com/itsaky/androidide/lsp/kotlin/navigation/TestSourceScopesTest.kt
  • lsp/kotlin/src/test/java/com/itsaky/androidide/lsp/kotlin/utils/SymbolVisibilityCheckerTest.kt

Included review availability: This review used your included allowance. 2 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 5 reviews per hour.

@itsaky-adfa
itsaky-adfa force-pushed the fix/ADFA-7115-kotlin-scopes branch from f197210 to 26c82db Compare November 20, 2026 13:18
Base automatically changed from fix/ADFA-7115-java-scopes to stage November 20, 2026 13:47
@itsaky-adfa
itsaky-adfa force-pushed the fix/ADFA-7115-kotlin-scopes branch from 26c82db to 3c7474d Compare November 20, 2026 13:47
@itsaky-adfa
itsaky-adfa merged commit 17aa023 into stage Nov 20, 2026
5 checks passed
@itsaky-adfa
itsaky-adfa deleted the fix/ADFA-7115-kotlin-scopes branch November 20, 2026 14:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants