Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(155)

Side by Side Diff: pkg/analyzer/lib/src/task/dart.dart

Issue 1133513003: Cache flushing implementation for the task model. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixes for review comments. Created 5 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/analyzer/lib/src/context/context.dart ('k') | pkg/analyzer/lib/src/task/model.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 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 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.task.dart; 5 library analyzer.src.task.dart;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 import 'dart:math' as math; 8 import 'dart:math' as math;
9 9
10 import 'package:analyzer/src/generated/ast.dart'; 10 import 'package:analyzer/src/generated/ast.dart';
11 import 'package:analyzer/src/generated/element.dart'; 11 import 'package:analyzer/src/generated/element.dart';
12 import 'package:analyzer/src/generated/engine.dart' hide AnalysisTask; 12 import 'package:analyzer/src/generated/engine.dart' hide AnalysisTask;
13 import 'package:analyzer/src/generated/error.dart'; 13 import 'package:analyzer/src/generated/error.dart';
14 import 'package:analyzer/src/generated/error_verifier.dart'; 14 import 'package:analyzer/src/generated/error_verifier.dart';
15 import 'package:analyzer/src/generated/java_engine.dart'; 15 import 'package:analyzer/src/generated/java_engine.dart';
16 import 'package:analyzer/src/generated/parser.dart'; 16 import 'package:analyzer/src/generated/parser.dart';
17 import 'package:analyzer/src/generated/resolver.dart'; 17 import 'package:analyzer/src/generated/resolver.dart';
18 import 'package:analyzer/src/generated/scanner.dart'; 18 import 'package:analyzer/src/generated/scanner.dart';
19 import 'package:analyzer/src/generated/sdk.dart'; 19 import 'package:analyzer/src/generated/sdk.dart';
20 import 'package:analyzer/src/generated/source.dart'; 20 import 'package:analyzer/src/generated/source.dart';
21 import 'package:analyzer/src/task/general.dart'; 21 import 'package:analyzer/src/task/general.dart';
22 import 'package:analyzer/src/task/incremental_element_builder.dart'; 22 import 'package:analyzer/src/task/incremental_element_builder.dart';
23 import 'package:analyzer/src/task/model.dart';
23 import 'package:analyzer/task/dart.dart'; 24 import 'package:analyzer/task/dart.dart';
24 import 'package:analyzer/task/general.dart'; 25 import 'package:analyzer/task/general.dart';
25 import 'package:analyzer/task/model.dart'; 26 import 'package:analyzer/task/model.dart';
26 27
27 /** 28 /**
29 * The [ResultCachingPolicy] for ASTs.
30 */
31 const ResultCachingPolicy AST_CACHING_POLICY =
32 const SimpleResultCachingPolicy(256, 64);
33
34 /**
28 * The errors produced while resolving a library directives. 35 * The errors produced while resolving a library directives.
29 * 36 *
30 * The list will be empty if there were no errors, but will not be `null`. 37 * The list will be empty if there were no errors, but will not be `null`.
31 * 38 *
32 * The result is only available for targets representing a Dart library. 39 * The result is only available for targets representing a Dart library.
33 */ 40 */
34 final ResultDescriptor<List<AnalysisError>> BUILD_DIRECTIVES_ERRORS = 41 final ResultDescriptor<List<AnalysisError>> BUILD_DIRECTIVES_ERRORS =
35 new ResultDescriptor<List<AnalysisError>>( 42 new ResultDescriptor<List<AnalysisError>>(
36 'BUILD_DIRECTIVES_ERRORS', AnalysisError.NO_ERRORS, 43 'BUILD_DIRECTIVES_ERRORS', AnalysisError.NO_ERRORS,
37 contributesTo: DART_ERRORS); 44 contributesTo: DART_ERRORS);
(...skipping 19 matching lines...) Expand all
57 */ 64 */
58 final ResultDescriptor<List<AnalysisError>> BUILD_LIBRARY_ERRORS = 65 final ResultDescriptor<List<AnalysisError>> BUILD_LIBRARY_ERRORS =
59 new ResultDescriptor<List<AnalysisError>>( 66 new ResultDescriptor<List<AnalysisError>>(
60 'BUILD_LIBRARY_ERRORS', AnalysisError.NO_ERRORS, 67 'BUILD_LIBRARY_ERRORS', AnalysisError.NO_ERRORS,
61 contributesTo: DART_ERRORS); 68 contributesTo: DART_ERRORS);
62 69
63 /** 70 /**
64 * The [ClassElement]s of a [LibrarySpecificUnit]. 71 * The [ClassElement]s of a [LibrarySpecificUnit].
65 */ 72 */
66 final ListResultDescriptor<ClassElement> CLASS_ELEMENTS = 73 final ListResultDescriptor<ClassElement> CLASS_ELEMENTS =
67 new ListResultDescriptor<ClassElement>('CLASS_ELEMENTS', null); 74 new ListResultDescriptor<ClassElement>('CLASS_ELEMENTS', null,
75 cachingPolicy: ELEMENT_CACHING_POLICY);
68 76
69 /** 77 /**
70 * The element model associated with a single compilation unit. 78 * The element model associated with a single compilation unit.
71 * 79 *
72 * The result is only available for targets representing a Dart compilation unit . 80 * The result is only available for targets representing a Dart compilation unit .
73 */ 81 */
74 final ResultDescriptor<CompilationUnitElement> COMPILATION_UNIT_ELEMENT = 82 final ResultDescriptor<CompilationUnitElement> COMPILATION_UNIT_ELEMENT =
75 new ResultDescriptor<CompilationUnitElement>( 83 new ResultDescriptor<CompilationUnitElement>(
76 'COMPILATION_UNIT_ELEMENT', null); 84 'COMPILATION_UNIT_ELEMENT', null,
85 cachingPolicy: ELEMENT_CACHING_POLICY);
77 86
78 /** 87 /**
79 * The [ConstructorElement]s of a [ClassElement]. 88 * The [ConstructorElement]s of a [ClassElement].
80 */ 89 */
81 final ResultDescriptor<List<ConstructorElement>> CONSTRUCTORS = 90 final ResultDescriptor<List<ConstructorElement>> CONSTRUCTORS =
82 new ResultDescriptor<List<ConstructorElement>>('CONSTRUCTORS', null); 91 new ResultDescriptor<List<ConstructorElement>>('CONSTRUCTORS', null);
83 92
84 /** 93 /**
85 * The errors produced while building a [ClassElement] constructors. 94 * The errors produced while building a [ClassElement] constructors.
86 * 95 *
87 * The list will be empty if there were no errors, but will not be `null`. 96 * The list will be empty if there were no errors, but will not be `null`.
88 * 97 *
89 * The result is only available for targets representing a [ClassElement]. 98 * The result is only available for targets representing a [ClassElement].
90 */ 99 */
91 final ResultDescriptor<List<AnalysisError>> CONSTRUCTORS_ERRORS = 100 final ResultDescriptor<List<AnalysisError>> CONSTRUCTORS_ERRORS =
92 new ResultDescriptor<List<AnalysisError>>( 101 new ResultDescriptor<List<AnalysisError>>(
93 'CONSTRUCTORS_ERRORS', AnalysisError.NO_ERRORS); 102 'CONSTRUCTORS_ERRORS', AnalysisError.NO_ERRORS);
94 103
95 /** 104 /**
105 * The [ResultCachingPolicy] for [Element]s.
106 */
107 const ResultCachingPolicy ELEMENT_CACHING_POLICY =
108 const SimpleResultCachingPolicy(-1, -1);
109
110 /**
96 * The sources representing the export closure of a library. 111 * The sources representing the export closure of a library.
97 * The [Source]s include only library sources, not their units. 112 * The [Source]s include only library sources, not their units.
98 * 113 *
99 * The result is only available for targets representing a Dart library. 114 * The result is only available for targets representing a Dart library.
100 */ 115 */
101 final ListResultDescriptor<Source> EXPORT_SOURCE_CLOSURE = 116 final ListResultDescriptor<Source> EXPORT_SOURCE_CLOSURE =
102 new ListResultDescriptor<Source>('EXPORT_SOURCE_CLOSURE', null); 117 new ListResultDescriptor<Source>('EXPORT_SOURCE_CLOSURE', null);
103 118
104 /** 119 /**
105 * The errors produced while generating hints a compilation unit. 120 * The errors produced while generating hints a compilation unit.
(...skipping 17 matching lines...) Expand all
123 138
124 /** 139 /**
125 * The partial [LibraryElement] associated with a library. 140 * The partial [LibraryElement] associated with a library.
126 * 141 *
127 * The [LibraryElement] and its [CompilationUnitElement]s are attached to each 142 * The [LibraryElement] and its [CompilationUnitElement]s are attached to each
128 * other. Directives 'library', 'part' and 'part of' are resolved. 143 * other. Directives 'library', 'part' and 'part of' are resolved.
129 * 144 *
130 * The result is only available for targets representing a Dart library. 145 * The result is only available for targets representing a Dart library.
131 */ 146 */
132 final ResultDescriptor<LibraryElement> LIBRARY_ELEMENT1 = 147 final ResultDescriptor<LibraryElement> LIBRARY_ELEMENT1 =
133 new ResultDescriptor<LibraryElement>('LIBRARY_ELEMENT1', null); 148 new ResultDescriptor<LibraryElement>('LIBRARY_ELEMENT1', null,
149 cachingPolicy: ELEMENT_CACHING_POLICY);
134 150
135 /** 151 /**
136 * The partial [LibraryElement] associated with a library. 152 * The partial [LibraryElement] associated with a library.
137 * 153 *
138 * In addition to [LIBRARY_ELEMENT1] [LibraryElement.imports] and 154 * In addition to [LIBRARY_ELEMENT1] [LibraryElement.imports] and
139 * [LibraryElement.exports] are set. 155 * [LibraryElement.exports] are set.
140 * 156 *
141 * The result is only available for targets representing a Dart library. 157 * The result is only available for targets representing a Dart library.
142 */ 158 */
143 final ResultDescriptor<LibraryElement> LIBRARY_ELEMENT2 = 159 final ResultDescriptor<LibraryElement> LIBRARY_ELEMENT2 =
144 new ResultDescriptor<LibraryElement>('LIBRARY_ELEMENT2', null); 160 new ResultDescriptor<LibraryElement>('LIBRARY_ELEMENT2', null,
161 cachingPolicy: ELEMENT_CACHING_POLICY);
145 162
146 /** 163 /**
147 * The partial [LibraryElement] associated with a library. 164 * The partial [LibraryElement] associated with a library.
148 * 165 *
149 * In addition to [LIBRARY_ELEMENT2] the [LibraryElement.publicNamespace] is set . 166 * In addition to [LIBRARY_ELEMENT2] the [LibraryElement.publicNamespace] is set .
150 * 167 *
151 * The result is only available for targets representing a Dart library. 168 * The result is only available for targets representing a Dart library.
152 */ 169 */
153 final ResultDescriptor<LibraryElement> LIBRARY_ELEMENT3 = 170 final ResultDescriptor<LibraryElement> LIBRARY_ELEMENT3 =
154 new ResultDescriptor<LibraryElement>('LIBRARY_ELEMENT3', null); 171 new ResultDescriptor<LibraryElement>('LIBRARY_ELEMENT3', null,
172 cachingPolicy: ELEMENT_CACHING_POLICY);
155 173
156 /** 174 /**
157 * The partial [LibraryElement] associated with a library. 175 * The partial [LibraryElement] associated with a library.
158 * 176 *
159 * In addition to [LIBRARY_ELEMENT3] the [LibraryElement.entryPoint] is set, 177 * In addition to [LIBRARY_ELEMENT3] the [LibraryElement.entryPoint] is set,
160 * if the library does not declare one already and one of the exported 178 * if the library does not declare one already and one of the exported
161 * libraries exports one. 179 * libraries exports one.
162 * 180 *
163 * Also [LibraryElement.exportNamespace] is set. 181 * Also [LibraryElement.exportNamespace] is set.
164 * 182 *
165 * The result is only available for targets representing a Dart library. 183 * The result is only available for targets representing a Dart library.
166 */ 184 */
167 final ResultDescriptor<LibraryElement> LIBRARY_ELEMENT4 = 185 final ResultDescriptor<LibraryElement> LIBRARY_ELEMENT4 =
168 new ResultDescriptor<LibraryElement>('LIBRARY_ELEMENT4', null); 186 new ResultDescriptor<LibraryElement>('LIBRARY_ELEMENT4', null,
187 cachingPolicy: ELEMENT_CACHING_POLICY);
169 188
170 /** 189 /**
171 * The partial [LibraryElement] associated with a library. 190 * The partial [LibraryElement] associated with a library.
172 * 191 *
173 * [LIBRARY_ELEMENT4] plus [RESOLVED_UNIT4] for every unit. 192 * [LIBRARY_ELEMENT4] plus [RESOLVED_UNIT4] for every unit.
174 * 193 *
175 * The result is only available for targets representing a Dart library. 194 * The result is only available for targets representing a Dart library.
176 */ 195 */
177 final ResultDescriptor<LibraryElement> LIBRARY_ELEMENT5 = 196 final ResultDescriptor<LibraryElement> LIBRARY_ELEMENT5 =
178 new ResultDescriptor<LibraryElement>('LIBRARY_ELEMENT5', null); 197 new ResultDescriptor<LibraryElement>('LIBRARY_ELEMENT5', null,
198 cachingPolicy: ELEMENT_CACHING_POLICY);
179 199
180 /** 200 /**
181 * The errors produced while parsing a compilation unit. 201 * The errors produced while parsing a compilation unit.
182 * 202 *
183 * The list will be empty if there were no errors, but will not be `null`. 203 * The list will be empty if there were no errors, but will not be `null`.
184 * 204 *
185 * The result is only available for targets representing a Dart compilation unit . 205 * The result is only available for targets representing a Dart compilation unit .
186 */ 206 */
187 final ResultDescriptor<List<AnalysisError>> PARSE_ERRORS = 207 final ResultDescriptor<List<AnalysisError>> PARSE_ERRORS =
188 new ResultDescriptor<List<AnalysisError>>( 208 new ResultDescriptor<List<AnalysisError>>(
(...skipping 24 matching lines...) Expand all
213 contributesTo: DART_ERRORS); 233 contributesTo: DART_ERRORS);
214 234
215 /** 235 /**
216 * The partially resolved [CompilationUnit] associated with a unit. 236 * The partially resolved [CompilationUnit] associated with a unit.
217 * 237 *
218 * All declarations bound to the element defined by the declaration. 238 * All declarations bound to the element defined by the declaration.
219 * 239 *
220 * The result is only available for targets representing a unit. 240 * The result is only available for targets representing a unit.
221 */ 241 */
222 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT1 = 242 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT1 =
223 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT1', null); 243 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT1', null,
244 cachingPolicy: AST_CACHING_POLICY);
224 245
225 /** 246 /**
226 * The partially resolved [CompilationUnit] associated with a unit. 247 * The partially resolved [CompilationUnit] associated with a unit.
227 * 248 *
228 * All the enum member elements are built. 249 * All the enum member elements are built.
229 * 250 *
230 * The result is only available for targets representing a unit. 251 * The result is only available for targets representing a unit.
231 */ 252 */
232 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT2 = 253 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT2 =
233 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT2', null); 254 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT2', null,
255 cachingPolicy: AST_CACHING_POLICY);
234 256
235 /** 257 /**
236 * The partially resolved [CompilationUnit] associated with a unit. 258 * The partially resolved [CompilationUnit] associated with a unit.
237 * 259 *
238 * All the function type aliases are resolved. 260 * All the function type aliases are resolved.
239 * 261 *
240 * The result is only available for targets representing a unit. 262 * The result is only available for targets representing a unit.
241 */ 263 */
242 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT3 = 264 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT3 =
243 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT3', null); 265 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT3', null,
266 cachingPolicy: AST_CACHING_POLICY);
244 267
245 /** 268 /**
246 * The partially resolved [CompilationUnit] associated with a unit. 269 * The partially resolved [CompilationUnit] associated with a unit.
247 * 270 *
248 * [RESOLVED_UNIT3] with resolved type names. 271 * [RESOLVED_UNIT3] with resolved type names.
249 * 272 *
250 * The result is only available for targets representing a unit. 273 * The result is only available for targets representing a unit.
251 */ 274 */
252 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT4 = 275 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT4 =
253 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT4', null); 276 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT4', null,
277 cachingPolicy: AST_CACHING_POLICY);
254 278
255 /** 279 /**
256 * The partially resolved [CompilationUnit] associated with a unit. 280 * The partially resolved [CompilationUnit] associated with a unit.
257 * 281 *
258 * [RESOLVED_UNIT4] plus resolved local variables and formal parameters. 282 * [RESOLVED_UNIT4] plus resolved local variables and formal parameters.
259 * 283 *
260 * The result is only available for targets representing a unit. 284 * The result is only available for targets representing a unit.
261 */ 285 */
262 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT5 = 286 final ResultDescriptor<CompilationUnit> RESOLVED_UNIT5 =
263 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT5', null); 287 new ResultDescriptor<CompilationUnit>('RESOLVED_UNIT5', null,
288 cachingPolicy: AST_CACHING_POLICY);
264 289
265 /** 290 /**
266 * The errors produced while scanning a compilation unit. 291 * The errors produced while scanning a compilation unit.
267 * 292 *
268 * The list will be empty if there were no errors, but will not be `null`. 293 * The list will be empty if there were no errors, but will not be `null`.
269 * 294 *
270 * The result is only available for targets representing a Dart compilation unit . 295 * The result is only available for targets representing a Dart compilation unit .
271 */ 296 */
272 final ResultDescriptor<List<AnalysisError>> SCAN_ERRORS = 297 final ResultDescriptor<List<AnalysisError>> SCAN_ERRORS =
273 new ResultDescriptor<List<AnalysisError>>( 298 new ResultDescriptor<List<AnalysisError>>(
274 'SCAN_ERRORS', AnalysisError.NO_ERRORS, contributesTo: DART_ERRORS); 299 'SCAN_ERRORS', AnalysisError.NO_ERRORS, contributesTo: DART_ERRORS);
275 300
276 /** 301 /**
302 * The [ResultCachingPolicy] for [TOKEN_STREAM].
303 */
304 const ResultCachingPolicy TOKEN_STREAM_CACHING_POLICY =
305 const SimpleResultCachingPolicy(1, 1);
306
307 /**
277 * The [TypeProvider] of the context. 308 * The [TypeProvider] of the context.
278 */ 309 */
279 final ResultDescriptor<TypeProvider> TYPE_PROVIDER = 310 final ResultDescriptor<TypeProvider> TYPE_PROVIDER =
280 new ResultDescriptor<TypeProvider>('TYPE_PROVIDER', null); 311 new ResultDescriptor<TypeProvider>('TYPE_PROVIDER', null);
281 312
282 /** 313 /**
283 * The [UsedImportedElements] of a [LibrarySpecificUnit]. 314 * The [UsedImportedElements] of a [LibrarySpecificUnit].
284 */ 315 */
285 final ResultDescriptor<UsedImportedElements> USED_IMPORTED_ELEMENTS = 316 final ResultDescriptor<UsedImportedElements> USED_IMPORTED_ELEMENTS =
286 new ResultDescriptor<UsedImportedElements>('USED_IMPORTED_ELEMENTS', null); 317 new ResultDescriptor<UsedImportedElements>('USED_IMPORTED_ELEMENTS', null,
318 cachingPolicy: ELEMENT_CACHING_POLICY);
287 319
288 /** 320 /**
289 * The [UsedLocalElements] of a [LibrarySpecificUnit]. 321 * The [UsedLocalElements] of a [LibrarySpecificUnit].
290 */ 322 */
291 final ResultDescriptor<UsedLocalElements> USED_LOCAL_ELEMENTS = 323 final ResultDescriptor<UsedLocalElements> USED_LOCAL_ELEMENTS =
292 new ResultDescriptor<UsedLocalElements>('USED_LOCAL_ELEMENTS', null); 324 new ResultDescriptor<UsedLocalElements>('USED_LOCAL_ELEMENTS', null,
325 cachingPolicy: ELEMENT_CACHING_POLICY);
293 326
294 /** 327 /**
295 * The errors produced while verifying a compilation unit. 328 * The errors produced while verifying a compilation unit.
296 * 329 *
297 * The list will be empty if there were no errors, but will not be `null`. 330 * The list will be empty if there were no errors, but will not be `null`.
298 * 331 *
299 * The result is only available for targets representing a Dart compilation unit . 332 * The result is only available for targets representing a Dart compilation unit .
300 */ 333 */
301 final ResultDescriptor<List<AnalysisError>> VERIFY_ERRORS = 334 final ResultDescriptor<List<AnalysisError>> VERIFY_ERRORS =
302 new ResultDescriptor<List<AnalysisError>>( 335 new ResultDescriptor<List<AnalysisError>>(
(...skipping 2403 matching lines...) Expand 10 before | Expand all | Expand 10 after
2706 @override 2739 @override
2707 bool moveNext() { 2740 bool moveNext() {
2708 if (_newSources.isEmpty) { 2741 if (_newSources.isEmpty) {
2709 return false; 2742 return false;
2710 } 2743 }
2711 currentTarget = _newSources.first; 2744 currentTarget = _newSources.first;
2712 _newSources.remove(currentTarget); 2745 _newSources.remove(currentTarget);
2713 return true; 2746 return true;
2714 } 2747 }
2715 } 2748 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/context/context.dart ('k') | pkg/analyzer/lib/src/task/model.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698