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

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

Issue 56933002: Version 0.8.10.1 (Closed) Base URL: http://dart.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 1 month 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 // This code was auto-generated, is not intended to be edited, and is subject to 1 // This code was auto-generated, is not intended to be edited, and is subject to
2 // significant change. Please see the README file for more information. 2 // significant change. Please see the README file for more information.
3 library engine; 3 library engine;
4 import 'java_core.dart'; 4 import 'java_core.dart';
5 import 'java_engine.dart'; 5 import 'java_engine.dart';
6 import 'utilities_collection.dart'; 6 import 'utilities_collection.dart';
7 import 'utilities_general.dart'; 7 import 'utilities_general.dart';
8 import 'instrumentation.dart'; 8 import 'instrumentation.dart';
9 import 'error.dart'; 9 import 'error.dart';
10 import 'source.dart'; 10 import 'source.dart';
(...skipping 4036 matching lines...) Expand 10 before | Expand all | Expand 10 after
4047 4047
4048 /** 4048 /**
4049 * Look through the cache for a task that needs to be performed. Return the ta sk that was found, 4049 * Look through the cache for a task that needs to be performed. Return the ta sk that was found,
4050 * or `null` if there is no more work to be done. 4050 * or `null` if there is no more work to be done.
4051 * 4051 *
4052 * @return the next task that needs to be performed 4052 * @return the next task that needs to be performed
4053 */ 4053 */
4054 AnalysisTask get nextTaskAnalysisTask { 4054 AnalysisTask get nextTaskAnalysisTask {
4055 { 4055 {
4056 bool hintsEnabled = _options.hint; 4056 bool hintsEnabled = _options.hint;
4057 if (_incrementalAnalysisCache != null) { 4057 if (_incrementalAnalysisCache != null && _incrementalAnalysisCache.hasWork ()) {
4058 AnalysisTask task = new IncrementalAnalysisTask(this, _incrementalAnalys isCache); 4058 AnalysisTask task = new IncrementalAnalysisTask(this, _incrementalAnalys isCache);
4059 _incrementalAnalysisCache = null; 4059 _incrementalAnalysisCache = null;
4060 } 4060 }
4061 for (Source source in _priorityOrder) { 4061 for (Source source in _priorityOrder) {
4062 AnalysisTask task = getNextTaskAnalysisTask2(source, _cache.get(source), true, hintsEnabled); 4062 AnalysisTask task = getNextTaskAnalysisTask2(source, _cache.get(source), true, hintsEnabled);
4063 if (task != null) { 4063 if (task != null) {
4064 return task; 4064 return task;
4065 } 4065 }
4066 } 4066 }
4067 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) { 4067 for (MapEntry<Source, SourceEntry> entry in _cache.entrySet()) {
(...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after
4589 * @param task the task that was performed 4589 * @param task the task that was performed
4590 * @return an entry containing the computed results 4590 * @return an entry containing the computed results
4591 * @throws AnalysisException if the results could not be recorded 4591 * @throws AnalysisException if the results could not be recorded
4592 */ 4592 */
4593 DartEntry recordIncrementalAnalysisTaskResults(IncrementalAnalysisTask task) { 4593 DartEntry recordIncrementalAnalysisTaskResults(IncrementalAnalysisTask task) {
4594 { 4594 {
4595 CompilationUnit unit = task.compilationUnit; 4595 CompilationUnit unit = task.compilationUnit;
4596 if (unit != null) { 4596 if (unit != null) {
4597 ChangeNoticeImpl notice = getNotice(task.source); 4597 ChangeNoticeImpl notice = getNotice(task.source);
4598 notice.compilationUnit = unit; 4598 notice.compilationUnit = unit;
4599 _incrementalAnalysisCache = IncrementalAnalysisCache.cacheResult(task.ca che, unit);
4599 } 4600 }
4600 } 4601 }
4601 return null; 4602 return null;
4602 } 4603 }
4603 4604
4604 /** 4605 /**
4605 * Record the results produced by performing a [ParseDartTask]. If the results were computed 4606 * Record the results produced by performing a [ParseDartTask]. If the results were computed
4606 * from data that is now out-of-date, then the results will not be recorded. 4607 * from data that is now out-of-date, then the results will not be recorded.
4607 * 4608 *
4608 * @param task the task that was performed 4609 * @param task the task that was performed
(...skipping 30 matching lines...) Expand all
4639 } else { 4640 } else {
4640 dartCopy.setValue(DartEntry.SOURCE_KIND, SourceKind.LIBRARY); 4641 dartCopy.setValue(DartEntry.SOURCE_KIND, SourceKind.LIBRARY);
4641 } 4642 }
4642 dartCopy.setValue(DartEntry.PARSED_UNIT, task.compilationUnit); 4643 dartCopy.setValue(DartEntry.PARSED_UNIT, task.compilationUnit);
4643 dartCopy.setValue(DartEntry.PARSE_ERRORS, task.errors); 4644 dartCopy.setValue(DartEntry.PARSE_ERRORS, task.errors);
4644 dartCopy.setValue(DartEntry.EXPORTED_LIBRARIES, task.exportedSources); 4645 dartCopy.setValue(DartEntry.EXPORTED_LIBRARIES, task.exportedSources);
4645 dartCopy.setValue(DartEntry.IMPORTED_LIBRARIES, task.importedSources); 4646 dartCopy.setValue(DartEntry.IMPORTED_LIBRARIES, task.importedSources);
4646 dartCopy.setValue(DartEntry.INCLUDED_PARTS, task.includedSources); 4647 dartCopy.setValue(DartEntry.INCLUDED_PARTS, task.includedSources);
4647 ChangeNoticeImpl notice = getNotice(source); 4648 ChangeNoticeImpl notice = getNotice(source);
4648 notice.setErrors(dartEntry.allErrors, lineInfo); 4649 notice.setErrors(dartEntry.allErrors, lineInfo);
4650 _incrementalAnalysisCache = IncrementalAnalysisCache.verifyStructure(_ incrementalAnalysisCache, source, task.compilationUnit);
4649 } else { 4651 } else {
4650 dartCopy.recordParseError(); 4652 dartCopy.recordParseError();
4651 } 4653 }
4652 dartCopy.exception = thrownException; 4654 dartCopy.exception = thrownException;
4653 _cache.put(source, dartCopy); 4655 _cache.put(source, dartCopy);
4654 dartEntry = dartCopy; 4656 dartEntry = dartCopy;
4655 } else { 4657 } else {
4656 DartEntryImpl dartCopy = dartEntry.writableCopy; 4658 DartEntryImpl dartCopy = dartEntry.writableCopy;
4657 if (thrownException == null || resultTime >= 0) { 4659 if (thrownException == null || resultTime >= 0) {
4658 dartCopy.recordParseNotInProcess(); 4660 dartCopy.recordParseNotInProcess();
(...skipping 922 matching lines...) Expand 10 before | Expand all | Expand 10 after
5581 } 5583 }
5582 /** 5584 /**
5583 * Instances of the class `IncrementalAnalysisCache` hold information used to pe rform 5585 * Instances of the class `IncrementalAnalysisCache` hold information used to pe rform
5584 * incremental analysis. 5586 * incremental analysis.
5585 * 5587 *
5586 * @see AnalysisContextImpl#setChangedContents(Source, String, int, int, int) 5588 * @see AnalysisContextImpl#setChangedContents(Source, String, int, int, int)
5587 */ 5589 */
5588 class IncrementalAnalysisCache { 5590 class IncrementalAnalysisCache {
5589 5591
5590 /** 5592 /**
5593 * Determine if the incremental analysis result can be cached for the next inc remental analysis.
5594 *
5595 * @param cache the prior incremental analysis cache
5596 * @param unit the incrementally updated compilation unit
5597 * @return the cache used for incremental analysis or `null` if incremental an alysis results
5598 * cannot be cached for the next incremental analysis
5599 */
5600 static IncrementalAnalysisCache cacheResult(IncrementalAnalysisCache cache, Co mpilationUnit unit) {
5601 if (cache != null && unit != null) {
5602 return new IncrementalAnalysisCache(cache.librarySource, cache.source, uni t, cache.newContents, cache.newContents, 0, 0, 0);
5603 }
5604 return null;
5605 }
5606
5607 /**
5591 * Determine if the cache should be cleared. 5608 * Determine if the cache should be cleared.
5592 * 5609 *
5593 * @param cache the prior cache or `null` if none 5610 * @param cache the prior cache or `null` if none
5594 * @param source the source being updated (not `null`) 5611 * @param source the source being updated (not `null`)
5595 * @return the cache used for incremental analysis or `null` if incremental an alysis cannot 5612 * @return the cache used for incremental analysis or `null` if incremental an alysis cannot
5596 * be performed 5613 * be performed
5597 */ 5614 */
5598 static IncrementalAnalysisCache clear(IncrementalAnalysisCache cache, Source s ource) { 5615 static IncrementalAnalysisCache clear(IncrementalAnalysisCache cache, Source s ource) {
5599 if (cache == null || cache.source == source) { 5616 if (cache == null || cache.source == source) {
5600 return null; 5617 return null;
5601 } 5618 }
5602 return cache; 5619 return cache;
5603 } 5620 }
5604 5621
5605 /** 5622 /**
5606 * Determine if incremental analysis can be performed from the given informati on. 5623 * Determine if incremental analysis can be performed from the given informati on.
5607 * 5624 *
5608 * @param cache the prior cache or `null` if none 5625 * @param cache the prior cache or `null` if none
5609 * @param source the source being updated (not `null`) 5626 * @param source the source being updated (not `null`)
5610 * @param oldContents the original source contents prior to this update (not ` null`) 5627 * @param oldContents the original source contents prior to this update (not ` null`)
5611 * @param newContents the new contents after this incremental change (not `nul l`) 5628 * @param newContents the new contents after this incremental change (not `nul l`)
5612 * @param offset the offset at which the change occurred 5629 * @param offset the offset at which the change occurred
5613 * @param oldLength the length of the text being replaced 5630 * @param oldLength the length of the text being replaced
5614 * @param newLength the length of the replacement text 5631 * @param newLength the length of the replacement text
5615 * @param sourceEntry the cached entry for the given source or `null` if none 5632 * @param sourceEntry the cached entry for the given source or `null` if none
5616 * @return the cache used for incremental analysis or `null` if incremental an alysis cannot 5633 * @return the cache used for incremental analysis or `null` if incremental an alysis cannot
5617 * be performed 5634 * be performed
5618 */ 5635 */
5619 static IncrementalAnalysisCache update(IncrementalAnalysisCache cache, Source source, String oldContents, String newContents, int offset, int oldLength, int n ewLength, SourceEntry sourceEntry) { 5636 static IncrementalAnalysisCache update(IncrementalAnalysisCache cache, Source source, String oldContents, String newContents, int offset, int oldLength, int n ewLength, SourceEntry sourceEntry) {
5620 if (cache == null || cache.source != source) { 5637 Source librarySource = null;
5621 if (sourceEntry is! DartEntryImpl) { 5638 CompilationUnit unit = null;
5622 return null; 5639 if (sourceEntry is DartEntryImpl) {
5623 }
5624 DartEntryImpl dartEntry = sourceEntry as DartEntryImpl; 5640 DartEntryImpl dartEntry = sourceEntry as DartEntryImpl;
5625 List<Source> librarySources = dartEntry.librariesContaining; 5641 List<Source> librarySources = dartEntry.librariesContaining;
5626 if (librarySources.length != 1) { 5642 if (librarySources.length == 1) {
5627 return null; 5643 librarySource = librarySources[0];
5644 if (librarySource != null) {
5645 unit = dartEntry.getValue2(DartEntry.RESOLVED_UNIT, librarySource);
5646 }
5628 } 5647 }
5629 Source librarySource = librarySources[0]; 5648 }
5630 if (librarySource == null) { 5649 if (cache == null || cache.source != source || unit != null) {
5631 return null;
5632 }
5633 CompilationUnit unit = dartEntry.getValue2(DartEntry.RESOLVED_UNIT, librar ySource);
5634 if (unit == null) { 5650 if (unit == null) {
5635 return null; 5651 return null;
5636 } 5652 }
5637 if (oldContents == null) { 5653 if (oldContents == null) {
5638 if (oldLength != 0) { 5654 if (oldLength != 0) {
5639 return null; 5655 return null;
5640 } 5656 }
5641 oldContents = "${newContents.substring(0, offset)}${newContents.substrin g(offset + newLength)}"; 5657 oldContents = "${newContents.substring(0, offset)}${newContents.substrin g(offset + newLength)}";
5642 } 5658 }
5643 return new IncrementalAnalysisCache(librarySource, source, unit, oldConten ts, newContents, offset, oldLength, newLength); 5659 return new IncrementalAnalysisCache(librarySource, source, unit, oldConten ts, newContents, offset, oldLength, newLength);
5644 } 5660 }
5645 if (cache.offset > offset || offset > cache.offset + cache.newLength) { 5661 if (cache.oldLength == 0 && cache.newLength == 0) {
5646 return null; 5662 cache.offset = offset;
5663 cache.oldLength = oldLength;
5664 cache.newLength = newLength;
5665 } else {
5666 if (cache.offset > offset || offset > cache.offset + cache.newLength) {
5667 return null;
5668 }
5669 cache.newLength += newLength - oldLength;
5647 } 5670 }
5648 cache.newContents = newContents; 5671 cache.newContents = newContents;
5649 cache.newLength += newLength - oldLength; 5672 return cache;
5673 }
5674
5675 /**
5676 * Verify that the incrementally parsed and resolved unit in the incremental c ache is structurally
5677 * equivalent to the fully parsed unit.
5678 *
5679 * @param cache the prior cache or `null` if none
5680 * @param source the source of the compilation unit that was parsed (not `null `)
5681 * @param unit the compilation unit that was just parsed
5682 * @return the cache used for incremental analysis or `null` if incremental an alysis results
5683 * cannot be cached for the next incremental analysis
5684 */
5685 static IncrementalAnalysisCache verifyStructure(IncrementalAnalysisCache cache , Source source, CompilationUnit unit) {
5686 if (cache != null && unit != null && cache.source == source) {
5687 if (!ASTComparator.equals3(cache.resolvedUnit, unit)) {
5688 return null;
5689 }
5690 }
5650 return cache; 5691 return cache;
5651 } 5692 }
5652 Source librarySource; 5693 Source librarySource;
5653 Source source; 5694 Source source;
5654 String oldContents; 5695 String oldContents;
5655 CompilationUnit resolvedUnit; 5696 CompilationUnit resolvedUnit;
5656 String newContents; 5697 String newContents;
5657 int offset = 0; 5698 int offset = 0;
5658 int oldLength = 0; 5699 int oldLength = 0;
5659 int newLength = 0; 5700 int newLength = 0;
5660 IncrementalAnalysisCache(Source librarySource, Source source, CompilationUnit resolvedUnit, String oldContents, String newContents, int offset, int oldLength, int newLength) { 5701 IncrementalAnalysisCache(Source librarySource, Source source, CompilationUnit resolvedUnit, String oldContents, String newContents, int offset, int oldLength, int newLength) {
5661 this.librarySource = librarySource; 5702 this.librarySource = librarySource;
5662 this.source = source; 5703 this.source = source;
5663 this.resolvedUnit = resolvedUnit; 5704 this.resolvedUnit = resolvedUnit;
5664 this.oldContents = oldContents; 5705 this.oldContents = oldContents;
5665 this.newContents = newContents; 5706 this.newContents = newContents;
5666 this.offset = offset; 5707 this.offset = offset;
5667 this.oldLength = oldLength; 5708 this.oldLength = oldLength;
5668 this.newLength = newLength; 5709 this.newLength = newLength;
5669 } 5710 }
5711
5712 /**
5713 * Determine if the cache contains source changes that need to be analyzed
5714 *
5715 * @return `true` if the cache contains changes to be analyzed, else `false`
5716 */
5717 bool hasWork() => oldLength > 0 && newLength > 0;
5670 } 5718 }
5671 /** 5719 /**
5672 * Instances of the class `InstrumentedAnalysisContextImpl` implement an 5720 * Instances of the class `InstrumentedAnalysisContextImpl` implement an
5673 * [AnalysisContext] by recording instrumentation data and delegating to 5721 * [AnalysisContext] by recording instrumentation data and delegating to
5674 * another analysis context to do the non-instrumentation work. 5722 * another analysis context to do the non-instrumentation work.
5675 * 5723 *
5676 * @coverage dart.engine 5724 * @coverage dart.engine
5677 */ 5725 */
5678 class InstrumentedAnalysisContextImpl implements InternalAnalysisContext { 5726 class InstrumentedAnalysisContextImpl implements InternalAnalysisContext {
5679 5727
(...skipping 1154 matching lines...) Expand 10 before | Expand all | Expand 10 after
6834 TimestampedData<CompilationUnit> getCompilationUnit(Source unitSource) => cont ext.internalResolveCompilationUnit(unitSource, libraryElement); 6882 TimestampedData<CompilationUnit> getCompilationUnit(Source unitSource) => cont ext.internalResolveCompilationUnit(unitSource, libraryElement);
6835 } 6883 }
6836 /** 6884 /**
6837 * Instances of the class `IncrementalAnalysisTask` incrementally update existin g analysis. 6885 * Instances of the class `IncrementalAnalysisTask` incrementally update existin g analysis.
6838 */ 6886 */
6839 class IncrementalAnalysisTask extends AnalysisTask { 6887 class IncrementalAnalysisTask extends AnalysisTask {
6840 6888
6841 /** 6889 /**
6842 * The information used to perform incremental analysis. 6890 * The information used to perform incremental analysis.
6843 */ 6891 */
6844 IncrementalAnalysisCache _cache; 6892 IncrementalAnalysisCache cache;
6845 6893
6846 /** 6894 /**
6847 * The compilation unit that was produced by incrementally updating the existi ng unit. 6895 * The compilation unit that was produced by incrementally updating the existi ng unit.
6848 */ 6896 */
6849 CompilationUnit compilationUnit; 6897 CompilationUnit compilationUnit;
6850 6898
6851 /** 6899 /**
6852 * Initialize a newly created task to perform analysis within the given contex t. 6900 * Initialize a newly created task to perform analysis within the given contex t.
6853 * 6901 *
6854 * @param context the context in which the task is to be performed 6902 * @param context the context in which the task is to be performed
6855 * @param cache the incremental analysis cache used to perform the analysis 6903 * @param cache the incremental analysis cache used to perform the analysis
6856 */ 6904 */
6857 IncrementalAnalysisTask(InternalAnalysisContext context, IncrementalAnalysisCa che cache) : super(context) { 6905 IncrementalAnalysisTask(InternalAnalysisContext context, IncrementalAnalysisCa che cache) : super(context) {
6858 this._cache = cache; 6906 this.cache = cache;
6859 } 6907 }
6860 accept(AnalysisTaskVisitor visitor) => visitor.visitIncrementalAnalysisTask(th is); 6908 accept(AnalysisTaskVisitor visitor) => visitor.visitIncrementalAnalysisTask(th is);
6861 6909
6862 /** 6910 /**
6863 * Return the source that is to be incrementally analyzed. 6911 * Return the source that is to be incrementally analyzed.
6864 * 6912 *
6865 * @return the source 6913 * @return the source
6866 */ 6914 */
6867 Source get source => _cache != null ? _cache.source : null; 6915 Source get source => cache != null ? cache.source : null;
6868 String get taskDescription => "incremental analysis ${(_cache != null ? _cache .source : "null")}"; 6916 String get taskDescription => "incremental analysis ${(cache != null ? cache.s ource : "null")}";
6869 void internalPerform() { 6917 void internalPerform() {
6870 if (_cache == null) { 6918 if (cache == null) {
6871 return; 6919 return;
6872 } 6920 }
6873 compilationUnit = _cache.resolvedUnit; 6921 compilationUnit = cache.resolvedUnit;
6874 } 6922 }
6875 } 6923 }
6876 /** 6924 /**
6877 * Instances of the class `ParseDartTask` parse a specific source as a Dart file . 6925 * Instances of the class `ParseDartTask` parse a specific source as a Dart file .
6878 */ 6926 */
6879 class ParseDartTask extends AnalysisTask { 6927 class ParseDartTask extends AnalysisTask {
6880 6928
6881 /** 6929 /**
6882 * The source to be parsed. 6930 * The source to be parsed.
6883 */ 6931 */
(...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after
7480 } 7528 }
7481 void logError2(String message, Exception exception) { 7529 void logError2(String message, Exception exception) {
7482 } 7530 }
7483 void logError3(Exception exception) { 7531 void logError3(Exception exception) {
7484 } 7532 }
7485 void logInformation(String message) { 7533 void logInformation(String message) {
7486 } 7534 }
7487 void logInformation2(String message, Exception exception) { 7535 void logInformation2(String message, Exception exception) {
7488 } 7536 }
7489 } 7537 }
OLDNEW
« no previous file with comments | « dart/pkg/analyzer/lib/src/generated/element.dart ('k') | dart/pkg/analyzer/lib/src/generated/error.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698