junichi11 / netbeans-color-codes-preview

Show colors in an editor's sidebar
https://netbeans-vm.apache.org/pluginportal/catalogue/?id=24
Apache License 2.0
32 stars 8 forks source link

Color preview 2.0: improve color support in Java by using the source lexer instead of regular expressions #34

Closed jmborer closed 5 years ago

jmborer commented 5 years ago

The plugin for Java is currently based on regexp expressions. To take is big step further, it would require the plugin to use the abstract source tree (AST) provided by the source code lexer (the same that is used during completion to provide the methods, vars etc.) instead of regular expressions. This would open a whole new world for the plugin: it can then recognize Color constants or declarations of any subclass of color such as ColorUIResource.

jmborer commented 5 years ago

You can start looking here how to use JavaSource class: https://platform.netbeans.org/tutorials/60/nbm-copyfqn.html

junichi11 commented 5 years ago

Maybe, I won't do that because it's expensive to use a parser.

jmborer commented 5 years ago

Not sure it is so expensive. You would be just re-using something that already exists for completion for example, no?

junichi11 commented 5 years ago

I'm not sure whether we can use the same parser result as other features. Perhaps, can't use it. If we have to use it to implement very useful features, I would use it. Otherwise, I would like to avoid using it.