This repository was archived by the owner on Dec 15, 2022. It is now read-only.
Fix lost colorization of function declaration names #653
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Requirements
Description of the Change
A recent update to https://github.com/tree-sitter/tree-sitter-javascript restructured the way function declarations are constructed in the syntax tree. This change is not present in the latest stable Atom (v1.38.0 at the time of this writing), but is present when I forked language-javascript (v0.132.0 at the time of this writing).
In effect, when I cloned and linked
language-javascript, the names for function declarations are no longer colorized.Current:

This PR restores colorization for function declaration names, according to the new syntax tree structure.
After this PR is merged:

Syntax tree in Atom 1.38.0 (working):

Syntax tree in language-javascript 0.132.0 (what breaks things):

Alternate Designs
A different selector could theoretically be used, but
function_declaration > identifierseemed most appropriate and consistent with what was already present in the grammar.Benefits
Colorization for function declaration names is restored to its former glory!
Possible Drawbacks
None that I can see, as the change is small and limited in scope, and per my screenshot above, function expressions are not negatively impacted by this change.
Applicable Issues
N/A