| 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 // 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; |
| (...skipping 2270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2281 | 2281 |
| 2282 @override | 2282 @override |
| 2283 ht.HtmlUnit parseHtmlUnit(Source source) => | 2283 ht.HtmlUnit parseHtmlUnit(Source source) => |
| 2284 _getHtmlParseData(source, HtmlEntry.PARSED_UNIT, null); | 2284 _getHtmlParseData(source, HtmlEntry.PARSED_UNIT, null); |
| 2285 | 2285 |
| 2286 @override | 2286 @override |
| 2287 AnalysisResult performAnalysisTask() { | 2287 AnalysisResult performAnalysisTask() { |
| 2288 if (_TRACE_PERFORM_TASK) { | 2288 if (_TRACE_PERFORM_TASK) { |
| 2289 print("----------------------------------------"); | 2289 print("----------------------------------------"); |
| 2290 } | 2290 } |
| 2291 PerformanceTag prevTag = PerformanceStatistics.performAnaysis.makeCurrent(); | 2291 return PerformanceStatistics.performAnaysis.makeCurrentWhile(() { |
| 2292 try { | |
| 2293 int getStart = JavaSystem.currentTimeMillis(); | 2292 int getStart = JavaSystem.currentTimeMillis(); |
| 2294 AnalysisTask task = nextAnalysisTask; | 2293 AnalysisTask task = nextAnalysisTask; |
| 2295 int getEnd = JavaSystem.currentTimeMillis(); | 2294 int getEnd = JavaSystem.currentTimeMillis(); |
| 2296 if (task == null && _validateCacheConsistency()) { | 2295 if (task == null && _validateCacheConsistency()) { |
| 2297 task = nextAnalysisTask; | 2296 task = nextAnalysisTask; |
| 2298 } | 2297 } |
| 2299 if (task == null) { | 2298 if (task == null) { |
| 2300 _validateLastIncrementalResolutionResult(); | 2299 _validateLastIncrementalResolutionResult(); |
| 2301 if (_performAnalysisTaskStopwatch != null) { | 2300 if (_performAnalysisTaskStopwatch != null) { |
| 2302 AnalysisEngine.instance.instrumentationService.logPerformance( | 2301 AnalysisEngine.instance.instrumentationService.logPerformance( |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2348 // } else if (notice.getHtmlUnit() != null) { | 2347 // } else if (notice.getHtmlUnit() != null) { |
| 2349 // notifyResolvedHtml(source, notice.getHtmlUnit()); | 2348 // notifyResolvedHtml(source, notice.getHtmlUnit()); |
| 2350 // } | 2349 // } |
| 2351 _notifyErrors(source, notice.errors, notice.lineInfo); | 2350 _notifyErrors(source, notice.errors, notice.lineInfo); |
| 2352 } | 2351 } |
| 2353 return new AnalysisResult( | 2352 return new AnalysisResult( |
| 2354 notices, | 2353 notices, |
| 2355 getEnd - getStart, | 2354 getEnd - getStart, |
| 2356 task.runtimeType.toString(), | 2355 task.runtimeType.toString(), |
| 2357 performEnd - performStart); | 2356 performEnd - performStart); |
| 2358 } finally { | 2357 }); |
| 2359 prevTag.makeCurrent(); | |
| 2360 } | |
| 2361 } | 2358 } |
| 2362 | 2359 |
| 2363 @override | 2360 @override |
| 2364 void recordLibraryElements(Map<Source, LibraryElement> elementMap) { | 2361 void recordLibraryElements(Map<Source, LibraryElement> elementMap) { |
| 2365 Source htmlSource = _sourceFactory.forUri(DartSdk.DART_HTML); | 2362 Source htmlSource = _sourceFactory.forUri(DartSdk.DART_HTML); |
| 2366 elementMap.forEach((Source librarySource, LibraryElement library) { | 2363 elementMap.forEach((Source librarySource, LibraryElement library) { |
| 2367 // | 2364 // |
| 2368 // Cache the element in the library's info. | 2365 // Cache the element in the library's info. |
| 2369 // | 2366 // |
| 2370 DartEntry dartEntry = _getReadableDartEntry(librarySource); | 2367 DartEntry dartEntry = _getReadableDartEntry(librarySource); |
| (...skipping 1082 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3453 * | 3450 * |
| 3454 * @param source the source whose content is to be resolved | 3451 * @param source the source whose content is to be resolved |
| 3455 * @param dartEntry the entry for the source | 3452 * @param dartEntry the entry for the source |
| 3456 * @return task data representing the created task | 3453 * @return task data representing the created task |
| 3457 */ | 3454 */ |
| 3458 AnalysisContextImpl_TaskData _createResolveDartLibraryTask(Source source, | 3455 AnalysisContextImpl_TaskData _createResolveDartLibraryTask(Source source, |
| 3459 DartEntry dartEntry) { | 3456 DartEntry dartEntry) { |
| 3460 try { | 3457 try { |
| 3461 AnalysisContextImpl_CycleBuilder builder = | 3458 AnalysisContextImpl_CycleBuilder builder = |
| 3462 new AnalysisContextImpl_CycleBuilder(this); | 3459 new AnalysisContextImpl_CycleBuilder(this); |
| 3463 PerformanceTag prevTag = PerformanceStatistics.cycles.makeCurrent(); | 3460 PerformanceStatistics.cycles.makeCurrentWhile(() { |
| 3464 try { | |
| 3465 builder.computeCycleContaining(source); | 3461 builder.computeCycleContaining(source); |
| 3466 } finally { | 3462 }); |
| 3467 prevTag.makeCurrent(); | |
| 3468 } | |
| 3469 AnalysisContextImpl_TaskData taskData = builder.taskData; | 3463 AnalysisContextImpl_TaskData taskData = builder.taskData; |
| 3470 if (taskData != null) { | 3464 if (taskData != null) { |
| 3471 return taskData; | 3465 return taskData; |
| 3472 } | 3466 } |
| 3473 return new AnalysisContextImpl_TaskData( | 3467 return new AnalysisContextImpl_TaskData( |
| 3474 new ResolveDartLibraryCycleTask(this, source, source, builder.librarie
sInCycle), | 3468 new ResolveDartLibraryCycleTask(this, source, source, builder.librarie
sInCycle), |
| 3475 false); | 3469 false); |
| 3476 } on AnalysisException catch (exception, stackTrace) { | 3470 } on AnalysisException catch (exception, stackTrace) { |
| 3477 dartEntry.recordResolutionError( | 3471 dartEntry.recordResolutionError( |
| 3478 new CaughtException(exception, stackTrace)); | 3472 new CaughtException(exception, stackTrace)); |
| (...skipping 5310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 8789 @override | 8783 @override |
| 8790 String get taskDescription => | 8784 String get taskDescription => |
| 8791 "generate errors and warnings for ${source.fullName}"; | 8785 "generate errors and warnings for ${source.fullName}"; |
| 8792 | 8786 |
| 8793 @override | 8787 @override |
| 8794 accept(AnalysisTaskVisitor visitor) => | 8788 accept(AnalysisTaskVisitor visitor) => |
| 8795 visitor.visitGenerateDartErrorsTask(this); | 8789 visitor.visitGenerateDartErrorsTask(this); |
| 8796 | 8790 |
| 8797 @override | 8791 @override |
| 8798 void internalPerform() { | 8792 void internalPerform() { |
| 8799 PerformanceTag prevTag = PerformanceStatistics.errors.makeCurrent(); | 8793 PerformanceStatistics.errors.makeCurrentWhile(() { |
| 8800 try { | |
| 8801 RecordingErrorListener errorListener = new RecordingErrorListener(); | 8794 RecordingErrorListener errorListener = new RecordingErrorListener(); |
| 8802 ErrorReporter errorReporter = new ErrorReporter(errorListener, source); | 8795 ErrorReporter errorReporter = new ErrorReporter(errorListener, source); |
| 8803 TypeProvider typeProvider = context.typeProvider; | 8796 TypeProvider typeProvider = context.typeProvider; |
| 8804 // | 8797 // |
| 8805 // Validate the directives | 8798 // Validate the directives |
| 8806 // | 8799 // |
| 8807 validateDirectives(context, source, _unit, errorListener); | 8800 validateDirectives(context, source, _unit, errorListener); |
| 8808 // | 8801 // |
| 8809 // Use the ConstantVerifier to verify the use of constants. | 8802 // Use the ConstantVerifier to verify the use of constants. |
| 8810 // This needs to happen before using the ErrorVerifier because some error | 8803 // This needs to happen before using the ErrorVerifier because some error |
| 8811 // codes need the computed constant values. | 8804 // codes need the computed constant values. |
| 8812 // | 8805 // |
| 8813 // TODO(paulberry): as a temporary workaround for issue 21572, | 8806 // TODO(paulberry): as a temporary workaround for issue 21572, |
| 8814 // ConstantVerifier is being run right after ConstantValueComputer, so we | 8807 // ConstantVerifier is being run right after ConstantValueComputer, so we |
| 8815 // don't need to run it here. Once issue 21572 is fixed, re-enable the | 8808 // don't need to run it here. Once issue 21572 is fixed, re-enable the |
| 8816 // call to ConstantVerifier. | 8809 // call to ConstantVerifier. |
| 8817 // ConstantVerifier constantVerifier = new ConstantVerifier(errorReporter,
libraryElement, typeProvider); | 8810 // ConstantVerifier constantVerifier = new ConstantVerifier(errorReporter,
libraryElement, typeProvider); |
| 8818 // _unit.accept(constantVerifier); | 8811 // _unit.accept(constantVerifier); |
| 8819 // | 8812 // |
| 8820 // Use the ErrorVerifier to compute the rest of the errors. | 8813 // Use the ErrorVerifier to compute the rest of the errors. |
| 8821 // | 8814 // |
| 8822 ErrorVerifier errorVerifier = new ErrorVerifier( | 8815 ErrorVerifier errorVerifier = new ErrorVerifier( |
| 8823 errorReporter, | 8816 errorReporter, |
| 8824 libraryElement, | 8817 libraryElement, |
| 8825 typeProvider, | 8818 typeProvider, |
| 8826 new InheritanceManager(libraryElement)); | 8819 new InheritanceManager(libraryElement)); |
| 8827 _unit.accept(errorVerifier); | 8820 _unit.accept(errorVerifier); |
| 8828 _errors = errorListener.getErrorsForSource(source); | 8821 _errors = errorListener.getErrorsForSource(source); |
| 8829 } finally { | 8822 }); |
| 8830 prevTag.makeCurrent(); | |
| 8831 } | |
| 8832 } | 8823 } |
| 8833 | 8824 |
| 8834 /** | 8825 /** |
| 8835 * Check each directive in the given compilation unit to see if the referenced
source exists and | 8826 * Check each directive in the given compilation unit to see if the referenced
source exists and |
| 8836 * report an error if it does not. | 8827 * report an error if it does not. |
| 8837 * | 8828 * |
| 8838 * @param context the context in which the library exists | 8829 * @param context the context in which the library exists |
| 8839 * @param librarySource the source representing the library containing the dir
ectives | 8830 * @param librarySource the source representing the library containing the dir
ectives |
| 8840 * @param unit the compilation unit containing the directives to be validated | 8831 * @param unit the compilation unit containing the directives to be validated |
| 8841 * @param errorListener the error listener to which errors should be reported | 8832 * @param errorListener the error listener to which errors should be reported |
| (...skipping 1216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10058 } | 10049 } |
| 10059 | 10050 |
| 10060 @override | 10051 @override |
| 10061 accept(AnalysisTaskVisitor visitor) => visitor.visitParseDartTask(this); | 10052 accept(AnalysisTaskVisitor visitor) => visitor.visitParseDartTask(this); |
| 10062 | 10053 |
| 10063 @override | 10054 @override |
| 10064 void internalPerform() { | 10055 void internalPerform() { |
| 10065 // | 10056 // |
| 10066 // Then parse the token stream. | 10057 // Then parse the token stream. |
| 10067 // | 10058 // |
| 10068 PerformanceTag prevTag = PerformanceStatistics.parse.makeCurrent(); | 10059 PerformanceStatistics.parse.makeCurrentWhile(() { |
| 10069 try { | |
| 10070 RecordingErrorListener errorListener = new RecordingErrorListener(); | 10060 RecordingErrorListener errorListener = new RecordingErrorListener(); |
| 10071 Parser parser = new Parser(source, errorListener); | 10061 Parser parser = new Parser(source, errorListener); |
| 10072 AnalysisOptions options = context.analysisOptions; | 10062 AnalysisOptions options = context.analysisOptions; |
| 10073 parser.parseFunctionBodies = options.analyzeFunctionBodies; | 10063 parser.parseFunctionBodies = options.analyzeFunctionBodies; |
| 10074 _unit = parser.parseCompilationUnit(_tokenStream); | 10064 _unit = parser.parseCompilationUnit(_tokenStream); |
| 10075 _unit.lineInfo = lineInfo; | 10065 _unit.lineInfo = lineInfo; |
| 10076 AnalysisContext analysisContext = context; | 10066 AnalysisContext analysisContext = context; |
| 10077 for (Directive directive in _unit.directives) { | 10067 for (Directive directive in _unit.directives) { |
| 10078 if (directive is PartOfDirective) { | 10068 if (directive is PartOfDirective) { |
| 10079 _containsPartOfDirective = true; | 10069 _containsPartOfDirective = true; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 10093 } | 10083 } |
| 10094 } else { | 10084 } else { |
| 10095 throw new AnalysisException( | 10085 throw new AnalysisException( |
| 10096 "$runtimeType failed to handle a ${directive.runtimeType}"); | 10086 "$runtimeType failed to handle a ${directive.runtimeType}"); |
| 10097 } | 10087 } |
| 10098 } | 10088 } |
| 10099 } | 10089 } |
| 10100 } | 10090 } |
| 10101 } | 10091 } |
| 10102 _errors = errorListener.getErrorsForSource(source); | 10092 _errors = errorListener.getErrorsForSource(source); |
| 10103 } finally { | 10093 }); |
| 10104 prevTag.makeCurrent(); | |
| 10105 } | |
| 10106 } | 10094 } |
| 10107 | 10095 |
| 10108 /** | 10096 /** |
| 10109 * Efficiently convert the given set of sources to an array. | 10097 * Efficiently convert the given set of sources to an array. |
| 10110 * | 10098 * |
| 10111 * @param sources the set to be converted | 10099 * @param sources the set to be converted |
| 10112 * @return an array containing all of the sources in the given set | 10100 * @return an array containing all of the sources in the given set |
| 10113 */ | 10101 */ |
| 10114 List<Source> _toArray(HashSet<Source> sources) { | 10102 List<Source> _toArray(HashSet<Source> sources) { |
| 10115 int size = sources.length; | 10103 int size = sources.length; |
| (...skipping 1178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11294 ResolverVisitor resolverVisitor = new ResolverVisitor.con2( | 11282 ResolverVisitor resolverVisitor = new ResolverVisitor.con2( |
| 11295 _libraryElement, | 11283 _libraryElement, |
| 11296 source, | 11284 source, |
| 11297 typeProvider, | 11285 typeProvider, |
| 11298 inheritanceManager, | 11286 inheritanceManager, |
| 11299 errorListener); | 11287 errorListener); |
| 11300 unit.accept(resolverVisitor); | 11288 unit.accept(resolverVisitor); |
| 11301 // | 11289 // |
| 11302 // Perform additional error checking. | 11290 // Perform additional error checking. |
| 11303 // | 11291 // |
| 11304 PerformanceTag prevTag = PerformanceStatistics.errors.makeCurrent(); | 11292 PerformanceStatistics.errors.makeCurrentWhile(() { |
| 11305 try { | |
| 11306 ErrorReporter errorReporter = new ErrorReporter(errorListener, source); | 11293 ErrorReporter errorReporter = new ErrorReporter(errorListener, source); |
| 11307 ErrorVerifier errorVerifier = new ErrorVerifier( | 11294 ErrorVerifier errorVerifier = new ErrorVerifier( |
| 11308 errorReporter, | 11295 errorReporter, |
| 11309 _libraryElement, | 11296 _libraryElement, |
| 11310 typeProvider, | 11297 typeProvider, |
| 11311 inheritanceManager); | 11298 inheritanceManager); |
| 11312 unit.accept(errorVerifier); | 11299 unit.accept(errorVerifier); |
| 11313 // TODO(paulberry): as a temporary workaround for issue 21572, | 11300 // TODO(paulberry): as a temporary workaround for issue 21572, |
| 11314 // ConstantVerifier is being run right after ConstantValueComputer, so we | 11301 // ConstantVerifier is being run right after ConstantValueComputer, so we |
| 11315 // don't need to run it here. Once issue 21572 is fixed, re-enable the | 11302 // don't need to run it here. Once issue 21572 is fixed, re-enable the |
| 11316 // call to ConstantVerifier. | 11303 // call to ConstantVerifier. |
| 11317 // ConstantVerifier constantVerifier = new ConstantVerifier(errorReporter,
_libraryElement, typeProvider); | 11304 // ConstantVerifier constantVerifier = new ConstantVerifier(errorReporter,
_libraryElement, typeProvider); |
| 11318 // unit.accept(constantVerifier); | 11305 // unit.accept(constantVerifier); |
| 11319 } finally { | 11306 }); |
| 11320 prevTag.makeCurrent(); | |
| 11321 } | |
| 11322 // | 11307 // |
| 11323 // Capture the results. | 11308 // Capture the results. |
| 11324 // | 11309 // |
| 11325 _resolvedUnit = unit; | 11310 _resolvedUnit = unit; |
| 11326 } | 11311 } |
| 11327 | 11312 |
| 11328 /** | 11313 /** |
| 11329 * Search the compilation units that are part of the given library and return
the element | 11314 * Search the compilation units that are part of the given library and return
the element |
| 11330 * representing the compilation unit with the given source. Return `null` if t
here is no | 11315 * representing the compilation unit with the given source. Return `null` if t
here is no |
| 11331 * such compilation unit. | 11316 * such compilation unit. |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11539 * | 11524 * |
| 11540 * @return the token stream that was produced by scanning the source | 11525 * @return the token stream that was produced by scanning the source |
| 11541 */ | 11526 */ |
| 11542 Token get tokenStream => _tokenStream; | 11527 Token get tokenStream => _tokenStream; |
| 11543 | 11528 |
| 11544 @override | 11529 @override |
| 11545 accept(AnalysisTaskVisitor visitor) => visitor.visitScanDartTask(this); | 11530 accept(AnalysisTaskVisitor visitor) => visitor.visitScanDartTask(this); |
| 11546 | 11531 |
| 11547 @override | 11532 @override |
| 11548 void internalPerform() { | 11533 void internalPerform() { |
| 11549 RecordingErrorListener errorListener = new RecordingErrorListener(); | 11534 PerformanceStatistics.scan.makeCurrentWhile(() { |
| 11550 PerformanceTag prevTag = PerformanceStatistics.scan.makeCurrent(); | 11535 RecordingErrorListener errorListener = new RecordingErrorListener(); |
| 11551 try { | 11536 try { |
| 11552 Scanner scanner = | 11537 Scanner scanner = |
| 11553 new Scanner(source, new CharSequenceReader(_content), errorListener); | 11538 new Scanner(source, new CharSequenceReader(_content), errorListener)
; |
| 11554 scanner.preserveComments = context.analysisOptions.preserveComments; | 11539 scanner.preserveComments = context.analysisOptions.preserveComments; |
| 11555 _tokenStream = scanner.tokenize(); | 11540 _tokenStream = scanner.tokenize(); |
| 11556 _lineInfo = new LineInfo(scanner.lineStarts); | 11541 _lineInfo = new LineInfo(scanner.lineStarts); |
| 11557 _errors = errorListener.getErrorsForSource(source); | 11542 _errors = errorListener.getErrorsForSource(source); |
| 11558 } catch (exception, stackTrace) { | 11543 } catch (exception, stackTrace) { |
| 11559 throw new AnalysisException( | 11544 throw new AnalysisException( |
| 11560 "Exception", | 11545 "Exception", |
| 11561 new CaughtException(exception, stackTrace)); | 11546 new CaughtException(exception, stackTrace)); |
| 11562 } finally { | 11547 } |
| 11563 prevTag.makeCurrent(); | 11548 }); |
| 11564 } | |
| 11565 } | 11549 } |
| 11566 } | 11550 } |
| 11567 | 11551 |
| 11568 /** | 11552 /** |
| 11569 * Instances of the class `SdkAnalysisContext` implement an [AnalysisContext] th
at only | 11553 * Instances of the class `SdkAnalysisContext` implement an [AnalysisContext] th
at only |
| 11570 * contains sources for a Dart SDK. | 11554 * contains sources for a Dart SDK. |
| 11571 */ | 11555 */ |
| 11572 class SdkAnalysisContext extends AnalysisContextImpl { | 11556 class SdkAnalysisContext extends AnalysisContextImpl { |
| 11573 @override | 11557 @override |
| 11574 AnalysisCache createCacheFromSourceFactory(SourceFactory factory) { | 11558 AnalysisCache createCacheFromSourceFactory(SourceFactory factory) { |
| (...skipping 863 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12438 if (element.id == _id) { | 12422 if (element.id == _id) { |
| 12439 result = element; | 12423 result = element; |
| 12440 throw new _ElementByIdFinderException(); | 12424 throw new _ElementByIdFinderException(); |
| 12441 } | 12425 } |
| 12442 super.visitElement(element); | 12426 super.visitElement(element); |
| 12443 } | 12427 } |
| 12444 } | 12428 } |
| 12445 | 12429 |
| 12446 class _ElementByIdFinderException { | 12430 class _ElementByIdFinderException { |
| 12447 } | 12431 } |
| OLD | NEW |