| OLD | NEW |
| 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 analyzer.src.dart.element.builder; | 5 library analyzer.src.dart.element.builder; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'package:analyzer/dart/ast/ast.dart'; | 9 import 'package:analyzer/dart/ast/ast.dart'; |
| 10 import 'package:analyzer/dart/ast/token.dart'; | 10 import 'package:analyzer/dart/ast/token.dart'; |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 /** | 324 /** |
| 325 * Initialize a newly created element builder to build the elements for a comp
ilation unit. | 325 * Initialize a newly created element builder to build the elements for a comp
ilation unit. |
| 326 * | 326 * |
| 327 * @param initialHolder the element holder associated with the compilation uni
t being built | 327 * @param initialHolder the element holder associated with the compilation uni
t being built |
| 328 */ | 328 */ |
| 329 ElementBuilder(ElementHolder initialHolder, this.compilationUnitElement) { | 329 ElementBuilder(ElementHolder initialHolder, this.compilationUnitElement) { |
| 330 _currentHolder = initialHolder; | 330 _currentHolder = initialHolder; |
| 331 } | 331 } |
| 332 | 332 |
| 333 @override | 333 @override |
| 334 Object visitAnnotation(Annotation node) { |
| 335 // Although it isn't valid to do so because closures are not constant |
| 336 // expressions, it's possible for one of the arguments to the constructor to |
| 337 // contain a closure. Wrapping the processing of the annotation this way |
| 338 // prevents these closures from being added to the list of functions in the |
| 339 // annotated declaration. |
| 340 ElementHolder holder = new ElementHolder(); |
| 341 ElementHolder previousHolder = _currentHolder; |
| 342 _currentHolder = holder; |
| 343 try { |
| 344 super.visitAnnotation(node); |
| 345 } finally { |
| 346 _currentHolder = previousHolder; |
| 347 } |
| 348 return null; |
| 349 } |
| 350 |
| 351 @override |
| 334 Object visitCatchClause(CatchClause node) { | 352 Object visitCatchClause(CatchClause node) { |
| 335 SimpleIdentifier exceptionParameter = node.exceptionParameter; | 353 SimpleIdentifier exceptionParameter = node.exceptionParameter; |
| 336 if (exceptionParameter != null) { | 354 if (exceptionParameter != null) { |
| 337 // exception | 355 // exception |
| 338 LocalVariableElementImpl exception = | 356 LocalVariableElementImpl exception = |
| 339 new LocalVariableElementImpl.forNode(exceptionParameter); | 357 new LocalVariableElementImpl.forNode(exceptionParameter); |
| 340 if (node.exceptionType == null) { | 358 if (node.exceptionType == null) { |
| 341 exception.hasImplicitType = true; | 359 exception.hasImplicitType = true; |
| 342 } | 360 } |
| 343 _currentHolder.addLocalVariable(exception); | 361 _currentHolder.addLocalVariable(exception); |
| (...skipping 1033 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1377 return null; | 1395 return null; |
| 1378 } | 1396 } |
| 1379 | 1397 |
| 1380 /** | 1398 /** |
| 1381 * Return the lexical identifiers associated with the given [identifiers]. | 1399 * Return the lexical identifiers associated with the given [identifiers]. |
| 1382 */ | 1400 */ |
| 1383 static List<String> _getIdentifiers(NodeList<SimpleIdentifier> identifiers) { | 1401 static List<String> _getIdentifiers(NodeList<SimpleIdentifier> identifiers) { |
| 1384 return identifiers.map((identifier) => identifier.name).toList(); | 1402 return identifiers.map((identifier) => identifier.name).toList(); |
| 1385 } | 1403 } |
| 1386 } | 1404 } |
| OLD | NEW |