Thanks to visit codestin.com
Credit goes to github.com

Skip to content

[SUSPENDED] REPL shows quick fixes [ci: last-only] #10499

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

Draft
wants to merge 1 commit into
base: 2.13.x
Choose a base branch
from

Conversation

som-snytt
Copy link
Contributor

@scala-jenkins scala-jenkins added this to the 2.13.13 milestone Aug 14, 2023
@SethTisue SethTisue modified the milestones: 2.13.13, 2.13.12 Aug 14, 2023
@som-snytt som-snytt force-pushed the issue/12844-repl-actions branch from f3067a1 to 20ecf9d Compare August 14, 2023 19:52
@som-snytt
Copy link
Contributor Author

Test shows which error currently has a quick fix.

scala> '\060'
        ^
       error: octal escape literals are unsupported: use \u0030 instead

scala> def foo() { }
                 ^
       warning: procedure syntax is deprecated: instead, add `: Unit =` to explicitly declare `foo`'s return type

quick> def foo(): Unit = { } // procedure syntax (defn)
def foo(): Unit

Rust underlines the modification.

  |
2 |     let guess = "42".parse().expect("Not a number!");
  |         ^^^^^
  |
help: consider giving `guess` an explicit type
  |
2 |     let guess: _ = "42".parse().expect("Not a number!");
  |              +++

An alternative 5-character prompt:

help!> def foo(): Unit = { } // procedure syntax (defn)

@som-snytt som-snytt force-pushed the issue/12844-repl-actions branch from 20ecf9d to 7cdbf68 Compare August 15, 2023 16:35
@som-snytt
Copy link
Contributor Author

It should obey -quickfix, which REPL should default to -quickfix:any.

Copy link
Member

@lrytz lrytz left a comment

Choose a reason for hiding this comment

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

Will be nice to have this in the release 👍

Maybe bad idea: store the quickfixed version in the REPL history instead of the original one?

@som-snytt
Copy link
Contributor Author

som-snytt commented Aug 16, 2023

I, too, thought of putting the edit in history; I'm glad you like my bad idea. That is easier than cut/paste.

I deferred handling multi-line, but the goal is probably to do something nicer.

I didn't test multi-warn, but the goal was one quick prompt with a long comment.

Thanks for trying it out. I'll make an effort to finish it up, given your feedback.

@SethTisue SethTisue modified the milestones: 2.13.12, 2.13.13 Aug 23, 2023
@SethTisue SethTisue added the prio:hi high priority (used only by core team, only near release time) label Sep 19, 2023
@SethTisue
Copy link
Member

@som-snytt ready to return this? this is one I'm especially eager to see land

@som-snytt

This comment was marked as outdated.

@SethTisue

This comment was marked as outdated.

@som-snytt

This comment was marked as outdated.

@som-snytt

This comment was marked as outdated.

@som-snytt som-snytt force-pushed the issue/12844-repl-actions branch from 7cdbf68 to 64f4a14 Compare October 28, 2023 16:01
@lrytz lrytz force-pushed the issue/12844-repl-actions branch from 64f4a14 to b1389bc Compare November 29, 2023 07:49
@lrytz
Copy link
Member

lrytz commented Nov 29, 2023

@SethTisue since you added the prio:hi label, can you take a look?

@som-snytt som-snytt force-pushed the issue/12844-repl-actions branch from b1389bc to 117885b Compare December 5, 2023 23:35
@lrytz lrytz removed the prio:hi high priority (used only by core team, only near release time) label Dec 19, 2023
@som-snytt som-snytt changed the title REPL shows quick fixes REPL shows quick fixes [ci: last-only] Jan 16, 2024
@som-snytt som-snytt force-pushed the issue/12844-repl-actions branch from 117885b to 68d29fd Compare January 16, 2024 20:46
@som-snytt
Copy link
Contributor Author

Oh wait, they removed prio: hi, the pressure is totally off.

After I get the previous effort to green check, I would prefer that the REPL emit the amended line just once, when all reporting is done. Adding the amended line to history would require all edits.

