| 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.source_library_builder; | 5 library fasta.source_library_builder; |
| 6 | 6 |
| 7 import 'package:kernel/ast.dart' show | 7 import 'package:kernel/ast.dart' show |
| 8 AsyncMarker, | 8 AsyncMarker, |
| 9 ProcedureKind; | 9 ProcedureKind; |
| 10 | 10 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 <ConstructorReferenceBuilder>[]; | 55 <ConstructorReferenceBuilder>[]; |
| 56 | 56 |
| 57 final List<LibraryBuilder> parts = <LibraryBuilder>[]; | 57 final List<LibraryBuilder> parts = <LibraryBuilder>[]; |
| 58 | 58 |
| 59 final List<Import> imports = <Import>[]; | 59 final List<Import> imports = <Import>[]; |
| 60 | 60 |
| 61 final Map<String, Builder> exports = <String, Builder>{}; | 61 final Map<String, Builder> exports = <String, Builder>{}; |
| 62 | 62 |
| 63 final Scope scope = new Scope(<String, Builder>{}, null, isModifiable: false); | 63 final Scope scope = new Scope(<String, Builder>{}, null, isModifiable: false); |
| 64 | 64 |
| 65 final Uri fileUri; |
| 66 |
| 65 String name; | 67 String name; |
| 66 | 68 |
| 67 String partOf; | 69 String partOf; |
| 68 | 70 |
| 69 Uri fileUri; | |
| 70 | |
| 71 List<MetadataBuilder> metadata; | 71 List<MetadataBuilder> metadata; |
| 72 | 72 |
| 73 Map<String, MemberBuilder> classMembers; | 73 Map<String, MemberBuilder> classMembers; |
| 74 | 74 |
| 75 // TODO(ahe): Rename this. It's not just for classes. | 75 // TODO(ahe): Rename this. It's not just for classes. |
| 76 List<T> classTypes; | 76 List<T> classTypes; |
| 77 | 77 |
| 78 SourceLibraryBuilder(this.loader); | 78 SourceLibraryBuilder(this.loader, this.fileUri); |
| 79 | 79 |
| 80 Uri get uri; | 80 Uri get uri; |
| 81 | 81 |
| 82 bool get isPart => partOf != null; | 82 bool get isPart => partOf != null; |
| 83 | 83 |
| 84 T addInterfaceType(String name, List<T> arguments); | 84 T addInterfaceType(String name, List<T> arguments); |
| 85 | 85 |
| 86 T addMixinApplication(T supertype, List<T> mixins); | 86 T addMixinApplication(T supertype, List<T> mixins); |
| 87 | 87 |
| 88 T addType(T type) { | 88 T addType(T type) { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 | 126 |
| 127 void addPart(List<MetadataBuilder> metadata, String path) { | 127 void addPart(List<MetadataBuilder> metadata, String path) { |
| 128 Uri resolvedUri; | 128 Uri resolvedUri; |
| 129 Uri newFileUri; | 129 Uri newFileUri; |
| 130 if (uri.scheme == "dart") { | 130 if (uri.scheme == "dart") { |
| 131 resolvedUri = new Uri(scheme: "dart", path: "${uri.path}/$path"); | 131 resolvedUri = new Uri(scheme: "dart", path: "${uri.path}/$path"); |
| 132 newFileUri = fileUri.resolve(path); | 132 newFileUri = fileUri.resolve(path); |
| 133 } else { | 133 } else { |
| 134 newFileUri = resolvedUri = resolve(path); | 134 newFileUri = resolvedUri = resolve(path); |
| 135 } | 135 } |
| 136 LibraryBuilder part = loader.read(resolvedUri); | 136 parts.add(loader.read(resolvedUri, newFileUri)); |
| 137 if (part is SourceLibraryBuilder) { | |
| 138 part.fileUri ??= newFileUri; | |
| 139 } | |
| 140 parts.add(part); | |
| 141 } | 137 } |
| 142 | 138 |
| 143 void addPartOf(List<MetadataBuilder> metadata, String name) { | 139 void addPartOf(List<MetadataBuilder> metadata, String name) { |
| 144 partOf = name; | 140 partOf = name; |
| 145 } | 141 } |
| 146 | 142 |
| 147 ClassBuilder addClass(List<MetadataBuilder> metadata, | 143 ClassBuilder addClass(List<MetadataBuilder> metadata, |
| 148 int modifiers, String name, | 144 int modifiers, String name, |
| 149 List<TypeVariableBuilder> typeVariables, T supertype, | 145 List<TypeVariableBuilder> typeVariables, T supertype, |
| 150 List<T> interfaces); | 146 List<T> interfaces); |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 } | 333 } |
| 338 | 334 |
| 339 int resolveConstructors(_) { | 335 int resolveConstructors(_) { |
| 340 int count = 0; | 336 int count = 0; |
| 341 members.forEach((String name, Builder member) { | 337 members.forEach((String name, Builder member) { |
| 342 count += member.resolveConstructors(this); | 338 count += member.resolveConstructors(this); |
| 343 }); | 339 }); |
| 344 return count; | 340 return count; |
| 345 } | 341 } |
| 346 } | 342 } |
| OLD | NEW |