blob: 579f351d4571af30b75daf274717ace963172d4f [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/ast/ast.dart';
import 'package:analyzer/dart/element/scope.dart';
/// This class provides access to [Scope]s corresponding to [AstNode]s.
class LinkingNodeContext {
static final _expando = Expando<LinkingNodeContext>();
final Scope scope;
LinkingNodeContext(AstNode node, this.scope) {
_expando[node] = this;
}
static LinkingNodeContext get(AstNode node) {
var context = _expando[node];
if (context == null) {
throw StateError('No context for: $node');
}
return context;
}
}