georgewfraser / vscode-tree-sitter

Accurate syntax coloring for VSCode using tree-sitter
MIT License
175 stars 25 forks source link

Simple decorator #11

Closed linus-skold closed 5 years ago

linus-skold commented 5 years ago

Reduced the amount of SyntaxNode[] that are created & returned by each color function into a Map Added help functions to easily add to the colorMap Added function to create the functionStyle, typeStyle etc... from the key used to populate the colorMap. "functions" -> "treeSitter.function" and so on This makes it easier to scale and expand if more types of coloring is wanted.

georgewfraser commented 5 years ago

I'm a little concerned that generating the decorators dynamically will have performance implications. VSCode does a bunch of optimizations based on the fact that the set of decorators is fixed.

linus-skold commented 5 years ago

Where have you read that it does optimizations on being fixed? I'm wondering how VSCode would know that the decorator is fixed in the first place without doing static analysis? They're both being created and stored in VSCode, and if they already exist when you try to create it, it should return a color reference. I would assume that they use 'treeSitter.*' as a key and that they store the decorator in <key, value> pair.