OLD | NEW |
| (Empty) |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | |
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. | |
4 | |
5 library analyzer.task.dart; | |
6 | |
7 import 'package:analyzer/src/generated/ast.dart'; | |
8 import 'package:analyzer/src/generated/element.dart'; | |
9 import 'package:analyzer/src/generated/error.dart'; | |
10 import 'package:analyzer/src/generated/scanner.dart'; | |
11 import 'package:analyzer/src/generated/source.dart'; | |
12 import 'package:analyzer/src/generated/utilities_general.dart'; | |
13 import 'package:analyzer/src/task/dart.dart'; | |
14 import 'package:analyzer/task/model.dart'; | |
15 | |
16 /** | |
17 * The analysis errors associated with a [Source] representing a compilation | |
18 * unit. | |
19 */ | |
20 final ListResultDescriptor<AnalysisError> DART_ERRORS = | |
21 new ListResultDescriptor<AnalysisError>( | |
22 'DART_ERRORS', AnalysisError.NO_ERRORS); | |
23 | |
24 /** | |
25 * The sources of the libraries that are explicitly imported into a library. | |
26 * | |
27 * The list will be empty if there are no explicit imports, but will not be | |
28 * `null`. | |
29 * | |
30 * The result is only available for [Source]s representing a library. | |
31 */ | |
32 final ListResultDescriptor<Source> EXPLICITLY_IMPORTED_LIBRARIES = | |
33 new ListResultDescriptor<Source>( | |
34 'EXPLICITLY_IMPORTED_LIBRARIES', Source.EMPTY_LIST); | |
35 | |
36 /** | |
37 * The sources of the libraries that are exported from a library. | |
38 * | |
39 * The list will be empty if there are no exported libraries, but will not be | |
40 * `null`. | |
41 * | |
42 * The result is only available for [Source]s representing a library. | |
43 */ | |
44 final ListResultDescriptor<Source> EXPORTED_LIBRARIES = | |
45 new ListResultDescriptor<Source>('EXPORTED_LIBRARIES', Source.EMPTY_LIST); | |
46 | |
47 /** | |
48 * The sources of the libraries that are implicitly or explicitly imported into | |
49 * a library. | |
50 * | |
51 * The list will minimally contain the source for `dart:core` because it is | |
52 * implicitly imported into every library, and therefore will never be `null`. | |
53 * | |
54 * The result is only available for [Source]s representing a library. | |
55 */ | |
56 final ListResultDescriptor<Source> IMPORTED_LIBRARIES = | |
57 new ListResultDescriptor<Source>('IMPORTED_LIBRARIES', Source.EMPTY_LIST); | |
58 | |
59 /** | |
60 * The sources of the parts that are included in a library. | |
61 * | |
62 * The list will be empty if there are no parts, but will not be `null`. The | |
63 * list does *not* include the source for the defining compilation unit. | |
64 * | |
65 * The result is only available for [Source]s representing a library. | |
66 */ | |
67 final ListResultDescriptor<Source> INCLUDED_PARTS = | |
68 new ListResultDescriptor<Source>('INCLUDED_PARTS', Source.EMPTY_LIST); | |
69 | |
70 /** | |
71 * A flag specifying whether a library is dependent on code that is only | |
72 * available in a client. | |
73 * | |
74 * The result is only available for [Source]s representing a library. | |
75 */ | |
76 final ResultDescriptor<bool> IS_CLIENT = | |
77 new ResultDescriptor<bool>('IS_CLIENT', false); | |
78 | |
79 /** | |
80 * A flag specifying whether a library is launchable. | |
81 * | |
82 * The result is only available for [Source]s representing a library. | |
83 */ | |
84 final ResultDescriptor<bool> IS_LAUNCHABLE = | |
85 new ResultDescriptor<bool>('IS_LAUNCHABLE', false); | |
86 | |
87 /** | |
88 * The fully built [LibraryElement] associated with a library. | |
89 * | |
90 * The result is only available for [Source]s representing a library. | |
91 */ | |
92 final ResultDescriptor<LibraryElement> LIBRARY_ELEMENT = | |
93 new ResultDescriptor<LibraryElement>('LIBRARY_ELEMENT', null); | |
94 | |
95 /** | |
96 * The compilation unit AST produced while parsing a compilation unit. | |
97 * | |
98 * The AST structure will not have resolution information associated with it. | |
99 * | |
100 * The result is only available for [Source]s representing a compilation unit. | |
101 */ | |
102 final ResultDescriptor<CompilationUnit> PARSED_UNIT = | |
103 new ResultDescriptor<CompilationUnit>('PARSED_UNIT', null, | |
104 cachingPolicy: AST_CACHING_POLICY); | |
105 | |
106 /** | |
107 * The resolved [CompilationUnit] associated with a compilation unit, with | |
108 * constants resolved. | |
109 * | |
110 * The result is only available for [LibrarySpecificUnit]s. | |
111 */ | |
112 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT = | |
113 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT', null, | |
114 cachingPolicy: AST_CACHING_POLICY); | |
115 | |
116 /** | |
117 * The kind of a [Source]. | |
118 */ | |
119 final ResultDescriptor<SourceKind> SOURCE_KIND = | |
120 new ResultDescriptor<SourceKind>('SOURCE_KIND', SourceKind.UNKNOWN); | |
121 | |
122 /** | |
123 * The token stream produced while scanning a compilation unit. | |
124 * | |
125 * The value is the first token in the file, or the special end-of-file marker | |
126 * at the end of the stream if the file does not contain any tokens. | |
127 * | |
128 * The result is only available for [Source]s representing a compilation unit. | |
129 */ | |
130 final ResultDescriptor<Token> TOKEN_STREAM = new ResultDescriptor<Token>( | |
131 'TOKEN_STREAM', null, cachingPolicy: TOKEN_STREAM_CACHING_POLICY); | |
132 | |
133 /** | |
134 * The sources of the Dart files that a library consists of. | |
135 * | |
136 * The list will include the source of the defining unit and [INCLUDED_PARTS]. | |
137 * So, it is never empty or `null`. | |
138 * | |
139 * The result is only available for [Source]s representing a library. | |
140 */ | |
141 final ListResultDescriptor<Source> UNITS = | |
142 new ListResultDescriptor<Source>('UNITS', Source.EMPTY_LIST); | |
143 | |
144 /** | |
145 * A specific compilation unit in a specific library. | |
146 * | |
147 * This kind of target is associated with information about a compilation unit | |
148 * that differs based on the library that the unit is a part of. For example, | |
149 * the result of resolving a compilation unit depends on the imports, which can | |
150 * change if a single part is included in more than one library. | |
151 */ | |
152 class LibrarySpecificUnit implements AnalysisTarget { | |
153 /** | |
154 * The defining compilation unit of the library in which the [unit] | |
155 * is analyzed. | |
156 */ | |
157 final Source library; | |
158 | |
159 /** | |
160 * The compilation unit which belongs to the [library]. | |
161 */ | |
162 final Source unit; | |
163 | |
164 /** | |
165 * Initialize a newly created target for the [unit] in the [library]. | |
166 */ | |
167 LibrarySpecificUnit(this.library, this.unit); | |
168 | |
169 @override | |
170 int get hashCode { | |
171 return JenkinsSmiHash.combine(library.hashCode, unit.hashCode); | |
172 } | |
173 | |
174 @override | |
175 Source get source => unit; | |
176 | |
177 @override | |
178 bool operator ==(other) { | |
179 return other is LibrarySpecificUnit && | |
180 other.library == library && | |
181 other.unit == unit; | |
182 } | |
183 | |
184 @override | |
185 String toString() => '$unit in $library'; | |
186 } | |
OLD | NEW |