| 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.element; | 5 library analyzer.src.dart.element.element; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 import 'dart:math' show min; | 8 import 'dart:math' show min; |
| 9 | 9 |
| 10 import 'package:analyzer/dart/ast/ast.dart'; | 10 import 'package:analyzer/dart/ast/ast.dart'; |
| (...skipping 1783 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1794 _enclosingElement = element as ElementImpl; | 1794 _enclosingElement = element as ElementImpl; |
| 1795 _cachedLocation = null; | 1795 _cachedLocation = null; |
| 1796 _cachedHashCode = null; | 1796 _cachedHashCode = null; |
| 1797 } | 1797 } |
| 1798 | 1798 |
| 1799 @override | 1799 @override |
| 1800 int get hashCode { | 1800 int get hashCode { |
| 1801 // TODO: We might want to re-visit this optimization in the future. | 1801 // TODO: We might want to re-visit this optimization in the future. |
| 1802 // We cache the hash code value as this is a very frequently called method. | 1802 // We cache the hash code value as this is a very frequently called method. |
| 1803 if (_cachedHashCode == null) { | 1803 if (_cachedHashCode == null) { |
| 1804 int hashIdentifier = identifier.hashCode; | 1804 _cachedHashCode = location.hashCode; |
| 1805 Element enclosing = enclosingElement; | |
| 1806 if (enclosing != null) { | |
| 1807 _cachedHashCode = hashIdentifier + enclosing.hashCode; | |
| 1808 } else { | |
| 1809 _cachedHashCode = hashIdentifier; | |
| 1810 } | |
| 1811 } | 1805 } |
| 1812 return _cachedHashCode; | 1806 return _cachedHashCode; |
| 1813 } | 1807 } |
| 1814 | 1808 |
| 1815 /** | 1809 /** |
| 1816 * Return an identifier that uniquely identifies this element among the | 1810 * Return an identifier that uniquely identifies this element among the |
| 1817 * children of this element's parent. | 1811 * children of this element's parent. |
| 1818 */ | 1812 */ |
| 1819 String get identifier => name; | 1813 String get identifier => name; |
| 1820 | 1814 |
| (...skipping 2984 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4805 | 4799 |
| 4806 @override | 4800 @override |
| 4807 void visitElement(Element element) { | 4801 void visitElement(Element element) { |
| 4808 int offset = element.nameOffset; | 4802 int offset = element.nameOffset; |
| 4809 if (offset != -1) { | 4803 if (offset != -1) { |
| 4810 map[offset] = element; | 4804 map[offset] = element; |
| 4811 } | 4805 } |
| 4812 super.visitElement(element); | 4806 super.visitElement(element); |
| 4813 } | 4807 } |
| 4814 } | 4808 } |
| OLD | NEW |