Chromium Code Reviews| 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.element; | 5 library engine.element; |
| 6 | 6 |
| 7 import 'dart:collection'; | 7 import 'dart:collection'; |
| 8 | 8 |
| 9 import 'package:analyzer/src/generated/utilities_general.dart'; | 9 import 'package:analyzer/src/generated/utilities_general.dart'; |
| 10 import 'package:analyzer/src/task/dart.dart'; | 10 import 'package:analyzer/src/task/dart.dart'; |
| (...skipping 2518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2529 */ | 2529 */ |
| 2530 List<ElementAnnotation> get metadata; | 2530 List<ElementAnnotation> get metadata; |
| 2531 | 2531 |
| 2532 /** | 2532 /** |
| 2533 * Return the name of this element, or `null` if this element does not have a | 2533 * Return the name of this element, or `null` if this element does not have a |
| 2534 * name. | 2534 * name. |
| 2535 */ | 2535 */ |
| 2536 String get name; | 2536 String get name; |
| 2537 | 2537 |
| 2538 /** | 2538 /** |
| 2539 * Return the length of the name of this element in the file that contains the | |
| 2540 * declaration of this element, or `0` if this element does not have a name. | |
| 2541 */ | |
| 2542 int get nameLength; | |
| 2543 | |
| 2544 /** | |
| 2539 * Return the offset of the name of this element in the file that contains the | 2545 * Return the offset of the name of this element in the file that contains the |
| 2540 * declaration of this element, or `-1` if this element is synthetic, does not | 2546 * declaration of this element, or `-1` if this element is synthetic, does not |
| 2541 * have a name, or otherwise does not have an offset. | 2547 * have a name, or otherwise does not have an offset. |
| 2542 */ | 2548 */ |
| 2543 int get nameOffset; | 2549 int get nameOffset; |
| 2544 | 2550 |
| 2545 /** | 2551 /** |
| 2546 * **DEPRECATED** Use `computeNode()` instead. | 2552 * **DEPRECATED** Use `computeNode()` instead. |
| 2547 * | 2553 * |
| 2548 * Return the resolved [AstNode] node that declares this element, or `null` if | 2554 * Return the resolved [AstNode] node that declares this element, or `null` if |
| (...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2929 | 2935 |
| 2930 @override | 2936 @override |
| 2931 String get name => _name; | 2937 String get name => _name; |
| 2932 | 2938 |
| 2933 void set name(String name) { | 2939 void set name(String name) { |
| 2934 this._name = name; | 2940 this._name = name; |
| 2935 _cachedLocation = null; | 2941 _cachedLocation = null; |
| 2936 _cachedHashCode = null; | 2942 _cachedHashCode = null; |
| 2937 } | 2943 } |
| 2938 | 2944 |
| 2939 /** | 2945 @override |
| 2940 * The offset of the name of this element in the file that contains the | 2946 int get nameLength => name != null ? name.length : 0; |
| 2941 * declaration of this element. | 2947 |
| 2942 */ | 2948 @override |
| 2943 int get nameOffset => _nameOffset; | 2949 int get nameOffset => _nameOffset; |
| 2944 | 2950 |
| 2945 /** | 2951 /** |
| 2946 * Sets the offset of the name of this element in the file that contains the | 2952 * Sets the offset of the name of this element in the file that contains the |
| 2947 * declaration of this element. | 2953 * declaration of this element. |
| 2948 */ | 2954 */ |
| 2949 void set nameOffset(int offset) { | 2955 void set nameOffset(int offset) { |
| 2950 _nameOffset = offset; | 2956 _nameOffset = offset; |
| 2951 _cachedHashCode = null; | 2957 _cachedHashCode = null; |
| 2952 _cachedLocation = null; | 2958 _cachedLocation = null; |
| (...skipping 4352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7305 * library using a `part` directive. | 7311 * library using a `part` directive. |
| 7306 */ | 7312 */ |
| 7307 List<CompilationUnitElement> _parts = CompilationUnitElement.EMPTY_LIST; | 7313 List<CompilationUnitElement> _parts = CompilationUnitElement.EMPTY_LIST; |
| 7308 | 7314 |
| 7309 /** | 7315 /** |
| 7310 * The element representing the synthetic function `loadLibrary` that is | 7316 * The element representing the synthetic function `loadLibrary` that is |
| 7311 * defined for this library, or `null` if the element has not yet been created . | 7317 * defined for this library, or `null` if the element has not yet been created . |
| 7312 */ | 7318 */ |
| 7313 FunctionElement _loadLibraryFunction; | 7319 FunctionElement _loadLibraryFunction; |
| 7314 | 7320 |
| 7321 @override | |
| 7322 final int nameLength; | |
| 7323 | |
| 7315 /** | 7324 /** |
| 7316 * The export [Namespace] of this library, `null` if it has not been | 7325 * The export [Namespace] of this library, `null` if it has not been |
| 7317 * computed yet. | 7326 * computed yet. |
| 7318 */ | 7327 */ |
| 7319 @override | 7328 @override |
| 7320 Namespace exportNamespace; | 7329 Namespace exportNamespace; |
| 7321 | 7330 |
| 7322 /** | 7331 /** |
| 7323 * The public [Namespace] of this library, `null` if it has not been | 7332 * The public [Namespace] of this library, `null` if it has not been |
| 7324 * computed yet. | 7333 * computed yet. |
| 7325 */ | 7334 */ |
| 7326 @override | 7335 @override |
| 7327 Namespace publicNamespace; | 7336 Namespace publicNamespace; |
| 7328 | 7337 |
| 7329 /** | 7338 /** |
| 7330 * Initialize a newly created library element in the given [context] to have | 7339 * Initialize a newly created library element in the given [context] to have |
| 7331 * the given [name] and [offset]. | 7340 * the given [name] and [offset]. |
| 7332 */ | 7341 */ |
| 7333 LibraryElementImpl(this.context, String name, int offset) | 7342 LibraryElementImpl(this.context, String name, int offset, this.nameLength) |
| 7334 : super(name, offset); | 7343 : super(name, offset); |
| 7335 | 7344 |
| 7336 /** | 7345 /** |
| 7337 * Initialize a newly created library element in the given [context] to have | 7346 * Initialize a newly created library element in the given [context] to have |
| 7338 * the given [name]. | 7347 * the given [name]. |
| 7339 */ | 7348 */ |
| 7340 LibraryElementImpl.forNode(this.context, LibraryIdentifier name) | 7349 LibraryElementImpl.forNode(this.context, LibraryIdentifier name) |
| 7341 : super.forNode(name); | 7350 : super.forNode(name), nameLength = name != null ? name.length : 0; |
|
Brian Wilkerson
2015/09/25 20:32:14
nit: Should the call to 'super' be last?
| |
| 7342 | 7351 |
| 7343 @override | 7352 @override |
| 7344 CompilationUnitElement get definingCompilationUnit => | 7353 CompilationUnitElement get definingCompilationUnit => |
| 7345 _definingCompilationUnit; | 7354 _definingCompilationUnit; |
| 7346 | 7355 |
| 7347 /** | 7356 /** |
| 7348 * Set the compilation unit that defines this library to the given compilation | 7357 * Set the compilation unit that defines this library to the given compilation |
| 7349 * [unit]. | 7358 * [unit]. |
| 7350 */ | 7359 */ |
| 7351 void set definingCompilationUnit(CompilationUnitElement unit) { | 7360 void set definingCompilationUnit(CompilationUnitElement unit) { |
| (...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7933 @override | 7942 @override |
| 7934 ElementLocation get location => _baseElement.location; | 7943 ElementLocation get location => _baseElement.location; |
| 7935 | 7944 |
| 7936 @override | 7945 @override |
| 7937 List<ElementAnnotation> get metadata => _baseElement.metadata; | 7946 List<ElementAnnotation> get metadata => _baseElement.metadata; |
| 7938 | 7947 |
| 7939 @override | 7948 @override |
| 7940 String get name => _baseElement.name; | 7949 String get name => _baseElement.name; |
| 7941 | 7950 |
| 7942 @override | 7951 @override |
| 7952 int get nameLength => _baseElement.nameLength; | |
| 7953 | |
| 7954 @override | |
| 7943 int get nameOffset => _baseElement.nameOffset; | 7955 int get nameOffset => _baseElement.nameOffset; |
| 7944 | 7956 |
| 7945 @deprecated | 7957 @deprecated |
| 7946 @override | 7958 @override |
| 7947 AstNode get node => computeNode(); | 7959 AstNode get node => computeNode(); |
| 7948 | 7960 |
| 7949 @override | 7961 @override |
| 7950 Source get source => _baseElement.source; | 7962 Source get source => _baseElement.source; |
| 7951 | 7963 |
| 7952 @override | 7964 @override |
| (...skipping 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8446 @override | 8458 @override |
| 8447 ElementLocation get location => null; | 8459 ElementLocation get location => null; |
| 8448 | 8460 |
| 8449 @override | 8461 @override |
| 8450 List<ElementAnnotation> get metadata => ElementAnnotation.EMPTY_LIST; | 8462 List<ElementAnnotation> get metadata => ElementAnnotation.EMPTY_LIST; |
| 8451 | 8463 |
| 8452 @override | 8464 @override |
| 8453 String get name => _name; | 8465 String get name => _name; |
| 8454 | 8466 |
| 8455 @override | 8467 @override |
| 8468 int get nameLength => name != null ? name.length : 0; | |
| 8469 | |
| 8470 @override | |
| 8456 int get nameOffset => -1; | 8471 int get nameOffset => -1; |
| 8457 | 8472 |
| 8458 @deprecated | 8473 @deprecated |
| 8459 @override | 8474 @override |
| 8460 AstNode get node => null; | 8475 AstNode get node => null; |
| 8461 | 8476 |
| 8462 @override | 8477 @override |
| 8463 Source get source => null; | 8478 Source get source => null; |
| 8464 | 8479 |
| 8465 @override | 8480 @override |
| (...skipping 2323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10789 | 10804 |
| 10790 @override | 10805 @override |
| 10791 void visitElement(Element element) { | 10806 void visitElement(Element element) { |
| 10792 int offset = element.nameOffset; | 10807 int offset = element.nameOffset; |
| 10793 if (offset != -1) { | 10808 if (offset != -1) { |
| 10794 map[offset] = element; | 10809 map[offset] = element; |
| 10795 } | 10810 } |
| 10796 super.visitElement(element); | 10811 super.visitElement(element); |
| 10797 } | 10812 } |
| 10798 } | 10813 } |
| OLD | NEW |