Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(320)

Side by Side Diff: Source/devtools/scripts/jsdoc-validator/tests/this.js

Issue 137553005: DevTools: [JsDocValidator] Refactor JsDoc annotation checkers (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Address comments from sergeyv Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/devtools/scripts/jsdoc-validator/tests/return.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 this.foo = this.foo + 1; // OK - outside of function.
2
3 function f() {
4 this.foo = this.foo + 1; // OK - global |this|.
5 }
6
7 /**
8 * @constructor
9 */
10 function TypeOne() {
11 this.foo = this.foo + 1; // OK - object field in ctor.
12
13 /**
14 * @this {TypeOne}
15 */
16 function callbackOne() {
17 this.foo = this.foo + 1; // OK - @this declared.
18
19 function badInnerCallback() {
20 this.foo = this.foo + 2; // ERROR - @this not declared.
21 }
22 }
23
24 function badCallbackInCtor() {
25 this.foo = this.foo + 1; // ERROR - @this not declared.
26 }
27 }
28
29 TypeOne.prototype = {
30 addListener: function(callback)
31 {
32 if (typeof callback !== "function")
33 throw "addListener: callback is not a function";
34 if (this._listeners.length === 0)
35 extensionServer.sendRequest({ command: commands.Subscribe, type: thi s._type });
36 this._listeners.push(callback);
37 extensionServer.registerHandler("notify-" + this._type, this._dispatch.b ind(this));
38 },
39
40 funcOne: function() {
41 this.foo = this.foo + 1; // OK - in method.
42 },
43
44 funcTwo: function() {
45 /**
46 * @this {TypeOne}
47 */
48 function callback() {
49 this.foo = this.foo + 1; // OK - @this declared.
50 }
51 },
52
53 funcThree: function() {
54 function badCallbackInMethod() {
55 this.foo = this.foo + 1; // ERROR - @this not declared.
56 }
57 }
58 }
59
60
61 /**
62 * @constructor
63 */
64 TypeTwo = function() {
65 this.bar = this.bar + 1; // OK - object field in ctor.
66
67 /**
68 * @this {TypeTwo}
69 */
70 function callbackOne() {
71 this.bar = this.bar + 1; // OK - @this declared.
72
73 function badInnerCallback() {
74 this.bar = this.bar + 2; // ERROR - @this not declared.
75 }
76 }
77
78 function badCallbackInCtor() {
79 this.bar = this.bar + 1; // ERROR - @this not declared.
80 }
81 }
82
83 TypeTwo.prototype = {
84 funcOne: function() {
85 this.bar = this.bar + 1; // OK - in method.
86 },
87
88 funcTwo: function() {
89 /**
90 * @this {TypeTwo}
91 */
92 function callback() {
93 this.bar = this.bar + 1; // OK - @this declared.
94 }
95 },
96
97 funcThree: function() {
98 function badCallbackInMethod() {
99 this.bar = this.bar + 1; // ERROR - @this not declared.
100 }
101 }
102 }
103
104 /**
105 * @return {!Object}
106 */
107 function returnConstructedObject() {
108
109 /**
110 * @constructor
111 */
112 TypeThree = function() {
113 this.bar = this.bar + 1; // OK - object field in ctor.
114
115 /**
116 * @this {TypeThree}
117 */
118 function callbackOne() {
119 this.bar = this.bar + 1; // OK - @this declared.
120
121 function badInnerCallback() {
122 this.bar = this.bar + 2; // ERROR - @this not declared.
123 }
124 }
125
126 function badCallbackInCtor() {
127 this.bar = this.bar + 1; // ERROR - @this not declared.
128 }
129 }
130
131 TypeThree.prototype = {
132 funcOne: function() {
133 this.bar = this.bar + 1; // OK - in method.
134 },
135
136 funcTwo: function() {
137 /**
138 * @this {TypeThree}
139 */
140 function callback() {
141 this.bar = this.bar + 1; // OK - @this declared.
142 }
143 },
144
145 funcThree: function() {
146 function badCallbackInMethod() {
147 this.bar = this.bar + 1; // ERROR - @this not declared.
148 }
149 }
150 }
151
152 return new TypeThree();
153 }
154
155 var object = {
156 /**
157 * @this {MyType}
158 */
159 value: function()
160 {
161 this.foo = 1; // OK - @this annotated.
162 }
163 };
164
165 (function() {
166 var object = {
167 /**
168 * @this {MyType}
169 */
170 value: function()
171 {
172 this.foo = 1; // OK - @this annotated.
173 }
174 };
175 })();
OLDNEW
« no previous file with comments | « Source/devtools/scripts/jsdoc-validator/tests/return.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698