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 /** | 5 /** |
6 * Defines the element model. The element model describes the semantic (as | 6 * Defines the element model. The element model describes the semantic (as |
7 * opposed to syntactic) structure of Dart code. The syntactic structure of the | 7 * opposed to syntactic) structure of Dart code. The syntactic structure of the |
8 * code is modeled by the [AST structure](../ast/ast.dart). | 8 * code is modeled by the [AST structure](../ast/ast.dart). |
9 * | 9 * |
10 * The element model consists of two closely related kinds of objects: elements | 10 * The element model consists of two closely related kinds of objects: elements |
(...skipping 22 matching lines...) Expand all Loading... |
33 * representation of the statements in a method body, but if one of those | 33 * representation of the statements in a method body, but if one of those |
34 * statements declares a local variable then the local variable will be | 34 * statements declares a local variable then the local variable will be |
35 * represented by an element. | 35 * represented by an element. |
36 */ | 36 */ |
37 library analyzer.dart.element.element; | 37 library analyzer.dart.element.element; |
38 | 38 |
39 import 'package:analyzer/dart/ast/ast.dart'; | 39 import 'package:analyzer/dart/ast/ast.dart'; |
40 import 'package:analyzer/dart/constant/value.dart'; | 40 import 'package:analyzer/dart/constant/value.dart'; |
41 import 'package:analyzer/dart/element/type.dart'; | 41 import 'package:analyzer/dart/element/type.dart'; |
42 import 'package:analyzer/src/generated/engine.dart' show AnalysisContext; | 42 import 'package:analyzer/src/generated/engine.dart' show AnalysisContext; |
43 import 'package:analyzer/src/generated/java_core.dart'; | |
44 import 'package:analyzer/src/generated/java_engine.dart'; | 43 import 'package:analyzer/src/generated/java_engine.dart'; |
45 import 'package:analyzer/src/generated/resolver.dart'; | 44 import 'package:analyzer/src/generated/resolver.dart'; |
46 import 'package:analyzer/src/generated/source.dart'; | 45 import 'package:analyzer/src/generated/source.dart'; |
47 import 'package:analyzer/src/generated/utilities_dart.dart'; | 46 import 'package:analyzer/src/generated/utilities_dart.dart'; |
48 import 'package:analyzer/src/task/dart.dart'; | 47 import 'package:analyzer/src/task/dart.dart'; |
49 import 'package:analyzer/task/model.dart' show AnalysisTarget; | 48 import 'package:analyzer/task/model.dart' show AnalysisTarget; |
50 | 49 |
51 /** | 50 /** |
52 * An element that represents a class. | 51 * An element that represents a class. |
53 * | 52 * |
(...skipping 803 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
857 | 856 |
858 /** | 857 /** |
859 * Return a representation of the value of this annotation, forcing the value | 858 * Return a representation of the value of this annotation, forcing the value |
860 * to be computed if it had not previously been computed, or `null` if the | 859 * to be computed if it had not previously been computed, or `null` if the |
861 * value of this annotation could not be computed because of errors. | 860 * value of this annotation could not be computed because of errors. |
862 */ | 861 */ |
863 DartObject computeConstantValue(); | 862 DartObject computeConstantValue(); |
864 } | 863 } |
865 | 864 |
866 /** | 865 /** |
867 * The enumeration `ElementKind` defines the various kinds of elements in the | 866 * The kind of elements in the element model. |
868 * element model. | |
869 * | 867 * |
870 * Clients may not extend, implement or mix-in this class. | 868 * Clients may not extend, implement or mix-in this class. |
871 */ | 869 */ |
872 class ElementKind extends Enum<ElementKind> { | 870 class ElementKind implements Comparable<ElementKind> { |
873 static const ElementKind CLASS = const ElementKind('CLASS', 0, "class"); | 871 static const ElementKind CLASS = const ElementKind('CLASS', 0, "class"); |
874 | 872 |
875 static const ElementKind COMPILATION_UNIT = | 873 static const ElementKind COMPILATION_UNIT = |
876 const ElementKind('COMPILATION_UNIT', 1, "compilation unit"); | 874 const ElementKind('COMPILATION_UNIT', 1, "compilation unit"); |
877 | 875 |
878 static const ElementKind CONSTRUCTOR = | 876 static const ElementKind CONSTRUCTOR = |
879 const ElementKind('CONSTRUCTOR', 2, "constructor"); | 877 const ElementKind('CONSTRUCTOR', 2, "constructor"); |
880 | 878 |
881 static const ElementKind DYNAMIC = | 879 static const ElementKind DYNAMIC = |
882 const ElementKind('DYNAMIC', 3, "<dynamic>"); | 880 const ElementKind('DYNAMIC', 3, "<dynamic>"); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
947 PARAMETER, | 945 PARAMETER, |
948 PREFIX, | 946 PREFIX, |
949 SETTER, | 947 SETTER, |
950 TOP_LEVEL_VARIABLE, | 948 TOP_LEVEL_VARIABLE, |
951 FUNCTION_TYPE_ALIAS, | 949 FUNCTION_TYPE_ALIAS, |
952 TYPE_PARAMETER, | 950 TYPE_PARAMETER, |
953 UNIVERSE | 951 UNIVERSE |
954 ]; | 952 ]; |
955 | 953 |
956 /** | 954 /** |
| 955 * The name of this element kind. |
| 956 */ |
| 957 final String name; |
| 958 |
| 959 /** |
| 960 * The ordinal value of the element kind. |
| 961 */ |
| 962 final int ordinal; |
| 963 |
| 964 /** |
957 * The name displayed in the UI for this kind of element. | 965 * The name displayed in the UI for this kind of element. |
958 */ | 966 */ |
959 final String displayName; | 967 final String displayName; |
960 | 968 |
961 /** | 969 /** |
962 * Initialize a newly created element kind to have the given [displayName]. | 970 * Initialize a newly created element kind to have the given [displayName]. |
963 */ | 971 */ |
964 const ElementKind(String name, int ordinal, this.displayName) | 972 const ElementKind(this.name, this.ordinal, this.displayName); |
965 : super(name, ordinal); | 973 |
| 974 @override |
| 975 int get hashCode => ordinal; |
| 976 |
| 977 @override |
| 978 int compareTo(ElementKind other) => ordinal - other.ordinal; |
| 979 |
| 980 @override |
| 981 String toString() => name; |
966 | 982 |
967 /** | 983 /** |
968 * Return the kind of the given [element], or [ERROR] if the element is | 984 * Return the kind of the given [element], or [ERROR] if the element is |
969 * `null`. This is a utility method that can reduce the need for null checks | 985 * `null`. This is a utility method that can reduce the need for null checks |
970 * in other places. | 986 * in other places. |
971 */ | 987 */ |
972 static ElementKind of(Element element) { | 988 static ElementKind of(Element element) { |
973 if (element == null) { | 989 if (element == null) { |
974 return ERROR; | 990 return ERROR; |
975 } | 991 } |
(...skipping 1035 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2011 DartType get type; | 2027 DartType get type; |
2012 | 2028 |
2013 /** | 2029 /** |
2014 * Return a representation of the value of this variable, forcing the value | 2030 * Return a representation of the value of this variable, forcing the value |
2015 * to be computed if it had not previously been computed, or `null` if either | 2031 * to be computed if it had not previously been computed, or `null` if either |
2016 * this variable was not declared with the 'const' modifier or if the value of | 2032 * this variable was not declared with the 'const' modifier or if the value of |
2017 * this variable could not be computed because of errors. | 2033 * this variable could not be computed because of errors. |
2018 */ | 2034 */ |
2019 DartObject computeConstantValue(); | 2035 DartObject computeConstantValue(); |
2020 } | 2036 } |
OLD | NEW |