-
Notifications
You must be signed in to change notification settings - Fork 20
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
Add things to default JavaScriptLanguageSupport #5
Comments
anyone can help me ? |
Hi iberck To enabled this you need to enable the Rhino Engine support for the SourceCompletionProvider. To do this you need to override the JavaScriptLanguageSupport class and register this instead of the regular JavaScript support. Firstly you will need to write a class like this:
You will need to register the class with the RSyntaxTextArea like this:
Note that if you have the source file in the library archive also, you will also see the Javadoc comments for the methods and fields. Also you will be able to import package using the syntax:
package(java.io);
The auto complete for Java classes should really be implemented in the JSR223JavaScriptEngine, but has not been moved yet. Also it needs to be easier to switch modes between the engines instead of overriding an entire class. Anyway. I hope this helps. Steve |
thanks for your answer Mr. Steve Upton, I will try with the above code. |
Steve: I have tried with your example and it works, thank you very much ! Can you help me with another question? How can I add custom completions to JavaScriptCompletionProvider, for example add a code template for insert a predefined constant when press ctrl + space ? I have tried adding a basic completion in constructor of MySourceCompletionProvider but it does not work:
Thanks in advance. |
Hi iberck, The object you really need is the ShotHandCompletionCache inside the Source completion provider. But you cannot access this because it is not protected and does not have a getter. A bit of an oversight. The whole API needs a bit of work. Anyway, you can get round it by modifying your overridden SourceCompletion class as before and intercepting the getAlreadyEnteredText method... e.g
private class MySourceCompletionProvider extends SourceCompletionProvider
{
This is not pretty, but there is not other way to add the completions. Looks like a big hole in the API. Kind regards Steve |
Hi Steve: Thank you for your answer and your time, I will try with it. |
Thanks again Steve, the example works fine for my purposes, are there any way to add custom highlight to default javascript highlight, for example highlight the "importPackage" sentence? I have tried modifing JavaScriptTokenMaker.flex, are there any best way ? Kind regards. |
The only way I have changed this is to modify the flex and recompile it. The importPackage is Rhino specific, so maybe there needs to be a RhinoJavaScript.flax file? I originally added the JavaScript syntax/autocomplete as I needed it for a project at work. It is loosely based on the Java completions. It is not completely finished and some bits needs reworking as inner functions do not work that well. I have written all the JavaScript API as Java classes and pass them, but I would like to replace this with pure JavaScript files once I (or someone else) have fixed the inner functions and other areas I have missed. On the whole, I would expect it to support most autocomplete/syntax. Steve |
Thank you steve, it works !!! |
Hi , I want to know how to apply custom javascript library to language support? |
Hello first of all thanks for your effort making this magnificent library.
I'm using the latest version of library (rsyntaxtextarea, autocomplete, languagesupport) and I have been researching all weekend adding stuff to support javascript autocomplete but my snippets not work.
I'm using the autocomplete javascript support language and I want to add code templates and support of autocomplete of my own classes to the default javascript default autocomplete support.
My base code is:
with the the above code the javascript autocomplete default support works fine, when I press "ctrl+." appears a autocomplete with javascript basic functions however I don't know how can add something to autocomplete javascript default support.
My first doubt (add codetemplates to javascript elements):
How can I archive press "Ctrl +." and add the new item "log" with the default autocomplete javascript elements?
My second doubt (autocomplete my own classes):
I use in my scripts the java class: "com.example.MyClass" wich is in the "client.jar" file,
My problem is when I define a var of type "MyClass", the autocomplete of membes/methods of var MyClass does not work.
Y define the vars like:
How can I archive this?
I tried with several examples I've found in the forums but I can not make it work, for example I have tried to add class file source to the jarManager but does not do what I want:
I'm using netbeans rcp framework.
Thank you very much for your time and help.
The text was updated successfully, but these errors were encountered: