scip-kotlinc Kotlin update, fixes and improvements by nicolas-guichard · Pull Request #973 · scip-code/scip-java · GitHub
Skip to content

scip-kotlinc Kotlin update, fixes and improvements#973

Open
nicolas-guichard wants to merge 18 commits into
scip-code:mainfrom
nicolas-guichard:push-snmzvsuoxslw
Open

scip-kotlinc Kotlin update, fixes and improvements#973
nicolas-guichard wants to merge 18 commits into
scip-code:mainfrom
nicolas-guichard:push-snmzvsuoxslw

Conversation

@nicolas-guichard

Copy link
Copy Markdown
Contributor

We've been maintaining a semanticdb-kotlinc fork at https://github.com/mozsearch/semanticdb-kotlinc for some time now, which was kept up-to-date with Kotlin updates with a couple of extra fixes and improvements along the way.

Since this repo seems to be actively maintained again, I've rebased our changes on top of the new scip-kotlinc to submit them here.

Now I only just saw #963 which plans to drop the plugin in favor of the Analysis API (which makes sense), so… This may still be useful until that PR is fully fleshed-out.

nicolas-guichard and others added 18 commits July 3, 2026 17:40
For scip-kotlinc:

* CheckerContext.containingFile was renamed to containingFileSymbol.

* FirCallableSymbol<*>.directOverriddenSymbolsSafe now takes context by
  context parameter.

* FirCallableSymbol.callableId was made nullable and is replaced by
  FirCallableSymbol.callableIdForRendering for rendering purpose.

* Anonymous objects are now considered as locals.

Ported from mozsearch/semanticdb-kotlinc@3f47564
This will allow us to distinguish between method and constructors, and
get better kind information for locals.

Ported from mozsearch/semanticdb-kotlinc@6affaf7
This changes the symbols of getters and setters to be `x.get().` and
`x.set().` instead of `getX().` and `setX().`.

Ported from mozsearch/semanticdb-kotlinc@7b4bd70
This will allow us to get the parent symbol for locals as well.
For non-locals, it should be equal to the current symbol minus the last
segment.

Ported from mozsearch/semanticdb-kotlinc@63c9b65
This should reduce memory usage a bit and avoids lots of “given file is
not under the sourceroot” clutter when running the tests.

Ported from https://github.com//mozsearch/semanticdb-kotlinc/commit/65b1898de26c02929f1fbd445a3c9c92e8fd3bab
scip-kotlinc changes:

getContainingSymbol was moved from o.j.k.fir.analysis.checkers to
org.jetbrains.kotlin.fir.resolve.

CompilerPluginRegistrar now has a virtual pluginId which must match the
CommandLineProcessor.

Ported from mozsearch/semanticdb-kotlinc@cde86db
- Remove unnecessary cast to FirClass in SymbolsCache (FirClassSymbol.fir already returns FirClass)
- Use parameterless toClassLikeSymbol() overload in AnalyzerCheckers
- Remove unnecessary inline modifier from test snippet

Ported from mozsearch/semanticdb-kotlinc@eb68377
…age collector

Previously handleException constructed a fresh CompilerConfiguration()
to retrieve the message collector key, which always fell back to
PrintingMessageCollector(System.err) — ignoring whatever collector the
actual compilation was configured with.

Pass the real CompilerConfiguration into PostAnalysisExtension so that
exception messages are routed through the same collector as all other
diagnostics. Also change the severity from EXCEPTION to WARNING, since
EXCEPTION is treated as isError=true by the Kotlin compiler and would
cause the build to fail — contrary to the plugin's intentional
"log-and-continue" behaviour.

The exception test now captures compiler output via result.messages and
asserts that the warning is actually emitted with the expected content,
rather than only checking the exit code.

Ported from mozsearch/semanticdb-kotlinc@e6b72f5
This is a test for 88f6272784c5e56eb135019a4b0dda5dd0808017.

Ported from mozsearch/semanticdb-kotlinc@2c1f170
…turn types

