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 analyzer.src.generated.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/src/generated/ast.dart'; |
| 11 import 'package:analyzer/src/generated/constant.dart' |
| 12 show DartObject, EvaluationResultImpl; |
| 13 import 'package:analyzer/src/generated/engine.dart' |
| 14 show AnalysisContext, AnalysisEngine, AnalysisException; |
| 15 import 'package:analyzer/src/generated/java_core.dart'; |
| 16 import 'package:analyzer/src/generated/java_engine.dart'; |
| 17 import 'package:analyzer/src/generated/resolver.dart'; |
| 18 import 'package:analyzer/src/generated/scanner.dart' show Keyword; |
| 19 import 'package:analyzer/src/generated/sdk.dart' show DartSdk; |
| 20 import 'package:analyzer/src/generated/source.dart'; |
| 21 import 'package:analyzer/src/generated/utilities_collection.dart'; |
| 22 import 'package:analyzer/src/generated/utilities_dart.dart'; |
10 import 'package:analyzer/src/generated/utilities_general.dart'; | 23 import 'package:analyzer/src/generated/utilities_general.dart'; |
11 import 'package:analyzer/src/task/dart.dart'; | 24 import 'package:analyzer/src/task/dart.dart'; |
12 import 'package:analyzer/task/model.dart' show AnalysisTarget; | 25 import 'package:analyzer/task/model.dart' show AnalysisTarget; |
13 | 26 |
14 import 'ast.dart'; | |
15 import 'constant.dart' show DartObject, EvaluationResultImpl; | |
16 import 'engine.dart' show AnalysisContext, AnalysisEngine, AnalysisException; | |
17 import 'java_core.dart'; | |
18 import 'java_engine.dart'; | |
19 import 'resolver.dart'; | |
20 import 'scanner.dart' show Keyword; | |
21 import 'sdk.dart' show DartSdk; | |
22 import 'source.dart'; | |
23 import 'utilities_collection.dart'; | |
24 import 'utilities_dart.dart'; | |
25 | |
26 /** | 27 /** |
27 * For AST nodes that could be in both the getter and setter contexts | 28 * For AST nodes that could be in both the getter and setter contexts |
28 * ([IndexExpression]s and [SimpleIdentifier]s), the additional resolved | 29 * ([IndexExpression]s and [SimpleIdentifier]s), the additional resolved |
29 * elements are stored in the AST node, in an [AuxiliaryElements]. Because | 30 * elements are stored in the AST node, in an [AuxiliaryElements]. Because |
30 * resolved elements are either statically resolved or resolved using propagated | 31 * resolved elements are either statically resolved or resolved using propagated |
31 * type information, this class is a wrapper for a pair of [ExecutableElement]s, | 32 * type information, this class is a wrapper for a pair of [ExecutableElement]s, |
32 * not just a single [ExecutableElement]. | 33 * not just a single [ExecutableElement]. |
33 */ | 34 */ |
34 class AuxiliaryElements { | 35 class AuxiliaryElements { |
35 /** | 36 /** |
(...skipping 2350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2386 /** | 2387 /** |
2387 * An Unicode right arrow. | 2388 * An Unicode right arrow. |
2388 */ | 2389 */ |
2389 static final String RIGHT_ARROW = " \u2192 "; | 2390 static final String RIGHT_ARROW = " \u2192 "; |
2390 | 2391 |
2391 /** | 2392 /** |
2392 * A comparator that can be used to sort elements by their name offset. | 2393 * A comparator that can be used to sort elements by their name offset. |
2393 * Elements with a smaller offset will be sorted to be before elements with a | 2394 * Elements with a smaller offset will be sorted to be before elements with a |
2394 * larger name offset. | 2395 * larger name offset. |
2395 */ | 2396 */ |
2396 static final Comparator<Element> SORT_BY_OFFSET = (Element firstElement, | 2397 static final Comparator<Element> SORT_BY_OFFSET = |
2397 Element secondElement) => | 2398 (Element firstElement, Element secondElement) => |
2398 firstElement.nameOffset - secondElement.nameOffset; | 2399 firstElement.nameOffset - secondElement.nameOffset; |
2399 | 2400 |
2400 /** | 2401 /** |
2401 * Return the analysis context in which this element is defined. | 2402 * Return the analysis context in which this element is defined. |
2402 */ | 2403 */ |
2403 AnalysisContext get context; | 2404 AnalysisContext get context; |
2404 | 2405 |
2405 /** | 2406 /** |
2406 * Return the display name of this element, or `null` if this element does not | 2407 * Return the display name of this element, or `null` if this element does not |
2407 * have a name. | 2408 * have a name. |
2408 * | 2409 * |
(...skipping 5234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
7643 } | 7644 } |
7644 | 7645 |
7645 @override | 7646 @override |
7646 List<LibraryElement> get visibleLibraries { | 7647 List<LibraryElement> get visibleLibraries { |
7647 Set<LibraryElement> visibleLibraries = new Set(); | 7648 Set<LibraryElement> visibleLibraries = new Set(); |
7648 _addVisibleLibraries(visibleLibraries, false); | 7649 _addVisibleLibraries(visibleLibraries, false); |
7649 return new List.from(visibleLibraries); | 7650 return new List.from(visibleLibraries); |
7650 } | 7651 } |
7651 | 7652 |
7652 @override | 7653 @override |
7653 bool operator ==(Object object) => object is LibraryElementImpl && | 7654 bool operator ==(Object object) => |
| 7655 object is LibraryElementImpl && |
7654 _definingCompilationUnit == object.definingCompilationUnit; | 7656 _definingCompilationUnit == object.definingCompilationUnit; |
7655 | 7657 |
7656 @override | 7658 @override |
7657 accept(ElementVisitor visitor) => visitor.visitLibraryElement(this); | 7659 accept(ElementVisitor visitor) => visitor.visitLibraryElement(this); |
7658 | 7660 |
7659 /** | 7661 /** |
7660 * Create the [FunctionElement] to be returned by [loadLibraryFunction], | 7662 * Create the [FunctionElement] to be returned by [loadLibraryFunction], |
7661 * using types provided by [typeProvider]. | 7663 * using types provided by [typeProvider]. |
7662 */ | 7664 */ |
7663 void createLoadLibraryFunction(TypeProvider typeProvider) { | 7665 void createLoadLibraryFunction(TypeProvider typeProvider) { |
(...skipping 1706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9370 } | 9372 } |
9371 | 9373 |
9372 /** | 9374 /** |
9373 * Set whether this accessor is static. | 9375 * Set whether this accessor is static. |
9374 */ | 9376 */ |
9375 void set static(bool isStatic) { | 9377 void set static(bool isStatic) { |
9376 setModifier(Modifier.STATIC, isStatic); | 9378 setModifier(Modifier.STATIC, isStatic); |
9377 } | 9379 } |
9378 | 9380 |
9379 @override | 9381 @override |
9380 bool operator ==(Object object) => super == object && | 9382 bool operator ==(Object object) => |
| 9383 super == object && |
9381 isGetter == (object as PropertyAccessorElement).isGetter; | 9384 isGetter == (object as PropertyAccessorElement).isGetter; |
9382 | 9385 |
9383 @override | 9386 @override |
9384 accept(ElementVisitor visitor) => visitor.visitPropertyAccessorElement(this); | 9387 accept(ElementVisitor visitor) => visitor.visitPropertyAccessorElement(this); |
9385 | 9388 |
9386 @override | 9389 @override |
9387 void appendTo(StringBuffer buffer) { | 9390 void appendTo(StringBuffer buffer) { |
9388 buffer.write(isGetter ? "get " : "set "); | 9391 buffer.write(isGetter ? "get " : "set "); |
9389 buffer.write(variable.displayName); | 9392 buffer.write(variable.displayName); |
9390 super.appendTo(buffer); | 9393 super.appendTo(buffer); |
(...skipping 1420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10811 | 10814 |
10812 @override | 10815 @override |
10813 void visitElement(Element element) { | 10816 void visitElement(Element element) { |
10814 int offset = element.nameOffset; | 10817 int offset = element.nameOffset; |
10815 if (offset != -1) { | 10818 if (offset != -1) { |
10816 map[offset] = element; | 10819 map[offset] = element; |
10817 } | 10820 } |
10818 super.visitElement(element); | 10821 super.visitElement(element); |
10819 } | 10822 } |
10820 } | 10823 } |
OLD | NEW |