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

Side by Side Diff: pkg/fasta/lib/src/import.dart

Issue 2629063005: Fasta builders. (Closed)
Patch Set: Address review comments. Created 3 years, 11 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 | « pkg/fasta/lib/src/export.dart ('k') | pkg/fasta/lib/src/modifier.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
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.
4
5 library fasta.import;
6
7 import 'builder/builder.dart' show
8 Builder,
9 LibraryBuilder,
10 PrefixBuilder;
11
12 import 'combinator.dart' show
13 Combinator;
14
15 typedef void AddToScope(String name, Builder member);
16
17 class Import {
18 /// The library being imported.
19 final LibraryBuilder imported;
20
21 final String prefix;
22
23 final List<Combinator> combinators;
24
25 Import(this.imported, this.prefix, this.combinators);
26
27 void finalizeImports(LibraryBuilder importer) {
28 AddToScope add;
29 PrefixBuilder prefix;
30 if (this.prefix == null) {
31 add = importer.addToScope;
32 } else {
33 prefix = new PrefixBuilder(this.prefix, <String, Builder>{}, importer);
34 add = (String name, Builder member) {
35 prefix.exports[name] = member;
36 };
37 }
38 imported.exports.forEach((String name, Builder member) {
39 if (combinators != null) {
40 for (Combinator combinator in combinators) {
41 if (combinator.isShow && !combinator.names.contains(name)) return;
42 if (combinator.isHide && combinator.names.contains(name)) return;
43 }
44 }
45 add(name, member);
46 });
47 if (prefix != null) {
48 Builder existing = importer.addBuilder(prefix.name, prefix);
49 if (existing == prefix) {
50 importer.addToScope(prefix.name, prefix);
51 }
52 }
53 }
54 }
OLDNEW
« no previous file with comments | « pkg/fasta/lib/src/export.dart ('k') | pkg/fasta/lib/src/modifier.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698