tern.java icon indicating copy to clipboard operation
tern.java copied to clipboard

ES6 Syntax Coloration inside JSDT Editor

Open angelozerr opened this issue 10 years ago • 6 comments

This issue is about using https://github.com/katspaugh/tj-mode to highlight with tern/acorn ES6 code (syntax coloration for ES6 template, let, import, export, etc).

To highlight ES6 code inside JSDT Editor:

  • tern.java must provides an implementation of ITokenScanner which uses https://github.com/katspaugh/tj-mode
  • JSDT must provide an extension point to extends the existing JavaCodeScanner. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=473559#c3

angelozerr avatar Sep 01 '15 16:09 angelozerr

@piotrtomiak @vrubezhny @dgolovin I have explained how to highlight JSDT Tern Editor with acorn at https://github.com/angelozerr/tern.java/tree/master/sandbox

angelozerr avatar Sep 01 '15 16:09 angelozerr

@angelozerr FYI we've improved syntax coloring for Luna and Mars in the recent release of Webclipse within a new feature - JSjet - we're using acorn for this. It also ships with a modified version of Tern.java. Would you mind if I update the list of "Who is using" ?

P.S. JSjet is the main reason I was quiet recently on github ;)

piotrtomiak avatar May 13 '16 14:05 piotrtomiak

FYI we've improved syntax coloring for Luna and Mars in the recent release of Webclipse within a new feature - JSjet - we're using acorn for this.

Nice! You mean that you are using acorn direcly instead of using a tern plugin. If it that, I think it's a good idea. My fear is for large JS files. JSDT 2.0.0 uses now esprima with Nashorm and for big files, it's very slow. They will study Google closure which seems to be fast.

I have too in my side studied how to support syntax coloration for my TypeScript Editor which is based on JSDT. Today I'm using JSDT token scanner, but I would like really support JSX syntax coloration. SO I have studied how VSCode have done that and it uses TextMate grammar. So I have ported quickly vscode-textmate projet written in TypeScript in Java inside https://github.com/angelozerr/textmate.java

It starts working but it can be slow (5sec) for large file. If you are interested with this project, I will be glad to collaborate together.

JSjet - we're using acorn for this. It also ships with a modified version of Tern.java.

Why?

Would you mind if I update the list of "Who is using" ?

yes sure with pleasure!

P.S. JSjet is the main reason I was quiet recently on github ;)

I understand, glad to have your news!

angelozerr avatar May 13 '16 15:05 angelozerr

It starts working but it can be slow (5sec) for large file. If you are interested with this project, I will be glad to collaborate together.

Let's see. Our current approach turns out to be really neat. With tsserver.js file our code performs really good and we will add more improvements to make it even faster.

JSjet - we're using acorn for this. It also ships with a modified version of Tern.java.

Why?

We've wanted to merge Tern seamlessly with JSDT and most of the changes are around preference pages reordering and include path.

piotrtomiak avatar May 16 '16 08:05 piotrtomiak

Let's see. Our current approach turns out to be really neat. With tsserver.js file our code performs really good and we will add more improvements to make it even faster.

That's very strange, JSDT 2.0.0 is very slow with esprima + Nashorm with tsserver.js. But perhaps you have optimized acorn walk (like tern-tjmode) to just return few JSON stream.and perhaps you execute acorn with J2V8?

What do you think about https://github.com/angelozerr/textmate.java? Could you be interested?

We've wanted to merge Tern seamlessly with JSDT and most of the changes are around preference pages reordering and include path.

Ok you mean tern script path. Thanks for your feedback?

angelozerr avatar May 16 '16 09:05 angelozerr

What do you think about https://github.com/angelozerr/textmate.java? Could you be interested?

Not immediately. We are focusing on plain JavaScript for now. I hope to be able to get to TypeScript soon.

piotrtomiak avatar May 16 '16 11:05 piotrtomiak