Coder Social home page Coder Social logo

Comments (8)

incendial avatar incendial commented on September 28, 2024

@DanTup fyi

from sdk.

DanTup avatar DanTup commented on September 28, 2024

@incendial I don't seem to be able to reproduce. The fixes run (the backslashes are removed), but no errors:

Recording.2024-03-04.143530.mp4

Can you reproduce in a new project, or only a specific one? Could you show a list of all the diagnostics you see for this file (and which fixes appear for each of the diagnostics)? It seems like we're trying to use both a FileEditBuilder and DartFileEditBuilder on the same file but I'm not sure which fix the FileEditBuilder is coming from.

from sdk.

DanTup avatar DanTup commented on September 28, 2024

btw, looks like I don't have any diagnostics on the last line which might be why I'm not triggering it - I presume if removing that line fixes it, you might have a diagnostic/fix showing up for it?

from sdk.

incendial avatar incendial commented on September 28, 2024
Screenshot 2024-03-04 at 18 41 48

Can you try enabling "use_raw_strings"?

from sdk.

DanTup avatar DanTup commented on September 28, 2024

Aha, that triggers it. Thanks!

from sdk.

DanTup avatar DanTup commented on September 28, 2024

@bwilkerson this is happening because the fixes use a mix of generic and Dart file builders. If there is a fix using each in the same file it results in this error when trying to fix both (both for the LSP server's "fix all" and dart fix).

For example remove_unnecessary_string_escapes uses the generic builder:

But convert_to_raw_string uses a Dart builder:

await builder.addDartFileEdit(file, (builder) {

I thought the right fix would be for the fixes to always use Dart edit builders and we should change the interface so they can't accidentally create other kinds of edit builders. However, we have a fix "Ignore diagnostic in analysis_options.yaml" which is a Dart fix but edits a non-Dart file and I realise that's not quite right.

One possibility would be to have addGenericFileEdit() return a Dart edit builder if called for a Dart file - however a Dart edit builder is not currently a superclass of a generic edit builder. So another option could be to just remove addGenericFileEdit entirely and force all code through a specific edit builder (Dart or YAML, and if we have other file types, make more specifically-named methods for each of them).

Any thoughts/opinions?

from sdk.

DanTup avatar DanTup commented on September 28, 2024

Maybe a slightly simpler idea: add an assert to addGenericFileEdit to ensure it's not called for Dart or YAML files. As long as all callers have some test it should avoid this happening accidentally (but avoids having to make a breaking API change).

I opened https://dart-review.googlesource.com/c/sdk/+/355441 along these lines.

from sdk.

bwilkerson avatar bwilkerson commented on September 28, 2024

For example remove_unnecessary_string_escapes uses the generic builder

That's definitely a bug. The fix clearly only applies to Dart files.

Maybe a slightly simpler idea: add an assert to addGenericFileEdit to ensure it's not called for Dart or YAML files.

I like that idea.

from sdk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.