OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 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 | 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 library fasta.import; | 5 library fasta.import; |
6 | 6 |
7 import 'builder/builder.dart' show Builder, LibraryBuilder, PrefixBuilder; | 7 import 'builder/builder.dart' show Builder, LibraryBuilder, PrefixBuilder; |
8 | 8 |
9 import 'combinator.dart' show Combinator; | 9 import 'combinator.dart' show Combinator; |
10 | 10 |
(...skipping 16 matching lines...) Expand all Loading... |
27 | 27 |
28 Import(this.importer, this.imported, this.prefix, this.combinators, | 28 Import(this.importer, this.imported, this.prefix, this.combinators, |
29 this.charOffset, this.prefixCharOffset); | 29 this.charOffset, this.prefixCharOffset); |
30 | 30 |
31 Uri get fileUri => importer.fileUri; | 31 Uri get fileUri => importer.fileUri; |
32 | 32 |
33 void finalizeImports(LibraryBuilder importer) { | 33 void finalizeImports(LibraryBuilder importer) { |
34 AddToScope add; | 34 AddToScope add; |
35 PrefixBuilder prefix; | 35 PrefixBuilder prefix; |
36 if (this.prefix == null) { | 36 if (this.prefix == null) { |
37 add = importer.addToScope; | 37 add = (String name, Builder member) { |
| 38 importer.addToScope(name, member, charOffset, true); |
| 39 }; |
38 } else { | 40 } else { |
39 prefix = new PrefixBuilder( | 41 prefix = new PrefixBuilder( |
40 this.prefix, <String, Builder>{}, importer, prefixCharOffset); | 42 this.prefix, <String, Builder>{}, importer, prefixCharOffset); |
41 add = (String name, Builder member) { | 43 add = (String name, Builder member) { |
42 prefix.exports[name] = member; | 44 prefix.exports[name] = member; |
43 }; | 45 }; |
44 } | 46 } |
45 imported.exports.forEach((String name, Builder member) { | 47 imported.exports.forEach((String name, Builder member) { |
46 if (combinators != null) { | 48 if (combinators != null) { |
47 for (Combinator combinator in combinators) { | 49 for (Combinator combinator in combinators) { |
48 if (combinator.isShow && !combinator.names.contains(name)) return; | 50 if (combinator.isShow && !combinator.names.contains(name)) return; |
49 if (combinator.isHide && combinator.names.contains(name)) return; | 51 if (combinator.isHide && combinator.names.contains(name)) return; |
50 } | 52 } |
51 } | 53 } |
52 add(name, member); | 54 add(name, member); |
53 }); | 55 }); |
54 if (prefix != null) { | 56 if (prefix != null) { |
55 Builder existing = importer.addBuilder(prefix.name, prefix, charOffset); | 57 Builder existing = importer.addBuilder(prefix.name, prefix, charOffset); |
56 if (existing == prefix) { | 58 if (existing == prefix) { |
57 importer.addToScope(prefix.name, prefix); | 59 importer.addToScope(prefix.name, prefix, prefixCharOffset, true); |
58 } | 60 } |
59 } | 61 } |
60 } | 62 } |
61 } | 63 } |
OLD | NEW |