Files
sdk/pkg/analyzer/lib/dart/analysis/declared_variables.dart
T
Konstantin Shcheglov 9f986d2501 Migrate package:analyzer to null safety.
Change-Id: Iffe4370431587e46a141ddc72a86ceec29c163b2
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/176486
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
2021-02-01 18:56:04 +00:00

31 lines
1.3 KiB
Dart

// Copyright (c) 2014, 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.
/// An object used to provide access to the values of variables that have been
/// defined on the command line using the `-D` option.
///
/// Clients may not extend, implement or mix-in this class.
class DeclaredVariables {
/// A table mapping the names of declared variables to their values.
final Map<String, String> _declaredVariables = <String, String>{};
/// Initialize a newly created set of declared variables in which there are no
/// variables.
DeclaredVariables();
/// Initialize a newly created set of declared variables to define variables
/// whose names are the keys in the give [variableMap] and whose values are
/// the corresponding values from the map.
DeclaredVariables.fromMap(Map<String, String> variableMap) {
_declaredVariables.addAll(variableMap);
}
/// Return the names of the variables for which a value has been defined.
Iterable<String> get variableNames => _declaredVariables.keys;
/// Return the raw string value of the variable with the given [name],
/// or `null` if the variable is not defined.
String? get(String name) => _declaredVariables[name];
}