Dart-Code icon indicating copy to clipboard operation
Dart-Code copied to clipboard

Make it easier to debug missing parentheses

Open 12people opened this issue 6 years ago • 4 comments

When my parentheses are off while writing Dart code, it's not clear where I should add or remove them. It can be frustrating trying to debug.

(Making things worse, VSCode doesn't add parenthesis when there's already a parenthesis to the right of a cursor. It often happens that I do not notice that a parenthesis that I meant to add wasn't added because of this.)

Please make it easier to find where to put a missing parenthesis.

12people avatar Jul 05 '19 07:07 12people

One way to make it clearer would be to be able to have dartfmt run up until the first error. Right now dartfmt just doesn't run when there are analysis errors, but dartfmt-ing everything up to the first error might help me sort out parenthesis/brace problems through indents?

eseidel avatar Jun 08 '21 19:06 eseidel

https://github.com/Dart-Code/Dart-Code/issues/3344 seems related too.

eseidel avatar Jun 08 '21 19:06 eseidel

I'm not sure if we could reliably format up to the first error since truncating there would likely also be invalid code and rejected by dartfmt.

Although I wonder if we could try auto-inserting them at the location where there are "expected )"-style errors, then re-parse (and repeat) to see if we can end up with valid code?

Something similar was discussed for semicolons at https://github.com/dart-lang/sdk/issues/45427, though there were some ambigious cases. If we're able to only do it if it produces valid code, then that might cut out some of the issues (although it may also narrow the number of cases where it works too).

DanTup avatar Jun 08 '21 20:06 DanTup

Also related to https://github.com/dart-lang/sdk/issues/46916

FMorschel avatar Aug 30 '24 22:08 FMorschel