blob: f7869e1ac12330f1d366497bf38439f59df5e560 [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 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/src/summary/idl.dart';
import 'package:analyzer/src/summary2/linked_bundle_context.dart';
/// The context of a unit - the context of the bundle, and the unit tokens.
class LinkedUnitContext {
final LinkedBundleContext bundleContext;
final UnlinkedTokens tokens;
LinkedUnitContext(this.bundleContext, this.tokens);
String getConstructorDeclarationName(LinkedNode node) {
var name = node.constructorDeclaration_name;
if (name != null) {
return getSimpleName(name);
}
return '';
}
InterfaceType getInterfaceType(LinkedNodeType linkedType) {
return bundleContext.getInterfaceType(linkedType);
}
String getSimpleName(LinkedNode node) {
return tokens.lexeme[node.simpleIdentifier_token];
}
String getUnitMemberName(LinkedNode node) {
return getSimpleName(node.namedCompilationUnitMember_name);
}
}