Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JavaScript] Rationalize function name detection. #2267

Open
Thom1729 opened this issue Feb 6, 2020 · 2 comments
Open

[JavaScript] Rationalize function name detection. #2267

Thom1729 opened this issue Feb 6, 2020 · 2 comments
Labels
C: Syntax T: enhancement Improvement of existing language features

Comments

@Thom1729
Copy link
Collaborator

Thom1729 commented Feb 6, 2020

In some cases, the current JavaScript syntax will highlight a variable name, mapping key, or property name as a function name (entity.name.function):

const f = function() {};

const obj = {
    f: function() {}
};

obj.f = function() {};

Originally, this seems to have been a convenience feature for display purposes. The implementation uses lookaheads and is not reliable, leading to an uneven user experience.

However, there is a real JavaScript feature by which anonymous functions will be named using the surrounding context in some cases. We could detect most of these cases using branching and reimplement the special name highlighting in terms of the language feature. This would seem to be the most correct way of handling what is otherwise a vaguely-motivated special case.

@michaelblyons
Copy link
Collaborator

Closed with #2417?

@Thom1729
Copy link
Collaborator Author

That one improves arrow function detection, but it still uses awkward lookaheads to highlight the “names” of anonymous functions. I've been looking into ways to rewrite that to avoid the messy lookaheads, but haven't hit upon the right implementation yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: Syntax T: enhancement Improvement of existing language features
Projects
None yet
Development

No branches or pull requests

3 participants