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

Send conversion method suggestions #7857

Merged

Conversation

4e6
Copy link
Contributor

@4e6 4e6 commented Sep 20, 2023

Pull Request Description

close #7320

Changelog:

  • update: enable conversion suggestions
  • fix: conversion suggestion building
  • fix: conversion suggestion types
  • fix: conversion JSON-RPC representation

Important Notes

For example, the Day_Of_Week_From conversion is sent as

{
   "type":"Add",
   "id":32,
   "suggestion":{
      "type":"method",
      "module":"Standard.Base.Data.Time.Day_Of_Week_From",
      "name":"from",
      "arguments":[
         {
            "name":"that",
            "reprType":"Standard.Base.Data.Numbers.Integer",
            "isSuspended":false,
            "hasDefault":false,
            "defaultValue":null,
            "tagValues":null
         },
         {
            "name":"first_day",
            "reprType":"Standard.Base.Data.Time.Day_Of_Week.Day_Of_Week",
            "isSuspended":false,
            "hasDefault":true,
            "defaultValue":"Day_Of_Week.Sunday",
            "tagValues":[
               "Standard.Base.Data.Time.Day_Of_Week.Day_Of_Week.Sunday",
               "Standard.Base.Data.Time.Day_Of_Week.Day_Of_Week.Monday",
               "Standard.Base.Data.Time.Day_Of_Week.Day_Of_Week.Tuesday",
               "Standard.Base.Data.Time.Day_Of_Week.Day_Of_Week.Wednesday",
               "Standard.Base.Data.Time.Day_Of_Week.Day_Of_Week.Thursday",
               "Standard.Base.Data.Time.Day_Of_Week.Day_Of_Week.Friday",
               "Standard.Base.Data.Time.Day_Of_Week.Day_Of_Week.Saturday"
            ]
         },
         {
            "name":"start_at_zero",
            "reprType":"Standard.Base.Data.Boolean.Boolean",
            "isSuspended":false,
            "hasDefault":true,
            "defaultValue":"False",
            "tagValues":[
               "Standard.Base.Data.Boolean.Boolean.True",
               "Standard.Base.Data.Boolean.Boolean.False"
            ]
         }
      ],
      "selfType":"Standard.Base.Data.Time.Day_Of_Week.Day_Of_Week",
      "returnType":"Standard.Base.Data.Time.Day_Of_Week.Day_Of_Week",
      "isStatic":false,
      "documentation":" Convert from an integer to a Day_Of_Week\n\nArguments:\n- `that`: The first day of the week.\n- `first_day`: The first day of the week.\n- `start_at_zero`: If True, first day of the week is 0 otherwise is 1.",
      "annotations":[
         
      ]
   }
}

Checklist

Please ensure that the following checklist has been satisfied before submitting the PR:

  • The documentation has been updated, if necessary.
  • All code follows the
    Scala,
    Java,
    and
    Rust
    style guides. In case you are using a language not listed above, follow the Rust style guide.
  • All code has been tested:
    • Unit tests have been written where possible.

@4e6 4e6 added the CI: No changelog needed Do not require a changelog entry for this PR. label Sep 20, 2023
@4e6 4e6 requested a review from JaroslavTulach as a code owner September 20, 2023 16:48
@4e6 4e6 self-assigned this Sep 20, 2023
@JaroslavTulach
Copy link
Member

For example, the Day_Of_Week_From conversion is sent as

Thank you @4e6, I think the information sent shall be sufficient for the IDE to find out all "roles" a "value at hand" can play (be converted to):

  "name":"from",

The IDE can search for all methods named from...

  "arguments":[
     {
        "name":"that",
        "reprType":"Standard.Base.Data.Numbers.Integer",
        "isSuspended":false,
        "hasDefault":false,
        "defaultValue":null,
        "tagValues":null
     },

...where the that argument has the reprType of the "value at hand" ...

  "returnType":"Standard.Base.Data.Time.Day_Of_Week.Day_Of_Week",

...and include the methods of returnType in component browser for such "value at hand". Once such a method is selected, the IDE would insert value_at_hand.to Day_Of_Week . method_of_day_of_week.

returnType = "Unnamed.Test.MyType",
selfType = "Number",
selfType = "Standard.Base.Data.Numbers.Number",
returnType = "Unnamed.Test.Foo",
Copy link
Member

Choose a reason for hiding this comment

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

Yes, that seems correct. selfType is now FQN. returnType is the type we convert to.

Suggestion
.Argument("opt", "Unnamed.Test.MyMaybe", false, false, None)
.Argument(
"other",
Copy link
Member

Choose a reason for hiding this comment

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

Optional arguments are available as well. Good.

@4e6 4e6 added the CI: Ready to merge This PR is eligible for automatic merge label Sep 21, 2023
@mergify mergify bot merged commit c88765d into develop Sep 21, 2023
@mergify mergify bot deleted the wip/db/7320-ability-to-get-the-list-of-target-conversion-types branch September 21, 2023 09:00
Copy link
Collaborator

@hubertp hubertp left a comment

Choose a reason for hiding this comment

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

👍

mergify bot pushed a commit that referenced this pull request Sep 21, 2023
related #7320
followup #7857

At the last moment noticed a typo when mapping the conversion to API type.
@enso-bot enso-bot bot mentioned this pull request Sep 22, 2023
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI: No changelog needed Do not require a changelog entry for this PR. CI: Ready to merge This PR is eligible for automatic merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Ability to get the list of target conversion types for a type
3 participants