I recently discovered that ZeroBrane Studio 1.90 comes with a lexer for Java, which makes it nicely syntax color Java files. However, it seems that ZB cannot list Java functions in the Outline pane, like it does for Lua and C/C++. Digging a little bit, it seems that there is no specification file for Java that (IIUC) describes syntax and keywords and what a function definition looks like in Java etc.
I tried to roll my own with the spec file for C/C++ as template, and the tiny bit of documentation from here https://studio.zerobrane.com/doc-plugin#registering-a-specification, but I could not get my mind around it. The only thing I achieved was for the syntax coloring to disappear, so I had to delete the java-lua file in the spec/ folder.
Is there any such spec file for Java available? I have googled a lot for such a thing, but to no avail. Or does anyone have a link to documentation for these things?
Any help would be appreciated. Thanks
Something like this may work (just add it to your configuration file):
if not CMarkSymbols then dofile "spec/cbase.lua" end
local function javalex(self, editor)
if editor.spec.lexer == "lexlpeg.java" then editor.spec.marksymbols = CMarkSymbols end
end
package { onEditorNew = javalex, onEditorLoad = javalex }
This piggybacks on the function parser for C files, but since function definitions are similar for Java files, it should work for most of the cases. You can also check what's done in CMarkSymbols
and write a similar function that does what you need for Java. I tested on simple Java files and it lists the functions/methods for me. You can also play with it and add classes and indentations for functions (similar to how it's done for Lua functions inside other functions).