add things to default JavaScriptLanguageSupport

Questions on using RSyntaxTextArea should go here.

Moderator: robert

add things to default JavaScriptLanguageSupport

Postby iberck » Mon Nov 11, 2013 6:42 pm

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:
Code: Select all
    private RSyntaxTextArea createTextAreaEditor() {
        textAreaEditor = new RSyntaxTextArea();
        textAreaEditor.setCaretPosition(0);
        textAreaEditor.requestFocusInWindow();
        textAreaEditor.setMarkOccurrences(true);
        textAreaEditor.setTabsEmulated(true);
        textAreaEditor.setTabSize(4);
        ToolTipManager.sharedInstance().registerComponent(textAreaEditor);
       
        textAreaEditor.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVASCRIPT);
        textAreaEditor.setCodeFoldingEnabled(true);
        textAreaEditor.setAntiAliasingEnabled(true);

        return textAreaEditor;
    }

    private void createLanguageSupport() {
        LanguageSupportFactory lsf = LanguageSupportFactory.get();
        lsf.register(textAreaEditor);
        LanguageSupport support = lsf.getSupportFor(SyntaxConstants.SYNTAX_STYLE_JAVASCRIPT);
        JavaScriptLanguageSupport languageSupport = (JavaScriptLanguageSupport) support;
        try {
            languageSupport.getJarManager().addCurrentJreClassFileSource();
        } catch (IOException ex) {
            Logger.getLogger(ScriptEditorJDialog.class.getName()).log(Level.SEVERE, null, ex);
        }
    }


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:
Code: Select all
var n = new Packages.com.example.MyClass();
n. (autocomplete does not work)
var r = new MyClass();
r. (autocomplete does not work)


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:

Code: Select all
        LanguageSupportFactory lsf = LanguageSupportFactory.get();
        lsf.register(textAreaEditor);
        LanguageSupport support = lsf.getSupportFor(SyntaxConstants.SYNTAX_STYLE_JAVASCRIPT);
        JavaScriptLanguageSupport languageSupport = (JavaScriptLanguageSupport) support;
        JarManager jarManager = languageSupport.getJarManager();
        try {
            jarManager.addClassFileSource(new JarLibraryInfo("d:/projects/client.jar"));
        } catch (IOException ex) {
            Logger.getLogger(ScriptEditorJDialog.class.getName()).log(Level.SEVERE, null, ex);
        }       


I'm using netbeans rcp framework.
Thank you very much for your time and help.
iberck
 

Re: add things to default JavaScriptLanguageSupport

Postby robert » Tue Nov 12, 2013 2:09 pm

Hi iberck,

I don't use the JS language support too much, and it is contributed by another user, so you may get better visibility if you post these questions as an issue on GitHub. The author will then get notification of the issue and might respond (I don't think he monitors this forum).
User avatar
robert
 
Posts: 798
Joined: Sat May 10, 2008 5:16 pm

Re: add things to default JavaScriptLanguageSupport

Postby Guest » Tue Nov 12, 2013 3:50 pm

Thank you robert, I will post in github.
Regards
Guest
 


Return to Help

Who is online

Users browsing this forum: Google [Bot] and 2 guests

cron