admin管理员组文章数量:1426093
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 autoplete 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 autoplete 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 autoplete, but not with anotherMethod. If I were to use var Extend = { /* code */ };
, autoplete 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?
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 autoplete 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 autoplete 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 autoplete, but not with anotherMethod. If I were to use var Extend = { /* code */ };
, autoplete 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?
Share Improve this question edited Jun 29, 2011 at 6:05 webjawns. asked Jun 9, 2011 at 21:41 webjawns.webjawns. 2,3002 gold badges14 silver badges35 bronze badges 3- Just out of curiosity - What happens if it's App.extend rather than App.Extend? – minikomi Commented Jun 28, 2011 at 7:45
- At first I thought this might be better filed under auto-plete, but then I though better of it and reverted. Sorry for the edits. – cwallenpoole Commented Jun 28, 2011 at 13:04
- @minikomi Thanks for the response. The case does not affect the oute. It could be App.extend, App.EXTEND, App.Extend, etc., and all don't work. I have also tried different terminology, just to test the oute. – webjawns. Commented Jun 29, 2011 at 6:01
3 Answers
Reset to default 1Since Javascript is not a piled 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, bining them in the background to give you autoplete.
I've played with a variety of IDEs and the only IDE I've seen it work from is Jetbrain's Webstorm
VJET JS IDE for Eclipse has a way of extending across multiple files using a vjetdoc syntax. Check it out -- http://www.ebayopensource/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()
Not familiar with Zend Studio, but from what you say it is not clear whether it works on globals only or not. I.e. if I understood you correctly, this works:
// global.js
var App = {
objectA: {
method1: function() {},
method2: function() {}
},
objectB: {
method1: function() {},
method2: function() {}
}
};
// extend.js
var Extend = {
anotherMethod: function() {}
};
However, if you add this, will this work?
// extend.js
...
var More = {
streetWithNoName: false,
};
More.helloWorld = [1, 2, 3]
If you cannot get auto-plete for helloWorld
on More.
(and as it works on Extend
, you should get the auto-plete for streetWithNoName
), then probably Zend is not doing a non-global pletion, which I guess is a very hard thing to do anyway. If it can, then you can always do:
var innerAppExtend = App.Extend = { ... };
as a workaround, if that's acceptable to you of course.
本文标签:
版权声明:本文标题:php - Autocomplete for a single JavaScript object extended across multiple files in Zend Studio (Eclipse PDT) - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745415737a2657676.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论