I recall from last summer that finish is not used since my version of reporting was scrapped. There must be an obvious mechanism for "emit your summary" since -Wconf filtering happens after the run. Maybe that's because you need msg A to hide msg B even if A is suppressed later?

Since I'm not very motivated, maybe the current solution suffices.

@som-snytt
Copy link
Contributor Author

som-snytt commented Jan 16, 2024

@SethTisue is going to take a look right after reviewing that other PR.

Marking RFR so I don't forget.

@som-snytt som-snytt marked this pull request as ready for review January 16, 2024 21:10
@SethTisue
Copy link
Member

SethTisue commented Jan 26, 2024

Code changes seem fine. I'm less sure about the UX.

Let's start by recalling the existing behavior (in 2.13.12), for comparison:

Screenshot 2024-01-26 at 12 00 26 PM

Here the new behavior with the same all-in-one-line example

Screenshot 2024-01-26 at 11 50 59 AM

and I think this what Som means by "I deferred handling multi-line, but the goal is probably to do something nicer" :

Screenshot 2024-01-26 at 11 50 59 AM

because the fix isn't on the first line, we don't get the fixed> thing showing us the fix.

The one-line example above seems pretty confusing to me. If a beginner saw this and didn't know anything about any of this, I think there's a good chance they'd be somewhat bewildered.

The multi-line screen shot is less featureful, but perhaps also less confusing. It fixed it for me without printing a bunch of potentially confusing extra stuff.

@som-snytt how attached are you to this fixed> thing in its current form? You have given this more thought than I have, but my first reaction is that it might actually be better to ship this without that stuff, so the UX is the same regardless of first-line vs multi-line.

The placement of [rewritten by -quickfix] seems confusing to me. It's telling me it rewrote something, but it hasn't even showed me the warning yet! If I could ask for one small change to this, it would be to put that later:

scala> def foo() { () }
                 ^
       warning: procedure syntax is deprecated: instead, ... [quickfixable]

applying quickfix. new code is:
def foo(): Unit = { () } // replace procedure syntax

def foo(): Unit

In the multiline case, it would be annoying to repeat an entire long piece of code just to show a one-line change. A slightly more ambitious change that would scale well to multiple lines and multiple quickfixes would be to use diff markers, like this:

scala> def foo()
     | {
     |   ()
     | }
       {
       ^
On line 2: warning: procedure syntax is deprecated: instead, ... [quickfixable]

applying quickfix:
- def foo()
+ def foo(): Unit =

def foo(): Unit

Wdyt?

Separate question: not sure it's desirable to always simply apply the fix. Have you considered a (y/n) type interaction, perhaps:

scala> def foo() { () }
                 ^
       warning: procedure syntax is deprecated: instead, ... [quickfixable]

- def foo()
+ def foo(): Unit =

Apply quickfix (y/n)? y

def foo(): Unit

For 2.13.13, I'm not sure whether to just say (as Adriaan used to) "let's book the progress". We don't know how much time we have (since we are waiting on 3.4.0), and also @som-snytt I don't know how much appetite you have for tinkering with this further, and or your opinions on my suggestions above. Thoughts?

@SethTisue SethTisue removed their assignment Jan 26, 2024
@som-snytt
Copy link
Contributor Author

I'll close this because I won't be researching the text presentation.

I'll look at whether the tweak to how edits are applied is worth using.

The goal was naive users get to see their mistakes auto-corrected in REPL.

@som-snytt som-snytt closed this Jan 26, 2024
@som-snytt som-snytt changed the title REPL shows quick fixes [ci: last-only] [SUSPENDED] REPL shows quick fixes [ci: last-only] Jan 27, 2024
@SethTisue SethTisue removed this from the 2.13.13 milestone Feb 10, 2024
@som-snytt
Copy link
Contributor Author

A year later, it looks like a neat idea.

@som-snytt som-snytt reopened this Jan 27, 2025
@scala-jenkins scala-jenkins added this to the 2.13.17 milestone Jan 27, 2025
@som-snytt som-snytt marked this pull request as draft January 31, 2025 05:04
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.

REPL should show code actions
4 participants