| 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 'package:kernel/ast.dart'; | 5 import 'package:kernel/ast.dart'; |
| 6 import 'package:kernel/binary/ast_to_binary.dart'; | 6 import 'package:kernel/binary/ast_to_binary.dart'; |
| 7 | 7 |
| 8 /// Writes libraries that satisfy the [predicate]. | 8 /// Writes libraries that satisfy the [predicate]. |
| 9 /// | 9 /// |
| 10 /// Only the referenced subset of canonical names is indexed and written, | 10 /// Only the referenced subset of canonical names is indexed and written, |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 void writeLibraries(Program program) { | 55 void writeLibraries(Program program) { |
| 56 var librariesToWrite = program.libraries.where(predicate).toList(); | 56 var librariesToWrite = program.libraries.where(predicate).toList(); |
| 57 writeList(librariesToWrite, writeNode); | 57 writeList(librariesToWrite, writeNode); |
| 58 } | 58 } |
| 59 | 59 |
| 60 @override | 60 @override |
| 61 void writeNode(Node node) { | 61 void writeNode(Node node) { |
| 62 if (node is Library && !predicate(node)) return; | 62 if (node is Library && !predicate(node)) return; |
| 63 node.accept(this); | 63 node.accept(this); |
| 64 } | 64 } |
| 65 |
| 66 @override |
| 67 void writeProgramIndex(Program program, List<Library> libraries) { |
| 68 var librariesToWrite = libraries.where(predicate).toList(); |
| 69 super.writeProgramIndex(program, librariesToWrite); |
| 70 } |
| 65 } | 71 } |
| 66 | 72 |
| 67 /// Extension of [StringIndexer] that also indexes canonical names of | 73 /// Extension of [StringIndexer] that also indexes canonical names of |
| 68 /// referenced classes and members. | 74 /// referenced classes and members. |
| 69 class ReferencesStringIndexer extends StringIndexer { | 75 class ReferencesStringIndexer extends StringIndexer { |
| 70 final List<CanonicalName> referencedNames = <CanonicalName>[]; | 76 final List<CanonicalName> referencedNames = <CanonicalName>[]; |
| 71 | 77 |
| 72 @override | 78 @override |
| 73 defaultMemberReference(Member node) { | 79 defaultMemberReference(Member node) { |
| 74 _handleReferencedName(node.canonicalName); | 80 _handleReferencedName(node.canonicalName); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 } | 122 } |
| 117 | 123 |
| 118 void _handleReferencedName(CanonicalName name) { | 124 void _handleReferencedName(CanonicalName name) { |
| 119 if (name == null || name.parent == null) return; | 125 if (name == null || name.parent == null) return; |
| 120 _handleReferencedName(name.parent); | 126 _handleReferencedName(name.parent); |
| 121 referencedNames.add(name); | 127 referencedNames.add(name); |
| 122 name.index = -1; | 128 name.index = -1; |
| 123 put(name.name); | 129 put(name.name); |
| 124 } | 130 } |
| 125 } | 131 } |
| OLD | NEW |