Giter Club home page Giter Club logo

Comments (9)

steelbrain avatar steelbrain commented on August 15, 2024

We actually cannot do this because we do not accept textEditor in parse, we can change that if we really want to do this. Thoughts?

from atom-linter.

Arcanemagus avatar Arcanemagus commented on August 15, 2024

Personally I think the benefit of the much better ranges returned to the user is worth the addition of passing in a TextEditor to the parse method, and I can't think of any cases where that would pose a major problem.

Almost all of the maintained linters long ago abandoned the parse() method, so this will mainly be an issue for the linters that need attention anyway.

from atom-linter.

pablomayobre avatar pablomayobre commented on August 15, 2024

So you would need to pass TextEditor, data, regex and options/flags? Mmm is there a way to reduce the number of things passed?

Maybe this library could generate a parser object, its constructor would take the regex and it's flags. This object can be stored by the linter. When you call the parse function of this object, you pass the TextEditor and the data generated by the linter, and that returns a valid Message.

Would there be a need to pass the filepath? You can get that from the TextEditor anyway

from atom-linter.

Arcanemagus avatar Arcanemagus commented on August 15, 2024

I just realized we can work around the need to pass in a TextEditor by using the approach taken here.

Essentially all open TextEditor's are searched for (the first) one matching the path from the message, if one can be found it is used to enhance the range returned with a "word range", otherwise the range can fall back to the current version where we just generate a fake one character range, and leave it to a subsequent lint when that file is open to expand it.

If we also move to using a JavaScript RegEx object instead of the XRegExp library, we can just have a raw regex passed in, which would allow us to cut out the flags part of the options. Combining the two allows the options parameter to be removed entirely.

I'm still not sure whether this function should be implemented at all, but the above plan would at least get us better ranges when possible, without requiring an additional parameter.

from atom-linter.

pablomayobre avatar pablomayobre commented on August 15, 2024

If the needs for flags is removed then it would be preferred to pass the TextEditor object itself, and not just it's path.

But if you are to implement this please consider bundling #166 in the mix to reduce the needed massaging currently required for parse

PS: We could make a list of linters currently using parse (I would be glad to submit PRs to them to upgrade to this new syntax with the proposed enhancements)

from atom-linter.

Arcanemagus avatar Arcanemagus commented on August 15, 2024

If the needs for flags is removed then it would be preferred to pass the TextEditor object itself, and not just it's path.

I meant the path would also be omitted, since it should be being parsed from the messages. Thinking about it a bit more though, it would have to be an optional argument for the linters that don't give the path in their output.

If we search for the TextEditor instead of relying on it being passed in then parse could be used for project level providers... not that it should 😛.

consider bundling #166 in the mix

Updating to v2 messages is a breaking change, if the parameters passed in here end up being changed then that will definitely be included since both are breaking changes.

from atom-linter.

pablomayobre avatar pablomayobre commented on August 15, 2024

Cool with me! Just a question about generateRange how would you provide a colEnd like the one that parse accepts?

Also how would you use a simple RegEx to provide all the information needed in parse? I didn't get that part

from atom-linter.

Arcanemagus avatar Arcanemagus commented on August 15, 2024

Just a question about generateRange how would you provide a colEnd like the one that parse accepts?

If you have a colEnd, then you don't need to call generateRange at all as you have an entire range already 😉.

Also how would you use a simple RegEx to provide all the information needed in parse? I didn't get that part

XRegExp is just a library that allows "perl like" regex, the major difference being that in pure JS regex you can only have a capturing group /(stuff)/, which with other libraries you can name a capturing group /(<name>:stuff)/. It's just a convenience tool... unfortunately I think we would need to keep it in here since the regex passed in is going to have different orders of where things are in the results, meaning we can't just use the same index into the result array for say "line".

from atom-linter.

Arcanemagus avatar Arcanemagus commented on August 15, 2024

Closing as the parse method will be being removed in a future release.

from atom-linter.

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.