This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.
Created attachment 146218 [details] Not working As you can see here: http://pastebin.com/kQW0qDYC I use a shorter version and give the method inherit an anonymous object. This breaks the navigator for this object (See Attachment not working.png). When I use this code: http://pastebin.com/0TChxnhy all is fine (See Attachment working.png). Is it a bug or a missing behavior? It should be possible, because there are no problem with IntelliJ IDEA for this (See Attachment idea.png). Regards Chirs
Created attachment 146219 [details] Working.png
Created attachment 146220 [details] idea.png
An other test happens with this code: var myModule = function() { return { foo: function() { console.log("foo"); }, bar: "bar" }; }; navigator only shows: myModule(): type. In intelliJ it can resolve the structure and shows me what you can see in intelliJ2.png
Created attachment 147661 [details] IntelliJ2
And as you can see all other available functions and properties, which are supported in ES5.
IMHO what you write about the simple example is wrong (it doesn't correspond to the runtime). In your example var myModule = function() { return { foo: function() { console.log("foo"); }, bar: "bar" }; }; myModule is really a function. You can not write myModule.foo() or myModyle.bar. If you write yourModule = myModule(), then it's ok and NetBeans offers after the yourModule function foo() and property bar. If the case would be var myModule = (function() { return { foo: function() { console.log("foo"); }, bar: "bar" }; })(); then probably the navigator should display the property.
Ok I understand it, but why is it possible that intelliJ can show me those properties? The other thing is that your example is valid, thx for that, I figured it out sry for that :/. With my old example: var fooBar = function() { return { foo: function() { console.log("foo"); }, bar: "bar" }; }; navigator shows me fooBar(); With the new example: var fooBar = (function() { return { foo: function() { console.log("foo"); }, bar: "bar" }; })(); navigator shows me fooBar: Function, but nothing more. No properties. And for the first example, when I write fooBar().bar, I can't navigate to bar, when I write your example var test = fooBar(); test.bar, I can. It's only that I can navigate and the navigator should show me the same or similar as intelliJ structure windows shows. If I open the same examples inside intelliJ, for the first it shows me that, what you see on the intelliJ2 screen and I can already navigate to bar. If I refactor the code to the right example, than it shows me what you can see in the screenshot intelliJFooBar.png Regards Chris
Created attachment 148564 [details] IntelliJ foo bar right example
>Ok I understand it, but why is it possible that intelliJ can show me >those properties? From my point of view, it's wrong. I can implemented in NB as well, but I think that this is not right. >navigator shows me fooBar: Function, but nothing more. No properties. I'm going to fix it. At least try:) >And for the first example, when I write fooBar().bar, >I can't navigate to bar, when I write your example var test = fooBar(); >test.bar, I can. This is a problem in resolving types (my guess). I have created new issue # 246299 to track this. Thanks
Ok, sounds good :). I think you are right, an IDE should avoid you from create wrong code (a bit for my perspective). So I think it is good to not implement the wrong version. Thx for the feedback. Can you have a look at this ticket too please? This is a real world project, which I have to use for my daily work. https://netbeans.org/bugzilla/show_bug.cgi?id=246268 Regards Chris
At the end I implemented both cases in web-main. Unfortunately it will not be a part of NB 8.0.1, so you have to use a devbuild. Regarding issue #246268, it will be probably more complicated. I'm going to look at this more.
Big thx to you, for your work. I will test it asap after it is deployed :). Yeah the other ticket is more compilcated, because all JS navigation support and resolving properties and so on, shouldn't be framework dependent. If the framework is correct and working, it should do the same as plain js code.
Integrated into 'main-silver', will be available in build *201408090001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-silver/rev/6c4a5dcecd7e User: Petr Pisl <ppisl@netbeans.org> Log: #243140 - Navigator doesnt show keys (properties, functions, ...) inside a anonymous object.
The problem with this example: http://pastebin.com/kQW0qDYC still exists in the latest nightly 201507130001.
Created attachment 155483 [details] gruntfile structure idea 14 As you can see in my screenshot (gruntfile structure idea 14) from idea 14, it shows you all properties inside the anonymous object in a gruntfile. Netbeans 8.1 beta doesn't show it.
The bug still exists in 8.2 RC. This is my JS object: var list = function() { return { restrict: 'E', controller: function($scope) { var vm = this; console.log($scope); vm.modes = listModes; }, controllerAs: 'listVm', templateUrl: 'list.tpl.html', replace: true, bindToController: true }; }; and the navigator only shows: list(). Nothing more. WebStorm will show you all properties inside the anonymous object in the return statement, the same I expect for NB.
This list method is a directive which will be used in an angular module: angular.module('myModule', []).directive('list', list);