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

Extract shared line lens and pipeline hint code #1895

Merged
merged 9 commits into from
Aug 19, 2023

Conversation

faldor20
Copy link
Contributor

@faldor20 faldor20 commented Jul 15, 2023

WHAT

🤖 Generated by Copilot at eed7bb7

This pull request refactors the code for the LineLens and PipelineHints features, which show the signatures and types of F# expressions at the end of the lines. The code is moved from a single file Components/LineLens.fs to three separate files Components/LineLens/LineLensShared.fs, Components/LineLens/LineLens.fs, and Components/LineLens/PipelineHints.fs, to improve the organization and readability of the code. The code also uses a new LineLens type and Instance values to expose the features as singletons, and updates the references to the features in other modules and the project file.

🤖 Generated by Copilot at eed7bb7

Sing, O Muse, of the skillful refactorer who moved the code
Of LineLens and PipelineHints, the helpful features divine,
To separate files, with shared types and functions, for clarity and ease
And updated the references, the project, and the activation, with care and grace

📁🔧🚀

WHY

The line lens and Pipeline hint code has significant duplication. I have attempted to share as much code as possible. This was initially motivated by investigating how difficult it would be to port this feature to the ocaml vscode extension

HOW

🤖 Generated by Copilot at eed7bb7

  • Move the code for LineLens and PipelineHints features to separate files and modules for better organization and readability (link, link, link, link)
  • Create a new module LineLensShared.fs that contains common types and functions for managing the decorations that show the signatures and types at the end of the lines (link)
  • Create a new module LineLens.fs that contains the code for the LineLens feature, which shows the signature of functions and values at the end of the line, and uses the LineLensShared.fs module (link)
  • Create a new module PipelineHints.fs that contains the code for the PipelineHints feature, which shows the type of expressions in pipelines at the end of the line, and uses the LineLensShared.fs module (link)
  • Delete the old module Components/LineLens.fs that contained the code for both features (link)
  • Create Instance values that expose the LineLens type as a singleton for each feature, and use them to access the features from other modules (link, link)
  • Update the project file to compile the new files and modules and remove the old file (link)
    • Add the new files Components/LineLens/LineLensShared.fs, Components/LineLens/LineLens.fs, and Components/LineLens/PipelineHints.fs to the list of compiled files (link)
    • Remove the old file Components/LineLens.fs from the list of compiled files (link)
    • Update the order of the files to respect the dependencies between the modules (link)
  • Update the function activate in src/fsharp.fs to use the Instance values of LineLens and PipelineHints instead of the old module names (link, link)
    • Replace the references to LineLens.activate and LineLens.deactivate with LineLens.Instance.activate and LineLens.Instance.deactivate (link)
    • Replace the references to PipelineHints.activate and PipelineHints.deactivate with PipelineHints.Instance.activate and PipelineHints.Instance.deactivate (link)
  • Update the function private in src/Components/SolutionExplorer.fs to use the Instance values of LineLens and PipelineHints instead of the old module names (link)
    • Replace the references to LineLens.removeDecorations and PipelineHints.removeDecorations with LineLens.Instance.removeDecorations and PipelineHints.Instance.removeDecorations (link)

@faldor20 faldor20 changed the title Extract line lens Extract shared line lens and pipeline hint code Jul 15, 2023
Copy link
Member

@TheAngryByrd TheAngryByrd left a comment

Choose a reason for hiding this comment

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

Thanks! Looks good.

We have some CI issues we need to get dealt with before we merge.

Copy link
Member

@TheAngryByrd TheAngryByrd left a comment

Choose a reason for hiding this comment

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

I can't get this to build locally

.\src\Components\LineLens\LineLens.fs(145,9): (145,56) error FSHARP: Type mismatch. Expecting a
    'Fable.Import.VSCode.Vscode.TextDocument -> Ionide.VSCode.FSharp.DTO.Result<Ionide.VSCode.FSharp.DTO.Symbols Microsoft.FSharp.Core.array> -> Fable.Import.VSCode.Vscode.Uri -> Fable.Core.JS.Promise<(Fable.Import.VSCode.Vscode.Range * Microsoft.FSharp.Core.string) Microsoft.FSharp.Core.array>'
but given a
    'Fable.Import.VSCode.Vscode.TextDocument -> Ionide.VSCode.FSharp.DTO.Result<Ionide.VSCode.FSharp.DTO.Symbols Microsoft.FSharp.Core.array> -> Fable.Import.VSCode.Vscode.Uri -> Fable.Core.JS.Promise<(Ionide.VSCode.FSharp.DTO.Range * Microsoft.FSharp.Core.string) Microsoft.FSharp.Core.array>'
The type 'Fable.Import.VSCode.Vscode.Range' does not match the type 'Ionide.VSCode.FSharp.DTO.Range' (code 1)
Compilation failed

@faldor20
Copy link
Contributor Author

@TheAngryByrd This should be fixed now, not sure what happened there, I must have not pushed something 🤦‍♂️

@TheAngryByrd
Copy link
Member

👋 I'm pretty busy until next week, I'll do another pass then.

@TheAngryByrd TheAngryByrd self-assigned this Aug 17, 2023
Copy link
Contributor

@baronfel baronfel left a comment

Choose a reason for hiding this comment

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

Nice - this really illustrates the shared workflow between the features. It'll also make it easier to add new kinds of lenses!

@baronfel baronfel dismissed TheAngryByrd’s stale review August 19, 2023 19:29

I've reviewed this now.

@baronfel baronfel merged commit 6e4ae40 into ionide:main Aug 19, 2023
1 of 2 checks passed
@baronfel
Copy link
Contributor

Thank you for this!

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