Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Autocomplete for a single JavaScript object extended across multiple files in Zend Studio (Eclipse PDT)

My IDE is Zend Studio 8, which features a relatively basic perspective for JavaScript (similar to, if not the same as, the perspective in Eclipse PDT). In the application I'm working on, we extend a base object across multiple files, which has effectively killed the autocomplete functionality. See below for an example scenario...

// global.js
var App = {
    objectA: {
        method1: function() {},
        method2: function() {}
    },
    objectB: {
        method1: function() {},
        method2: function() {}
    }
};

// extend.js
App.Extend = {
    anotherMethod: function() {}
};

In this scenario, typing App. causes autocomplete to appear with objectA and objectB, but not Extend. If I add Extend to the App variable in global.js, it will appear in the autocomplete, but not with anotherMethod. If I were to use var Extend = { /* code */ };, autocomplete would work for the Extend object, so the problem does not seem to be related to the fact that the code is extended across multiple files. Perhaps it is because a single object is being spread across multiple files...or something else.

Anyone have any ideas?

like image 679
webjawns.com Avatar asked Jun 09 '11 21:06

webjawns.com


2 Answers

Since Javascript is not a compiled language, the IDE has no idea where your extended classes are. Some advanced IDEs try to workaround this by considering every javascript file to be part of single project and thus, combining them in the background to give you autocomplete.

I've played with a variety of IDEs and the only IDE I've seen it work from is Jetbrain's Webstorm

like image 144
Mrchief Avatar answered Oct 22 '22 13:10

Mrchief


VJET JS IDE for Eclipse has a way of extending across multiple files using a vjetdoc syntax. Check it out -- http://www.ebayopensource.org/wiki/display/VJET/JS+code+assist+and+validation+for+two+or+more+js+files

It works with object literal, variables, functions. As soon as you go to class concepts there is typically a wrapper function to define classes. In VJET there is vjo.ctype which allows you to create classes in js. VJET provides correct assist for classes defined with this type construction kit. Here is an example:

Base.js
vjo.ctype("namespace.Base")
.endType();

App.js
vjo.ctype("namespace.App")
.inherits("namespace.Base")
.protos({
   doIt:function(){}
})
.endType()
like image 38
Justin Early Avatar answered Oct 22 '22 12:10

Justin Early