blob: dc2007fcccdfb1112a5d269436a7b9962093dd39 [file] [log] [blame]
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'dart:core' hide MapEntry;
import 'package:kernel/ast.dart';
import '../fasta_codes.dart' show templateInternalProblemNotFoundIn;
import '../scope.dart';
import '../problems.dart';
import 'builder.dart';
import 'declaration.dart';
import 'declaration_builder.dart';
import 'library_builder.dart';
import 'metadata_builder.dart';
import 'type_builder.dart';
import 'type_variable_builder.dart';
abstract class ExtensionBuilder extends DeclarationBuilder {
final List<TypeVariableBuilder> typeParameters;
final TypeBuilder onType;
List<MetadataBuilder> metadata,
int modifiers,
String name,
LibraryBuilder parent,
int charOffset,
Scope scope,
: super(metadata, modifiers, name, parent, charOffset, scope);
/// Return the [Extension] built by this builder.
Extension get extension;
/// Lookup a static member of this declaration.
Builder findStaticBuilder(
String name, int charOffset, Uri fileUri, LibraryBuilder accessingLibrary,
{bool isSetter: false}) {
if (accessingLibrary.origin != library.origin && name.startsWith("_")) {
return null;
Builder declaration = isSetter
? scope.lookupSetter(name, charOffset, fileUri, isInstanceScope: false)
: scope.lookup(name, charOffset, fileUri, isInstanceScope: false);
// TODO(johnniwinther): Handle patched extensions.
return declaration;
// Deliberately unrelated return type to statically detect more accidental
// use until is fully retired.
UnrelatedTarget get target => unsupported(
" is deprecated. "
"Use ExtensionBuilder.extension instead.",
DartType buildType(LibraryBuilder library,
NullabilityBuilder nullabilityBuilder, List<TypeBuilder> arguments) {
throw new UnsupportedError("ExtensionBuilder.buildType is not supported.");
DartType buildTypesWithBuiltArguments(LibraryBuilder library,
Nullability nullability, List<DartType> arguments) {
throw new UnsupportedError("ExtensionBuilder.buildTypesWithBuiltArguments "
"is not supported.");
bool get isExtension => true;
InterfaceType get thisType => null;
Builder lookupLocalMember(String name,
{bool setter: false, bool required: false}) {
// TODO(johnniwinther): Support patching on extensions.
Builder builder = setter ? scope.setters[name] : scope.local[name];
if (required && builder == null) {
name, fullNameForErrors),
return builder;
String get debugName => "ExtensionBuilder";
void buildOutlineExpressions(LibraryBuilder library) {
void build(String ignore, Builder declaration) {
MemberBuilder member = declaration;
// TODO(johnniwinther): Handle annotations on the extension declaration.
// isPatch ? origin.extension : extension,
// metadata, library, this, null);