Chromium Code Reviews| Index: pkg/analyzer/lib/src/dart/analysis/driver.dart |
| diff --git a/pkg/analyzer/lib/src/dart/analysis/driver.dart b/pkg/analyzer/lib/src/dart/analysis/driver.dart |
| index ab34b86e42aa6b0181a4706a3fe2a1ad3f677a3a..5982439b2532e93fe7bd33e681f66af328332ff8 100644 |
| --- a/pkg/analyzer/lib/src/dart/analysis/driver.dart |
| +++ b/pkg/analyzer/lib/src/dart/analysis/driver.dart |
| @@ -20,7 +20,7 @@ import 'package:analyzer/src/dart/analysis/search.dart'; |
| import 'package:analyzer/src/dart/analysis/status.dart'; |
| import 'package:analyzer/src/dart/analysis/top_level_declaration.dart'; |
| import 'package:analyzer/src/generated/engine.dart' |
| - show AnalysisContext, AnalysisEngine, AnalysisOptions, ChangeSet; |
| + show AnalysisContext, AnalysisEngine, AnalysisOptions; |
| import 'package:analyzer/src/generated/source.dart'; |
| import 'package:analyzer/src/services/lint.dart'; |
| import 'package:analyzer/src/summary/api_signature.dart'; |
| @@ -683,17 +683,6 @@ class AnalysisDriver { |
| _LibraryContext libraryContext = _createLibraryContext(libraryFile); |
| AnalysisContext analysisContext = _createAnalysisContext(libraryContext); |
| try { |
| - analysisContext.setContents(file.source, file.content); |
| - |
| - // TODO(scheglov) Remove this. |
| - // https://github.com/dart-lang/sdk/issues/28110 |
| - analysisContext.setContents(libraryFile.source, libraryFile.content); |
| - for (FileState part in libraryFile.partedFiles) { |
| - if (part.exists) { |
| - analysisContext.setContents(part.source, part.content); |
| - } |
| - } |
| - |
| CompilationUnit resolvedUnit = analysisContext.resolveCompilationUnit2( |
| file.source, libraryFile.source); |
| List<AnalysisError> errors = analysisContext.computeErrors(file.source); |
| @@ -761,12 +750,10 @@ class AnalysisDriver { |
| AnalysisContextImpl analysisContext = |
| AnalysisEngine.instance.createAnalysisContext(); |
| analysisContext.analysisOptions = _analysisOptions; |
| - |
| analysisContext.sourceFactory = _sourceFactory.clone(); |
| + analysisContext.contentCache = new _ContentCacheWrapper(_fsState); |
| analysisContext.resultProvider = |
| new InputPackagesResultProvider(analysisContext, libraryContext.store); |
| - analysisContext |
| - .applyChanges(new ChangeSet()..addedSource(libraryContext.file.source)); |
| return analysisContext; |
| } |
| @@ -1531,6 +1518,45 @@ class PerformanceLogSection { |
| } |
| /** |
| + * [ContentCache] wrapper around [FileContentOverlay]. |
| + */ |
| +class _ContentCacheWrapper implements ContentCache { |
| + final FileSystemState fsState; |
| + |
| + _ContentCacheWrapper(this.fsState); |
| + |
| + @override |
| + void accept(ContentCacheVisitor visitor) { |
| + throw new UnimplementedError(); |
| + } |
| + |
| + @override |
| + String getContents(Source source) { |
| + return _getFileForSource(source).content; |
| + } |
| + |
| + @override |
| + bool getExists(Source source) { |
| + return _getFileForSource(source).exists; |
| + } |
| + |
| + @override |
| + int getModificationStamp(Source source) { |
| + return getExists(source) ? 0 : -1; |
|
Paul Berry
2017/01/04 20:50:50
Since the contract for `getExists` says it might r
|
| + } |
| + |
| + @override |
| + String setContents(Source source, String contents) { |
| + throw new UnimplementedError(); |
| + } |
| + |
| + FileState _getFileForSource(Source source) { |
| + String path = source.fullName; |
| + return fsState.getFileForPath(path); |
| + } |
| +} |
| + |
| +/** |
| * Task that computes the list of files that were added to the driver and |
| * have at least one reference to an identifier [name] defined outside of the |
| * file. |