-
Notifications
You must be signed in to change notification settings - Fork 14
Kotlin 2 #97
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
Open
nicolas-guichard
wants to merge
54
commits into
sourcegraph:main
Choose a base branch
from
nicolas-guichard:kotlin-2
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Kotlin 2 #97
+1,718
−22,131
Conversation
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
Run `gradle splotlessApply`, remove trailing whitesepace and file endings.
Also remove the in-repo copy of Semanticdb.java (it is autogenerated by protoc outside the source tree), and the unused krotoconfig.json, but keep the SemanticdbBuilders.kt that used to be autogenerated by Kroto+.
This was deprecated in Kotlin 1.9 already.
Squashed version of slycodemonkey@3701395.
This is from titooan@3ddcc1c
We don't want the output schema to change, otherwise we're not outputing SemanticDB anymore and downstream tooling like scip-java reject our output. We start with 24 failing tests to fix.
Its cast always fails
According to existing tests, exceptions in the semanticdb-kotlinc plugin should not propagate to the host. Down to 23 failing tests.
We want the symbol for a class to be package/package/Class#, instead this gave us `package/package/Class`#. Now we have just Class#, packages will be added back in a future commit. The display name should just be the simple class name. Still 23 failing tests.
This: - Adds special handling for packages, which are represented by FqName rather than PackageDescriptor. → This gives package/package/Class# instead of just Class#. - Removes FileKt# fake classes for toplevel methods and properties These don't appear in imports, so I don't think they are wanted. This changes the test expectations, but remains SemanticDB-compliant. → This gives kotlin/io/println(). instead of kotlin/io/ConsoleKt#println(). Down to 19 failing tests.
SemanticDB and SCIP don't disambiguate methods by adding their full signature, instead they sort overloaded methods by declaration order, the first one is `method().`, the next one is `method(+1).`, the next one `method(+2).` etc. Down to 14 failing tests.
Identify getters/setters using FirPropertyAccessorSymbol.isGetter and FirPropertyAccessorSymbol.isSetter instead of doing string comparisons. Still 14 failing tests.
Down to 13 failing tests.
Constructors should have the special `<init>`(). symbol. Down to 11 failing tests.
We are generally interested in the identifier for each item, but sometimes want some other token instead, such as the constructor, get or set keywords. Down to 5 failing tests.
We need to support the package directive and the imports so that: - `package a.b.c` has 3 symbol occurences, for `a/`, `a/b/` and `a/b/c/` - `import a.b.Klass` has 3 symbol occurences, for `a/`, `a/b/` and `a/b/Klass#` Still 5 failing tests.
Down to 4 failing tests.
We don't want all types to list Any as their supertype. Down to 3 failings tests.
Down to 2 failing tests.
Down to 1 failing test.
When we have a reference to a FirPropertySymbol, it is not obvious if it is used as a read or a write. Emit both just in case. No more failing tests!
Class overriddenSymbols were not pointing to actual symbols. Function overriddenSymbols were missing.
We don't want to call all anonymous objects <anonymous>, or we can't desambiguate between two anonymous objects from the same package. We emit anonymous objects just like regular classes, but take care to point at the `object` keyword for the class and primary constructor.
This was caught by Searchfox's scip-indexer, which would error out: ``` [ERROR scip_indexer] InvalidLocalSymbol("local 84getCurrentIndex().") ```
Draft
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.
This is based on https://github.com/slycodemonkey/scip-kotlin, which replaces the
AnalysisHandlerExtension
with aFirAdditionalCheckersExtension
to collect declarations and expressions and anIrGenerationExtension
to analyze them (at the FIR level) after everything has been resolved.Test plan
All existing tests pass (or were slightly adapted, eg. class and method signatures).
This is currently used in a test instance of Searchfox at https://kdab.searchfox.org/mozilla-central/source, see eg. https://kdab.searchfox.org/mozilla-central/source/mobile/android/android-components/components/browser/domains/src/main/java/mozilla/components/browser/domains/Domain.kt.
This means the output is accepted by
scip-java index-semanticdb
then Searchfox'sscip-indexer
on the whole Firefox for Android code base.New tests were added based on my testing with Searchfox.