Skip to content
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

[kotlin2cpg] Improve fullnames. #4988

Merged
merged 33 commits into from
Oct 24, 2024
Merged

[kotlin2cpg] Improve fullnames. #4988

merged 33 commits into from
Oct 24, 2024

Conversation

ml86
Copy link
Contributor

@ml86 ml86 commented Oct 2, 2024

Improve and cleanup the fullname calculation for methods and callsites.
The most noteable changes here are:

  1. The lambda function naming schema changed from
    package.<fileName>.<lambda>counter:signature to
    package.scope.<lambda>counter:signature.
    This give a better indication which lambda function is represented
    also gets rid of exception of using the filename in the method
    fullnames.
  2. Fixed lambda function signatures.
  3. The fullname schema of extension methods changed from
    extendedClassFullName.extensionMethodName:signatureWithoutThisParameter
    to
    package.extensionMethodName:signatureWithThisParameter
    The fact that the this parameter is part of the signature is an
    exception in our java fullnames but necessary in order to distinguish
    otherwise identical extension methods.
  4. We avoid the recalculation of the binding context with every file
    processed. This is now done once at the begining.
  5. Calls to ::class are now represented as calls to
    <operator>.class.
  6. Calculate proper BINDING nodes for lambda and anonymous functions.
  7. Calculate proper base class for type decls created for lambda and anonymous functions.
  8. Fully removed old TypeRenderer class. All full names now go via new rendering.
  9. --keep-type-arguments has no effect anymore. This feature was only implemented partially and
    we might bring it back later.

@ml86 ml86 requested a review from maltek October 2, 2024 14:58
@ml86 ml86 force-pushed the markus/kotlinFullName branch from fc98ac0 to a8a56cc Compare October 9, 2024 09:57
Copy link
Contributor

@maltek maltek left a comment

Choose a reason for hiding this comment

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

looks much better than before :)

@ml86 ml86 force-pushed the markus/kotlinFullName branch from 993373e to 28df4db Compare October 21, 2024 14:52
@ml86 ml86 requested a review from maltek October 21, 2024 15:19
ml86 added 23 commits October 22, 2024 10:48
Improve and cleanup the fullname calculation for methods and callsites.
The most noteable changes here are:
1. The lambda function naming schema changed from
   `package.<fileName>.<lambda>counter:signature` to
   `package.scope.<lambda>counter:signature`.
   This give a better indication which lambda function is represented
   also gets rid of exception of using the filename in the method
   fullnames.
2. Fixed lambda function signatures.
3. The fullname schema of extension methods changed from
   `extendedClassFullName.extensionMethodName:signatureWithoutThisParameter`
   to
   `package.extensionMethodName:signatureWithThisParameter`
   The fact that the this parameter is part of the signature is an
   exception in our java fullnames but necessary in order to distinguish
   otherwise identical extension methods.
4. We avoid the recalculation of the binding context with every file
   processed. This is now done once at the begining.
5. Calls to `::class` are now represented as calls to
   `<operator>.class`.
The instance arg/param now have index 1 as they are not the receiver on
which the call is dispatches. It is a static call after all.
Additionally fixed the inheritance information for lambda type decl
nodes.
Split some methods into BindingContextUtils and renamed those methods.
- No more special case for handling `kotlin.Function`.
- Removed some unused code.
- Stop using currentTimeMillis.
This results in expresssion types now being renderer in the new fassion.
- Removed implicitParameterName and hasApplyOrAlsoScopeFunctionParent
  APIs from TypeInfoProvider.
- Removed wrong parameter deconstruction in lambda. New implemention is
  missing.
- Some lambda to builtin `apply` and `also` functions did not get return
  statements generated. That is now fixed.
ml86 added 5 commits October 22, 2024 10:48
…oProvider.

Also refactored assignmentAstForDestructuringEntry. The right hand side
base is now created outside of this function allowing for other
constructs than pure identifiers. The pure identifier were e.g. wrong
in case of class member references.
@ml86 ml86 force-pushed the markus/kotlinFullName branch from 44fec0e to 7a949ea Compare October 22, 2024 08:54
DavidBakerEffendi and others added 5 commits October 22, 2024 21:23
In case of incomplete type information calls with overloads can get
ambiguous. We now use the ambiguous function descriptors to get as
much of a methodFullName correct as possible.
@ml86 ml86 force-pushed the markus/kotlinFullName branch from 23b9f5c to f0e5106 Compare October 23, 2024 15:21
@ml86 ml86 merged commit 23c0d1e into master Oct 24, 2024
5 checks passed
@max-leuthaeuser max-leuthaeuser deleted the markus/kotlinFullName branch November 12, 2024 14:51
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.

3 participants