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:front_end/src/base/processed_options.dart'; | 8 import 'package:front_end/src/base/processed_options.dart'; |
8 import 'package:front_end/src/incremental_resolved_ast_generator_impl.dart'; | 9 import 'package:front_end/src/incremental_resolved_ast_generator_impl.dart'; |
9 import 'package:analyzer/dart/ast/ast.dart'; | |
10 | 10 |
11 import 'compiler_options.dart'; | 11 import 'compiler_options.dart'; |
12 | 12 |
13 /// Represents the difference between "old" and "new" states of a program. | 13 /// Represents the difference between "old" and "new" states of a program. |
14 /// | 14 /// |
15 /// Not intended to be implemented or extended by clients. | 15 /// Not intended to be implemented or extended by clients. |
16 class DeltaLibraries { | 16 class DeltaLibraries { |
17 /// The new state of the program, as a map from Uri to [ResolvedLibrary]. | 17 /// The new state of the program, as a two-layer map. |
| 18 /// |
| 19 /// The outer map key is the library URI. The inner map key is the |
| 20 /// compilation unit (part) URI. The map values are the resolved compilation |
| 21 /// units. |
18 /// | 22 /// |
19 /// Libraries whose resolved AST is known to be unchanged since the last | 23 /// Libraries whose resolved AST is known to be unchanged since the last |
20 /// [DeltaLibraries] are not included. | 24 /// [DeltaLibraries] are not included. |
21 final Map<Uri, ResolvedLibrary> newState; | 25 final Map<Uri, Map<Uri, CompilationUnit>> newState; |
22 | 26 |
23 DeltaLibraries(this.newState); | 27 DeltaLibraries(this.newState); |
24 | 28 |
25 /// TODO(paulberry): add information about libraries that were removed. | 29 /// TODO(paulberry): add information about libraries that were removed. |
26 } | |
27 | |
28 /// Represents the resolved ASTs for all the compilation units in a single | |
29 /// library. | |
30 /// | |
31 /// Not intended to be implemented or extended by clients. | |
32 class ResolvedLibrary { | |
33 final CompilationUnit definingCompilationUnit; | |
34 | |
35 final Map<Uri, CompilationUnit> partUnits; | |
36 | |
37 ResolvedLibrary(this.definingCompilationUnit, this.partUnits); | |
38 } | 30 } |
39 | 31 |
40 /// Interface for generating an initial resolved representation of a program and | 32 /// Interface for generating an initial resolved representation of a program and |
41 /// keeping it up to date as incremental changes are made. | 33 /// keeping it up to date as incremental changes are made. |
42 /// | 34 /// |
43 /// This class maintains an internal "previous program state"; each | 35 /// This class maintains an internal "previous program state"; each |
44 /// time [computeDelta] is called, it updates the previous program state and | 36 /// time [computeDelta] is called, it updates the previous program state and |
45 /// produces a representation of what has changed. When there are few changes, | 37 /// produces a representation of what has changed. When there are few changes, |
46 /// a call to [computeDelta] should be much faster than compiling the whole | 38 /// a call to [computeDelta] should be much faster than compiling the whole |
47 /// program from scratch. | 39 /// program from scratch. |
(...skipping 12 matching lines...) Expand all Loading... |
60 /// Not intended to be implemented or extended by clients. | 52 /// Not intended to be implemented or extended by clients. |
61 abstract class IncrementalResolvedAstGenerator { | 53 abstract class IncrementalResolvedAstGenerator { |
62 /// Creates an [IncrementalResolvedAstGenerator] which is prepared to generate | 54 /// Creates an [IncrementalResolvedAstGenerator] which is prepared to generate |
63 /// resolved ASTs for the program whose main library is in the given | 55 /// resolved ASTs for the program whose main library is in the given |
64 /// [source]. | 56 /// [source]. |
65 /// | 57 /// |
66 /// No file system access is performed by this constructor; the initial | 58 /// No file system access is performed by this constructor; the initial |
67 /// "previous program state" is an empty program containing no code, and the | 59 /// "previous program state" is an empty program containing no code, and the |
68 /// initial set of valid sources is empty. To obtain a resolved AST | 60 /// initial set of valid sources is empty. To obtain a resolved AST |
69 /// representation of the program, call [computeDelta]. | 61 /// representation of the program, call [computeDelta]. |
70 factory IncrementalResolvedAstGenerator(Uri source, CompilerOptions options) =
> | 62 factory IncrementalResolvedAstGenerator( |
71 new IncrementalResolvedAstGeneratorImpl(source, new ProcessedOptions(optio
ns)); | 63 Uri source, CompilerOptions options) => |
| 64 new IncrementalResolvedAstGeneratorImpl( |
| 65 source, new ProcessedOptions(options)); |
72 | 66 |
73 /// Generates a resolved AST representation of the changes to the program, | 67 /// Generates a resolved AST representation of the changes to the program, |
74 /// assuming that all valid sources are unchanged since the last call to | 68 /// assuming that all valid sources are unchanged since the last call to |
75 /// [computeDelta]. | 69 /// [computeDelta]. |
76 /// | 70 /// |
77 /// Source files in the set of valid sources are guaranteed not to be re-read | 71 /// Source files in the set of valid sources are guaranteed not to be re-read |
78 /// from disk; they are assumed to be unchanged regardless of the state of the | 72 /// from disk; they are assumed to be unchanged regardless of the state of the |
79 /// filesystem. | 73 /// filesystem. |
80 /// | 74 /// |
81 /// If the future completes successfully, the previous file state is updated | 75 /// If the future completes successfully, the previous file state is updated |
(...skipping 13 matching lines...) Expand all Loading... |
95 | 89 |
96 /// Remove all source files from the set of valid sources. This guarantees | 90 /// Remove all source files from the set of valid sources. This guarantees |
97 /// that all files will be re-read on the next call to [computeDelta]. | 91 /// that all files will be re-read on the next call to [computeDelta]. |
98 /// | 92 /// |
99 /// Note that this does not erase the previous program state; the next time | 93 /// Note that this does not erase the previous program state; the next time |
100 /// [computeDelta] is called, if parts of the program are discovered to be | 94 /// [computeDelta] is called, if parts of the program are discovered to be |
101 /// unchanged, parts of the previous program state will still be re-used to | 95 /// unchanged, parts of the previous program state will still be re-used to |
102 /// speed up compilation. | 96 /// speed up compilation. |
103 void invalidateAll(); | 97 void invalidateAll(); |
104 } | 98 } |
OLD | NEW |