| 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 engine.ast; | 5 library engine.ast; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'element.dart'; | 9 import 'element.dart'; |
| 10 import 'engine.dart' show AnalysisEngine; | 10 import 'engine.dart' show AnalysisEngine; |
| (...skipping 6491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6502 * Return the element associated with the given [node], or `null` if there is | 6502 * Return the element associated with the given [node], or `null` if there is |
| 6503 * no element associated with the node. | 6503 * no element associated with the node. |
| 6504 */ | 6504 */ |
| 6505 static Element locate(AstNode node) { | 6505 static Element locate(AstNode node) { |
| 6506 if (node == null) { | 6506 if (node == null) { |
| 6507 return null; | 6507 return null; |
| 6508 } | 6508 } |
| 6509 ElementLocator_ElementMapper mapper = new ElementLocator_ElementMapper(); | 6509 ElementLocator_ElementMapper mapper = new ElementLocator_ElementMapper(); |
| 6510 return node.accept(mapper); | 6510 return node.accept(mapper); |
| 6511 } | 6511 } |
| 6512 | |
| 6513 /** | |
| 6514 * Return the element associated with the given [node], or `null` if there is | |
| 6515 * no element associated with the node. | |
| 6516 */ | |
| 6517 static Element locateWithOffset(AstNode node, int offset) { | |
| 6518 // TODO(brianwilkerson) 'offset' is not used. Figure out what's going on: | |
| 6519 // whether there's a bug or whether this method is unnecessary. | |
| 6520 if (node == null) { | |
| 6521 return null; | |
| 6522 } | |
| 6523 // try to get Element from node | |
| 6524 Element nodeElement = locate(node); | |
| 6525 if (nodeElement != null) { | |
| 6526 return nodeElement; | |
| 6527 } | |
| 6528 // no Element | |
| 6529 return null; | |
| 6530 } | |
| 6531 } | 6512 } |
| 6532 | 6513 |
| 6533 /** | 6514 /** |
| 6534 * Visitor that maps nodes to elements. | 6515 * Visitor that maps nodes to elements. |
| 6535 */ | 6516 */ |
| 6536 class ElementLocator_ElementMapper extends GeneralizingAstVisitor<Element> { | 6517 class ElementLocator_ElementMapper extends GeneralizingAstVisitor<Element> { |
| 6537 @override | 6518 @override |
| 6538 Element visitAnnotation(Annotation node) => node.element; | 6519 Element visitAnnotation(Annotation node) => node.element; |
| 6539 | 6520 |
| 6540 @override | 6521 @override |
| (...skipping 14142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 20683 } | 20664 } |
| 20684 | 20665 |
| 20685 @override | 20666 @override |
| 20686 accept(AstVisitor visitor) => visitor.visitYieldStatement(this); | 20667 accept(AstVisitor visitor) => visitor.visitYieldStatement(this); |
| 20687 | 20668 |
| 20688 @override | 20669 @override |
| 20689 void visitChildren(AstVisitor visitor) { | 20670 void visitChildren(AstVisitor visitor) { |
| 20690 _safelyVisitChild(_expression, visitor); | 20671 _safelyVisitChild(_expression, visitor); |
| 20691 } | 20672 } |
| 20692 } | 20673 } |
| OLD | NEW |