Graph: Support JSX syntax highlighting#62027
Conversation
| @@ -0,0 +1,2 @@ | |||
| ;; This file inherits from javascript/highlights.scm | |||
| (jsx_attribute (property_identifier) @identifier.attribute) | |||
There was a problem hiding this comment.
@varungandhi-src This is the only thing we were specifically highlighting in our tsx file so I kept this the same here
There was a problem hiding this comment.
For the source of truth, we rely on languages.yml in Linguist, because language detection going forward is based on go-enry, which in turn is based on Linguist. Yes, there is some old code relying on language detection from syntect, but we want to rely on that less with time.
https://sourcegraph.com/github.com/github-linguist/linguist/-/blob/lib/linguist/languages.yml
You'll notice that TSX and TypeScript are listed as separate languages there, whereas the 'jsx' file extension is present on JavaScript. So we should not introduce a new language/ParserId for JSX here, we should instead:
- Add the JSX-specific query to the existing JavaScript queries
- Make sure that
.jsxfiles are getting mapped toJavaScriptin the language detection code in our Go wrapper code for go-enry inpackage languages.
When JavaScript (or javascript) is passed as the language from the Go code, we should use the correct Tree-sitter grammar automatically.
|
|
||
| var baseHighlightConfig = syntaxHighlightConfig{ | ||
| Extensions: map[string]string{ | ||
| "jsx": "jsx", // default `getLanguage()` helper doesn't handle JSX |
There was a problem hiding this comment.
This is not needed, since go-enry properly returns jsx as javascript which is what we want
|
I noticed that the SCIP kind was copied from tsx/highlights.scm and it was incorrect there too. So I've fixed the SCIP kinds (see scip.proto for descriptions https://github.com/sourcegraph/scip/blob/main/scip.proto#L582-L583). It looks like Updated screenshots in light mode and dark mode. |
Co-authored-by: Varun Gandhi <varun.gandhi@sourcegraph.com>
Adds support to highlight JSX files. Co-authored-by: Varun Gandhi <varun.gandhi@sourcegraph.com> (cherry picked from commit 2f57b2d)
Fixes ENG-20458
Fixes https://github.com/sourcegraph/sourcegraph/issues/50596
Adds support to highlight JSX files. Adds new SCM file for jsx.
Test plan