Getting Netbeans autocomplete working for a JavaScript project with lots of classes as includes

840 views Asked by At

I have a project in Netbeans 8.0 with around 12 javascript includes. When in one JavaScript class file, if I instantiate another custom class from the project and press "." after the var name, it does not pop up any autocompletes with my member variables and methods from my classes in the project.

Example: in one javascript file have a class like :

class Person(){
    doStuff(){
        // sh happens
    }
}

and in another javascript include, (both of which are included in index.html as the project's main URL in the project properties) try to reference it mid-code like...

class StaffManager(){
    manageStuff(){
        var aPerson = new Person();
            aPerson.doSt ;/* BY THIS TIME AUTOCOMPLETE SHOULD BE SAYING "doStuff()" right? (I had to add the semicolon for stack overflow not to throw err)*/

    }
}

Look at the commment, that's where you stop typing because autocomplete is giving you options from the class... or so it did in my old IDE's.

Is this supposed to work in Netbeans? Or what did I miss?

  • Do I need to start some kind of class path declaration? (can't it just parse my project?)
  • Does it parse "new ___()" to reference classes for autocomplete or is there any way to type cast vars that makes autocomplete work?

I'm new to OOP application development in javascript using Netbeans, and am missing something pretty game-changing for rapidly developing software: proper auto complete for custom classes. I'm assuming it MUST do this, as so many other IDEs do, but if not please also feel free to suggest how easy it can be in other IDEs that do this auto-magically.

Thank You.

2

There are 2 answers

1
Chrizzly On

First you can try to import your Person object via the ES2015 import. So import * from Person or smth like that. This is, maybe a better way if it is possible on your enviroment. And than you can see, whether it is working or not.

If not feel free to create a ticket here please, with steps to reproduce and maybe a little sample project: https://issues.apache.org/jira/projects/NETBEANS. Would be help a lot. I think it should work, I can test it later too.

Thx :)

0
OG Sean On

Update:

Apparently what I want to do with these classes is only in the ES6 spec that may not have been supported until maybe Netbeans 8.2, I found this article highlighting a bunch of E6 syntax additions to the editor that are right up this alley.

This came out last year (2016) so I don't know how I missed the memo. I've been coding valid programming with no autocomplete and red underlined error flags for too long! If you are doing ES6 and are using Netbeans 8.1 or older you should definitely upgrade asap!

Here's the reference to that article where it gives some nice examples of new features you can do in editor in 8.2+:

https://jaxenter.com/netbeans/ecmascript-6-lands-in-netbeans-ide