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

Side by Side Diff: pkg/analyzer/lib/src/generated/incremental_resolver.dart

Issue 738343002: Drop return types in DeclarationMatcher visitor. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month 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 | « no previous file | 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
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library engine.incremental_resolver; 5 library engine.incremental_resolver;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'ast.dart'; 9 import 'ast.dart';
10 import 'element.dart'; 10 import 'element.dart';
11 import 'error.dart'; 11 import 'error.dart';
12 import 'java_engine.dart'; 12 import 'java_engine.dart';
13 import 'resolver.dart'; 13 import 'resolver.dart';
14 import 'scanner.dart'; 14 import 'scanner.dart';
15 import 'source.dart'; 15 import 'source.dart';
16 16
17 17
18 /** 18 /**
19 * Instances of the class [DeclarationMatcher] determine whether the element 19 * Instances of the class [DeclarationMatcher] determine whether the element
20 * model defined by a given AST structure matches an existing element model. 20 * model defined by a given AST structure matches an existing element model.
21 */ 21 */
22 class DeclarationMatcher extends RecursiveAstVisitor<Object> { 22 class DeclarationMatcher extends RecursiveAstVisitor {
23 /** 23 /**
24 * The compilation unit containing the AST nodes being visited. 24 * The compilation unit containing the AST nodes being visited.
25 */ 25 */
26 CompilationUnitElement _enclosingUnit; 26 CompilationUnitElement _enclosingUnit;
27 27
28 /** 28 /**
29 * The function type alias containing the AST nodes being visited, or `null` i f we are not 29 * The function type alias containing the AST nodes being visited, or `null` i f we are not
30 * in the scope of a function type alias. 30 * in the scope of a function type alias.
31 */ 31 */
32 FunctionTypeAliasElement _enclosingAlias; 32 FunctionTypeAliasElement _enclosingAlias;
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 _gatherElements(element); 83 _gatherElements(element);
84 try { 84 try {
85 node.accept(this); 85 node.accept(this);
86 } on _DeclarationMismatchException catch (exception) { 86 } on _DeclarationMismatchException catch (exception) {
87 return false; 87 return false;
88 } 88 }
89 return _unmatchedElements.isEmpty; 89 return _unmatchedElements.isEmpty;
90 } 90 }
91 91
92 @override 92 @override
93 Object visitCatchClause(CatchClause node) { 93 visitCatchClause(CatchClause node) {
94 SimpleIdentifier exceptionParameter = node.exceptionParameter; 94 SimpleIdentifier exceptionParameter = node.exceptionParameter;
95 if (exceptionParameter != null) { 95 if (exceptionParameter != null) {
96 List<LocalVariableElement> localVariables = 96 List<LocalVariableElement> localVariables =
97 _enclosingExecutable.localVariables; 97 _enclosingExecutable.localVariables;
98 LocalVariableElement exceptionElement = 98 LocalVariableElement exceptionElement =
99 _findIdentifier(localVariables, exceptionParameter); 99 _findIdentifier(localVariables, exceptionParameter);
100 _processElement(exceptionElement); 100 _processElement(exceptionElement);
101 SimpleIdentifier stackTraceParameter = node.stackTraceParameter; 101 SimpleIdentifier stackTraceParameter = node.stackTraceParameter;
102 if (stackTraceParameter != null) { 102 if (stackTraceParameter != null) {
103 LocalVariableElement stackTraceElement = 103 LocalVariableElement stackTraceElement =
104 _findIdentifier(localVariables, stackTraceParameter); 104 _findIdentifier(localVariables, stackTraceParameter);
105 _processElement(stackTraceElement); 105 _processElement(stackTraceElement);
106 } 106 }
107 } 107 }
108 return super.visitCatchClause(node); 108 super.visitCatchClause(node);
109 } 109 }
110 110
111 @override 111 @override
112 Object visitClassDeclaration(ClassDeclaration node) { 112 visitClassDeclaration(ClassDeclaration node) {
113 String name = node.name.name; 113 String name = node.name.name;
114 ClassElement clazz = _findElement(_enclosingUnit.types, name); 114 ClassElement clazz = _findElement(_enclosingUnit.types, name);
115 _enclosingClass = clazz; 115 _enclosingClass = clazz;
116 _processElement(clazz); 116 _processElement(clazz);
117 // check for missing clauses 117 // check for missing clauses
118 if (node.extendsClause == null) { 118 if (node.extendsClause == null) {
119 _assertTrue(clazz.supertype.name == 'Object'); 119 _assertTrue(clazz.supertype.name == 'Object');
120 } 120 }
121 if (node.implementsClause == null) { 121 if (node.implementsClause == null) {
122 _assertTrue(clazz.interfaces.isEmpty); 122 _assertTrue(clazz.interfaces.isEmpty);
123 } 123 }
124 if (node.withClause == null) { 124 if (node.withClause == null) {
125 _assertTrue(clazz.mixins.isEmpty); 125 _assertTrue(clazz.mixins.isEmpty);
126 } 126 }
127 // process clauses and members 127 // process clauses and members
128 _hasConstructor = false; 128 _hasConstructor = false;
129 super.visitClassDeclaration(node); 129 super.visitClassDeclaration(node);
130 // process default constructor 130 // process default constructor
131 if (!_hasConstructor) { 131 if (!_hasConstructor) {
132 ConstructorElement constructor = clazz.unnamedConstructor; 132 ConstructorElement constructor = clazz.unnamedConstructor;
133 _processElement(constructor); 133 _processElement(constructor);
134 if (!constructor.isSynthetic) { 134 if (!constructor.isSynthetic) {
135 _assertEquals(constructor.parameters.length, 0); 135 _assertEquals(constructor.parameters.length, 0);
136 } 136 }
137 } 137 }
138 return null; 138 return null;
Brian Wilkerson 2014/11/20 15:43:05 We don't need explicit returns at the end of metho
scheglov 2014/11/20 15:58:49 Done.
139 } 139 }
140 140
141 @override 141 @override
142 Object visitClassTypeAlias(ClassTypeAlias node) { 142 visitClassTypeAlias(ClassTypeAlias node) {
143 ClassElement outerClass = _enclosingClass; 143 ClassElement outerClass = _enclosingClass;
144 try { 144 try {
145 SimpleIdentifier className = node.name; 145 SimpleIdentifier className = node.name;
146 _enclosingClass = _findIdentifier(_enclosingUnit.types, className); 146 _enclosingClass = _findIdentifier(_enclosingUnit.types, className);
147 _processElement(_enclosingClass); 147 _processElement(_enclosingClass);
148 return super.visitClassTypeAlias(node); 148 super.visitClassTypeAlias(node);
149 } finally { 149 } finally {
150 _enclosingClass = outerClass; 150 _enclosingClass = outerClass;
151 } 151 }
152 } 152 }
153 153
154 @override 154 @override
155 Object visitCompilationUnit(CompilationUnit node) { 155 visitCompilationUnit(CompilationUnit node) {
156 _processElement(_enclosingUnit); 156 _processElement(_enclosingUnit);
157 return super.visitCompilationUnit(node); 157 super.visitCompilationUnit(node);
158 } 158 }
159 159
160 @override 160 @override
161 Object visitConstructorDeclaration(ConstructorDeclaration node) { 161 visitConstructorDeclaration(ConstructorDeclaration node) {
162 ExecutableElement outerExecutable = _enclosingExecutable; 162 ExecutableElement outerExecutable = _enclosingExecutable;
163 try { 163 try {
164 SimpleIdentifier constructorName = node.name; 164 SimpleIdentifier constructorName = node.name;
165 if (constructorName == null) { 165 if (constructorName == null) {
166 _enclosingExecutable = _enclosingClass.unnamedConstructor; 166 _enclosingExecutable = _enclosingClass.unnamedConstructor;
167 } else { 167 } else {
168 _enclosingExecutable = 168 _enclosingExecutable =
169 _enclosingClass.getNamedConstructor(constructorName.name); 169 _enclosingClass.getNamedConstructor(constructorName.name);
170 } 170 }
171 _processElement(_enclosingExecutable); 171 _processElement(_enclosingExecutable);
172 return super.visitConstructorDeclaration(node); 172 super.visitConstructorDeclaration(node);
173 } finally { 173 } finally {
174 _enclosingExecutable = outerExecutable; 174 _enclosingExecutable = outerExecutable;
175 } 175 }
176 } 176 }
177 177
178 @override 178 @override
179 Object visitDeclaredIdentifier(DeclaredIdentifier node) { 179 visitDeclaredIdentifier(DeclaredIdentifier node) {
180 SimpleIdentifier variableName = node.identifier; 180 SimpleIdentifier variableName = node.identifier;
181 LocalVariableElement element = 181 LocalVariableElement element =
182 _findIdentifier(_enclosingExecutable.localVariables, variableName); 182 _findIdentifier(_enclosingExecutable.localVariables, variableName);
183 _processElement(element); 183 _processElement(element);
184 return super.visitDeclaredIdentifier(node); 184 super.visitDeclaredIdentifier(node);
185 } 185 }
186 186
187 @override 187 @override
188 Object visitDefaultFormalParameter(DefaultFormalParameter node) { 188 visitDefaultFormalParameter(DefaultFormalParameter node) {
189 SimpleIdentifier parameterName = node.parameter.identifier; 189 SimpleIdentifier parameterName = node.parameter.identifier;
190 ParameterElement element = _getElementForParameter(node, parameterName); 190 ParameterElement element = _getElementForParameter(node, parameterName);
191 Expression defaultValue = node.defaultValue; 191 Expression defaultValue = node.defaultValue;
192 if (defaultValue != null) { 192 if (defaultValue != null) {
193 ExecutableElement outerExecutable = _enclosingExecutable; 193 ExecutableElement outerExecutable = _enclosingExecutable;
194 try { 194 try {
195 if (element == null) { 195 if (element == null) {
196 // TODO(brianwilkerson) Report this internal error. 196 // TODO(brianwilkerson) Report this internal error.
197 } else { 197 } else {
198 _enclosingExecutable = element.initializer; 198 _enclosingExecutable = element.initializer;
199 } 199 }
200 defaultValue.accept(this); 200 defaultValue.accept(this);
201 } finally { 201 } finally {
202 _enclosingExecutable = outerExecutable; 202 _enclosingExecutable = outerExecutable;
203 } 203 }
204 _processElement(_enclosingExecutable); 204 _processElement(_enclosingExecutable);
205 } 205 }
206 ParameterElement outerParameter = _enclosingParameter; 206 ParameterElement outerParameter = _enclosingParameter;
207 try { 207 try {
208 _enclosingParameter = element; 208 _enclosingParameter = element;
209 _processElement(_enclosingParameter); 209 _processElement(_enclosingParameter);
210 return super.visitDefaultFormalParameter(node); 210 super.visitDefaultFormalParameter(node);
211 } finally { 211 } finally {
212 _enclosingParameter = outerParameter; 212 _enclosingParameter = outerParameter;
213 } 213 }
214 } 214 }
215 215
216 @override 216 @override
217 Object visitEnumDeclaration(EnumDeclaration node) { 217 visitEnumDeclaration(EnumDeclaration node) {
218 ClassElement enclosingEnum = 218 ClassElement enclosingEnum =
219 _findIdentifier(_enclosingUnit.enums, node.name); 219 _findIdentifier(_enclosingUnit.enums, node.name);
220 _processElement(enclosingEnum); 220 _processElement(enclosingEnum);
221 List<FieldElement> constants = enclosingEnum.fields; 221 List<FieldElement> constants = enclosingEnum.fields;
222 for (EnumConstantDeclaration constant in node.constants) { 222 for (EnumConstantDeclaration constant in node.constants) {
223 FieldElement constantElement = _findIdentifier(constants, constant.name); 223 FieldElement constantElement = _findIdentifier(constants, constant.name);
224 _processElement(constantElement); 224 _processElement(constantElement);
225 } 225 }
226 return super.visitEnumDeclaration(node); 226 super.visitEnumDeclaration(node);
227 } 227 }
228 228
229 @override 229 @override
230 Object visitExportDirective(ExportDirective node) { 230 visitExportDirective(ExportDirective node) {
231 String uri = _getStringValue(node.uri); 231 String uri = _getStringValue(node.uri);
232 if (uri != null) { 232 if (uri != null) {
233 LibraryElement library = _enclosingUnit.library; 233 LibraryElement library = _enclosingUnit.library;
234 ExportElement exportElement = _findExport( 234 ExportElement exportElement = _findExport(
235 library.exports, 235 library.exports,
236 _enclosingUnit.context.sourceFactory.resolveUri(_enclosingUnit.source, uri)); 236 _enclosingUnit.context.sourceFactory.resolveUri(_enclosingUnit.source, uri));
237 _processElement(exportElement); 237 _processElement(exportElement);
238 } 238 }
239 return super.visitExportDirective(node); 239 super.visitExportDirective(node);
240 } 240 }
241 241
242 @override 242 @override
243 visitExtendsClause(ExtendsClause node) { 243 visitExtendsClause(ExtendsClause node) {
244 _assertSameType(node.superclass, _enclosingClass.supertype); 244 _assertSameType(node.superclass, _enclosingClass.supertype);
245 } 245 }
246 246
247 @override 247 @override
248 Object visitFieldFormalParameter(FieldFormalParameter node) { 248 visitFieldFormalParameter(FieldFormalParameter node) {
249 if (node.parent is! DefaultFormalParameter) { 249 if (node.parent is! DefaultFormalParameter) {
250 SimpleIdentifier parameterName = node.identifier; 250 SimpleIdentifier parameterName = node.identifier;
251 ParameterElement element = _getElementForParameter(node, parameterName); 251 ParameterElement element = _getElementForParameter(node, parameterName);
252 ParameterElement outerParameter = _enclosingParameter; 252 ParameterElement outerParameter = _enclosingParameter;
253 try { 253 try {
254 _enclosingParameter = element; 254 _enclosingParameter = element;
255 _processElement(_enclosingParameter); 255 _processElement(_enclosingParameter);
256 return super.visitFieldFormalParameter(node); 256 super.visitFieldFormalParameter(node);
257 } finally { 257 } finally {
258 _enclosingParameter = outerParameter; 258 _enclosingParameter = outerParameter;
259 } 259 }
260 } else { 260 } else {
261 return super.visitFieldFormalParameter(node); 261 super.visitFieldFormalParameter(node);
262 } 262 }
263 } 263 }
264 264
265 @override 265 @override
266 Object visitFunctionDeclaration(FunctionDeclaration node) { 266 visitFunctionDeclaration(FunctionDeclaration node) {
267 ExecutableElement outerExecutable = _enclosingExecutable; 267 ExecutableElement outerExecutable = _enclosingExecutable;
268 try { 268 try {
269 SimpleIdentifier functionName = node.name; 269 SimpleIdentifier functionName = node.name;
270 Token property = node.propertyKeyword; 270 Token property = node.propertyKeyword;
271 if (property == null) { 271 if (property == null) {
272 if (_enclosingExecutable != null) { 272 if (_enclosingExecutable != null) {
273 _enclosingExecutable = 273 _enclosingExecutable =
274 _findIdentifier(_enclosingExecutable.functions, functionName); 274 _findIdentifier(_enclosingExecutable.functions, functionName);
275 } else { 275 } else {
276 _enclosingExecutable = 276 _enclosingExecutable =
277 _findIdentifier(_enclosingUnit.functions, functionName); 277 _findIdentifier(_enclosingUnit.functions, functionName);
278 } 278 }
279 } else { 279 } else {
280 PropertyAccessorElement accessor = 280 PropertyAccessorElement accessor =
281 _findIdentifier(_enclosingUnit.accessors, functionName); 281 _findIdentifier(_enclosingUnit.accessors, functionName);
282 if ((property as KeywordToken).keyword == Keyword.SET) { 282 if ((property as KeywordToken).keyword == Keyword.SET) {
283 accessor = accessor.variable.setter; 283 accessor = accessor.variable.setter;
284 } 284 }
285 _enclosingExecutable = accessor; 285 _enclosingExecutable = accessor;
286 } 286 }
287 _processElement(_enclosingExecutable); 287 _processElement(_enclosingExecutable);
288 return super.visitFunctionDeclaration(node); 288 super.visitFunctionDeclaration(node);
289 } finally { 289 } finally {
290 _enclosingExecutable = outerExecutable; 290 _enclosingExecutable = outerExecutable;
291 } 291 }
292 } 292 }
293 293
294 @override 294 @override
295 Object visitFunctionExpression(FunctionExpression node) { 295 visitFunctionExpression(FunctionExpression node) {
296 if (node.parent is! FunctionDeclaration) { 296 if (node.parent is! FunctionDeclaration) {
297 FunctionElement element = 297 FunctionElement element =
298 _findAtOffset(_enclosingExecutable.functions, node.beginToken.offset); 298 _findAtOffset(_enclosingExecutable.functions, node.beginToken.offset);
299 _processElement(element); 299 _processElement(element);
300 } 300 }
301 ExecutableElement outerExecutable = _enclosingExecutable; 301 ExecutableElement outerExecutable = _enclosingExecutable;
302 try { 302 try {
303 _enclosingExecutable = node.element; 303 _enclosingExecutable = node.element;
304 _processElement(_enclosingExecutable); 304 _processElement(_enclosingExecutable);
305 return super.visitFunctionExpression(node); 305 super.visitFunctionExpression(node);
306 } finally { 306 } finally {
307 _enclosingExecutable = outerExecutable; 307 _enclosingExecutable = outerExecutable;
308 } 308 }
309 } 309 }
310 310
311 @override 311 @override
312 Object visitFunctionTypeAlias(FunctionTypeAlias node) { 312 visitFunctionTypeAlias(FunctionTypeAlias node) {
313 FunctionTypeAliasElement outerAlias = _enclosingAlias; 313 FunctionTypeAliasElement outerAlias = _enclosingAlias;
314 try { 314 try {
315 SimpleIdentifier aliasName = node.name; 315 SimpleIdentifier aliasName = node.name;
316 _enclosingAlias = 316 _enclosingAlias =
317 _findIdentifier(_enclosingUnit.functionTypeAliases, aliasName); 317 _findIdentifier(_enclosingUnit.functionTypeAliases, aliasName);
318 _processElement(_enclosingAlias); 318 _processElement(_enclosingAlias);
319 return super.visitFunctionTypeAlias(node); 319 super.visitFunctionTypeAlias(node);
320 } finally { 320 } finally {
321 _enclosingAlias = outerAlias; 321 _enclosingAlias = outerAlias;
322 } 322 }
323 } 323 }
324 324
325 @override 325 @override
326 Object visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) { 326 visitFunctionTypedFormalParameter(FunctionTypedFormalParameter node) {
327 if (node.parent is! DefaultFormalParameter) { 327 if (node.parent is! DefaultFormalParameter) {
328 SimpleIdentifier parameterName = node.identifier; 328 SimpleIdentifier parameterName = node.identifier;
329 ParameterElement element = _getElementForParameter(node, parameterName); 329 ParameterElement element = _getElementForParameter(node, parameterName);
330 ParameterElement outerParameter = _enclosingParameter; 330 ParameterElement outerParameter = _enclosingParameter;
331 try { 331 try {
332 _enclosingParameter = element; 332 _enclosingParameter = element;
333 _processElement(_enclosingParameter); 333 _processElement(_enclosingParameter);
334 return super.visitFunctionTypedFormalParameter(node); 334 super.visitFunctionTypedFormalParameter(node);
335 } finally { 335 } finally {
336 _enclosingParameter = outerParameter; 336 _enclosingParameter = outerParameter;
337 } 337 }
338 } else { 338 } else {
339 return super.visitFunctionTypedFormalParameter(node); 339 super.visitFunctionTypedFormalParameter(node);
340 } 340 }
341 } 341 }
342 342
343 @override 343 @override
344 visitImplementsClause(ImplementsClause node) { 344 visitImplementsClause(ImplementsClause node) {
345 List<TypeName> nodes = node.interfaces; 345 List<TypeName> nodes = node.interfaces;
346 List<InterfaceType> types = _enclosingClass.interfaces; 346 List<InterfaceType> types = _enclosingClass.interfaces;
347 _assertSameTypes(nodes, types); 347 _assertSameTypes(nodes, types);
348 } 348 }
349 349
350 @override 350 @override
351 Object visitImportDirective(ImportDirective node) { 351 visitImportDirective(ImportDirective node) {
352 String uri = _getStringValue(node.uri); 352 String uri = _getStringValue(node.uri);
353 if (uri != null) { 353 if (uri != null) {
354 LibraryElement library = _enclosingUnit.library; 354 LibraryElement library = _enclosingUnit.library;
355 ImportElement importElement = _findImport( 355 ImportElement importElement = _findImport(
356 library.imports, 356 library.imports,
357 _enclosingUnit.context.sourceFactory.resolveUri(_enclosingUnit.source, uri), 357 _enclosingUnit.context.sourceFactory.resolveUri(_enclosingUnit.source, uri),
358 node.prefix); 358 node.prefix);
359 _processElement(importElement); 359 _processElement(importElement);
360 } 360 }
361 return super.visitImportDirective(node); 361 super.visitImportDirective(node);
362 } 362 }
363 363
364 @override 364 @override
365 Object visitLabeledStatement(LabeledStatement node) { 365 visitLabeledStatement(LabeledStatement node) {
366 for (Label label in node.labels) { 366 for (Label label in node.labels) {
367 SimpleIdentifier labelName = label.label; 367 SimpleIdentifier labelName = label.label;
368 LabelElement element = 368 LabelElement element =
369 _findIdentifier(_enclosingExecutable.labels, labelName); 369 _findIdentifier(_enclosingExecutable.labels, labelName);
370 _processElement(element); 370 _processElement(element);
371 } 371 }
372 return super.visitLabeledStatement(node); 372 super.visitLabeledStatement(node);
373 } 373 }
374 374
375 @override 375 @override
376 Object visitMethodDeclaration(MethodDeclaration node) { 376 visitMethodDeclaration(MethodDeclaration node) {
377 ExecutableElement outerExecutable = _enclosingExecutable; 377 ExecutableElement outerExecutable = _enclosingExecutable;
378 try { 378 try {
379 Token property = node.propertyKeyword; 379 Token property = node.propertyKeyword;
380 SimpleIdentifier methodName = node.name; 380 SimpleIdentifier methodName = node.name;
381 String nameOfMethod = methodName.name; 381 String nameOfMethod = methodName.name;
382 if (nameOfMethod == TokenType.MINUS.lexeme && 382 if (nameOfMethod == TokenType.MINUS.lexeme &&
383 node.parameters.parameters.length == 0) { 383 node.parameters.parameters.length == 0) {
384 nameOfMethod = "unary-"; 384 nameOfMethod = "unary-";
385 } 385 }
386 if (property == null) { 386 if (property == null) {
387 _enclosingExecutable = _findWithNameAndOffset( 387 _enclosingExecutable = _findWithNameAndOffset(
388 _enclosingClass.methods, 388 _enclosingClass.methods,
389 nameOfMethod, 389 nameOfMethod,
390 methodName.offset); 390 methodName.offset);
391 methodName.staticElement = _enclosingExecutable; 391 methodName.staticElement = _enclosingExecutable;
392 } else { 392 } else {
393 PropertyAccessorElement accessor = 393 PropertyAccessorElement accessor =
394 _findIdentifier(_enclosingClass.accessors, methodName); 394 _findIdentifier(_enclosingClass.accessors, methodName);
395 if ((property as KeywordToken).keyword == Keyword.SET) { 395 if ((property as KeywordToken).keyword == Keyword.SET) {
396 accessor = accessor.variable.setter; 396 accessor = accessor.variable.setter;
397 methodName.staticElement = accessor; 397 methodName.staticElement = accessor;
398 } 398 }
399 _enclosingExecutable = accessor; 399 _enclosingExecutable = accessor;
400 } 400 }
401 _processElement(_enclosingExecutable); 401 _processElement(_enclosingExecutable);
402 return super.visitMethodDeclaration(node); 402 super.visitMethodDeclaration(node);
403 } finally { 403 } finally {
404 _enclosingExecutable = outerExecutable; 404 _enclosingExecutable = outerExecutable;
405 } 405 }
406 } 406 }
407 407
408 @override 408 @override
409 Object visitPartDirective(PartDirective node) { 409 visitPartDirective(PartDirective node) {
410 String uri = _getStringValue(node.uri); 410 String uri = _getStringValue(node.uri);
411 if (uri != null) { 411 if (uri != null) {
412 Source partSource = 412 Source partSource =
413 _enclosingUnit.context.sourceFactory.resolveUri(_enclosingUnit.source, uri); 413 _enclosingUnit.context.sourceFactory.resolveUri(_enclosingUnit.source, uri);
414 CompilationUnitElement element = 414 CompilationUnitElement element =
415 _findPart(_enclosingUnit.library.parts, partSource); 415 _findPart(_enclosingUnit.library.parts, partSource);
416 _processElement(element); 416 _processElement(element);
417 } 417 }
418 return super.visitPartDirective(node); 418 super.visitPartDirective(node);
419 } 419 }
420 420
421 @override 421 @override
422 Object visitSimpleFormalParameter(SimpleFormalParameter node) { 422 visitSimpleFormalParameter(SimpleFormalParameter node) {
423 if (node.parent is! DefaultFormalParameter) { 423 if (node.parent is! DefaultFormalParameter) {
424 SimpleIdentifier parameterName = node.identifier; 424 SimpleIdentifier parameterName = node.identifier;
425 ParameterElement element = _getElementForParameter(node, parameterName); 425 ParameterElement element = _getElementForParameter(node, parameterName);
426 ParameterElement outerParameter = _enclosingParameter; 426 ParameterElement outerParameter = _enclosingParameter;
427 try { 427 try {
428 _enclosingParameter = element; 428 _enclosingParameter = element;
429 _processElement(_enclosingParameter); 429 _processElement(_enclosingParameter);
430 return super.visitSimpleFormalParameter(node); 430 super.visitSimpleFormalParameter(node);
431 } finally { 431 } finally {
432 _enclosingParameter = outerParameter; 432 _enclosingParameter = outerParameter;
433 } 433 }
434 } else { 434 } else {
435 } 435 }
436 return super.visitSimpleFormalParameter(node); 436 super.visitSimpleFormalParameter(node);
437 } 437 }
438 438
439 @override 439 @override
440 Object visitSwitchCase(SwitchCase node) { 440 visitSwitchCase(SwitchCase node) {
441 for (Label label in node.labels) { 441 for (Label label in node.labels) {
442 SimpleIdentifier labelName = label.label; 442 SimpleIdentifier labelName = label.label;
443 LabelElement element = 443 LabelElement element =
444 _findIdentifier(_enclosingExecutable.labels, labelName); 444 _findIdentifier(_enclosingExecutable.labels, labelName);
445 _processElement(element); 445 _processElement(element);
446 } 446 }
447 return super.visitSwitchCase(node); 447 super.visitSwitchCase(node);
448 } 448 }
449 449
450 @override 450 @override
451 Object visitSwitchDefault(SwitchDefault node) { 451 visitSwitchDefault(SwitchDefault node) {
452 for (Label label in node.labels) { 452 for (Label label in node.labels) {
453 SimpleIdentifier labelName = label.label; 453 SimpleIdentifier labelName = label.label;
454 LabelElement element = 454 LabelElement element =
455 _findIdentifier(_enclosingExecutable.labels, labelName); 455 _findIdentifier(_enclosingExecutable.labels, labelName);
456 _processElement(element); 456 _processElement(element);
457 } 457 }
458 return super.visitSwitchDefault(node); 458 super.visitSwitchDefault(node);
459 } 459 }
460 460
461 @override 461 @override
462 Object visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) { 462 visitTopLevelVariableDeclaration(TopLevelVariableDeclaration node) {
463 _inTopLevelVariableDeclaration = true; 463 _inTopLevelVariableDeclaration = true;
464 try { 464 try {
465 return super.visitTopLevelVariableDeclaration(node); 465 super.visitTopLevelVariableDeclaration(node);
466 } finally { 466 } finally {
467 _inTopLevelVariableDeclaration = false; 467 _inTopLevelVariableDeclaration = false;
468 } 468 }
469 } 469 }
470 470
471 @override 471 @override
472 Object visitTypeParameter(TypeParameter node) { 472 visitTypeParameter(TypeParameter node) {
473 SimpleIdentifier parameterName = node.name; 473 SimpleIdentifier parameterName = node.name;
474 TypeParameterElement element = null; 474 TypeParameterElement element = null;
475 if (_enclosingClass != null) { 475 if (_enclosingClass != null) {
476 element = _findIdentifier(_enclosingClass.typeParameters, parameterName); 476 element = _findIdentifier(_enclosingClass.typeParameters, parameterName);
477 } else if (_enclosingAlias != null) { 477 } else if (_enclosingAlias != null) {
478 element = _findIdentifier(_enclosingAlias.typeParameters, parameterName); 478 element = _findIdentifier(_enclosingAlias.typeParameters, parameterName);
479 } 479 }
480 _processElement(element); 480 _processElement(element);
481 return super.visitTypeParameter(node); 481 super.visitTypeParameter(node);
482 } 482 }
483 483
484 @override 484 @override
485 Object visitVariableDeclaration(VariableDeclaration node) { 485 visitVariableDeclaration(VariableDeclaration node) {
486 String name = node.name.name; 486 String name = node.name.name;
487 if (_inTopLevelVariableDeclaration) { 487 if (_inTopLevelVariableDeclaration) {
488 TopLevelVariableElement variable = 488 TopLevelVariableElement variable =
489 _findElement(_enclosingUnit.topLevelVariables, name); 489 _findElement(_enclosingUnit.topLevelVariables, name);
490 _assertNotNull(variable); 490 _assertNotNull(variable);
491 _assertFalse(variable.isSynthetic); 491 _assertFalse(variable.isSynthetic);
492 _assertEquals(node.isConst, variable.isConst); 492 _assertEquals(node.isConst, variable.isConst);
493 _assertEquals(node.isFinal, variable.isFinal); 493 _assertEquals(node.isFinal, variable.isFinal);
494 _assertSameType( 494 _assertSameType(
495 (node.parent as VariableDeclarationList).type, 495 (node.parent as VariableDeclarationList).type,
496 variable.type); 496 variable.type);
497 _processElement(variable); 497 _processElement(variable);
498 return null; 498 return;
499 } 499 }
500 VariableElement element; 500 VariableElement element;
501 if (_enclosingExecutable != null) { 501 if (_enclosingExecutable != null) {
502 element = _findElement(_enclosingExecutable.localVariables, name); 502 element = _findElement(_enclosingExecutable.localVariables, name);
503 } 503 }
504 if (element == null && _enclosingClass != null) { 504 if (element == null && _enclosingClass != null) {
505 element = _findElement(_enclosingClass.fields, name); 505 element = _findElement(_enclosingClass.fields, name);
506 } 506 }
507 return super.visitVariableDeclaration(node); 507 super.visitVariableDeclaration(node);
508 } 508 }
509 509
510 @override 510 @override
511 visitWithClause(WithClause node) { 511 visitWithClause(WithClause node) {
512 List<TypeName> nodes = node.mixinTypes; 512 List<TypeName> nodes = node.mixinTypes;
513 List<InterfaceType> types = _enclosingClass.mixins; 513 List<InterfaceType> types = _enclosingClass.mixins;
514 _assertSameTypes(nodes, types); 514 _assertSameTypes(nodes, types);
515 } 515 }
516 516
517 void _assertEquals(Object a, Object b) { 517 void _assertEquals(Object a, Object b) {
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
1102 } 1102 }
1103 } 1103 }
1104 1104
1105 void _addElement(Element element) { 1105 void _addElement(Element element) {
1106 if (element != null) { 1106 if (element != null) {
1107 matcher._allElements.add(element); 1107 matcher._allElements.add(element);
1108 matcher._unmatchedElements.add(element); 1108 matcher._unmatchedElements.add(element);
1109 } 1109 }
1110 } 1110 }
1111 } 1111 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698