OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 import 'dart:async'; | 5 import 'dart:async'; |
6 | 6 |
7 import 'package:analyzer/dart/ast/ast.dart'; | 7 import 'package:analyzer/dart/ast/ast.dart'; |
8 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; | 8 import 'package:analyzer/dart/ast/standard_resolution_map.dart'; |
9 import 'package:analyzer/dart/element/element.dart'; | 9 import 'package:analyzer/dart/element/element.dart'; |
10 import 'package:analyzer/error/error.dart'; | 10 import 'package:analyzer/error/error.dart'; |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
50 class IncrementalKernelGeneratorImpl implements IncrementalKernelGenerator { | 50 class IncrementalKernelGeneratorImpl implements IncrementalKernelGenerator { |
51 final IncrementalResolvedAstGenerator _resolvedAstGenerator; | 51 final IncrementalResolvedAstGenerator _resolvedAstGenerator; |
52 final ProcessedOptions _options; | 52 final ProcessedOptions _options; |
53 | 53 |
54 IncrementalKernelGeneratorImpl(Uri source, ProcessedOptions options) | 54 IncrementalKernelGeneratorImpl(Uri source, ProcessedOptions options) |
55 : _resolvedAstGenerator = | 55 : _resolvedAstGenerator = |
56 new IncrementalResolvedAstGeneratorImpl(source, options), | 56 new IncrementalResolvedAstGeneratorImpl(source, options), |
57 _options = options; | 57 _options = options; |
58 | 58 |
59 @override | 59 @override |
60 Future<DeltaProgram> computeDelta() async { | 60 Future<DeltaProgram> computeDelta( |
| 61 {Future<Null> watch(Uri uri, bool used)}) async { |
61 var deltaLibraries = await _resolvedAstGenerator.computeDelta(); | 62 var deltaLibraries = await _resolvedAstGenerator.computeDelta(); |
62 var kernelOptions = _convertOptions(_options); | 63 var kernelOptions = _convertOptions(_options); |
63 var packages = null; // TODO(paulberry) | 64 var packages = null; // TODO(paulberry) |
64 var kernels = <Uri, Program>{}; | 65 var kernels = <Uri, Program>{}; |
65 deltaLibraries.newState.forEach((uri, resolvedLibrary) { | 66 for (Uri uri in deltaLibraries.newState.keys) { |
66 // The kernel generation code doesn't currently support building a kernel | 67 // The kernel generation code doesn't currently support building a kernel |
67 // directly from resolved ASTs--it wants to query an analysis context. So | 68 // directly from resolved ASTs--it wants to query an analysis context. So |
68 // we provide it with a proxy analysis context that feeds it the resolved | 69 // we provide it with a proxy analysis context that feeds it the resolved |
69 // ASTs. | 70 // ASTs. |
70 var strongMode = true; // TODO(paulberry): set this correctly | 71 var strongMode = true; // TODO(paulberry): set this correctly |
71 var analysisOptions = new _AnalysisOptionsProxy(strongMode); | 72 var analysisOptions = new _AnalysisOptionsProxy(strongMode); |
72 var context = | 73 var context = |
73 new _AnalysisContextProxy(deltaLibraries.newState, analysisOptions); | 74 new _AnalysisContextProxy(deltaLibraries.newState, analysisOptions); |
74 var repository = new Repository(); | 75 var repository = new Repository(); |
75 var loader = | 76 var loader = |
76 new DartLoader(repository, kernelOptions, packages, context: context); | 77 new DartLoader(repository, kernelOptions, packages, context: context); |
77 loader.loadLibrary(uri); | 78 loader.loadLibrary(uri); |
78 kernels[uri] = new Program(repository.libraries); | 79 kernels[uri] = new Program(repository.libraries); |
79 }); | 80 // TODO(paulberry) rework watch invocation to eliminate race condition, |
| 81 // include part source files, and prevent watch from being a bottleneck |
| 82 if (watch != null) await watch(uri, true); |
| 83 } |
| 84 // TODO(paulberry) invoke watch with used=false for each unused source |
80 return new DeltaProgram(kernels); | 85 return new DeltaProgram(kernels); |
81 } | 86 } |
82 | 87 |
83 @override | 88 @override |
84 void invalidate(String path) => _resolvedAstGenerator.invalidate(path); | 89 void invalidate(String path) => _resolvedAstGenerator.invalidate(path); |
85 | 90 |
86 @override | 91 @override |
87 void invalidateAll() => _resolvedAstGenerator.invalidateAll(); | 92 void invalidateAll() => _resolvedAstGenerator.invalidateAll(); |
88 } | 93 } |
89 | 94 |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
138 Source forUri2(Uri absoluteUri) => new _SourceProxy(absoluteUri); | 143 Source forUri2(Uri absoluteUri) => new _SourceProxy(absoluteUri); |
139 | 144 |
140 noSuchMethod(Invocation invocation) => unimplemented(); | 145 noSuchMethod(Invocation invocation) => unimplemented(); |
141 } | 146 } |
142 | 147 |
143 class _SourceProxy extends BasicSource { | 148 class _SourceProxy extends BasicSource { |
144 _SourceProxy(Uri uri) : super(uri); | 149 _SourceProxy(Uri uri) : super(uri); |
145 | 150 |
146 noSuchMethod(Invocation invocation) => unimplemented(); | 151 noSuchMethod(Invocation invocation) => unimplemented(); |
147 } | 152 } |
OLD | NEW |