Giter VIP home page Giter VIP logo

Comments (6)

RDambrosio016 avatar RDambrosio016 commented on July 25, 2024 1

i would rather stick with primary/secondary and then just add info, i dont think theres a difference between info, note, and help

from rslint.

Stupremee avatar Stupremee commented on July 25, 2024

Can you name more benefits that make annotate-snippets better than codespan (except multiline-suggestions)?

Edit: I looked a bit through annotate-snippets documentation and it looks like it can display much more stuff but it definitely requires a better API to use it in RSLint.

from rslint.

Stupremee avatar Stupremee commented on July 25, 2024

I came up with a simple API design that is similair to codespan-reporting but adjusted to work with annotate-snippets

// not sure if we want to change the name to `Snippet` or stay with `Diagnostic`
Snippet::new(file_id)
    .title(Annotation::note("SyntaxError", "expected `,`, found `;`"))
    .annotate(AnnotatioType::Error, span, "")
    .annotate_help(span, "remove this `;`")
    .footer(Footer::help("remove this `;`"))

To display the errors we could take a similar approach as codespan-reporting and have an extra method (emit)
that will take a impl Files and Vec<Snippet> and will display them.

from rslint.

RDambrosio016 avatar RDambrosio016 commented on July 25, 2024

I would rather not keep the Snippet name, i dont really like it, i think diagnostic is better and most of rslint uses the word diagnostic. Moreover, id like to keep the diagnostic builder interface for the most part, also, id like to take some ideas from rustc_errors. I think this would be better:

Diagnostic::new(file_id, "some-code", "some error name here")
  .primary(span, "oh no")
  .secondary(span, "oh wow")
  .suggestion(Applicability::Always, "isNaN(foo)")

I think for the struct we can take some ideas from rustc_errors, notes are sub-diagnostics, suggestions are a vector of suggestions, etc. suggestions would use a diff to label any insertions, and we can also have other kinds of sub-diagnostics. Annotate-snippets' IR makes it easy for us to define our own diagnostic features

from rslint.

Stupremee avatar Stupremee commented on July 25, 2024

So you don't want to use the different annotation types for the labels / annotations that can be used in annotate-snippets?
I think they can be quite useful.

from rslint.

Stupremee avatar Stupremee commented on July 25, 2024

I will officially work on this now

from rslint.

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.