xref: /Universal-ctags/Units/parser-javascript.r/bug3571233.js.d/input.js (revision 98d1c5fd667b6cb3b9bc425af1882960fd3ffce7)
1/*
2 * "Functions nested inside methods show improper scope with the parent method
3 * being reported as "function""
4 *
5 * ctags -f - bug3571233.js should output:
6 *
7 * classes
8 *    MyClass
9 *
10 * methods
11 *    MyClass.method2
12 *
13 * functions
14 *    MyClass.method2.nestedFunction1
15 *    MyClass.method2.nestedFunction2
16 *    function1
17 *    function1.nestedFunction3
18 *    function2
19 *    function2.nestedFunction4
20 *    function2.nestedFunction5
21 *
22 *
23 * Note that MyClass is shown both as a class and as a function (the parser
24 * discovers it actually is a class only later on).  This isn't really easy to
25 * fix because a JavaScript function is only a class if it happen to be used as
26 * one, for example it has prototypes.
27 */
28
29function MyClass() {
30}
31
32MyClass.prototype.method2 = function() {
33  // these functions have improper scope
34  function nestedFunction1() {
35
36  }
37
38  function nestedFunction2() {
39
40  }
41};
42
43// following work fine, just here as a reference
44function function1() {
45  function nestedFunction3() {
46  }
47};
48
49function2 = function() {
50  function nestedFunction4() {
51  }
52
53  function nestedFunction5() {
54  }
55};
56
57