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

Side by Side Diff: pkg/analyzer/lib/src/generated/engine.dart

Issue 823123004: Display overlays at /overlays URI. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 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
OLDNEW
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 // This code was auto-generated, is not intended to be edited, and is subject to 5 // This code was auto-generated, is not intended to be edited, and is subject to
6 // significant change. Please see the README file for more information. 6 // significant change. Please see the README file for more information.
7 7
8 library engine; 8 library engine;
9 9
10 import "dart:math" as math; 10 import "dart:math" as math;
11 import 'dart:async'; 11 import 'dart:async';
12 import 'dart:collection'; 12 import 'dart:collection';
13 13
14 import 'package:analyzer/src/cancelable_future.dart'; 14 import 'package:analyzer/src/cancelable_future.dart';
15 import 'package:analyzer/src/generated/incremental_resolution_validator.dart';
15 import 'package:analyzer/src/task/task_dart.dart'; 16 import 'package:analyzer/src/task/task_dart.dart';
16 17
17 import '../../instrumentation/instrumentation.dart'; 18 import '../../instrumentation/instrumentation.dart';
18 import 'ast.dart'; 19 import 'ast.dart';
19 import 'constant.dart'; 20 import 'constant.dart';
20 import 'element.dart'; 21 import 'element.dart';
21 import 'error.dart'; 22 import 'error.dart';
22 import 'error_verifier.dart'; 23 import 'error_verifier.dart';
23 import 'html.dart' as ht; 24 import 'html.dart' as ht;
24 import 'incremental_resolver.dart' show IncrementalResolver, 25 import 'incremental_resolver.dart' show IncrementalResolver,
25 PoorMansIncrementalResolver; 26 PoorMansIncrementalResolver;
26 import 'incremental_scanner.dart'; 27 import 'incremental_scanner.dart';
27 import 'java_core.dart'; 28 import 'java_core.dart';
28 import 'java_engine.dart'; 29 import 'java_engine.dart';
29 import 'parser.dart' show Parser, IncrementalParser; 30 import 'parser.dart' show Parser, IncrementalParser;
30 import 'resolver.dart'; 31 import 'resolver.dart';
31 import 'scanner.dart'; 32 import 'scanner.dart';
32 import 'sdk.dart' show DartSdk; 33 import 'sdk.dart' show DartSdk;
33 import 'source.dart'; 34 import 'source.dart';
34 import 'utilities_collection.dart'; 35 import 'utilities_collection.dart';
35 import 'utilities_general.dart'; 36 import 'utilities_general.dart';
36 import 'package:analyzer/src/generated/incremental_resolution_validator.dart';
37 37
38 /** 38 /**
39 * Type of callback functions used by PendingFuture. Functions of this type 39 * Type of callback functions used by PendingFuture. Functions of this type
40 * should perform a computation based on the data in [sourceEntry] and return 40 * should perform a computation based on the data in [sourceEntry] and return
41 * it. If the computation can't be performed yet because more analysis is 41 * it. If the computation can't be performed yet because more analysis is
42 * needed, null should be returned. 42 * needed, null should be returned.
43 * 43 *
44 * The function may also throw an exception, in which case the corresponding 44 * The function may also throw an exception, in which case the corresponding
45 * future will be completed with failure. 45 * future will be completed with failure.
46 * 46 *
(...skipping 2195 matching lines...) Expand 10 before | Expand all | Expand 10 after
2242 // } 2242 // }
2243 _notifyErrors(source, notice.errors, notice.lineInfo); 2243 _notifyErrors(source, notice.errors, notice.lineInfo);
2244 } 2244 }
2245 return new AnalysisResult( 2245 return new AnalysisResult(
2246 notices, 2246 notices,
2247 getEnd - getStart, 2247 getEnd - getStart,
2248 task.runtimeType.toString(), 2248 task.runtimeType.toString(),
2249 performEnd - performStart); 2249 performEnd - performStart);
2250 } 2250 }
2251 2251
2252 void _validateLastIncrementalResolutionResult() {
2253 if (incrementalResolutionValidation_lastUnitSource == null ||
2254 incrementalResolutionValidation_lastLibrarySource == null ||
2255 incrementalResolutionValidation_lastUnit == null) {
2256 return;
2257 }
2258 CompilationUnit fullUnit = getResolvedCompilationUnit2(
2259 incrementalResolutionValidation_lastUnitSource,
2260 incrementalResolutionValidation_lastLibrarySource);
2261 if (fullUnit != null) {
2262 try {
2263 assertSameResolution(
2264 incrementalResolutionValidation_lastUnit,
2265 fullUnit);
2266 } on IncrementalResolutionMismatch catch (mismatch, stack) {
2267 String failure = mismatch.message;
2268 String message =
2269 'Incremental resolution mismatch:\n$failure\nat\n$stack';
2270 AnalysisEngine.instance.logger.logError(message);
2271 }
2272 }
2273 incrementalResolutionValidation_lastUnitSource = null;
2274 incrementalResolutionValidation_lastLibrarySource = null;
2275 incrementalResolutionValidation_lastUnit = null;
2276 }
2277
2278 @override 2252 @override
2279 void recordLibraryElements(Map<Source, LibraryElement> elementMap) { 2253 void recordLibraryElements(Map<Source, LibraryElement> elementMap) {
2280 Source htmlSource = _sourceFactory.forUri(DartSdk.DART_HTML); 2254 Source htmlSource = _sourceFactory.forUri(DartSdk.DART_HTML);
2281 elementMap.forEach((Source librarySource, LibraryElement library) { 2255 elementMap.forEach((Source librarySource, LibraryElement library) {
2282 // 2256 //
2283 // Cache the element in the library's info. 2257 // Cache the element in the library's info.
2284 // 2258 //
2285 DartEntry dartEntry = _getReadableDartEntry(librarySource); 2259 DartEntry dartEntry = _getReadableDartEntry(librarySource);
2286 if (dartEntry != null) { 2260 if (dartEntry != null) {
2287 _recordElementData(dartEntry, library, library.source, htmlSource); 2261 _recordElementData(dartEntry, library, library.source, htmlSource);
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
2598 sourceEntry, 2572 sourceEntry,
2599 descriptor, 2573 descriptor,
2600 sourceEntry.getStateInLibrary(descriptor, librarySource)); 2574 sourceEntry.getStateInLibrary(descriptor, librarySource));
2601 } 2575 }
2602 } 2576 }
2603 } 2577 }
2604 } 2578 }
2605 } 2579 }
2606 2580
2607 /** 2581 /**
2582 * Visit all entries of the content cache.
2583 */
2584 void visitContentCache(ContentCacheVisitor visitor) {
2585 _contentCache.accept(visitor);
2586 }
2587
2588 /**
2608 * Record that we have accessed the AST structure associated with the given so urce. At the moment, 2589 * Record that we have accessed the AST structure associated with the given so urce. At the moment,
2609 * there is no differentiation between the parsed and resolved forms of the AS T. 2590 * there is no differentiation between the parsed and resolved forms of the AS T.
2610 * 2591 *
2611 * @param source the source whose AST structure was accessed 2592 * @param source the source whose AST structure was accessed
2612 */ 2593 */
2613 void _accessedAst(Source source) { 2594 void _accessedAst(Source source) {
2614 _cache.accessedAst(source); 2595 _cache.accessedAst(source);
2615 } 2596 }
2616 2597
2617 /** 2598 /**
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
2756 //TODO(pquitslund): revisit if we need all units or whether one will do 2737 //TODO(pquitslund): revisit if we need all units or whether one will do
2757 dartEntry = new GenerateDartLintsTask( 2738 dartEntry = new GenerateDartLintsTask(
2758 this, 2739 this,
2759 units, 2740 units,
2760 getLibraryElement(librarySource)).perform(_resultRecorder) as DartEntr y; 2741 getLibraryElement(librarySource)).perform(_resultRecorder) as DartEntr y;
2761 state = dartEntry.getStateInLibrary(descriptor, librarySource); 2742 state = dartEntry.getStateInLibrary(descriptor, librarySource);
2762 } 2743 }
2763 return dartEntry; 2744 return dartEntry;
2764 } 2745 }
2765 2746
2766
2767 /** 2747 /**
2768 * Given a source for a Dart file, return a cache entry in which the state of the data represented 2748 * Given a source for a Dart file, return a cache entry in which the state of the data represented
2769 * by the given descriptor is either [CacheState.VALID] or [CacheState.ERROR]. This 2749 * by the given descriptor is either [CacheState.VALID] or [CacheState.ERROR]. This
2770 * method assumes that the data can be produced by parsing the source if it is not already cached. 2750 * method assumes that the data can be produced by parsing the source if it is not already cached.
2771 * 2751 *
2772 * <b>Note:</b> This method cannot be used in an async environment. 2752 * <b>Note:</b> This method cannot be used in an async environment.
2773 * 2753 *
2774 * @param source the source representing the Dart file 2754 * @param source the source representing the Dart file
2775 * @param dartEntry the cache entry associated with the Dart file 2755 * @param dartEntry the cache entry associated with the Dart file
2776 * @param descriptor the descriptor representing the data to be returned 2756 * @param descriptor the descriptor representing the data to be returned
(...skipping 21 matching lines...) Expand all
2798 this, 2778 this,
2799 source, 2779 source,
2800 dartEntry.getValue(DartEntry.TOKEN_STREAM), 2780 dartEntry.getValue(DartEntry.TOKEN_STREAM),
2801 dartEntry.getValue( 2781 dartEntry.getValue(
2802 SourceEntry.LINE_INFO)).perform(_resultRecorder) as DartEntry; 2782 SourceEntry.LINE_INFO)).perform(_resultRecorder) as DartEntry;
2803 state = dartEntry.getState(descriptor); 2783 state = dartEntry.getState(descriptor);
2804 } 2784 }
2805 return dartEntry; 2785 return dartEntry;
2806 } 2786 }
2807 2787
2788
2808 /** 2789 /**
2809 * Given a source for a Dart file and the library that contains it, return a c ache entry in which 2790 * Given a source for a Dart file and the library that contains it, return a c ache entry in which
2810 * the state of the data represented by the given descriptor is either [CacheS tate.VALID] or 2791 * the state of the data represented by the given descriptor is either [CacheS tate.VALID] or
2811 * [CacheState.ERROR]. This method assumes that the data can be produced by re solving the 2792 * [CacheState.ERROR]. This method assumes that the data can be produced by re solving the
2812 * source in the context of the library if it is not already cached. 2793 * source in the context of the library if it is not already cached.
2813 * 2794 *
2814 * <b>Note:</b> This method cannot be used in an async environment. 2795 * <b>Note:</b> This method cannot be used in an async environment.
2815 * 2796 *
2816 * @param unitSource the source representing the Dart file 2797 * @param unitSource the source representing the Dart file
2817 * @param librarySource the source representing the library containing the Dar t file 2798 * @param librarySource the source representing the library containing the Dar t file
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
3157 } 3138 }
3158 } else if (originalContents != null) { 3139 } else if (originalContents != null) {
3159 _incrementalAnalysisCache = 3140 _incrementalAnalysisCache =
3160 IncrementalAnalysisCache.clear(_incrementalAnalysisCache, source); 3141 IncrementalAnalysisCache.clear(_incrementalAnalysisCache, source);
3161 _sourceChanged(source); 3142 _sourceChanged(source);
3162 changed = true; 3143 changed = true;
3163 } 3144 }
3164 return changed; 3145 return changed;
3165 } 3146 }
3166 3147
3167 // /**
3168 // * Create a [BuildUnitElementTask] for the given [source].
3169 // */
3170 // AnalysisContextImpl_TaskData _createBuildUnitElementTask(Source source,
3171 // DartEntry dartEntry, Source librarySource) {
3172 // CompilationUnit unit = dartEntry.resolvableCompilationUnit;
3173 // if (unit == null) {
3174 // return _createParseDartTask(source, dartEntry);
3175 // }
3176 // return new AnalysisContextImpl_TaskData(
3177 // new BuildUnitElementTask(this, source, librarySource, unit),
3178 // false);
3179 // }
3180
3181 /** 3148 /**
3182 * Set the contents of the given source to the given contents and mark the sou rce as having 3149 * Set the contents of the given source to the given contents and mark the sou rce as having
3183 * changed. This has the effect of overriding the default contents of the sour ce. If the contents 3150 * changed. This has the effect of overriding the default contents of the sour ce. If the contents
3184 * are `null` the override is removed so that the default contents will be ret urned. 3151 * are `null` the override is removed so that the default contents will be ret urned.
3185 * [setContents] triggers a source changed event where as this method does not . 3152 * [setContents] triggers a source changed event where as this method does not .
3186 * 3153 *
3187 * @param source the source whose contents are being overridden 3154 * @param source the source whose contents are being overridden
3188 * @param contents the new contents of the source 3155 * @param contents the new contents of the source
3189 */ 3156 */
3190 bool _contentsChanged(Source source, String contents) { 3157 bool _contentsChanged(Source source, String contents) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
3233 } 3200 }
3234 // If not the same content (e.g. the file is being closed without save), 3201 // If not the same content (e.g. the file is being closed without save),
3235 // then force analysis. 3202 // then force analysis.
3236 if (changed) { 3203 if (changed) {
3237 _sourceChanged(source); 3204 _sourceChanged(source);
3238 } 3205 }
3239 } 3206 }
3240 return changed; 3207 return changed;
3241 } 3208 }
3242 3209
3210 // /**
3211 // * Create a [BuildUnitElementTask] for the given [source].
3212 // */
3213 // AnalysisContextImpl_TaskData _createBuildUnitElementTask(Source source,
3214 // DartEntry dartEntry, Source librarySource) {
3215 // CompilationUnit unit = dartEntry.resolvableCompilationUnit;
3216 // if (unit == null) {
3217 // return _createParseDartTask(source, dartEntry);
3218 // }
3219 // return new AnalysisContextImpl_TaskData(
3220 // new BuildUnitElementTask(this, source, librarySource, unit),
3221 // false);
3222 // }
3223
3243 /** 3224 /**
3244 * Create a [GenerateDartErrorsTask] for the given source, marking the verific ation errors 3225 * Create a [GenerateDartErrorsTask] for the given source, marking the verific ation errors
3245 * as being in-process. The compilation unit and the library can be the same i f the compilation 3226 * as being in-process. The compilation unit and the library can be the same i f the compilation
3246 * unit is the defining compilation unit of the library. 3227 * unit is the defining compilation unit of the library.
3247 * 3228 *
3248 * @param unitSource the source for the compilation unit to be verified 3229 * @param unitSource the source for the compilation unit to be verified
3249 * @param unitEntry the entry for the compilation unit 3230 * @param unitEntry the entry for the compilation unit
3250 * @param librarySource the source for the library containing the compilation unit 3231 * @param librarySource the source for the library containing the compilation unit
3251 * @param libraryEntry the entry for the library 3232 * @param libraryEntry the entry for the library
3252 * @return task data representing the created task 3233 * @return task data representing the created task
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
3363 dartEntry.setStateInLibrary( 3344 dartEntry.setStateInLibrary(
3364 DartEntry.LINTS, 3345 DartEntry.LINTS,
3365 librarySource, 3346 librarySource,
3366 CacheState.IN_PROCESS); 3347 CacheState.IN_PROCESS);
3367 //TODO(pquitslund): revisit if we need all units or whether one will do 3348 //TODO(pquitslund): revisit if we need all units or whether one will do
3368 return new AnalysisContextImpl_TaskData( 3349 return new AnalysisContextImpl_TaskData(
3369 new GenerateDartLintsTask(this, units, libraryElement), 3350 new GenerateDartLintsTask(this, units, libraryElement),
3370 false); 3351 false);
3371 } 3352 }
3372 3353
3373
3374
3375 /** 3354 /**
3376 * Create a [GetContentTask] for the given source, marking the content as bein g in-process. 3355 * Create a [GetContentTask] for the given source, marking the content as bein g in-process.
3377 * 3356 *
3378 * @param source the source whose content is to be accessed 3357 * @param source the source whose content is to be accessed
3379 * @param sourceEntry the entry for the source 3358 * @param sourceEntry the entry for the source
3380 * @return task data representing the created task 3359 * @return task data representing the created task
3381 */ 3360 */
3382 AnalysisContextImpl_TaskData _createGetContentTask(Source source, 3361 AnalysisContextImpl_TaskData _createGetContentTask(Source source,
3383 SourceEntry sourceEntry) { 3362 SourceEntry sourceEntry) {
3384 sourceEntry.setState(SourceEntry.CONTENT, CacheState.IN_PROCESS); 3363 sourceEntry.setState(SourceEntry.CONTENT, CacheState.IN_PROCESS);
3385 return new AnalysisContextImpl_TaskData( 3364 return new AnalysisContextImpl_TaskData(
3386 new GetContentTask(this, source), 3365 new GetContentTask(this, source),
3387 false); 3366 false);
3388 } 3367 }
3389 3368
3369
3370
3390 /** 3371 /**
3391 * Create a [ParseDartTask] for the given [source]. 3372 * Create a [ParseDartTask] for the given [source].
3392 */ 3373 */
3393 AnalysisContextImpl_TaskData _createParseDartTask(Source source, 3374 AnalysisContextImpl_TaskData _createParseDartTask(Source source,
3394 DartEntry dartEntry) { 3375 DartEntry dartEntry) {
3395 if (dartEntry.getState(DartEntry.TOKEN_STREAM) != CacheState.VALID || 3376 if (dartEntry.getState(DartEntry.TOKEN_STREAM) != CacheState.VALID ||
3396 dartEntry.getState(SourceEntry.LINE_INFO) != CacheState.VALID) { 3377 dartEntry.getState(SourceEntry.LINE_INFO) != CacheState.VALID) {
3397 return _createScanDartTask(source, dartEntry); 3378 return _createScanDartTask(source, dartEntry);
3398 } 3379 }
3399 Token tokenStream = dartEntry.getValue(DartEntry.TOKEN_STREAM); 3380 Token tokenStream = dartEntry.getValue(DartEntry.TOKEN_STREAM);
(...skipping 972 matching lines...) Expand 10 before | Expand all | Expand 10 after
4372 * @param lineInfo the line information associated with the source 4353 * @param lineInfo the line information associated with the source
4373 */ 4354 */
4374 void _notifyErrors(Source source, List<AnalysisError> errors, 4355 void _notifyErrors(Source source, List<AnalysisError> errors,
4375 LineInfo lineInfo) { 4356 LineInfo lineInfo) {
4376 int count = _listeners.length; 4357 int count = _listeners.length;
4377 for (int i = 0; i < count; i++) { 4358 for (int i = 0; i < count; i++) {
4378 _listeners[i].computedErrors(this, source, errors, lineInfo); 4359 _listeners[i].computedErrors(this, source, errors, lineInfo);
4379 } 4360 }
4380 } 4361 }
4381 4362
4363 /**
4364 * Record the results produced by performing a [task] and return the cache
4365 * entry associated with the results.
4366 */
4367 DartEntry _recordBuildUnitElementTask(BuildUnitElementTask task) {
4368 Source source = task.source;
4369 Source library = task.library;
4370 DartEntry dartEntry = _cache.get(source);
4371 CaughtException thrownException = task.exception;
4372 if (thrownException != null) {
4373 dartEntry.recordBuildElementErrorInLibrary(library, thrownException);
4374 throw new AnalysisException('<rethrow>', thrownException);
4375 }
4376 dartEntry.setValueInLibrary(DartEntry.BUILT_UNIT, library, task.unit);
4377 dartEntry.setValueInLibrary(
4378 DartEntry.BUILT_ELEMENT,
4379 library,
4380 task.unitElement);
4381 ChangeNoticeImpl notice = _getNotice(source);
4382 LineInfo lineInfo = dartEntry.getValue(SourceEntry.LINE_INFO);
4383 notice.setErrors(dartEntry.allErrors, lineInfo);
4384 return dartEntry;
4385 }
4386
4382 // /** 4387 // /**
4383 // * Notify all of the analysis listeners that the given source is no longer i ncluded in the set of 4388 // * Notify all of the analysis listeners that the given source is no longer i ncluded in the set of
4384 // * sources that are being analyzed. 4389 // * sources that are being analyzed.
4385 // * 4390 // *
4386 // * @param source the source that is no longer being analyzed 4391 // * @param source the source that is no longer being analyzed
4387 // */ 4392 // */
4388 // void _notifyExcludedSource(Source source) { 4393 // void _notifyExcludedSource(Source source) {
4389 // int count = _listeners.length; 4394 // int count = _listeners.length;
4390 // for (int i = 0; i < count; i++) { 4395 // for (int i = 0; i < count; i++) {
4391 // _listeners[i].excludedSource(this, source); 4396 // _listeners[i].excludedSource(this, source);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
4451 // * @param unit the result of resolving the source 4456 // * @param unit the result of resolving the source
4452 // */ 4457 // */
4453 // void _notifyResolvedHtml(Source source, ht.HtmlUnit unit) { 4458 // void _notifyResolvedHtml(Source source, ht.HtmlUnit unit) {
4454 // int count = _listeners.length; 4459 // int count = _listeners.length;
4455 // for (int i = 0; i < count; i++) { 4460 // for (int i = 0; i < count; i++) {
4456 // _listeners[i].resolvedHtml(this, source, unit); 4461 // _listeners[i].resolvedHtml(this, source, unit);
4457 // } 4462 // }
4458 // } 4463 // }
4459 4464
4460 /** 4465 /**
4461 * Record the results produced by performing a [task] and return the cache
4462 * entry associated with the results.
4463 */
4464 DartEntry _recordBuildUnitElementTask(BuildUnitElementTask task) {
4465 Source source = task.source;
4466 Source library = task.library;
4467 DartEntry dartEntry = _cache.get(source);
4468 CaughtException thrownException = task.exception;
4469 if (thrownException != null) {
4470 dartEntry.recordBuildElementErrorInLibrary(library, thrownException);
4471 throw new AnalysisException('<rethrow>', thrownException);
4472 }
4473 dartEntry.setValueInLibrary(DartEntry.BUILT_UNIT, library, task.unit);
4474 dartEntry.setValueInLibrary(
4475 DartEntry.BUILT_ELEMENT,
4476 library,
4477 task.unitElement);
4478 ChangeNoticeImpl notice = _getNotice(source);
4479 LineInfo lineInfo = dartEntry.getValue(SourceEntry.LINE_INFO);
4480 notice.setErrors(dartEntry.allErrors, lineInfo);
4481 return dartEntry;
4482 }
4483
4484 /**
4485 * Given a cache entry and a library element, record the library element and o ther information 4466 * Given a cache entry and a library element, record the library element and o ther information
4486 * gleaned from the element in the cache entry. 4467 * gleaned from the element in the cache entry.
4487 * 4468 *
4488 * @param dartCopy the cache entry in which data is to be recorded 4469 * @param dartCopy the cache entry in which data is to be recorded
4489 * @param library the library element used to record information 4470 * @param library the library element used to record information
4490 * @param librarySource the source for the library used to record information 4471 * @param librarySource the source for the library used to record information
4491 * @param htmlSource the source for the HTML library 4472 * @param htmlSource the source for the HTML library
4492 */ 4473 */
4493 void _recordElementData(DartEntry dartEntry, LibraryElement library, 4474 void _recordElementData(DartEntry dartEntry, LibraryElement library,
4494 Source librarySource, Source htmlSource) { 4475 Source librarySource, Source htmlSource) {
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
4603 } else { 4584 } else {
4604 dartEntry.recordLintErrorInLibrary(librarySource, thrownException); 4585 dartEntry.recordLintErrorInLibrary(librarySource, thrownException);
4605 } 4586 }
4606 }); 4587 });
4607 if (thrownException != null) { 4588 if (thrownException != null) {
4608 throw new AnalysisException('<rethrow>', thrownException); 4589 throw new AnalysisException('<rethrow>', thrownException);
4609 } 4590 }
4610 return libraryEntry; 4591 return libraryEntry;
4611 } 4592 }
4612 4593
4613
4614 /** 4594 /**
4615 * Record the results produced by performing a [task] and return the cache 4595 * Record the results produced by performing a [task] and return the cache
4616 * entry associated with the results. 4596 * entry associated with the results.
4617 */ 4597 */
4618 SourceEntry _recordGetContentsTask(GetContentTask task) { 4598 SourceEntry _recordGetContentsTask(GetContentTask task) {
4619 if (!task.isComplete) { 4599 if (!task.isComplete) {
4620 return null; 4600 return null;
4621 } 4601 }
4622 Source source = task.source; 4602 Source source = task.source;
4623 SourceEntry sourceEntry = _cache.get(source); 4603 SourceEntry sourceEntry = _cache.get(source);
4624 CaughtException thrownException = task.exception; 4604 CaughtException thrownException = task.exception;
4625 if (thrownException != null) { 4605 if (thrownException != null) {
4626 sourceEntry.recordContentError(thrownException); 4606 sourceEntry.recordContentError(thrownException);
4627 _workManager.remove(source); 4607 _workManager.remove(source);
4628 throw new AnalysisException('<rethrow>', thrownException); 4608 throw new AnalysisException('<rethrow>', thrownException);
4629 } 4609 }
4630 sourceEntry.modificationTime = task.modificationTime; 4610 sourceEntry.modificationTime = task.modificationTime;
4631 sourceEntry.setValue(SourceEntry.CONTENT, task.content); 4611 sourceEntry.setValue(SourceEntry.CONTENT, task.content);
4632 return sourceEntry; 4612 return sourceEntry;
4633 } 4613 }
4634 4614
4615
4635 /** 4616 /**
4636 * Record the results produced by performing a [IncrementalAnalysisTask]. 4617 * Record the results produced by performing a [IncrementalAnalysisTask].
4637 * 4618 *
4638 * @param task the task that was performed 4619 * @param task the task that was performed
4639 * @return an entry containing the computed results 4620 * @return an entry containing the computed results
4640 * @throws AnalysisException if the results could not be recorded 4621 * @throws AnalysisException if the results could not be recorded
4641 */ 4622 */
4642 DartEntry 4623 DartEntry
4643 _recordIncrementalAnalysisTaskResults(IncrementalAnalysisTask task) { 4624 _recordIncrementalAnalysisTaskResults(IncrementalAnalysisTask task) {
4644 CompilationUnit unit = task.compilationUnit; 4625 CompilationUnit unit = task.compilationUnit;
(...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after
5130 buffer.write(missingSources.length); 5111 buffer.write(missingSources.length);
5131 buffer.writeln(" missing sources"); 5112 buffer.writeln(" missing sources");
5132 for (Source source in missingSources) { 5113 for (Source source in missingSources) {
5133 buffer.write(" "); 5114 buffer.write(" ");
5134 buffer.writeln(source.fullName); 5115 buffer.writeln(source.fullName);
5135 } 5116 }
5136 _logInformation(buffer.toString()); 5117 _logInformation(buffer.toString());
5137 } 5118 }
5138 return changedSources.length > 0; 5119 return changedSources.length > 0;
5139 } 5120 }
5121
5122 void _validateLastIncrementalResolutionResult() {
5123 if (incrementalResolutionValidation_lastUnitSource == null ||
5124 incrementalResolutionValidation_lastLibrarySource == null ||
5125 incrementalResolutionValidation_lastUnit == null) {
5126 return;
5127 }
5128 CompilationUnit fullUnit = getResolvedCompilationUnit2(
5129 incrementalResolutionValidation_lastUnitSource,
5130 incrementalResolutionValidation_lastLibrarySource);
5131 if (fullUnit != null) {
5132 try {
5133 assertSameResolution(
5134 incrementalResolutionValidation_lastUnit,
5135 fullUnit);
5136 } on IncrementalResolutionMismatch catch (mismatch, stack) {
5137 String failure = mismatch.message;
5138 String message =
5139 'Incremental resolution mismatch:\n$failure\nat\n$stack';
5140 AnalysisEngine.instance.logger.logError(message);
5141 }
5142 }
5143 incrementalResolutionValidation_lastUnitSource = null;
5144 incrementalResolutionValidation_lastLibrarySource = null;
5145 incrementalResolutionValidation_lastUnit = null;
5146 }
5140 } 5147 }
5141 5148
5142 /** 5149 /**
5143 * An `AnalysisTaskResultRecorder` is used by an analysis context to record the 5150 * An `AnalysisTaskResultRecorder` is used by an analysis context to record the
5144 * results of a task. 5151 * results of a task.
5145 */ 5152 */
5146 class AnalysisContextImpl_AnalysisTaskResultRecorder implements 5153 class AnalysisContextImpl_AnalysisTaskResultRecorder implements
5147 AnalysisTaskVisitor<SourceEntry> { 5154 AnalysisTaskVisitor<SourceEntry> {
5148 final AnalysisContextImpl AnalysisContextImpl_this; 5155 final AnalysisContextImpl AnalysisContextImpl_this;
5149 5156
(...skipping 676 matching lines...) Expand 10 before | Expand all | Expand 10 after
5826 */ 5833 */
5827 List<AnalysisContextStatistics_PartitionData> get partitionData; 5834 List<AnalysisContextStatistics_PartitionData> get partitionData;
5828 5835
5829 /** 5836 /**
5830 * Return an array containing all of the sources in the cache. 5837 * Return an array containing all of the sources in the cache.
5831 */ 5838 */
5832 List<Source> get sources; 5839 List<Source> get sources;
5833 } 5840 }
5834 5841
5835 /** 5842 /**
5843 * Information about single piece of data in the cache.
5844 */
5845 abstract class AnalysisContextStatistics_CacheRow {
5846 /**
5847 * List of possible states which can be queried.
5848 */
5849 static const List<CacheState> STATES = const <CacheState>[
5850 CacheState.ERROR,
5851 CacheState.FLUSHED,
5852 CacheState.IN_PROCESS,
5853 CacheState.INVALID,
5854 CacheState.VALID];
5855
5856 /**
5857 * Return the number of entries whose state is [CacheState.ERROR].
5858 */
5859 int get errorCount;
5860
5861 /**
5862 * Return the number of entries whose state is [CacheState.FLUSHED].
5863 */
5864 int get flushedCount;
5865
5866 /**
5867 * Return the number of entries whose state is [CacheState.IN_PROCESS].
5868 */
5869 int get inProcessCount;
5870
5871 /**
5872 * Return the number of entries whose state is [CacheState.INVALID].
5873 */
5874 int get invalidCount;
5875
5876 /**
5877 * Return the name of the data represented by this object.
5878 */
5879 String get name;
5880
5881 /**
5882 * Return the number of entries whose state is [CacheState.VALID].
5883 */
5884 int get validCount;
5885
5886 /**
5887 * Return the number of entries whose state is [state].
5888 */
5889 int getCount(CacheState state);
5890 }
5891
5892 /**
5893 * Information about a single partition in the cache.
5894 */
5895 abstract class AnalysisContextStatistics_PartitionData {
5896 /**
5897 * Return the number of entries in the partition that have an AST structure in one state or
5898 * another.
5899 */
5900 int get astCount;
5901
5902 /**
5903 * Return the total number of entries in the partition.
5904 */
5905 int get totalCount;
5906 }
5907
5908 /**
5836 * Implementation of the [AnalysisContextStatistics]. 5909 * Implementation of the [AnalysisContextStatistics].
5837 */ 5910 */
5838 class AnalysisContextStatisticsImpl implements AnalysisContextStatistics { 5911 class AnalysisContextStatisticsImpl implements AnalysisContextStatistics {
5839 Map<String, AnalysisContextStatistics_CacheRow> _dataMap = 5912 Map<String, AnalysisContextStatistics_CacheRow> _dataMap =
5840 new HashMap<String, AnalysisContextStatistics_CacheRow>(); 5913 new HashMap<String, AnalysisContextStatistics_CacheRow>();
5841 5914
5842 List<Source> _sources = new List<Source>(); 5915 List<Source> _sources = new List<Source>();
5843 5916
5844 HashSet<CaughtException> _exceptions = new HashSet<CaughtException>(); 5917 HashSet<CaughtException> _exceptions = new HashSet<CaughtException>();
5845 5918
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
5942 AnalysisContextStatistics_PartitionData { 6015 AnalysisContextStatistics_PartitionData {
5943 final int astCount; 6016 final int astCount;
5944 6017
5945 final int totalCount; 6018 final int totalCount;
5946 6019
5947 AnalysisContextStatisticsImpl_PartitionDataImpl(this.astCount, 6020 AnalysisContextStatisticsImpl_PartitionDataImpl(this.astCount,
5948 this.totalCount); 6021 this.totalCount);
5949 } 6022 }
5950 6023
5951 /** 6024 /**
5952 * Information about single piece of data in the cache.
5953 */
5954 abstract class AnalysisContextStatistics_CacheRow {
5955 /**
5956 * List of possible states which can be queried.
5957 */
5958 static const List<CacheState> STATES = const <CacheState>[
5959 CacheState.ERROR,
5960 CacheState.FLUSHED,
5961 CacheState.IN_PROCESS,
5962 CacheState.INVALID,
5963 CacheState.VALID];
5964
5965 /**
5966 * Return the number of entries whose state is [CacheState.ERROR].
5967 */
5968 int get errorCount;
5969
5970 /**
5971 * Return the number of entries whose state is [CacheState.FLUSHED].
5972 */
5973 int get flushedCount;
5974
5975 /**
5976 * Return the number of entries whose state is [CacheState.IN_PROCESS].
5977 */
5978 int get inProcessCount;
5979
5980 /**
5981 * Return the number of entries whose state is [CacheState.INVALID].
5982 */
5983 int get invalidCount;
5984
5985 /**
5986 * Return the name of the data represented by this object.
5987 */
5988 String get name;
5989
5990 /**
5991 * Return the number of entries whose state is [CacheState.VALID].
5992 */
5993 int get validCount;
5994
5995 /**
5996 * Return the number of entries whose state is [state].
5997 */
5998 int getCount(CacheState state);
5999 }
6000
6001 /**
6002 * Information about a single partition in the cache.
6003 */
6004 abstract class AnalysisContextStatistics_PartitionData {
6005 /**
6006 * Return the number of entries in the partition that have an AST structure in one state or
6007 * another.
6008 */
6009 int get astCount;
6010
6011 /**
6012 * Return the total number of entries in the partition.
6013 */
6014 int get totalCount;
6015 }
6016
6017 /**
6018 * Instances of the class `AnalysisDelta` indicate changes to the types of analy sis that 6025 * Instances of the class `AnalysisDelta` indicate changes to the types of analy sis that
6019 * should be performed. 6026 * should be performed.
6020 */ 6027 */
6021 class AnalysisDelta { 6028 class AnalysisDelta {
6022 /** 6029 /**
6023 * A mapping from source to what type of analysis should be performed on that source. 6030 * A mapping from source to what type of analysis should be performed on that source.
6024 */ 6031 */
6025 HashMap<Source, AnalysisLevel> _analysisMap = 6032 HashMap<Source, AnalysisLevel> _analysisMap =
6026 new HashMap<Source, AnalysisLevel>(); 6033 new HashMap<Source, AnalysisLevel>();
6027 6034
(...skipping 843 matching lines...) Expand 10 before | Expand all | Expand 10 after
6871 E visitResolveHtmlTask(ResolveHtmlTask task); 6878 E visitResolveHtmlTask(ResolveHtmlTask task);
6872 6879
6873 /** 6880 /**
6874 * Visit the given [task], returning the result of the visit. This method will 6881 * Visit the given [task], returning the result of the visit. This method will
6875 * throw an AnalysisException if the visitor throws an exception. 6882 * throw an AnalysisException if the visitor throws an exception.
6876 */ 6883 */
6877 E visitScanDartTask(ScanDartTask task); 6884 E visitScanDartTask(ScanDartTask task);
6878 } 6885 }
6879 6886
6880 /** 6887 /**
6888 * A `CachedResult` is a single analysis result that is stored in a
6889 * [SourceEntry].
6890 */
6891 class CachedResult<E> {
6892 /**
6893 * The state of the cached value.
6894 */
6895 CacheState state;
6896
6897 /**
6898 * The value being cached, or `null` if there is no value (for example, when
6899 * the [state] is [CacheState.INVALID].
6900 */
6901 E value;
6902
6903 /**
6904 * Initialize a newly created result holder to represent the value of data
6905 * described by the given [descriptor].
6906 */
6907 CachedResult(DataDescriptor descriptor) {
6908 state = CacheState.INVALID;
6909 value = descriptor.defaultValue;
6910 }
6911 }
6912
6913 /**
6881 * Instances of the class `CachePartition` implement a single partition in an LR U cache of 6914 * Instances of the class `CachePartition` implement a single partition in an LR U cache of
6882 * information related to analysis. 6915 * information related to analysis.
6883 */ 6916 */
6884 abstract class CachePartition { 6917 abstract class CachePartition {
6885 /** 6918 /**
6886 * The context that owns this partition. Multiple contexts can reference a par tition, but only one 6919 * The context that owns this partition. Multiple contexts can reference a par tition, but only one
6887 * context can own it. 6920 * context can own it.
6888 */ 6921 */
6889 final InternalAnalysisContext context; 6922 final InternalAnalysisContext context;
6890 6923
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after
7191 ERROR, 7224 ERROR,
7192 FLUSHED, 7225 FLUSHED,
7193 IN_PROCESS, 7226 IN_PROCESS,
7194 INVALID, 7227 INVALID,
7195 VALID]; 7228 VALID];
7196 7229
7197 const CacheState(String name, int ordinal) : super(name, ordinal); 7230 const CacheState(String name, int ordinal) : super(name, ordinal);
7198 } 7231 }
7199 7232
7200 /** 7233 /**
7201 * A `CachedResult` is a single analysis result that is stored in a
7202 * [SourceEntry].
7203 */
7204 class CachedResult<E> {
7205 /**
7206 * The state of the cached value.
7207 */
7208 CacheState state;
7209
7210 /**
7211 * The value being cached, or `null` if there is no value (for example, when
7212 * the [state] is [CacheState.INVALID].
7213 */
7214 E value;
7215
7216 /**
7217 * Initialize a newly created result holder to represent the value of data
7218 * described by the given [descriptor].
7219 */
7220 CachedResult(DataDescriptor descriptor) {
7221 state = CacheState.INVALID;
7222 value = descriptor.defaultValue;
7223 }
7224 }
7225
7226 /**
7227 * The interface `ChangeNotice` defines the behavior of objects that represent a change to the 7234 * The interface `ChangeNotice` defines the behavior of objects that represent a change to the
7228 * analysis results associated with a given source. 7235 * analysis results associated with a given source.
7229 */ 7236 */
7230 abstract class ChangeNotice implements AnalysisErrorInfo { 7237 abstract class ChangeNotice implements AnalysisErrorInfo {
7231 /** 7238 /**
7232 * Return the fully resolved AST that changed as a result of the analysis, or `null` if the 7239 * Return the fully resolved AST that changed as a result of the analysis, or `null` if the
7233 * AST was not changed. 7240 * AST was not changed.
7234 * 7241 *
7235 * @return the fully resolved AST that changed as a result of the analysis 7242 * @return the fully resolved AST that changed as a result of the analysis
7236 */ 7243 */
(...skipping 1642 matching lines...) Expand 10 before | Expand all | Expand 10 after
8879 /// Generates lint feedback for a single Dart library. 8886 /// Generates lint feedback for a single Dart library.
8880 class GenerateDartLintsTask extends AnalysisTask { 8887 class GenerateDartLintsTask extends AnalysisTask {
8881 8888
8882 ///The compilation units that comprise the library, with the defining 8889 ///The compilation units that comprise the library, with the defining
8883 ///compilation unit appearing first in the array. 8890 ///compilation unit appearing first in the array.
8884 final List<TimestampedData<CompilationUnit>> _units; 8891 final List<TimestampedData<CompilationUnit>> _units;
8885 8892
8886 /// The element model for the library being analyzed. 8893 /// The element model for the library being analyzed.
8887 final LibraryElement libraryElement; 8894 final LibraryElement libraryElement;
8888 8895
8896 /// A mapping of analyzed sources to their associated lint warnings.
8897 /// May be [null] if the task has not been performed or if analysis did not
8898 /// complete normally.
8899 HashMap<Source, List<AnalysisError>> lintMap;
8900
8889 /// Initialize a newly created task to perform lint checking over these 8901 /// Initialize a newly created task to perform lint checking over these
8890 /// [_units] belonging to this [libraryElement] within the given [context]. 8902 /// [_units] belonging to this [libraryElement] within the given [context].
8891 GenerateDartLintsTask(context, this._units, this.libraryElement) 8903 GenerateDartLintsTask(context, this._units, this.libraryElement)
8892 : super(context); 8904 : super(context);
8893 8905
8894 /// A mapping of analyzed sources to their associated lint warnings.
8895 /// May be [null] if the task has not been performed or if analysis did not
8896 /// complete normally.
8897 HashMap<Source, List<AnalysisError>> lintMap;
8898
8899 @override 8906 @override
8900 String get taskDescription { 8907 String get taskDescription {
8901 Source librarySource = libraryElement.source; 8908 Source librarySource = libraryElement.source;
8902 return (librarySource == null) ? 8909 return (librarySource == null) ?
8903 "generate Dart lints for library without source" : 8910 "generate Dart lints for library without source" :
8904 "generate Dart lints for ${librarySource.fullName}"; 8911 "generate Dart lints for ${librarySource.fullName}";
8905 } 8912 }
8906 8913
8907 @override 8914 @override
8908 accept(AnalysisTaskVisitor visitor) => 8915 accept(AnalysisTaskVisitor visitor) =>
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
8998 @override 9005 @override
8999 accept(AnalysisTaskVisitor visitor) => visitor.visitGetContentTask(this); 9006 accept(AnalysisTaskVisitor visitor) => visitor.visitGetContentTask(this);
9000 9007
9001 @override 9008 @override
9002 void internalPerform() { 9009 void internalPerform() {
9003 _complete = true; 9010 _complete = true;
9004 try { 9011 try {
9005 TimestampedData<String> data = context.getContents(source); 9012 TimestampedData<String> data = context.getContents(source);
9006 _content = data.data; 9013 _content = data.data;
9007 _modificationTime = data.modificationTime; 9014 _modificationTime = data.modificationTime;
9008 AnalysisEngine.instance.instrumentationService.logFileRead(source.fullName , _modificationTime, _content); 9015 AnalysisEngine.instance.instrumentationService.logFileRead(
9016 source.fullName,
9017 _modificationTime,
9018 _content);
9009 } catch (exception, stackTrace) { 9019 } catch (exception, stackTrace) {
9010 throw new AnalysisException( 9020 throw new AnalysisException(
9011 "Could not get contents of $source", 9021 "Could not get contents of $source",
9012 new CaughtException(exception, stackTrace)); 9022 new CaughtException(exception, stackTrace));
9013 } 9023 }
9014 } 9024 }
9015 } 9025 }
9016 9026
9017 /** 9027 /**
9018 * An `HtmlEntry` maintains the information cached by an analysis context about 9028 * An `HtmlEntry` maintains the information cached by an analysis context about
(...skipping 3219 matching lines...) Expand 10 before | Expand all | Expand 10 after
12238 if (element.id == _id) { 12248 if (element.id == _id) {
12239 result = element; 12249 result = element;
12240 throw new _ElementByIdFinderException(); 12250 throw new _ElementByIdFinderException();
12241 } 12251 }
12242 super.visitElement(element); 12252 super.visitElement(element);
12243 } 12253 }
12244 } 12254 }
12245 12255
12246 class _ElementByIdFinderException { 12256 class _ElementByIdFinderException {
12247 } 12257 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698