blob: ddc7a64c4bbf6d538646181974adc26954ae662b [file] [log] [blame]
// Copyright (c) 2016, 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.
library fasta.member_builder;
import 'dart:core' hide MapEntry;
import 'package:kernel/ast.dart';
import '../problems.dart' show unsupported;
import 'builder.dart'
show ClassBuilder, Builder, LibraryBuilder, ModifierBuilder;
import 'declaration.dart';
import 'declaration_builder.dart';
import 'extension_builder.dart';
abstract class MemberBuilder extends ModifierBuilder {
/// For top-level members, the parent is set correctly during
/// construction. However, for class members, the parent is initially the
/// library and updated later.
Builder parent;
String get name;
MemberBuilder(this.parent, int charOffset) : super(parent, charOffset);
bool get isDeclarationInstanceMember => isDeclarationMember && !isStatic;
bool get isClassInstanceMember => isClassMember && !isStatic;
bool get isExtensionInstanceMember => isExtensionMember && !isStatic;
bool get isDeclarationMember => parent is DeclarationBuilder;
bool get isClassMember => parent is ClassBuilder;
bool get isExtensionMember => parent is ExtensionBuilder;
bool get isTopLevel => !isDeclarationMember;
bool get isNative => false;
bool get isRedirectingGenerativeConstructor => false;
LibraryBuilder get library {
if (parent is LibraryBuilder) {
LibraryBuilder library = parent;
return library.partOfLibrary ?? library;
} else if (parent is ExtensionBuilder) {
ExtensionBuilder extension = parent;
return extension.library;
} else {
ClassBuilder cls = parent;
return cls.library;
/// The [Member] built by this builder;
Member get member;
// TODO(johnniwinther): Deprecate this.
Member get target => member;
// TODO(johnniwinther): Remove this and create a [ProcedureBuilder] interface.
Member get extensionTearOff =>
unsupported("extensionTearOff", charOffset, fileUri);
// TODO(johnniwinther): Remove this and create a [ProcedureBuilder] interface.
Procedure get procedure => unsupported("procedure", charOffset, fileUri);
// TODO(johnniwinther): Remove this and create a [ProcedureBuilder] interface.
ProcedureKind get kind => unsupported("kind", charOffset, fileUri);
void buildOutlineExpressions(LibraryBuilder library) {}
String get fullNameForErrors => name;
void inferType() => unsupported("inferType", charOffset, fileUri);
void inferCopiedType(covariant Object other) {
unsupported("inferType", charOffset, fileUri);