- local functions: verifies that named functions declared inside a
  function body receive local symbols (local0, local1), that explicit
  return type references are emitted (kotlin/Int#), and that call-site
  references resolve to the same local symbol. Also adds a
  SemanticdbSymbolsTest entry confirming the locals counter increments
  correctly.

- user-defined class as return type: verifies that SemanticSimple-
  FunctionChecker emits a REFERENCE occurrence for a user-defined class
  appearing in the return-type position (sample/MyClass#), exercising
  the returnTypeRef path that built-in types do not reach.

Ported from mozsearch/semanticdb-kotlinc@ff23a7e
displayName() in SemanticdbTextDocumentBuilder fell through to
`firBasedSymbol.toString()` for two symbol types, producing strings
like "FirTypeAliasSymbol sample/MyAlias" and "FirTypeParameterSymbol T"
instead of the short name.

- Broaden the FirClassSymbol branch to FirClassLikeSymbol so that
  FirTypeAliasSymbol (a subtype of FirClassLikeSymbol but not of
  FirClassSymbol) also uses classId.shortClassName.
- Add an explicit FirTypeParameterSymbol branch that returns
  symbol.name.asString().

Add tests that exercise the corrected paths:

- typealias: first test for SemanticTypeAliasChecker; verifies the
  DEFINITION occurrence and SymbolInformation (including the now-correct
  displayName "MyAlias"). Notes that type-alias references in value
  declarations are not currently tracked (the property checker resolves
  aliases to their expansion).

- type parameters: first test for SemanticTypeParameterChecker; verifies
  the DEFINITION occurrence and SymbolInformation (displayName "T").
  Notes that T in type-annotation positions does not produce REFERENCE
  occurrences because toClassLikeSymbol() returns null for type
  parameters.

Ported from mozsearch/semanticdb-kotlinc@20b1d20
…rrences

- Fix SemanticSimpleFunctionChecker and SemanticPropertyChecker to emit
  REFERENCE occurrences for extension receiver types
- Add SemanticEnumEntryChecker to emit DEFINITION occurrences for enum
  entries (previously missing from AnalyzerDeclarationCheckers)
- Fix semanticdbKind() to return Kind.ENUM_MEMBER for FirEnumEntry (FirEnumEntry
  extends FirVariable, which would otherwise map to Kind.LOCAL)
- Fix SemanticClassReferenceExpressionChecker (is/as operators) to use the
  already-extracted typeRef and source locals consistently rather than
  re-accessing expression.conversionTypeRef on each line
- Extract emitTypeRef() helper to reduce duplication across checkers; use it
  for supertype references in SemanticClassLikeChecker so they get the same
  fake-source guard as other type reference emissions
- Add tests for extension receivers, enum entries, named/unnamed companion
  objects, string template references, and is/as type references

Ported from mozsearch/semanticdb-kotlinc@d823d35
…uators

- multiple supertype references: verifies that SemanticClassLikeChecker
  emits REFERENCE occurrences for every entry in superTypeRefs, and that
  SymbolInformation.overriddenSymbols is populated for all supertypes
- three-way overload disambiguator: extends the existing two-overload
  coverage to three, verifying the (+1)/(+2) suffix counting logic in
  methodDisambiguator()

Ported from mozsearch/semanticdb-kotlinc@24b6433
The "non-0-based" phrasing predates this branch but is misleading: line
helpers return 1-based values (callers subtract 1 for protobuf), while
column helpers already return 0-based values. Make the docstrings say
what they actually return.

Ported from mozsearch/semanticdb-kotlinc@3059517
Add two test cases:

- enum entry with body (Op.PLUS { override ... }): the body is modeled
  as a synthetic anonymous subclass, so the entry gets a multi-line
  enclosing_range and the overridden member surfaces as a local symbol
  rather than a sample/Op#PLUS.apply() global. Asserts both.
- multi-line generic class declaration: general coverage we lacked for
  generic classes. Asserts enclosing_range for the class, its type
  parameter, and a member.

Ported from mozsearch/semanticdb-kotlinc@979f1f3
Changes in scip-kotlinc:
- Rename FirSimpleFunction -> FirNamedFunction in SemanticSimpleFunctionChecker
- Replace removed isLocalMember with isLocalDeclaredInBlock
  (moved within org.jetbrains.kotlin.fir.analysis.checkers.declaration)

Ported from mozsearch/semanticdb-kotlinc@832bf44
Changes to scip-kotlinc:
- -Xcontext-parameters argument isn't required anymore
- FirAllModifierRenderer now takes an argument

Ported from mozsearch/semanticdb-kotlinc@89427a5
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