Accept class, object, and property targets in FUN/FUNS (#18)#19
Merged
Accept class, object, and property targets in FUN/FUNS (#18)#19
Conversation
Restore 0.1.x behavior for non-function targets. 0.2.0 narrowed `<!---FUN
name-->` to `KtNamedFunction` only, which broke consumers like Kotlin/DataFrame
that point directives at an `object` / `class` / `interface` wrapper with
`//SampleStart` / `//SampleEnd` markers inside. `KtNamedFunction`,
`KtClassOrObject`, and `KtProperty` are now all valid targets; enum entries,
type aliases, local declarations, and `.kts` scripts remain unsupported.
- `FqnResolver`: widen the short-name and FQN indices from `KtNamedFunction`
to `KtNamedDeclaration`. Index classes / objects / properties alongside
functions (still recursing into class bodies for nested members;
`KtEnumEntry` is explicitly skipped). Add `ambiguous()` helper that returns
candidate FQNs when a bare short name resolves to multiple declarations.
- `SampleExtractor`: accept `KtNamedDeclaration`. Functions keep the existing
body-with-braces-stripped behavior via the `KtDeclarationWithBody` branch;
classes / objects / properties fall through to `buildSampleText()` so the
existing `//SampleStart` / `//SampleEnd` marker semantics apply verbatim.
- `SamplesTransformer`: widen signatures to `KtNamedDeclaration`; expose
`ambiguous()` as a proxy.
- `Korro.kt`: emit an "Ambiguous FUN 'X'" diagnostic with candidate FQNs when
a bare short name is ambiguous (avoids a misleading "Cannot resolve" now
that the index includes more kinds). Widen the FUNS zero-match message
from "matched no functions" to "matched no declarations".
- Add `integration-tests/fixtures/declarations/` covering top-level object,
primary-constructor class, nested `interface { object }` (the DataFrame
pattern), top-level property with getter-body markers, and a FUNS glob
over sibling objects. New `declarationsFixture()` test method.
- Update `CLAUDE.md`, `MIGRATION.md`, and `README.md` invariants to list the
three supported declaration kinds.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
FUN/FUNStargets:KtNamedFunction,KtClassOrObject, andKtPropertyare all valid now. Unblocks Kotlin/DataFrame's nestedinterface { object { … } }wrapper pattern (fixes Regression: FUN no longer resolves non-function targets (classes, objects, properties) #18).Ambiguous FUN 'X'diagnostic with candidate FQNs for the new collision mode where a bare short name matches declarations of multiple kinds; widenFUNSzero-match message from "matched no functions" to "matched no declarations".declarations/covering top-level object, primary-constructor class, nestedinterface { object }(DataFrame's exact pattern), top-level property with getter-body markers, and a FUNS glob over sibling objects.Test plan
./gradlew build./gradlew :integration-tests:test— 9 tests pass, including newdeclarationsFixture()HsqldbGuide.ktnested-interface pattern)