Hi Greg,
I'm glad you find the project useful! To get started with Jython code completion, the first thing to do would be to decide whether to "override" the standard Python highlighting (I assume Jython's syntax is a superset of Python's) and use it for Jython, or add your own Jython support. The former is simpler than the latter, and you can change this easily enough later.
Assuming the former, you'll want to examine RSTALanguageSupport project to see how things work. Maybe start with the C support in the org.fife.rsta.ac.c package. That does pretty much nothing but static code completions based off the CompletionXML.dtd you've already discovered, so it's fairly straightforward. You could copy that package as a starting point, for example, and rename the classes accordingly:
- Code: Select all
com.grog.rsta.jython.JythonLanguageSupport.java
com.grog.rsta.jython.JythonCompletionProvider.java
etc.
You need to register your new LanguageSupport with the org.fife.rsta.ac.LanguageSupportFactory so it can be used:
- Code: Select all
LanguageSupportFactory lsf = LanguageSupportFactory.get();
lsf.addLanguageSupport(SyntaxConstants.SYNTAX_STYLE_PYTHON, "com.grog.rsta.jython.JythonLanguageSupport");
...
lsf.register(myTextArea);
Now any RSyntaxTextArea editing SYNTAX_STYLE_PYTHON code should get code completion for whatever you put into your "jython.xml" (or whatever your equivalent of c.xml is named). This should get you any static code completions, for example, keywords or default-package functions (if there are any). You can even add parameter support as seen in the C example.
Once that's working, you could take a step back and look at using classes in the Java language support (org.fife.rsta.ac.java.*) to get code completion for simple Java packages, etc. Be forewarned though - I tried to comment the code well, but it's
far from documented. It's also certainly far from perfect, but I consider it "good enough", since even just code completions for members one level deep adds a "wow factor" to an application. In any case, the JavaScript support (org.fife.rsta.ac.js) is probably a shining example of how to grab and use stuff from the Java language support. Another user is graciously implementing JavaScript code completion (using Rhino, though I believe it's pluggable for any JSR223-compliant JS implementation), and his work allows users to point to classes in Java files and get code completion from them. So that would be a good resource.
Feel free to post any specific questions, and good luck!