-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Custom colours for declarations and uses of local variables #132
Comments
I'm sorry, but I didn't remember that I had opened a similar issue before (#119). Please, close that one. Today I've downloaded the source code of
That way, I've been able to compile the project. Later, I've looked into the source code, but my knowledge about the NetBeans Platform, and about lexers and parsers, is scarce. So I've had to read some articles about the latter. My conclusion is that, to achieve what I want, a lexer is not enough: I need a parser that gives me the AST (abstract syntax tree), to know the context and differentiate what's a local variable, what's a method call, etc. Am I right? Checking the code, I've seen some classes that seem to form the lexer of Thank you. |
That feature would be great to have. I really would like to help but my knowledge about lexer and parser is same as your level. |
I've continued reading about this topic today (very interesting, by the way), and I can confirm that we need a parser. But not any parser: we need one that is able to build the AST even though the source code contains errors. Indeed, that will be the most common situation, because the user will be editing the code while the highlighting is in progress. Check this, specially the last answer: https://stackoverflow.com/questions/44484852/is-it-advisable-to-use-tokens-for-the-purpose-of-syntax-highlighting . On the other hand, I've been wondering how NetBeans highlights the Java code. I remember that they use a custom version of So I guess that they use the parser of this modified Can we easily get the AST from a TypeScript file? Well, 2 years ago I played with the samples shown here: https://github.com/Microsoft/TypeScript/wiki/Using-the-Compiler-API . One of them is called Traversing the AST with a little linter and shows you how to inspect the whole AST. Is it tolerant to errors in the code? I didn't test it but I think so. The problem is: How would we connect this TypeScript code with @Chris2011: I guess that our first step should be learning about the NetBeans Platform (what parts make it up, how they work, etc.) Without that, I guess that any further step would be (almost) useless. In my case the problem is that I've not much spare time :S . But I would love learning and being able to extend my favourite IDE. |
Short answer, nbts uses the Language Server Protocol (LSP) of TypeScript. |
@Chris2011 But also for the syntax highlighting? I've checked the source code of |
For this, I think @jamie-everlaw or @jeffrey-easyesi can help here out to answer that question. |
From the last days, I learned that LSP can't handle syntax highlighting yet. But there is a proposal for smth like that: microsoft/vscode-languageserver-node#367. So you need to do smth else. What I know, back the days, when I had a look into the plugin, they copied the JS tokens from the JS implementation of NetBeans, because the API for getting the tokens is not public. I don't know whether they used JavaCC or ANTLR. |
Kind of own lexer, so used the JSTokens from NetBeans and extends them. |
Hello:
I think that it would be very useful if we could configure different colours for the declarations and uses of local variables. This feature is available when editing code in Java and JavaScript, and it helps a lot to identify, at first sight, which variables are declared in each method or block of code.
Will you be so kind to add this feature, please?
Thank you.
The text was updated successfully, but these errors were encountered: