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

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

Issue 1403033002: State-carrying context API. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Fixes and tests. Created 5 years, 2 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
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/engine.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library analyzer.src.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 629 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 } 763 }
758 764
759 @override 765 @override
760 CompilationUnitElement getCompilationUnitElement( 766 CompilationUnitElement getCompilationUnitElement(
761 Source unitSource, Source librarySource) { 767 Source unitSource, Source librarySource) {
762 AnalysisTarget target = new LibrarySpecificUnit(librarySource, unitSource); 768 AnalysisTarget target = new LibrarySpecificUnit(librarySource, unitSource);
763 return getResult(target, COMPILATION_UNIT_ELEMENT); 769 return getResult(target, COMPILATION_UNIT_ELEMENT);
764 } 770 }
765 771
766 @override 772 @override
773 Object getConfigurationData(ResultDescriptor key) => _configurationData[key];
774
775 @override
767 TimestampedData<String> getContents(Source source) { 776 TimestampedData<String> getContents(Source source) {
768 String contents = _contentCache.getContents(source); 777 String contents = _contentCache.getContents(source);
769 if (contents != null) { 778 if (contents != null) {
770 return new TimestampedData<String>( 779 return new TimestampedData<String>(
771 _contentCache.getModificationStamp(source), contents); 780 _contentCache.getModificationStamp(source), contents);
772 } 781 }
773 return source.contents; 782 return source.contents;
774 } 783 }
775 784
776 @override 785 @override
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
1194 @override 1203 @override
1195 void setChangedContents(Source source, String contents, int offset, 1204 void setChangedContents(Source source, String contents, int offset,
1196 int oldLength, int newLength) { 1205 int oldLength, int newLength) {
1197 if (_contentRangeChanged(source, contents, offset, oldLength, newLength)) { 1206 if (_contentRangeChanged(source, contents, offset, oldLength, newLength)) {
1198 _onSourcesChangedController.add(new SourcesChangedEvent.changedRange( 1207 _onSourcesChangedController.add(new SourcesChangedEvent.changedRange(
1199 source, contents, offset, oldLength, newLength)); 1208 source, contents, offset, oldLength, newLength));
1200 } 1209 }
1201 } 1210 }
1202 1211
1203 @override 1212 @override
1213 void setConfigurationData(ResultDescriptor key, Object data) {
1214 _configurationData[key] = data;
1215 }
1216
1217 @override
1204 void setContents(Source source, String contents) { 1218 void setContents(Source source, String contents) {
1205 _contentsChanged(source, contents, true); 1219 _contentsChanged(source, contents, true);
1206 } 1220 }
1207 1221
1208 @override 1222 @override
1209 bool shouldErrorsBeAnalyzed(Source source, Object entry) { 1223 bool shouldErrorsBeAnalyzed(Source source, Object entry) {
1210 CacheEntry entry = analysisCache.get(source); 1224 CacheEntry entry = analysisCache.get(source);
1211 if (source.isInSystemLibrary) { 1225 if (source.isInSystemLibrary) {
1212 return _options.generateSdkErrors; 1226 return _options.generateSdkErrors;
1213 } else if (!entry.explicitlyAdded) { 1227 } else if (!entry.explicitlyAdded) {
(...skipping 875 matching lines...) Expand 10 before | Expand all | Expand 10 after
2089 new PendingFuture<T>(_context, target, computeValue); 2103 new PendingFuture<T>(_context, target, computeValue);
2090 if (!pendingFuture.evaluate(entry)) { 2104 if (!pendingFuture.evaluate(entry)) {
2091 _context._pendingFutureTargets 2105 _context._pendingFutureTargets
2092 .putIfAbsent(target, () => <PendingFuture>[]) 2106 .putIfAbsent(target, () => <PendingFuture>[])
2093 .add(pendingFuture); 2107 .add(pendingFuture);
2094 scheduleComputation(); 2108 scheduleComputation();
2095 } 2109 }
2096 return pendingFuture.future; 2110 return pendingFuture.future;
2097 } 2111 }
2098 } 2112 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/engine.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698