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

Side by Side Diff: packages/analyzer/lib/src/context/context.dart

Issue 1521693002: Roll Observatory deps (charted -> ^0.3.0) (Closed) Base URL: https://chromium.googlesource.com/external/github.com/dart-lang/observatory_pub_packages.git@master
Patch Set: Created 5 years 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
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.context.context; 5 library analyzer.src.context.context;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 9
10 import 'package:analyzer/instrumentation/instrumentation.dart'; 10 import 'package:analyzer/instrumentation/instrumentation.dart';
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 */ 108 */
109 CachePartition _privatePartition; 109 CachePartition _privatePartition;
110 110
111 /** 111 /**
112 * The cache in which information about the results associated with targets 112 * The cache in which information about the results associated with targets
113 * are stored. 113 * are stored.
114 */ 114 */
115 AnalysisCache _cache; 115 AnalysisCache _cache;
116 116
117 /** 117 /**
118 * Configuration data associated with this context.
119 */
120 final HashMap<ResultDescriptor, Object> _configurationData =
121 new HashMap<ResultDescriptor, Object>();
122
123 /**
118 * The task manager used to manage the tasks used to analyze code. 124 * The task manager used to manage the tasks used to analyze code.
119 */ 125 */
120 TaskManager _taskManager; 126 TaskManager _taskManager;
121 127
122 /** 128 /**
123 * A list of all [WorkManager]s used by this context. 129 * A list of all [WorkManager]s used by this context.
124 */ 130 */
125 final List<WorkManager> workManagers = <WorkManager>[]; 131 final List<WorkManager> workManagers = <WorkManager>[];
126 132
127 /** 133 /**
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
402 _sourceFactory.context = null; 408 _sourceFactory.context = null;
403 } 409 }
404 factory.context = this; 410 factory.context = this;
405 _sourceFactory = factory; 411 _sourceFactory = factory;
406 _cache = createCacheFromSourceFactory(factory); 412 _cache = createCacheFromSourceFactory(factory);
407 for (WorkManager workManager in workManagers) { 413 for (WorkManager workManager in workManagers) {
408 workManager.onSourceFactoryChanged(); 414 workManager.onSourceFactoryChanged();
409 } 415 }
410 } 416 }
411 417
418 /**
419 * Invalidate analysis cache.
420 */
421 void invalidateCachedResults() {
422 _cache = createCacheFromSourceFactory(_sourceFactory);
423 }
424
412 @override 425 @override
413 List<Source> get sources { 426 List<Source> get sources {
414 return _cache.sources.toList(); 427 return _cache.sources.toList();
415 } 428 }
416 429
417 /** 430 /**
418 * Return a list of the sources that would be processed by 431 * Return a list of the sources that would be processed by
419 * [performAnalysisTask]. This method duplicates, and must therefore be kept 432 * [performAnalysisTask]. This method duplicates, and must therefore be kept
420 * in sync with, [getNextAnalysisTask]. This method is intended to be used for 433 * in sync with, [getNextAnalysisTask]. This method is intended to be used for
421 * testing purposes only. 434 * testing purposes only.
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 return null; 589 return null;
577 } 590 }
578 String code = getContents(source).data; 591 String code = getContents(source).data;
579 String comment = code.substring(docRange.offset, docRange.end); 592 String comment = code.substring(docRange.offset, docRange.end);
580 return comment.replaceAll('\r\n', '\n'); 593 return comment.replaceAll('\r\n', '\n');
581 } 594 }
582 595
583 @override 596 @override
584 List<AnalysisError> computeErrors(Source source) { 597 List<AnalysisError> computeErrors(Source source) {
585 String name = source.shortName; 598 String name = source.shortName;
586 if (AnalysisEngine.isDartFileName(name)) { 599 if (AnalysisEngine.isHtmlFileName(name)) {
587 return computeResult(source, DART_ERRORS);
588 } else if (AnalysisEngine.isHtmlFileName(name)) {
589 return computeResult(source, HTML_ERRORS); 600 return computeResult(source, HTML_ERRORS);
590 } 601 }
591 return AnalysisError.NO_ERRORS; 602 return computeResult(source, DART_ERRORS);
592 } 603 }
593 604
594 @override 605 @override
595 List<Source> computeExportedLibraries(Source source) => 606 List<Source> computeExportedLibraries(Source source) =>
596 computeResult(source, EXPORTED_LIBRARIES); 607 computeResult(source, EXPORTED_LIBRARIES);
597 608
598 @override 609 @override
599 @deprecated 610 @deprecated
600 HtmlElement computeHtmlElement(Source source) { 611 HtmlElement computeHtmlElement(Source source) {
601 // TODO(brianwilkerson) Remove this method after switching to the new task 612 // TODO(brianwilkerson) Remove this method after switching to the new task
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
759 } 770 }
760 771
761 @override 772 @override
762 CompilationUnitElement getCompilationUnitElement( 773 CompilationUnitElement getCompilationUnitElement(
763 Source unitSource, Source librarySource) { 774 Source unitSource, Source librarySource) {
764 AnalysisTarget target = new LibrarySpecificUnit(librarySource, unitSource); 775 AnalysisTarget target = new LibrarySpecificUnit(librarySource, unitSource);
765 return getResult(target, COMPILATION_UNIT_ELEMENT); 776 return getResult(target, COMPILATION_UNIT_ELEMENT);
766 } 777 }
767 778
768 @override 779 @override
780 Object getConfigurationData(ResultDescriptor key) => _configurationData[key];
781
782 @override
769 TimestampedData<String> getContents(Source source) { 783 TimestampedData<String> getContents(Source source) {
770 String contents = _contentCache.getContents(source); 784 String contents = _contentCache.getContents(source);
771 if (contents != null) { 785 if (contents != null) {
772 return new TimestampedData<String>( 786 return new TimestampedData<String>(
773 _contentCache.getModificationStamp(source), contents); 787 _contentCache.getModificationStamp(source), contents);
774 } 788 }
775 return source.contents; 789 return source.contents;
776 } 790 }
777 791
778 @override 792 @override
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
1145 entry.setState(RESOLVED_UNIT, CacheState.FLUSHED); 1159 entry.setState(RESOLVED_UNIT, CacheState.FLUSHED);
1146 entry.setState(RESOLVED_UNIT1, CacheState.FLUSHED); 1160 entry.setState(RESOLVED_UNIT1, CacheState.FLUSHED);
1147 entry.setState(RESOLVED_UNIT2, CacheState.FLUSHED); 1161 entry.setState(RESOLVED_UNIT2, CacheState.FLUSHED);
1148 entry.setState(RESOLVED_UNIT3, CacheState.FLUSHED); 1162 entry.setState(RESOLVED_UNIT3, CacheState.FLUSHED);
1149 entry.setState(RESOLVED_UNIT4, CacheState.FLUSHED); 1163 entry.setState(RESOLVED_UNIT4, CacheState.FLUSHED);
1150 entry.setState(RESOLVED_UNIT5, CacheState.FLUSHED); 1164 entry.setState(RESOLVED_UNIT5, CacheState.FLUSHED);
1151 entry.setState(RESOLVED_UNIT6, CacheState.FLUSHED); 1165 entry.setState(RESOLVED_UNIT6, CacheState.FLUSHED);
1152 entry.setState(RESOLVED_UNIT7, CacheState.FLUSHED); 1166 entry.setState(RESOLVED_UNIT7, CacheState.FLUSHED);
1153 entry.setState(RESOLVED_UNIT8, CacheState.FLUSHED); 1167 entry.setState(RESOLVED_UNIT8, CacheState.FLUSHED);
1154 entry.setState(RESOLVED_UNIT9, CacheState.FLUSHED); 1168 entry.setState(RESOLVED_UNIT9, CacheState.FLUSHED);
1169 entry.setState(RESOLVED_UNIT10, CacheState.FLUSHED);
1155 // USED_IMPORTED_ELEMENTS 1170 // USED_IMPORTED_ELEMENTS
1156 // USED_LOCAL_ELEMENTS 1171 // USED_LOCAL_ELEMENTS
1172 setValue(STRONG_MODE_ERRORS, AnalysisError.NO_ERRORS);
1157 setValue(VARIABLE_REFERENCE_ERRORS, AnalysisError.NO_ERRORS); 1173 setValue(VARIABLE_REFERENCE_ERRORS, AnalysisError.NO_ERRORS);
1158 setValue(VERIFY_ERRORS, AnalysisError.NO_ERRORS); 1174 setValue(VERIFY_ERRORS, AnalysisError.NO_ERRORS);
1159 }); 1175 });
1160 1176
1161 CacheEntry entry = getCacheEntry(AnalysisContextTarget.request); 1177 CacheEntry entry = getCacheEntry(AnalysisContextTarget.request);
1162 entry.setValue(TYPE_PROVIDER, typeProvider, TargetedResult.EMPTY_LIST); 1178 entry.setValue(TYPE_PROVIDER, typeProvider, TargetedResult.EMPTY_LIST);
1163 } 1179 }
1164 1180
1165 @override 1181 @override
1166 void removeListener(AnalysisListener listener) { 1182 void removeListener(AnalysisListener listener) {
(...skipping 27 matching lines...) Expand all
1194 @override 1210 @override
1195 void setChangedContents(Source source, String contents, int offset, 1211 void setChangedContents(Source source, String contents, int offset,
1196 int oldLength, int newLength) { 1212 int oldLength, int newLength) {
1197 if (_contentRangeChanged(source, contents, offset, oldLength, newLength)) { 1213 if (_contentRangeChanged(source, contents, offset, oldLength, newLength)) {
1198 _onSourcesChangedController.add(new SourcesChangedEvent.changedRange( 1214 _onSourcesChangedController.add(new SourcesChangedEvent.changedRange(
1199 source, contents, offset, oldLength, newLength)); 1215 source, contents, offset, oldLength, newLength));
1200 } 1216 }
1201 } 1217 }
1202 1218
1203 @override 1219 @override
1220 void setConfigurationData(ResultDescriptor key, Object data) {
1221 _configurationData[key] = data;
1222 }
1223
1224 @override
1204 void setContents(Source source, String contents) { 1225 void setContents(Source source, String contents) {
1205 _contentsChanged(source, contents, true); 1226 _contentsChanged(source, contents, true);
1206 } 1227 }
1207 1228
1208 @override 1229 @override
1209 bool shouldErrorsBeAnalyzed(Source source, Object entry) { 1230 bool shouldErrorsBeAnalyzed(Source source, Object entry) {
1210 CacheEntry entry = analysisCache.get(source); 1231 CacheEntry entry = analysisCache.get(source);
1211 if (source.isInSystemLibrary) { 1232 if (source.isInSystemLibrary) {
1212 return _options.generateSdkErrors; 1233 return _options.generateSdkErrors;
1213 } else if (!entry.explicitlyAdded) { 1234 } else if (!entry.explicitlyAdded) {
1214 return _options.generateImplicitErrors; 1235 return _options.generateImplicitErrors;
1215 } else { 1236 } else {
1216 return true; 1237 return true;
1217 } 1238 }
1218 } 1239 }
1219 1240
1220 @override 1241 @override
1221 void test_flushAstStructures(Source source) { 1242 void test_flushAstStructures(Source source) {
1222 CacheEntry entry = getCacheEntry(source); 1243 CacheEntry entry = getCacheEntry(source);
1223 entry.setState(PARSED_UNIT, CacheState.FLUSHED); 1244 entry.setState(PARSED_UNIT, CacheState.FLUSHED);
1224 entry.setState(RESOLVED_UNIT1, CacheState.FLUSHED); 1245 entry.setState(RESOLVED_UNIT1, CacheState.FLUSHED);
1225 entry.setState(RESOLVED_UNIT2, CacheState.FLUSHED); 1246 entry.setState(RESOLVED_UNIT2, CacheState.FLUSHED);
1226 entry.setState(RESOLVED_UNIT3, CacheState.FLUSHED); 1247 entry.setState(RESOLVED_UNIT3, CacheState.FLUSHED);
1227 entry.setState(RESOLVED_UNIT4, CacheState.FLUSHED); 1248 entry.setState(RESOLVED_UNIT4, CacheState.FLUSHED);
1228 entry.setState(RESOLVED_UNIT5, CacheState.FLUSHED); 1249 entry.setState(RESOLVED_UNIT5, CacheState.FLUSHED);
1229 entry.setState(RESOLVED_UNIT6, CacheState.FLUSHED); 1250 entry.setState(RESOLVED_UNIT6, CacheState.FLUSHED);
1230 entry.setState(RESOLVED_UNIT7, CacheState.FLUSHED); 1251 entry.setState(RESOLVED_UNIT7, CacheState.FLUSHED);
1231 entry.setState(RESOLVED_UNIT8, CacheState.FLUSHED); 1252 entry.setState(RESOLVED_UNIT8, CacheState.FLUSHED);
1232 entry.setState(RESOLVED_UNIT9, CacheState.FLUSHED); 1253 entry.setState(RESOLVED_UNIT9, CacheState.FLUSHED);
1254 entry.setState(RESOLVED_UNIT10, CacheState.FLUSHED);
1233 entry.setState(RESOLVED_UNIT, CacheState.FLUSHED); 1255 entry.setState(RESOLVED_UNIT, CacheState.FLUSHED);
1234 } 1256 }
1235 1257
1236 @override 1258 @override
1237 bool validateCacheConsistency() { 1259 bool validateCacheConsistency() {
1238 int consistencyCheckStart = JavaSystem.nanoTime(); 1260 int consistencyCheckStart = JavaSystem.nanoTime();
1239 HashSet<Source> changedSources = new HashSet<Source>(); 1261 HashSet<Source> changedSources = new HashSet<Source>();
1240 HashSet<Source> missingSources = new HashSet<Source>(); 1262 HashSet<Source> missingSources = new HashSet<Source>();
1241 for (Source source in _cache.sources) { 1263 for (Source source in _cache.sources) {
1242 CacheEntry entry = _cache.get(source); 1264 CacheEntry entry = _cache.get(source);
(...skipping 845 matching lines...) Expand 10 before | Expand all | Expand 10 after
2088 new PendingFuture<T>(_context, target, computeValue); 2110 new PendingFuture<T>(_context, target, computeValue);
2089 if (!pendingFuture.evaluate(entry)) { 2111 if (!pendingFuture.evaluate(entry)) {
2090 _context._pendingFutureTargets 2112 _context._pendingFutureTargets
2091 .putIfAbsent(target, () => <PendingFuture>[]) 2113 .putIfAbsent(target, () => <PendingFuture>[])
2092 .add(pendingFuture); 2114 .add(pendingFuture);
2093 scheduleComputation(); 2115 scheduleComputation();
2094 } 2116 }
2095 return pendingFuture.future; 2117 return pendingFuture.future;
2096 } 2118 }
2097 } 2119 }
OLDNEW
« no previous file with comments | « packages/analyzer/lib/source/analysis_options_provider.dart ('k') | packages/analyzer/lib/src/generated/ast.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698