atom / language-javascript

JavaScript language package for Atom
Other
194 stars 236 forks source link

List of missing scopes in comparison to language-babel #625

Open atomiks opened 6 years ago

atomiks commented 6 years ago

Prerequisites

Description

Comparing the new language-javascript using tree-sitter grammar and language-babel using the old system, I'm noticing many missing features, to the point where I can't use it yet but would like to. I hope that this list will help you improve the current highlighting.

class Example {
  notScopedAsFunction = () => {}
  scopedAsFunction() {}
}

Versions

1.32.2

Ben3eeE commented 6 years ago

this is missing a scope

This is tracked in https://github.com/atom/language-javascript/issues/618

Bracket matcher doesn't match JSX tags, but it does in language-babel

This is tracked in https://github.com/atom/bracket-matcher/issues/355


Opened a PR for some of the others. Arrow functions and - in negative constant literals I am not sure about.

atomiks commented 6 years ago

I've updated the OP in accordance with the PR merge and separately tracked issues.

The two that need addressing is the arrow function styling for classes and standalone functions. I'll update the issue if I find anything else missing

savetheclocktower commented 5 years ago

The two cases that are not yet addressed are not possible without feature additions to Atom. The arrow function and its name are considered siblings in the parsed tree-sitter hierarchy, and there's no way to isolate (e.g.) "identifier with arrow-function as its next sibling" in a grammar, as @maxbrunsfeld described here. This would also be useful for highlighting foo as a function in the code let obj = { foo: () => {} } and its equivalents.

This is less of a need with modern JS syntactic niceties; hell, I remember when IE would leak memory if you used named function expressions. But arrow functions in class property bodies will remain popular as a way of binding this to the class instance, so I don't think it's something we can avoid altogether.

So the underlying request here is to "extend[] our AST-based highlighting system to support non-local relationships," in @maxbrunsfeld's words. I'd like to create a ticket for this, but I'm not sure which repo it belongs in. Can someone point me in the right direction?