blob: 00998c8e03f27324161e176a33850749f83eebb7 [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.
// @dart = 2.9
library fasta.metadata_builder;
import 'package:_fe_analyzer_shared/src/scanner/scanner.dart' show Token;
import 'package:kernel/ast.dart';
import '../kernel/body_builder.dart' show BodyBuilder;
import '../source/source_library_builder.dart' show SourceLibraryBuilder;
import '../scope.dart' show Scope;
import 'declaration_builder.dart';
import 'member_builder.dart';
class MetadataBuilder {
final Token beginToken;
int get charOffset => beginToken.charOffset;
static void buildAnnotations(
Annotatable parent,
List<MetadataBuilder> metadata,
SourceLibraryBuilder library,
DeclarationBuilder classOrExtensionBuilder,
MemberBuilder member,
Uri fileUri) {
if (metadata == null) return;
Scope scope = parent is Library ||
parent is Class ||
parent is Extension ||
classOrExtensionBuilder == null
? library.scope
: classOrExtensionBuilder.scope;
BodyBuilder bodyBuilder = library.loader
library, classOrExtensionBuilder, member, scope, fileUri);
for (int i = 0; i < metadata.length; ++i) {
MetadataBuilder annotationBuilder = metadata[i];
bodyBuilder.inferAnnotations(parent, parent.annotations);