Bounty 200$ - VSCode haxe-jsx extention

Hello, haxe developers!

I’m going to write some articles about react.js/redux/mobx programming with haxe.
But to compete with typescript, haxe needs cross platform IDE with nice jsx support.
So here visual code studio haxe-jsx extention demands:

  • Separated from vshaxe
  • Support for haxe-react lib and it’s jsx-function
  • Components and properties highlight
  • Go to component class definition from jsx
  • ?Close tag and properties auto complete(may be this option requires separate bounty)

Bounties for implementation are 200$ from me and gratitude of haxe-js users. Please contact me via skype rebelxman or comment here:)

1 Like

Why “separated from vshaxe”

Just because of modularity principles. It’s easy to maintain, develop and provide release independence from haxe language extention.

I’d also like to take this opportunity to say thank you Philippe for your work in the field of haxe and react.js worlds integration:)

1 Like

Admittedly the foundation might not agree with building react support inside the general plugin (though something generic enough might be designed), but it would be troublesome to replicate project awareness / code navigation for instance.

By the way as you know haxedevelop does this thing without any problem.

1 Like

Regarding syntax highlighting of jsx, I did make a PR to haxe grammar a while ago but it was considered a bad idea to mix JSX/Framework-specific stuff with Haxe syntax itself. (see Add jsx() support. by jeremyfa · Pull Request #30 · vshaxe/haxe-TmLanguage · GitHub)

I guess it would be nice if the same thing was possible with a separate plugin that extends the official syntax without having to mix them together.

@jeremyfa and whay about @back2dos suggestion to colorise any XMLish string? Can an extension override the syntax without annoying user manipulations?

One point against colorizing everything XMLish: you would get a hint that it’s not JSX if it doesn’t get colourised if you forget the jsx function.

1 Like

I really wonder if anyone would mind if the standard Haxe plugin colorized strings that look like markup as markup. What would the downsides be?

That probably should be optional, but that could be useful in many scenarios.

Why though? I’m all for making it optional if there are good reasons, but so far I haven’t heard one, so forgive my curiosity ^^

That’s not how tmLanguage works I think, maybe we could have jsx highlighting included for haxe-react jsx(...) function and coconut’s function render() '...', because these are two largest libs in Haxe world (I think?)

Still I’d love to find a solution when we could keep library-specific highlighting separate from the basic haxe syntax rules.

Well, I think we should start somewhere. This is how HXX currently looks:

This is how the same code looks with the normal XML highlighting:

It’s certainly not perfect in that inline code is not treated at all, but it’s two things:

  1. way better
  2. not in any way framework specific

If we could say that string interpolation gets treated as before, that’d be a workable solution. I currently don’t use ${} which would highlight inline code, because I find it disturbing when inline code jumps out at me while the greater markup structure fades into the background.

I admit to have no clue about this part. But let’s not conflate feasibility and desirability. Jeremy said he could do it and it was rejected on quite philosophical grounds. Assuming for the sake of the argument that it can be done: are there concrete reasons not to do it?

In the end, we need to come to a conclusion on how haxe will handle this. I don’t see that happening any time soon. If in the mean time we could have a pragmatic solution, I would very much prefer that to having no solution at all. If you want to pitch Haxe as a front end tech, showing JSX/HXX without even highlighting is not exactly going to score points.

As mentioned in the PR, this solution wouldn’t be framework specific and would generally work whenever some kind of markup is embedded in Haxe code, which I would say is a Good Thing™.

Matching all strings that start with '< or "< is doable, but current work on the PR would need to be improved to match incomplete xml strings gracefully, which I believe is possible though not trivial.

An easier approach is a more pragmatic solution that matches specific cases like jsx('<somexml>string</somexml>').

Similarly, it would be fairly easy to match strings preceded by a specific haxe metadata as mentioned in the PR like:

@xml '<somexml>string</somexml>'

That would still be valid haxe syntax and allow to opt-in for xml syntax highlighting on a per-string basis.

None of these options is perfect and they all have pros and cons.

Imo, best option would be the one mentioned by @back2dos : match every string that starts with '< or "<, but with the addition that we update the tmLanguage syntax file so that invalid xml doesn’t break the whole file syntax highlighting (doable but not trivial).

I stopped working on these because it didn’t seem to get anywhere and I don’t want to spend my time for nothing but the issue (syntax highlighting of xml-like syntax) is still valid and indeed, as long as this is not solved, Javascript/Typescript will be miles ahead Haxe to make React applications despite the work of @elsassph and others. That feature would also be nice for generic inline xml string templating as well (non jsx/react).

I will be happy to resume my work on this if we come up with a practical solution that people could agree on though.

@elsassph I am not aware of any way to extend a grammar syntax file with a separate extension, but that would indeed be the best option. Should check out if there is any way to do this with VSCode.

After checking a bit more, I guess it would be possible to embed a grammar into another one if this vscode feature ever gets implemented, but no idea when this will become a reality.

Meanwhile, we could be pragmatic and add xml-string syntax highlighting in official haxe grammar file (in a way that it doesn’t break existing string parsing, so no harm done), and remove it in the future when vscode allows us to do it from a separate extension/grammar.

I am personally in favor of a solution that would be useful today, which can always be replaced by a better solution in the future if there is any. The xml syntax highlighting is fairly easy to remove or add from the haxe grammar file anyway so nothing has to be definitive here.

1 Like

Let’s do it :slight_smile:

1 Like

Cleanest would be to be able to completely override syntax coloring from another extension - feasible?

Otherwise, maybe we ask @nadako very nicely to add an option to Haxe’s VSCode?

@elsassph Not sure we can use an alternative grammar file depending on an option in haxe plugin (but maybe there is a way I don’t know?)

The only way to have alternative haxe grammar files I see is to first split current haxe plugin into 2 separate extensions: one for the completion/language server etc… and one just for the grammar. That way, it would be possible to replace the grammar independently from the rest.

Anyway, in both cases that means we need to create an haxe+xml grammar file, which may or may not become the default grammar, for now, in haxe plugin, like what I started in the PR.

I will see if I can update the grammar file I have been working on to match every xml string and be robust enough so that it doesn’t break syntax of whole file if the xml isn’t valid then.

If it’s enough to install a “haxe-jsx” extension to get that working it would be ok - not sure how the prioritisation of extensions work.

As mentioned here or there, relying on extensions load order to override config or grammar is rather hacky and should be avoided :confused: