|
3 | 3 | // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
|
5 | 5 | import 'package:_fe_analyzer_shared/src/messages/severity.dart' show Severity; |
6 | | -import 'package:front_end/src/builder/property_builder.dart'; |
7 | 6 | import 'package:kernel/ast.dart' show Annotatable, Library, Version; |
8 | 7 | import 'package:kernel/reference_from_index.dart'; |
9 | 8 |
|
10 | 9 | import '../api_prototype/experimental_flags.dart'; |
11 | 10 | import '../base/combinator.dart' show CombinatorBuilder; |
12 | 11 | import '../base/export.dart' show Export; |
13 | 12 | import '../base/loader.dart' show Loader; |
14 | | -import '../base/lookup_result.dart'; |
15 | 13 | import '../base/messages.dart' |
16 | 14 | show |
17 | 15 | FormattedMessage, |
18 | 16 | LocatedMessage, |
19 | 17 | Message, |
20 | 18 | ProblemReporting, |
21 | 19 | noLength, |
22 | | - templateDuplicatedExport, |
23 | 20 | templateInternalProblemConstructorNotFound, |
24 | 21 | templateInternalProblemNotFoundIn, |
25 | 22 | templateInternalProblemPrivateConstructorAccess; |
26 | 23 | import '../base/name_space.dart'; |
27 | 24 | import '../base/problems.dart' show internalProblem; |
28 | 25 | import '../base/scope.dart'; |
29 | | -import '../base/uri_offset.dart'; |
30 | 26 | import '../fragment/fragment.dart'; |
31 | 27 | import '../kernel/body_builder_context.dart'; |
32 | | -import '../kernel/load_library_builder.dart'; |
33 | 28 | import '../source/offset_map.dart'; |
34 | 29 | import '../source/outline_builder.dart'; |
35 | 30 | import '../source/source_class_builder.dart'; |
@@ -83,7 +78,7 @@ sealed class CompilationUnit { |
83 | 78 |
|
84 | 79 | List<Export> get exporters; |
85 | 80 |
|
86 | | - void addExporter(CompilationUnit exporter, |
| 81 | + void addExporter(SourceCompilationUnit exporter, |
87 | 82 | List<CombinatorBuilder>? combinators, int charOffset); |
88 | 83 |
|
89 | 84 | /// Add a problem with a severity determined by the severity of the message. |
@@ -376,10 +371,6 @@ abstract class LibraryBuilder implements Builder, ProblemReporting { |
376 | 371 | /// Duplicates and augmenting members are _not_ included. |
377 | 372 | Iterator<T> fullMemberIterator<T extends NamedBuilder>(); |
378 | 373 |
|
379 | | - /// Returns true if the export scope was modified. |
380 | | - bool addToExportScope(String name, NamedBuilder member, |
381 | | - {required UriOffset uriOffset}); |
382 | | - |
383 | 374 | /// Looks up [constructorName] in the class named [className]. |
384 | 375 | /// |
385 | 376 | /// The class is looked up in this library's export scope unless |
@@ -478,92 +469,6 @@ abstract class LibraryBuilderImpl extends BuilderImpl |
478 | 469 | problemOnLibrary: true); |
479 | 470 | } |
480 | 471 |
|
481 | | - /// Computes a builder for the export collision between [declaration] and |
482 | | - /// [other]. If [declaration] is declared in [libraryNameSpace] then this is |
483 | | - /// returned instead of reporting a collision. |
484 | | - NamedBuilder _computeAmbiguousDeclarationForExport( |
485 | | - String name, NamedBuilder declaration, NamedBuilder other, |
486 | | - {required UriOffset uriOffset}) { |
487 | | - // Prefix builders and load library builders are not part of an export |
488 | | - // scope. |
489 | | - assert(declaration is! PrefixBuilder, |
490 | | - "Unexpected prefix builder $declaration."); |
491 | | - assert(other is! PrefixBuilder, "Unexpected prefix builder $other."); |
492 | | - assert(declaration is! LoadLibraryBuilder, |
493 | | - "Unexpected load library builder $declaration."); |
494 | | - assert(other is! LoadLibraryBuilder, |
495 | | - "Unexpected load library builder $other."); |
496 | | - |
497 | | - if (declaration == other) return declaration; |
498 | | - if (declaration is InvalidTypeDeclarationBuilder) return declaration; |
499 | | - if (other is InvalidTypeDeclarationBuilder) return other; |
500 | | - NamedBuilder? preferred; |
501 | | - Uri? uri; |
502 | | - Uri? otherUri; |
503 | | - if (libraryNameSpace.lookupLocalMember(name)?.getable == declaration) { |
504 | | - return declaration; |
505 | | - } else { |
506 | | - uri = computeLibraryUri(declaration); |
507 | | - otherUri = computeLibraryUri(other); |
508 | | - if (otherUri.isScheme("dart") && !uri.isScheme("dart")) { |
509 | | - preferred = declaration; |
510 | | - } else if (uri.isScheme("dart") && !otherUri.isScheme("dart")) { |
511 | | - preferred = other; |
512 | | - } |
513 | | - } |
514 | | - if (preferred != null) { |
515 | | - return preferred; |
516 | | - } |
517 | | - |
518 | | - Uri firstUri = uri; |
519 | | - Uri secondUri = otherUri; |
520 | | - if (firstUri.toString().compareTo(secondUri.toString()) > 0) { |
521 | | - firstUri = secondUri; |
522 | | - secondUri = uri; |
523 | | - } |
524 | | - |
525 | | - // TODO(ahe): We should probably use a context object here |
526 | | - // instead of including URIs in this message. |
527 | | - Message message = |
528 | | - templateDuplicatedExport.withArguments(name, firstUri, secondUri); |
529 | | - addProblem(message, uriOffset.fileOffset, noLength, uriOffset.uri); |
530 | | - // We report the error lazily (setting suppressMessage to false) because the |
531 | | - // spec 18.1 states that 'It is not an error if N is introduced by two or |
532 | | - // more imports but never referred to.' |
533 | | - return new InvalidTypeDeclarationBuilder(name, |
534 | | - message.withLocation(uriOffset.uri, uriOffset.fileOffset, name.length), |
535 | | - suppressMessage: false); |
536 | | - } |
537 | | - |
538 | | - @override |
539 | | - bool addToExportScope(String name, NamedBuilder member, |
540 | | - {required UriOffset uriOffset}) { |
541 | | - if (name.startsWith("_")) return false; |
542 | | - if (member is PrefixBuilder) return false; |
543 | | - bool isSetter = isMappedAsSetter(member); |
544 | | - LookupResult? result = exportNameSpace.lookupLocalMember(name); |
545 | | - NamedBuilder? existing = isSetter ? result?.setable : result?.getable; |
546 | | - if (existing == member) { |
547 | | - return false; |
548 | | - } else { |
549 | | - if (member is MemberBuilder && member.isConflictingSetter) { |
550 | | - // TODO(johnniwinther): Remove this case when getables and setables are |
551 | | - // contained in the same map in the name space. |
552 | | - exportNameSpace.addLocalMember(name, member, setter: isSetter); |
553 | | - return true; |
554 | | - } else if (existing != null) { |
555 | | - NamedBuilder result = _computeAmbiguousDeclarationForExport( |
556 | | - name, existing, member, |
557 | | - uriOffset: uriOffset); |
558 | | - exportNameSpace.addLocalMember(name, result, setter: isSetter); |
559 | | - return result != existing; |
560 | | - } else { |
561 | | - exportNameSpace.addLocalMember(name, member, setter: isSetter); |
562 | | - return true; |
563 | | - } |
564 | | - } |
565 | | - } |
566 | | - |
567 | 472 | @override |
568 | 473 | MemberBuilder getConstructor(String className, |
569 | 474 | {String? constructorName, bool bypassLibraryPrivacy = false}) { |
|
0 commit comments