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 145637 [details] Screenshot of 'false positive' 'Unused' hints I'm getting 'false positive' 'Unused' hint for - function arguments: path, ref, pfx ... all of them are forwarded into external function - therefore should be treated as used - single local variable ... is in several places var myF = function MyLib_myF(path, ref, pfx, options) { var v = expand(path, ref, pfx, options); if( options && options.option1 && (v === path) ) return path; v = page.root + '~/' + v; return v; }; More details in attachment.
Created attachment 145639 [details] Missing_occurences_for_rename
Was going to file another bug "JavaScript edit misses some occurrences during rename of func args", but now I see that root cause is the same - logical model of the JS file is built incorrectly and names are not considered to be related. See same piece of code and another screenshot for details.
Reproducible, workaround is to remove the "MyLib_myF" from the 1st line var myF = function (path, ref, pfx, options) {... Your code works but just out of curiosity, why is the function named? It cannot be invoked by MyLib_myF() right? For instance following: var myF = function MyLib_myF(path, ref, pfx, options) { alert(1) }; console.log(typeof MyLib_myF); // undefined MyLib_myF(); // throws ReferenceError Can't you remove the the name as suggested above? It would fix all the problems here. Product Version: NetBeans IDE 8.0 RC1 (Build 201402242200) Java: 1.8.0; Java HotSpot(TM) Client VM 25.0-b69 Runtime: Java(TM) SE Runtime Environment 1.8.0-b129 System: Linux version 3.2.0-48-generic-pae running on i386; UTF-8; en_US (nb)
(In reply to Vladimir Riha from comment #3) > Your code works but just out of curiosity, why is the function named? Never mind, I realized the difference right after submitting the comment :)
Just to be in sync - the function name there is only intended for debugging purposes - Chrome (WebKit) displays it in stack trace. With no function name explicitly provided it tries to 'generate' function name using the name of variable the function is assigned to, but this is typically far from being accurate (especially when function is assigned to multiple variables). Typically that name will be thrown away by JS minifiers and yes, cannot be used directly. And, just for information, this case is described in details here https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions_and_function_scope -> "Function constructor vs. function declaration vs. function expression" -> case #4.
The problem is in the creating function in model. This example code creates two functions in model (MyLib_myF and myF) which is wrong. Instead of this myF should be reference to MyLib_myF.
Fixed in web-main. Thanks for the reporting and the test case.
Integrated into 'main-silver', will be available in build *201403290001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress) Changeset: http://hg.netbeans.org/main-silver/rev/d09160df9e79 User: Petr Pisl <ppisl@netbeans.org> Log: #242421 - False positive 'unused' hint for vars and func args in named function expression
Verified in Dev Product Version: NetBeans IDE Dev (Build 201404040001) Java: 1.8.0; Java HotSpot(TM) Client VM 25.0-b70 Runtime: Java(TM) SE Runtime Environment 1.8.0-b132 System: Linux version 3.2.0-48-generic-pae running on i386; UTF-8; en_US (nb)
Transplanted to the releases/release80 for patch 1.
Integrated into 'releases/release80', will be available in build *201404240045* or newer. Wait for official and publicly available build. Changeset: http://hg.netbeans.org/releases/rev/e73614e61133 User: Petr Pisl <ppisl@netbeans.org> Log: #242421 - False positive 'unused' hint for vars and func args in named function expression
verified in patch1 Product Version: NetBeans IDE 8.0 (Build 201403101706) Updates: NetBeans IDE is updated to version NetBeans 8.0 Patch 1 Java: 1.8.0_05; Java HotSpot(TM) Client VM 25.5-b02 Runtime: Java(TM) SE Runtime Environment 1.8.0_05-b13 System: Linux version 3.2.0-60-generic-pae running on i386; UTF-8; en_US (nb)
It seems like not all cases of this bug are fixed, for example in this excerpt I'm getting false positive 'unused' hint for var 'r' and var 'i' (Product Version: NetBeans IDE Dev (Build 201407010002)). After removing the 'MyLib_myMethod' function name hint disappears just like in more simple case. - - - - - - - - - - - - - - - - - - - - - - - - var myLib = new MyLib(); function MyLib() { /** * This is dummy JsDoc */ this.myMethod = function MyLib_myMethod(array) { var r = ""; for( var i = 0; i < array.length; i++ ) { r = r + array[i]; } return r; }; } myLib.myMethod([1, 2, 3, 4]);
The original issue is fixed, please file a new one instead of reopening already verified issue. Thank you
I have created new issue #245445