Prepare to publish analyzer 0.40.0 and _fe_analyzer_shared 8.0.0.

Change-Id: I126207dcc47885565a3a6d7002ff15ad3cc493c5
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122483
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
Konstantin Shcheglov 2020-08-18 15:12:10 +00:00 committed by commit-bot@chromium.org
parent 2bf61f4936
commit a51f1747e0
78 changed files with 405 additions and 3264 deletions

View file

@ -1,5 +1,5 @@
name: _fe_analyzer_shared
version: 7.0.0
version: 8.0.0
description: Logic that is shared between the front_end and analyzer packages.
homepage: https://github.com/dart-lang/sdk/tree/master/pkg/_fe_analyzer_shared

View file

@ -1,5 +1,44 @@
## 0.39.18-dev
## 0.40.0
* Added `LibraryElement.featureSet`.
* Removed deprecated `EmbedderSdk` and related classes.
* `FunctionType` returned from `ExecutableElement.type` return `null`
as its `element`. Use `ExecutableElement`s directly if necessary.
* `FunctionTypeAliasElement` does not implement `FunctionTypedElement`
anymore, implements `TypeParameterizedElement` instead.
* Removed deprecated `CustomUriResolver`.
* Removed deprecated `ExplicitSourceResolver`, `FileUriResolver`,
`LocalSourcePredicate`, `PackageUriResolver`, `RelativeFileUriResolver`.
* Removed deprecated `ErrorCode` instances.
* The `withNullability` flag in `DartType.getDisplayString()` is now required.
* Removed deprecated `DartType.substitute2`, and `FunctionType.substitute3`,
use `ClassElement.instantiate`, `FunctionTypeAliasElement.instantiate()`,
or `FunctionType.instantiate()`.
* Removed deprecated `FunctionType.boundTypeParameters`, use `typeFormals`
for now. Later, it will be deprecated, and replaced with `typeParameters`.
* Removed `InterfaceType.instantiate()`, `InterfaceType.substitute4`,
use `ClassElement.instantiate()`.
* Removed `typeParameters` and `instantiate()` from `ParameterizedType`.
Use `typeParameters` and `instantiate()` from `ClassElement`.
* Removed deprecated methods from `DeclaredVariables`.
* Removed deprecated `typeProvider` and `typeSystem` getters.
Use corresponding `LibraryElement` getters instead.
* Removed deprecated options from `AnalysisOptions`.
* Removed deprecated `ClassElement.hasReferenceToSuper`.
* Removed deprecated `DartType.isObject`.
Use `DartType.isDartCoreObject` instead.
* Removed deprecated declarations in `AnalysisContext` and `ContextLocator`.
* Removed deprecated libraries.
* Removed deprecated declarations from TypeProvider.
* Removed deprecated `ParseResult` and `ResolveResult`.
* Removed deprecated `AnalysisContext.typeProvider` and `typeSystem`.
Use the corresponding getters of `LibraryElement`.
* Removed deprecated methods of `AnalysisSession`.
* Removed deprecated declarations from `dart/ast/ast.dart`.
* Removed deprecated methods from `AstFactory`.
* Removed deprecated `parseFile2`..
* Removed deprecated `TypeDefiningElement.type`.
* Features in `Feature` are not constants anymore.
* Replaced `Feature.firstSupportedVersion` with `releaseVersion`.
## 0.39.17
* Depend on cli_util 0.2.0.

View file

@ -1,8 +0,0 @@
// Copyright (c) 2017, 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.
@deprecated
library context.context_root;
export 'package:analyzer/src/context/context_root.dart';

View file

@ -1,8 +0,0 @@
// 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.
@deprecated
library analyzer.context.declared_variables;
export 'package:analyzer/dart/analysis/declared_variables.dart';

View file

@ -27,43 +27,6 @@ abstract class AnalysisContext {
/// Return the currently active analysis session.
AnalysisSession get currentSession;
/// A list of the absolute, normalized paths of files and directories that
/// will not be analyzed.
///
/// Deprecated: Use `contextRoot.excludedPaths`.
@deprecated
List<String> get excludedPaths;
/// A list of the absolute, normalized paths of files and directories that
/// will be analyzed. If a path in the list represents a file, then that file
/// will be analyzed, even if it is in the list of [excludedPaths]. If path in
/// the list represents a directory, then all of the files contained in that
/// directory, either directly or indirectly, and that are not explicitly
/// excluded by the list of [excludedPaths] will be analyzed.
///
/// Deprecated: Use `contextRoot.includedPaths`.
@deprecated
List<String> get includedPaths;
/// Return the workspace for containing the context root.
Workspace get workspace;
/// Return the absolute, normalized paths of all of the files that are
/// contained in this context. These are all of the files that are included
/// directly or indirectly by one or more of the [includedPaths] and that are
/// not excluded by any of the [excludedPaths].
///
/// Deprecated: Use `contextRoot.analyzedFiles`.
@deprecated
Iterable<String> analyzedFiles();
/// Return `true` if the file or directory with the given [path] will be
/// analyzed in this context. A file (or directory) will be analyzed if it is
/// either the same as or contained in one of the [includedPaths] and, if it
/// is contained in one of the [includedPaths], is not the same as or
/// contained in one of the [excludedPaths].
///
/// Deprecated: Use `contextRoot.isAnalyzed`.
@deprecated
bool isAnalyzed(String path);
}

View file

@ -2,7 +2,6 @@
// 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/analysis/analysis_context.dart';
import 'package:analyzer/dart/analysis/context_root.dart';
import 'package:analyzer/file_system/file_system.dart';
import 'package:analyzer/src/dart/analysis/context_locator.dart';
@ -20,29 +19,6 @@ abstract class ContextLocator {
factory ContextLocator({ResourceProvider resourceProvider}) =
ContextLocatorImpl;
/// Return a list of the analysis contexts that should be used to analyze the
/// files that are included by the list of [includedPaths] and not excluded by
/// the list of [excludedPaths].
///
/// If an [optionsFile] is specified, then it is assumed to be the path to the
/// `analysis_options.yaml` (or `.analysis_options`) file that should be used
/// in place of the ones that would be found by looking in the directories
/// containing the context roots.
///
/// If a [packagesFile] is specified, then it is assumed to be the path to the
/// `.packages` file that should be used in place of the one that would be
/// found by looking in the directories containing the context roots.
///
/// If the [sdkPath] is specified, then it is used as the path to the root of
/// the SDK that should be used during analysis.
@deprecated
List<AnalysisContext> locateContexts(
{@required List<String> includedPaths,
List<String> excludedPaths = const <String>[],
String optionsFile,
String packagesFile,
String sdkPath});
/// Return a list of the context roots that should be used to analyze the
/// files that are included by the list of [includedPaths] and not excluded by
/// the list of [excludedPaths].

View file

@ -2,11 +2,6 @@
// 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/constant/value.dart';
import 'package:analyzer/dart/element/type_provider.dart';
import 'package:analyzer/src/dart/constant/from_environment_evaluator.dart';
import 'package:analyzer/src/dart/element/type_system.dart';
/// An object used to provide access to the values of variables that have been
/// defined on the command line using the `-D` option.
///
@ -29,59 +24,7 @@ class DeclaredVariables {
/// Return the names of the variables for which a value has been defined.
Iterable<String> get variableNames => _declaredVariables.keys;
/// Add all variables of [other] to this object.
@deprecated
void addAll(DeclaredVariables other) {
_declaredVariables.addAll(other._declaredVariables);
}
/// Define a variable with the given [name] to have the given [value].
@deprecated
void define(String name, String value) {
_declaredVariables[name] = value;
}
/// Return the raw string value of the variable with the given [name],
/// or `null` of the variable is not defined.
String get(String name) => _declaredVariables[name];
/// Return the value of the variable with the given [name] interpreted as a
/// 'boolean' value. If the variable is not defined (or [name] is `null`), a
/// DartObject representing "unknown" is returned. If the value cannot be
/// parsed as a boolean, a DartObject representing 'null' is returned. The
/// [typeProvider] is the type provider used to find the type 'bool'.
@Deprecated("Clients don't need this functionality")
DartObject getBool(TypeProvider typeProvider, String name) {
return _evaluator(typeProvider).getBool(name);
}
/// Return the value of the variable with the given [name] interpreted as an
/// integer value. If the variable is not defined (or [name] is `null`), a
/// DartObject representing "unknown" is returned. If the value cannot be
/// parsed as an integer, a DartObject representing 'null' is returned.
@Deprecated("Clients don't need this functionality")
DartObject getInt(TypeProvider typeProvider, String name) {
return _evaluator(typeProvider).getInt(name);
}
/// Return the value of the variable with the given [name] interpreted as a
/// String value, or `null` if the variable is not defined. Return the value
/// of the variable with the given name interpreted as a String value. If the
/// variable is not defined (or [name] is `null`), a DartObject representing
/// "unknown" is returned. The [typeProvider] is the type provider used to
/// find the type 'String'.
@Deprecated("Clients don't need this functionality")
DartObject getString(TypeProvider typeProvider, String name) {
return _evaluator(typeProvider).getString(name);
}
FromEnvironmentEvaluator _evaluator(TypeProvider typeProvider) {
var typeSystem = TypeSystemImpl(
implicitCasts: false,
isNonNullableByDefault: false,
strictInference: false,
typeProvider: typeProvider,
);
return FromEnvironmentEvaluator(typeSystem, this);
}
}

View file

@ -11,29 +11,29 @@ import 'package:pub_semver/pub_semver.dart';
/// experimental flags.
abstract class Feature {
/// Feature information for the 2018 constant update.
static const constant_update_2018 = ExperimentalFeatures.constant_update_2018;
static final constant_update_2018 = ExperimentalFeatures.constant_update_2018;
/// Feature information for non-nullability by default.
static const non_nullable = ExperimentalFeatures.non_nullable;
static final non_nullable = ExperimentalFeatures.non_nullable;
/// Feature information for control flow collections.
static const control_flow_collections =
static final control_flow_collections =
ExperimentalFeatures.control_flow_collections;
/// Feature information for extension methods.
static const extension_methods = ExperimentalFeatures.extension_methods;
static final extension_methods = ExperimentalFeatures.extension_methods;
/// Feature information for spread collections.
static const spread_collections = ExperimentalFeatures.spread_collections;
static final spread_collections = ExperimentalFeatures.spread_collections;
/// Feature information for set literals.
static const set_literals = ExperimentalFeatures.set_literals;
static final set_literals = ExperimentalFeatures.set_literals;
/// Feature information for the triple-shift operator.
static const triple_shift = ExperimentalFeatures.triple_shift;
static final triple_shift = ExperimentalFeatures.triple_shift;
/// Feature information for variance.
static const variance = ExperimentalFeatures.variance;
static final variance = ExperimentalFeatures.variance;
/// If the feature may be enabled or disabled on the command line, the
/// experimental flag that may be used to enable it. Otherwise `null`.
@ -41,9 +41,9 @@ abstract class Feature {
/// Should be `null` if [status] is `current` or `abandoned`.
String get experimentalFlag;
/// If [status] is not `future`, the first version of the Dart SDK in which
/// the given feature was supported. Otherwise `null`.
Version get firstSupportedVersion;
/// If [status] is not `future`, the first language version in which this
/// feature was enabled by default. Otherwise `null`.
Version get releaseVersion;
/// The status of the feature.
FeatureStatus get status;

View file

@ -6,8 +6,8 @@ import 'package:analyzer/dart/analysis/session.dart';
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type_provider.dart';
import 'package:analyzer/dart/element/type_system.dart';
import 'package:analyzer/error/error.dart';
import 'package:analyzer/src/dart/element/type_system.dart';
import 'package:analyzer/src/generated/source.dart';
/// The result of performing some kind of analysis on a single file. Every
@ -90,15 +90,7 @@ abstract class ParsedLibraryResult implements AnalysisResult {
/// those discovered during scanning and parsing.
///
/// Clients may not extend, implement or mix-in this class.
// ignore: deprecated_member_use_from_same_package
abstract class ParsedUnitResult implements ParseResult {}
/// The result of parsing of a single file. The errors returned include only
/// those discovered during scanning and parsing.
///
/// Clients may not extend, implement or mix-in this class.
@deprecated
abstract class ParseResult implements AnalysisResultWithErrors {
abstract class ParsedUnitResult implements AnalysisResultWithErrors {
/// The content of the file that was scanned and parsed.
String get content;
@ -150,15 +142,7 @@ abstract class ResolvedLibraryResult implements AnalysisResult {
/// include both syntactic and semantic errors.
///
/// Clients may not extend, implement or mix-in this class.
// ignore: deprecated_member_use_from_same_package
abstract class ResolvedUnitResult implements ResolveResult {}
/// The result of building a resolved AST for a single file. The errors returned
/// include both syntactic and semantic errors.
///
/// Clients may not extend, implement or mix-in this class.
@deprecated
abstract class ResolveResult implements AnalysisResultWithErrors {
abstract class ResolvedUnitResult implements AnalysisResultWithErrors {
/// The content of the file that was scanned, parsed and resolved.
String get content;

View file

@ -9,10 +9,8 @@ import 'package:analyzer/dart/analysis/declared_variables.dart';
import 'package:analyzer/dart/analysis/results.dart';
import 'package:analyzer/dart/analysis/uri_converter.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type_provider.dart';
import 'package:analyzer/exception/exception.dart';
import 'package:analyzer/file_system/file_system.dart';
import 'package:analyzer/src/dart/element/type_system.dart';
import 'package:analyzer/src/generated/source.dart';
/// A consistent view of the results of analyzing one or more files.
@ -32,21 +30,6 @@ abstract class AnalysisSession {
/// Return the [ResourceProvider] that is used to access the file system.
ResourceProvider get resourceProvider;
/// Return the source factory used to resolve URIs.
///
/// Deprecated: Use the methods on [uriConverter] instead.
@deprecated
SourceFactory get sourceFactory;
/// Return a type provider that is consistent with the results returned by
/// this session.
@Deprecated('Use LibraryElement.typeProvider')
Future<TypeProvider> get typeProvider;
/// Return the type system being used by this session.
@Deprecated('Use LibraryElement.typeSystem')
Future<TypeSystem> get typeSystem;
/// Return the URI converter used to convert between URI's and file paths.
UriConverter get uriConverter;
@ -65,20 +48,6 @@ abstract class AnalysisSession {
/// the library with the given [uri].
Future<LibraryElement> getLibraryByUri(String uri);
/// Return a future that will complete with information about the results of
/// parsing the file with the given absolute, normalized [path].
///
/// Deprecated: Use [getParsedUnit] instead.
@deprecated
Future<ParseResult> getParsedAst(String path);
/// Return information about the results of parsing the file with the given
/// absolute, normalized [path].
///
/// Deprecated: Use [getParsedUnit] instead.
@deprecated
ParseResult getParsedAstSync(String path);
/// Return information about the results of parsing units of the library file
/// with the given absolute, normalized [path].
///
@ -96,13 +65,6 @@ abstract class AnalysisSession {
/// absolute, normalized [path].
ParsedUnitResult getParsedUnit(String path);
/// Return a future that will complete with information about the results of
/// resolving the file with the given absolute, normalized [path].
///
/// Deprecated: Use [getResolvedUnit] instead.
@deprecated
Future<ResolveResult> getResolvedAst(String path);
/// Return a future that will complete with information about the results of
/// resolving all of the files in the library with the given absolute,
/// normalized [path].

View file

@ -56,39 +56,6 @@ ParseStringResult parseFile(
throwIfDiagnostics: throwIfDiagnostics);
}
/// Return the result of parsing the file at the given [path].
///
/// If a [resourceProvider] is given, it will be used to access the file system.
///
/// [featureSet] determines what set of features will be assumed by the parser.
/// This parameter is required because the analyzer does not yet have a
/// performant way of computing the correct feature set for a single file to be
/// parsed. Callers that need the feature set to be strictly correct must
/// create an [AnalysisContextCollection], query it to get an [AnalysisContext],
/// query it to get an [AnalysisSession], and then call `getParsedUnit`.
///
/// Callers that don't need the feature set to be strictly correct can pass in
/// `FeatureSet.fromEnableFlags([])` to enable the default set of features; this
/// is much more performant than using an analysis session, because it doesn't
/// require the analyzer to process the SDK.
///
/// If [throwIfDiagnostics] is `true` (the default), then if any diagnostics are
/// produced because of syntactic errors in the [content] an `ArgumentError`
/// will be thrown. If the parameter is `false`, then the caller can check the
/// result to see whether there are any errors.
@Deprecated('Use parseFile')
ParseStringResult parseFile2(
{@required String path,
ResourceProvider resourceProvider,
@required FeatureSet featureSet,
bool throwIfDiagnostics = true}) {
return parseFile(
path: path,
resourceProvider: resourceProvider,
featureSet: featureSet,
throwIfDiagnostics: throwIfDiagnostics);
}
/// Returns the result of parsing the given [content] as a compilation unit.
///
/// If a [featureSet] is provided, it will be the default set of features that

View file

@ -1353,16 +1353,6 @@ abstract class Configuration implements AstNode {
/// Set the token for the left parenthesis to the given [token].
set leftParenthesis(Token token);
/// Return the URI of the implementation library to be used if the condition
/// is true.
@deprecated
StringLiteral get libraryUri;
/// Set the URI of the implementation library to be used if the condition is
/// true to the given [uri].
@deprecated
set libraryUri(StringLiteral uri);
/// Return the name of the declared variable whose value is being used in the
/// condition.
DottedName get name;
@ -1439,9 +1429,6 @@ abstract class ConstructorDeclaration implements ClassMember {
@override
ConstructorElement get declaredElement;
/// Set the element associated with this constructor to the given [element].
set element(ConstructorElement element);
/// Return the token for the 'external' keyword to the given [token].
Token get externalKeyword;
@ -2388,10 +2375,6 @@ abstract class FormalParameter implements AstNode {
/// parameter.
bool get isRequiredPositional;
/// Return the kind of this parameter.
@deprecated
ParameterKind get kind;
/// Return the annotations associated with this parameter.
NodeList<Annotation> get metadata;
@ -2682,9 +2665,6 @@ abstract class FunctionExpression implements Expression {
/// structure has not been resolved.
ExecutableElement get declaredElement;
/// Set the element associated with the function to the given [element].
set element(ExecutableElement element);
/// Return the parameters associated with the function, or `null` if the
/// function is part of a top-level getter.
FormalParameterList get parameters;
@ -3288,8 +3268,7 @@ abstract class IndexExpression
/// ('new' | 'const')? [TypeName] ('.' [SimpleIdentifier])? [ArgumentList]
///
/// Clients may not extend, implement or mix-in this class.
abstract class InstanceCreationExpression
implements Expression, ConstructorReferenceNode {
abstract class InstanceCreationExpression implements Expression {
/// Return the list of arguments to the constructor.
ArgumentList get argumentList;
@ -3315,14 +3294,6 @@ abstract class InstanceCreationExpression
/// Set the 'new' or 'const' keyword used to indicate how an object should be
/// created to the given [token].
set keyword(Token token);
@Deprecated('Use constructorName.staticElement')
@override
ConstructorElement get staticElement;
@Deprecated('Use constructorName.staticElement')
@override
set staticElement(ConstructorElement staticElement);
}
/// An integer literal expression.
@ -4032,11 +4003,6 @@ abstract class NodeList<E extends AstNode> implements List<E> {
/// Return the node that is the parent of each of the elements in the list.
AstNode get owner;
/// Set the node that is the parent of each of the elements in the list to the
/// given [node].
@deprecated // Never intended for public use.
set owner(AstNode node);
/// Return the node at the given [index] in the list or throw a [RangeError]
/// if [index] is out of bounds.
@override
@ -5186,14 +5152,6 @@ abstract class TypeParameterList implements AstNode {
///
/// Clients may not extend, implement or mix-in this class.
abstract class UriBasedDirective implements Directive {
/// Return the source to which the URI was resolved.
@deprecated
Source get source;
/// Set the source to which the URI was resolved to the given [source].
@deprecated
set source(Source source);
/// Return the URI referenced by this directive.
StringLiteral get uri;

View file

@ -346,16 +346,6 @@ abstract class AstFactory {
TypeArgumentList typeArguments,
@required ArgumentList argumentList});
/// Returns a newly created field declaration. Either or both of the [comment]
/// and [metadata] can be `null` if the declaration does not have the
/// corresponding attribute. The [staticKeyword] can be `null` if the field is
/// not a static field.
///
/// Use [fieldDeclaration2] instead.
@deprecated
FieldDeclaration fieldDeclaration(Comment comment, List<Annotation> metadata,
Token staticKeyword, VariableDeclarationList fieldList, Token semicolon);
/// Returns a newly created field declaration. Either or both of the
/// [comment] and [metadata] can be `null` if the declaration does not have
/// the corresponding attribute. The [staticKeyword] can be `null` if the
@ -370,27 +360,6 @@ abstract class AstFactory {
@required VariableDeclarationList fieldList,
@required Token semicolon});
/// Returns a newly created formal parameter. Either or both of the [comment]
/// and [metadata] can be `null` if the parameter does not have the
/// corresponding attribute. The [keyword] can be `null` if there is a type.
/// The [type] must be `null` if the keyword is 'var'. The [thisKeyword] and
/// [period] can be `null` if the keyword 'this' was not provided. The
/// [parameters] can be `null` if this is not a function-typed field formal
/// parameter.
///
/// Use [fieldFormalParameter2] instead.
@deprecated
FieldFormalParameter fieldFormalParameter(
Comment comment,
List<Annotation> metadata,
Token keyword,
TypeAnnotation type,
Token thisKeyword,
Token period,
SimpleIdentifier identifier,
TypeParameterList typeParameters,
FormalParameterList parameters);
/// Returns a newly created formal parameter. Either or both of the [comment]
/// and [metadata] can be `null` if the parameter does not have the
/// corresponding attribute. The [keyword] can be `null` if there is a type.
@ -508,21 +477,6 @@ abstract class AstFactory {
FormalParameterList parameters,
Token semicolon);
/// Returns a newly created formal parameter. Either or both of the
/// [comment] and [metadata] can be `null` if the parameter does not have the
/// corresponding attribute. The [returnType] can be `null` if no return type
/// was specified.
///
/// Use [functionTypedFormalParameter2] instead.
@deprecated
FunctionTypedFormalParameter functionTypedFormalParameter(
Comment comment,
List<Annotation> metadata,
TypeAnnotation returnType,
SimpleIdentifier identifier,
TypeParameterList typeParameters,
FormalParameterList parameters);
/// Returns a newly created formal parameter. Either or both of the
/// [comment] and [metadata] can be `null` if the parameter does not have the
/// corresponding attribute. The [returnType] can be `null` if no return type
@ -608,12 +562,6 @@ abstract class AstFactory {
List<Combinator> combinators,
Token semicolon);
/// Returns a newly created index expression suitable for use in a cascade
/// expression.
@Deprecated('Use indexExpressionForCascade2')
IndexExpression indexExpressionForCascade(
Token period, Token leftBracket, Expression index, Token rightBracket);
/// Returns a newly created index expression.
IndexExpression indexExpressionForCascade2(
{@required Token period,
@ -622,12 +570,6 @@ abstract class AstFactory {
@required Expression index,
@required Token rightBracket});
/// Returns a newly created index expression suitable for use outside a
/// cascade expression.
@Deprecated('Use indexExpressionForTarget2')
IndexExpression indexExpressionForTarget(Expression target, Token leftBracket,
Expression index, Token rightBracket);
/// Returns a newly created index expression.
IndexExpression indexExpressionForTarget2(
{@required Expression target,
@ -820,20 +762,6 @@ abstract class AstFactory {
ShowCombinator showCombinator(
Token keyword, List<SimpleIdentifier> shownNames);
/// Returns a newly created formal parameter. Either or both of the
/// [comment] and [metadata] can be `null` if the parameter does not have the
/// corresponding attribute. The [keyword] can be `null` if a type was
/// specified. The [type] must be `null` if the keyword is 'var'.
///
/// Use [simpleFormalParameter2] instead.
@deprecated
SimpleFormalParameter simpleFormalParameter(
Comment comment,
List<Annotation> metadata,
Token keyword,
TypeAnnotation type,
SimpleIdentifier identifier);
/// Returns a newly created formal parameter. Either or both of the
/// [comment] and [metadata] can be `null` if the parameter does not have the
/// corresponding attribute. The [keyword] can be `null` if a type was

View file

@ -81,13 +81,6 @@ abstract class ClassElement
/// instance field.
bool get hasNonFinalField;
/// Return `true` if this class has at least one reference to `super` (and
/// hence cannot be used as a mixin), or `false` if this element represents a
/// mixin, even if the mixin has a reference to `super`, because it is allowed
/// to be used as a mixin.
@Deprecated('It was used internally, should not be part of API')
bool get hasReferenceToSuper;
/// Return `true` if this class declares a static member.
bool get hasStaticMember;
@ -121,19 +114,6 @@ abstract class ClassElement
/// application if it was declared using the syntax "class A = B with C;".
bool get isMixinApplication;
/// Return `true` if this class [isProxy], or if it inherits the proxy
/// annotation from a supertype.
@Deprecated(
'The @proxy annotation is deprecated in the langauge, and will be removed',
)
bool get isOrInheritsProxy;
/// Return `true` if this element has an annotation of the form '@proxy'.
@Deprecated(
'The @proxy annotation is deprecated in the langauge, and will be removed',
)
bool get isProxy;
/// Return `true` if this class can validly be used as a mixin when defining
/// another class. For classes defined by a mixin declaration, the result is
/// always `true`. For classes defined by a class declaration or a mixin
@ -195,10 +175,6 @@ abstract class ClassElement
/// nullability status of the declaring library.
InterfaceType get thisType;
@override
@deprecated
InterfaceType get type;
/// Return the unnamed constructor declared in this class, or `null` if either
/// this class does not declare an unnamed constructor but does declare named
/// constructors or if this class represents a mixin declaration. The returned
@ -239,14 +215,6 @@ abstract class ClassElement
@required NullabilitySuffix nullabilitySuffix,
});
/// Create the [InterfaceType] for this class with type arguments that
/// correspond to the bounds of the type parameters, and the given
/// [nullabilitySuffix].
@Deprecated('Use TypeSystem.instantiateToBounds2() instead')
InterfaceType instantiateToBounds({
@required NullabilitySuffix nullabilitySuffix,
});
/// Return the element representing the method that results from looking up
/// the given [methodName] in this class with respect to the given [library],
/// ignoring abstract methods, or `null` if the look up fails. The behavior of
@ -664,12 +632,6 @@ abstract class Element implements AnalysisTarget {
/// by the visitor as a result of visiting this element.
T accept<T>(ElementVisitor<T> visitor);
/// Return the most immediate ancestor of this element for which the
/// [predicate] returns `true`, or `null` if there is no such ancestor. Note
/// that this element will never be returned.
@Deprecated('Use either thisOrAncestorMatching or thisOrAncestorOfType')
E getAncestor<E extends Element>(Predicate<Element> predicate);
/// Return the presentation of this element as it should appear when
/// presented to users.
///
@ -1170,7 +1132,7 @@ abstract class FunctionElement implements ExecutableElement, LocalElement {
///
/// Clients may not extend, implement or mix-in this class.
abstract class FunctionTypeAliasElement
implements FunctionTypedElement, TypeDefiningElement {
implements TypeParameterizedElement, TypeDefiningElement {
@override
CompilationUnitElement get enclosingElement;
@ -1190,34 +1152,6 @@ abstract class FunctionTypeAliasElement
@required List<DartType> typeArguments,
@required NullabilitySuffix nullabilitySuffix,
});
/// Produces the function type resulting from instantiating this typedef with
/// the given [typeArguments] and [nullabilitySuffix].
///
/// Note that this always instantiates the typedef itself, so for a
/// [GenericTypeAliasElement] the returned [FunctionType] might still be a
/// generic function, with type formals. For example, if the typedef is:
/// typedef F<T> = void Function<U>(T, U);
/// then `F<int>` will produce `void Function<U>(int, U)`.
@Deprecated('Use instantiate() instead')
FunctionType instantiate2({
@required List<DartType> typeArguments,
@required NullabilitySuffix nullabilitySuffix,
});
/// Produces the function type resulting from instantiating this typedef with
/// type arguments that correspond to the bounds of the type parameters, and
/// the given [nullabilitySuffix].
///
/// Note that this always instantiates the typedef itself, so for a
/// [GenericTypeAliasElement] the returned [FunctionType] might still be a
/// generic function, with type formals. For example, if the typedef is:
/// typedef F<T> = void Function<U>(T, U);
/// then `F<int>` will produce `void Function<U>(int, U)`.
@Deprecated('Use TypeSystem.instantiateToBounds2() instead')
FunctionType instantiateToBounds({
@required NullabilitySuffix nullabilitySuffix,
});
}
/// An element that has a [FunctionType] as its [type].
@ -1364,14 +1298,6 @@ abstract class LibraryElement implements Element {
/// The language version for this library.
LibraryLanguageVersion get languageVersion;
/// The major component of the language version for this library.
@Deprecated("Use 'languageVersion'")
int get languageVersionMajor;
/// The minor component of the language version for this library.
@Deprecated("Use 'languageVersion'")
int get languageVersionMinor;
/// Return the element representing the synthetic function `loadLibrary` that
/// is implicitly defined for this library if the library is imported using a
/// deferred import.
@ -1479,10 +1405,6 @@ abstract class MultiplyDefinedElement implements Element {
/// Return a list containing all of the elements that were defined within the
/// scope to have the same name.
List<Element> get conflictingElements;
/// Return the type of this element as the dynamic type.
@deprecated
DartType get type;
}
/// An [ExecutableElement], with the additional information of a list of
@ -1710,11 +1632,7 @@ abstract class TopLevelVariableElement implements PropertyInducingElement {
/// An element that defines a type.
///
/// Clients may not extend, implement or mix-in this class.
abstract class TypeDefiningElement implements Element {
/// Return the type defined by this element.
@deprecated
DartType get type;
}
abstract class TypeDefiningElement implements Element {}
/// A type parameter.
///
@ -1729,10 +1647,6 @@ abstract class TypeParameterElement implements TypeDefiningElement {
@override
TypeParameterElement get declaration;
@override
@deprecated
TypeParameterType get type;
/// Create the [TypeParameterType] with the given [nullabilitySuffix] for
/// this type parameter.
TypeParameterType instantiate({

View file

@ -23,6 +23,7 @@ import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/nullability_suffix.dart';
import 'package:analyzer/dart/element/type_visitor.dart';
import 'package:analyzer/src/dart/element/type.dart' show InterfaceTypeImpl;
import 'package:meta/meta.dart';
/// The type associated with elements in the element model.
///
@ -108,10 +109,6 @@ abstract class DartType {
/// Return `true` if this type represents the type 'dynamic'.
bool get isDynamic;
/// Return `true` if this type represents the type 'Object'.
@Deprecated('Use isDartCoreObject')
bool get isObject;
/// Return `true` if this type represents the type 'void'.
bool get isVoid;
@ -161,7 +158,7 @@ abstract class DartType {
///
/// Clients should not depend on the content of the returned value as it will
/// be changed if doing so would improve the UX.
String getDisplayString({bool withNullability = false});
String getDisplayString({@required bool withNullability});
/// If this type is a [TypeParameterType], returns its bound if it has one, or
/// [objectType] otherwise.
@ -169,27 +166,6 @@ abstract class DartType {
/// For any other type, returns `this`. Applies recursively -- if the bound is
/// itself a type parameter, that is resolved too.
DartType resolveToBound(DartType objectType);
/// Return the type resulting from substituting the given [argumentTypes] for
/// the given [parameterTypes] in this type. The specification defines this
/// operation in section 2:
/// <blockquote>
/// The notation <i>[x<sub>1</sub>, ..., x<sub>n</sub>/y<sub>1</sub>, ...,
/// y<sub>n</sub>]E</i> denotes a copy of <i>E</i> in which all occurrences of
/// <i>y<sub>i</sub>, 1 <= i <= n</i> have been replaced with
/// <i>x<sub>i</sub></i>.
/// </blockquote>
/// Note that, contrary to the specification, this method will not create a
/// copy of this type if no substitutions were required, but will return this
/// type directly.
///
/// Note too that the current implementation of this method is only guaranteed
/// to work when the parameter types are type variables.
@Deprecated("""
Use ClassElement.instantiate() or FunctionTypeAliasElement.instantiate()
""")
DartType substitute2(
List<DartType> argumentTypes, List<DartType> parameterTypes);
}
/// The type `dynamic` is a type which is a supertype of all other types, just
@ -212,10 +188,6 @@ abstract class DynamicType implements DartType {}
///
/// Clients may not extend, implement or mix-in this class.
abstract class FunctionType implements ParameterizedType {
/// Deprecated: use [typeFormals].
@deprecated
List<TypeParameterElement> get boundTypeParameters;
/// Return a map from the names of named parameters to the types of the named
/// parameters of this type of function. The entries in the map will be
/// iterated in the same order as the order in which the named parameters were
@ -260,19 +232,10 @@ abstract class FunctionType implements ParameterizedType {
/// from the perspective of this function type.
List<TypeParameterElement> get typeFormals;
@override
/// Produces a new function type by substituting type parameters of this
/// function type with the given [typeArguments]. The resulting function
/// type will have no type parameters.
FunctionType instantiate(List<DartType> argumentTypes);
@Deprecated("Use FunctionTypeAliasElement.instantiate()")
@override
FunctionType substitute2(
List<DartType> argumentTypes, List<DartType> parameterTypes);
/// Return the type resulting from substituting the given [argumentTypes] for
/// this type's parameters. This is fully equivalent to
/// `substitute(argumentTypes, getTypeArguments())`.
@deprecated // use instantiate
FunctionType substitute3(List<DartType> argumentTypes);
}
/// The type introduced by either a class or an interface, or a reference to
@ -337,10 +300,6 @@ abstract class InterfaceType implements ParameterizedType {
/// with the given name.
PropertyAccessorElement getSetter(String name);
@Deprecated("Use ClassElement.instantiate()")
@override
InterfaceType instantiate(List<DartType> argumentTypes);
/// Return the element representing the constructor that results from looking
/// up the constructor with the given [name] in this class with respect to the
/// given [library], or `null` if the look up fails. The behavior of this
@ -565,17 +524,6 @@ abstract class InterfaceType implements ParameterizedType {
PropertyAccessorElement lookUpSetterInSuperclass(
String name, LibraryElement library);
@Deprecated("Use ClassElement.instantiate()")
@override
InterfaceType substitute2(
List<DartType> argumentTypes, List<DartType> parameterTypes);
/// Return the type resulting from substituting the given arguments for this
/// type's parameters. This is fully equivalent to `substitute2(argumentTypes,
/// getTypeArguments())`.
@deprecated // use instantiate
InterfaceType substitute4(List<DartType> argumentTypes);
/// Returns a "smart" version of the "least upper bound" of the given types.
///
/// If these types have the same element and differ only in terms of the type
@ -611,16 +559,6 @@ abstract class ParameterizedType implements DartType {
/// A [FunctionType] has type arguments only if it is a result of a typedef
/// instantiation, otherwise the result is `null`.
List<DartType> get typeArguments;
/// Return a list containing all of the type parameters declared for this
/// type.
@Deprecated("Use ClassElement.typeParameters or FunctionType.typeFormals")
List<TypeParameterElement> get typeParameters;
/// Return the type resulting from instantiating (replacing) the given
/// [argumentTypes] for this type's bound type parameters.
@Deprecated("Use ClassElement.instantiate()")
ParameterizedType instantiate(List<DartType> argumentTypes);
}
/// The type introduced by a type parameter.
@ -644,9 +582,4 @@ abstract class TypeParameterType implements DartType {
/// The special type `void` is used to indicate that the value of an
/// expression is meaningless, and intended to be discarded.
abstract class VoidType implements DartType {
@override
@deprecated
VoidType substitute2(
List<DartType> argumentTypes, List<DartType> parameterTypes);
}
abstract class VoidType implements DartType {}

View file

@ -4,7 +4,6 @@
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/src/dart/constant/value.dart';
/// The interface `TypeProvider` defines the behavior of objects that provide
/// access to types defined by the language.
@ -50,14 +49,6 @@ abstract class TypeProvider {
/// Return the type representing 'FutureOr<Null>'.
InterfaceType get futureOrNullType;
/// Return the type representing the built-in type 'FutureOr'.
@Deprecated('Use futureOrType2() instead.')
InterfaceType get futureOrType;
/// Return the type representing the built-in type 'Future'.
@Deprecated('Use futureType2() instead.')
InterfaceType get futureType;
/// Return the element representing the built-in class 'int'.
ClassElement get intElement;
@ -73,27 +64,15 @@ abstract class TypeProvider {
/// Return the type representing the type 'Iterable<Object>'.
InterfaceType get iterableObjectType;
/// Return the type representing the built-in type 'Iterable'.
@Deprecated('Use iterableType2() instead.')
InterfaceType get iterableType;
/// Return the element representing the built-in class 'List'.
ClassElement get listElement;
/// Return the type representing the built-in type 'List'.
@Deprecated('Use listType2() instead.')
InterfaceType get listType;
/// Return the element representing the built-in class 'Map'.
ClassElement get mapElement;
/// Return the type representing 'Map<Object, Object>'.
InterfaceType get mapObjectObjectType;
/// Return the type representing the built-in type 'Map'.
@Deprecated('Use mapType2() instead.')
InterfaceType get mapType;
/// Return the type representing the built-in type 'Never'.
DartType get neverType;
@ -101,18 +80,9 @@ abstract class TypeProvider {
/// or implemented.
Set<ClassElement> get nonSubtypableClasses;
/// Return a list containing all of the types that cannot be either extended
/// or implemented.
@Deprecated('Use nonSubtypableClasses instead.')
List<InterfaceType> get nonSubtypableTypes;
/// Return the element representing the built-in class 'null'.
ClassElement get nullElement;
/// Return a [DartObjectImpl] representing the `null` object.
@deprecated
DartObjectImpl get nullObject;
/// Return the type representing the built-in type 'Null'.
InterfaceType get nullType;
@ -128,10 +98,6 @@ abstract class TypeProvider {
/// Return the element representing the built-in class 'Set'.
ClassElement get setElement;
/// Return the type representing the built-in type 'Set'.
@Deprecated('Use setType2() instead.')
InterfaceType get setType;
/// Return the type representing the built-in type 'StackTrace'.
InterfaceType get stackTraceType;
@ -141,10 +107,6 @@ abstract class TypeProvider {
/// Return the element representing the built-in class 'Stream'.
ClassElement get streamElement;
/// Return the type representing the built-in type 'Stream'.
@Deprecated('Use streamType2() instead.')
InterfaceType get streamType;
/// Return the element representing the built-in class 'String'.
ClassElement get stringElement;

View file

@ -1,15 +0,0 @@
// 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.
@deprecated
library analyzer.plugin.embedded_resolver_provider;
import 'package:analyzer/file_system/file_system.dart';
import 'package:analyzer/source/embedder.dart';
/// A function that will return a [UriResolver] that can be used to resolve
/// URI's for embedded libraries within a given folder, or `null` if we should
/// fall back to the standard URI resolver.
@deprecated
typedef EmbeddedResolverProvider = EmbedderUriResolver Function(Folder folder);

View file

@ -1,8 +0,0 @@
// Copyright (c) 2015, 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.
@deprecated
library analyzer.src.analysis_options.analysis_options_provider;
export 'package:analyzer/src/analysis_options/analysis_options_provider.dart';

View file

@ -1,8 +0,0 @@
// 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.
@deprecated
library analyzer.source.custom_resolver;
export 'package:analyzer/src/source/custom_resolver.dart';

View file

@ -1,194 +0,0 @@
// Copyright (c) 2015, 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.
@deprecated
library analyzer.source.embedder;
import 'dart:collection' show HashMap;
import 'dart:core';
import 'dart:io' as io;
import 'package:analyzer/file_system/file_system.dart';
import 'package:analyzer/source/package_map_provider.dart'
show PackageMapProvider;
import 'package:analyzer/src/generated/java_io.dart' show JavaFile;
import 'package:analyzer/src/generated/sdk.dart';
import 'package:analyzer/src/generated/sdk_io.dart';
import 'package:analyzer/src/generated/source.dart';
import 'package:analyzer/src/generated/source_io.dart' show FileBasedSource;
import 'package:analyzer/src/summary/idl.dart' show PackageBundle;
import 'package:pub_semver/src/version.dart';
import 'package:yaml/yaml.dart';
export 'package:analyzer/src/context/builder.dart' show EmbedderYamlLocator;
const String _DART_COLON_PREFIX = 'dart:';
const String _EMBEDDED_LIB_MAP_KEY = 'embedded_libs';
/// Check if this map defines embedded libraries.
@deprecated
bool definesEmbeddedLibs(Map map) => map[_EMBEDDED_LIB_MAP_KEY] != null;
/// An SDK backed by URI mappings derived from an `_embedder.yaml` file.
@deprecated
class EmbedderSdk extends AbstractDartSdk {
final Map<String, String> _urlMappings = HashMap<String, String>();
EmbedderSdk([Map<Folder, YamlMap> embedderYamls]) {
embedderYamls?.forEach(_processEmbedderYaml);
}
@override
String get allowedExperimentsJson {
return null;
}
@override
Version get languageVersion => throw UnimplementedError();
@override
String get sdkVersion => '0';
/// The url mappings for this SDK.
Map<String, String> get urlMappings => _urlMappings;
@override
String getRelativePathFromFile(JavaFile file) => file.getAbsolutePath();
@deprecated
@override
PackageBundle getSummarySdkBundle(bool _) => null;
@override
FileBasedSource internalMapDartUri(String dartUri) {
String libraryName;
String relativePath;
int index = dartUri.indexOf('/');
if (index >= 0) {
libraryName = dartUri.substring(0, index);
relativePath = dartUri.substring(index + 1);
} else {
libraryName = dartUri;
relativePath = "";
}
SdkLibrary library = getSdkLibrary(libraryName);
if (library == null) {
return null;
}
String srcPath;
if (relativePath.isEmpty) {
srcPath = library.path;
} else {
String libraryPath = library.path;
int index = libraryPath.lastIndexOf(io.Platform.pathSeparator);
if (index == -1) {
index = libraryPath.lastIndexOf('/');
if (index == -1) {
return null;
}
}
String prefix = libraryPath.substring(0, index + 1);
srcPath = '$prefix$relativePath';
}
String filePath = srcPath.replaceAll('/', io.Platform.pathSeparator);
try {
JavaFile file = JavaFile(filePath);
return FileBasedSource(file, Uri.parse(dartUri));
} on FormatException {
return null;
}
}
/// Install the mapping from [name] to [libDir]/[file].
void _processEmbeddedLibs(String name, String file, Folder libDir) {
if (!name.startsWith(_DART_COLON_PREFIX)) {
// SDK libraries must begin with 'dart:'.
return;
}
String libPath = libDir.canonicalizePath(file);
_urlMappings[name] = libPath;
SdkLibraryImpl library = SdkLibraryImpl(name);
library.path = libPath;
libraryMap.setLibrary(name, library);
}
/// Given the 'embedderYamls' from [EmbedderYamlLocator] check each one for the
/// top level key 'embedded_libs'. Under the 'embedded_libs' key are key value
/// pairs. Each key is a 'dart:' library uri and each value is a path
/// (relative to the directory containing `_embedder.yaml`) to a dart script
/// for the given library. For example:
///
/// embedded_libs:
/// 'dart:io': '../../sdk/io/io.dart'
///
/// If a key doesn't begin with `dart:` it is ignored.
void _processEmbedderYaml(Folder libDir, YamlMap map) {
YamlNode embedded_libs = map[_EMBEDDED_LIB_MAP_KEY];
if (embedded_libs is YamlMap) {
embedded_libs.forEach((k, v) => _processEmbeddedLibs(k, v, libDir));
}
}
}
/// Given the 'embedderYamls' from [EmbedderYamlLocator] check each one for the
/// top level key 'embedded_libs'. Under the 'embedded_libs' key are key value
/// pairs. Each key is a 'dart:' library uri and each value is a path
/// (relative to the directory containing `_embedder.yaml`) to a dart script
/// for the given library. For example:
///
/// embedded_libs:
/// 'dart:io': '../../sdk/io/io.dart'
///
/// If a key doesn't begin with `dart:` it is ignored.
///
/// This class is deprecated; use DartUriResolver directly. In particular, if
/// there used to be an instance creation of the form:
///
/// ```
/// new EmbedderUriResolver(embedderMap)
/// ```
///
/// This should be replaced by
///
/// ```
/// new DartUriResolver(new EmbedderSdk(embedderMap))
/// ```
@deprecated
class EmbedderUriResolver implements DartUriResolver {
EmbedderSdk _embedderSdk;
DartUriResolver _dartUriResolver;
/// Construct a [EmbedderUriResolver] from a package map
/// (see [PackageMapProvider]).
EmbedderUriResolver(Map<Folder, YamlMap> embedderMap)
: this._forSdk(EmbedderSdk(embedderMap));
/// (Provisional API.)
EmbedderUriResolver._forSdk(this._embedderSdk) {
_dartUriResolver = DartUriResolver(_embedderSdk);
}
@override
DartSdk get dartSdk => _embedderSdk;
/// Number of embedded libraries.
int get length => _embedderSdk?.urlMappings?.length ?? 0;
@override
void clearCache() {}
@override
Source resolveAbsolute(Uri uri, [Uri actualUri]) =>
_dartUriResolver.resolveAbsolute(uri, actualUri);
@override
Uri restoreAbsolute(Source source) {
String path = source.fullName;
if (path.length > 3 && path[1] == ':' && path[2] == '\\') {
path = '/${path[0]}:${path.substring(2).replaceAll('\\', '/')}';
}
Source sdkSource = dartSdk.fromFileUri(Uri.parse('file://$path'));
return sdkSource?.uri;
}
}

View file

@ -1,8 +0,0 @@
// 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.
@deprecated
library analyzer.source.package_map_provider;
export 'package:analyzer/src/source/package_map_provider.dart';

View file

@ -1,8 +0,0 @@
// 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.
@deprecated
library src.source.package_map_provider;
export 'package:analyzer/src/source/package_map_resolver.dart';

View file

@ -1,8 +0,0 @@
// Copyright (c) 2015, 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.
@deprecated
library analyzer.source.path_filter;
export 'package:analyzer/src/source/path_filter.dart';

View file

@ -54,7 +54,7 @@ void applyAnalysisOptionFlags(AnalysisOptionsImpl options, ArgResults args,
}
}
/// Use the command-line [args] to create a context builder.
/// Use the command-line [args] to create a context builder options.
ContextBuilderOptions createContextBuilderOptions(
ResourceProvider resourceProvider,
ArgResults args,

View file

@ -40,12 +40,6 @@ class AnalysisContextImpl implements AnalysisContext {
throw StateError('Cannot be changed.');
}
@Deprecated('Use LibraryElement.typeProvider')
@override
TypeProvider get typeProvider {
return _synchronousSession.typeProvider;
}
TypeProviderImpl get typeProviderLegacy {
return _synchronousSession.typeProviderLegacy;
}
@ -54,12 +48,6 @@ class AnalysisContextImpl implements AnalysisContext {
return _synchronousSession.typeProviderNonNullableByDefault;
}
@Deprecated('Use LibraryElement.typeSystem')
@override
TypeSystemImpl get typeSystem {
return _synchronousSession.typeSystem;
}
TypeSystemImpl get typeSystemLegacy {
return _synchronousSession.typeSystemLegacy;
}

View file

@ -4,29 +4,14 @@
import 'dart:collection';
import 'package:analyzer/dart/analysis/analysis_context.dart';
import 'package:analyzer/dart/analysis/context_locator.dart';
import 'package:analyzer/dart/analysis/context_root.dart';
import 'package:analyzer/file_system/file_system.dart';
import 'package:analyzer/file_system/physical_file_system.dart'
show PhysicalResourceProvider;
import 'package:analyzer/src/context/builder.dart'
show ContextBuilder, ContextBuilderOptions;
import 'package:analyzer/src/context/context_root.dart' as old;
import 'package:analyzer/src/dart/analysis/byte_store.dart'
show MemoryByteStore;
import 'package:analyzer/src/dart/analysis/context_root.dart';
import 'package:analyzer/src/dart/analysis/driver.dart'
show AnalysisDriver, AnalysisDriverScheduler;
import 'package:analyzer/src/dart/analysis/driver_based_analysis_context.dart';
import 'package:analyzer/src/dart/analysis/file_state.dart'
show FileContentOverlay;
import 'package:analyzer/src/dart/analysis/performance_logger.dart'
show PerformanceLog;
import 'package:analyzer/src/generated/sdk.dart' show DartSdkManager;
import 'package:analyzer/src/task/options.dart';
import 'package:analyzer/src/util/yaml.dart';
import 'package:cli_util/cli_util.dart';
import 'package:glob/glob.dart';
import 'package:meta/meta.dart';
import 'package:path/path.dart';
@ -56,53 +41,6 @@ class ContextLocatorImpl implements ContextLocator {
: resourceProvider =
resourceProvider ?? PhysicalResourceProvider.INSTANCE;
@deprecated
@override
List<AnalysisContext> locateContexts(
{@required List<String> includedPaths,
List<String> excludedPaths = const <String>[],
String optionsFile,
String packagesFile,
String sdkPath}) {
// TODO(scheglov) Remove this, and make `sdkPath` required.
sdkPath ??= getSdkPath();
ArgumentError.checkNotNull(sdkPath, 'sdkPath');
List<ContextRoot> roots = locateRoots(
includedPaths: includedPaths,
excludedPaths: excludedPaths,
optionsFile: optionsFile,
packagesFile: packagesFile);
if (roots.isEmpty) {
return const <AnalysisContext>[];
}
PerformanceLog performanceLog = PerformanceLog(StringBuffer());
AnalysisDriverScheduler scheduler = AnalysisDriverScheduler(performanceLog);
DartSdkManager sdkManager = DartSdkManager(sdkPath);
scheduler.start();
ContextBuilderOptions options = ContextBuilderOptions();
ContextBuilder builder =
ContextBuilder(resourceProvider, sdkManager, null, options: options);
if (packagesFile != null) {
options.defaultPackageFilePath = packagesFile;
}
builder.analysisDriverScheduler = scheduler;
builder.byteStore = MemoryByteStore();
builder.fileContentOverlay = FileContentOverlay();
builder.performanceLog = performanceLog;
List<AnalysisContext> contextList = <AnalysisContext>[];
for (ContextRoot root in roots) {
old.ContextRoot contextRoot = old.ContextRoot(
root.root.path, root.excludedPaths.toList(),
pathContext: resourceProvider.pathContext);
AnalysisDriver driver = builder.buildDriver(contextRoot);
DriverBasedAnalysisContext context =
DriverBasedAnalysisContext(resourceProvider, root, driver);
contextList.add(context);
}
return contextList;
}
@override
List<ContextRoot> locateRoots(
{@required List<String> includedPaths,

View file

@ -39,31 +39,11 @@ class DriverBasedAnalysisContext implements AnalysisContext {
@override
AnalysisSession get currentSession => driver.currentSession;
@deprecated
@override
List<String> get excludedPaths => contextRoot.excludedPaths.toList();
@deprecated
@override
List<String> get includedPaths => contextRoot.includedPaths.toList();
@override
Workspace get workspace {
return _workspace ??= _buildWorkspace();
}
@deprecated
@override
Iterable<String> analyzedFiles() {
return contextRoot.analyzedFiles();
}
@deprecated
@override
bool isAnalyzed(String path) {
return contextRoot.isAnalyzed(path);
}
Workspace _buildWorkspace() {
String path = contextRoot.root.path;
ContextBuilder builder = ContextBuilder(

View file

@ -33,7 +33,7 @@ class ExperimentStatus with _CurrentState implements FeatureSet {
static final Version currentVersion = Version.parse(_currentVersion);
/// A map containing information about all known experimental flags.
static const Map<String, ExperimentalFeature> knownFeatures = _knownFeatures;
static final Map<String, ExperimentalFeature> knownFeatures = _knownFeatures;
final List<bool> _enableFlags;

View file

@ -11,7 +11,7 @@ part of 'experiments.dart';
const _currentVersion = '2.10.0';
/// A map containing information about all known experimental flags.
const _knownFeatures = <String, ExperimentalFeature>{
final _knownFeatures = <String, ExperimentalFeature>{
EnableString.constant_update_2018: ExperimentalFeatures.constant_update_2018,
EnableString.control_flow_collections:
ExperimentalFeatures.control_flow_collections,
@ -74,94 +74,104 @@ class EnableString {
}
class ExperimentalFeatures {
static const constant_update_2018 = ExperimentalFeature(
static final constant_update_2018 = ExperimentalFeature(
index: 0,
enableString: EnableString.constant_update_2018,
isEnabledByDefault: IsEnabledByDefault.constant_update_2018,
isExpired: IsExpired.constant_update_2018,
documentation: 'Enhanced constant expressions',
firstSupportedVersion: '2.4.1',
experimentalReleaseVersion: null,
releaseVersion: Version.parse('2.4.1'),
);
static const control_flow_collections = ExperimentalFeature(
static final control_flow_collections = ExperimentalFeature(
index: 1,
enableString: EnableString.control_flow_collections,
isEnabledByDefault: IsEnabledByDefault.control_flow_collections,
isExpired: IsExpired.control_flow_collections,
documentation: 'Control Flow Collections',
firstSupportedVersion: '2.2.2',
experimentalReleaseVersion: null,
releaseVersion: Version.parse('2.2.2'),
);
static const extension_methods = ExperimentalFeature(
static final extension_methods = ExperimentalFeature(
index: 2,
enableString: EnableString.extension_methods,
isEnabledByDefault: IsEnabledByDefault.extension_methods,
isExpired: IsExpired.extension_methods,
documentation: 'Extension Methods',
firstSupportedVersion: '2.6.0',
experimentalReleaseVersion: null,
releaseVersion: Version.parse('2.6.0'),
);
static const non_nullable = ExperimentalFeature(
static final non_nullable = ExperimentalFeature(
index: 3,
enableString: EnableString.non_nullable,
isEnabledByDefault: IsEnabledByDefault.non_nullable,
isExpired: IsExpired.non_nullable,
documentation: 'Non Nullable by default',
firstSupportedVersion: null,
experimentalReleaseVersion: null,
releaseVersion: null,
);
static const nonfunction_type_aliases = ExperimentalFeature(
static final nonfunction_type_aliases = ExperimentalFeature(
index: 4,
enableString: EnableString.nonfunction_type_aliases,
isEnabledByDefault: IsEnabledByDefault.nonfunction_type_aliases,
isExpired: IsExpired.nonfunction_type_aliases,
documentation: 'Type aliases define a <type>, not just a <functionType>',
firstSupportedVersion: null,
experimentalReleaseVersion: null,
releaseVersion: null,
);
static const set_literals = ExperimentalFeature(
static final set_literals = ExperimentalFeature(
index: 5,
enableString: EnableString.set_literals,
isEnabledByDefault: IsEnabledByDefault.set_literals,
isExpired: IsExpired.set_literals,
documentation: 'Set Literals',
firstSupportedVersion: '2.2.0',
experimentalReleaseVersion: null,
releaseVersion: Version.parse('2.2.0'),
);
static const spread_collections = ExperimentalFeature(
static final spread_collections = ExperimentalFeature(
index: 6,
enableString: EnableString.spread_collections,
isEnabledByDefault: IsEnabledByDefault.spread_collections,
isExpired: IsExpired.spread_collections,
documentation: 'Spread Collections',
firstSupportedVersion: '2.2.2',
experimentalReleaseVersion: null,
releaseVersion: Version.parse('2.2.2'),
);
static const triple_shift = ExperimentalFeature(
static final triple_shift = ExperimentalFeature(
index: 7,
enableString: EnableString.triple_shift,
isEnabledByDefault: IsEnabledByDefault.triple_shift,
isExpired: IsExpired.triple_shift,
documentation: 'Triple-shift operator',
firstSupportedVersion: null,
experimentalReleaseVersion: null,
releaseVersion: null,
);
static const value_class = ExperimentalFeature(
static final value_class = ExperimentalFeature(
index: 8,
enableString: EnableString.value_class,
isEnabledByDefault: IsEnabledByDefault.value_class,
isExpired: IsExpired.value_class,
documentation: 'Value class',
firstSupportedVersion: null,
experimentalReleaseVersion: null,
releaseVersion: null,
);
static const variance = ExperimentalFeature(
static final variance = ExperimentalFeature(
index: 9,
enableString: EnableString.variance,
isEnabledByDefault: IsEnabledByDefault.variance,
isExpired: IsExpired.variance,
documentation: 'Sound variance',
firstSupportedVersion: null,
experimentalReleaseVersion: null,
releaseVersion: null,
);
}

View file

@ -127,8 +127,8 @@ List<bool> restrictEnableFlagsToVersion(List<bool> flags, Version version) {
flags = List.from(flags);
for (var feature in _knownFeatures.values) {
var firstSupportedVersion = feature.firstSupportedVersion;
if (firstSupportedVersion == null || firstSupportedVersion > version) {
var releaseVersion = feature.releaseVersion;
if (releaseVersion == null || releaseVersion > version) {
flags[feature.index] = false;
}
}
@ -299,20 +299,25 @@ class ExperimentalFeature implements Feature {
/// Documentation for the feature, if known. `null` for expired flags.
final String documentation;
final String _firstSupportedVersion;
/// The first language version in which this feature can be enabled using
/// the [enableString] experimental flag.
final Version experimentalReleaseVersion;
const ExperimentalFeature({
@override
final Version releaseVersion;
ExperimentalFeature({
@required this.index,
@required this.enableString,
@required this.isEnabledByDefault,
@required this.isExpired,
@required this.documentation,
@required String firstSupportedVersion,
}) : _firstSupportedVersion = firstSupportedVersion,
assert(index != null),
@required this.experimentalReleaseVersion,
@required this.releaseVersion,
}) : assert(index != null),
assert(isEnabledByDefault
? firstSupportedVersion != null
: firstSupportedVersion == null),
? releaseVersion != null
: releaseVersion == null),
assert(enableString != null);
/// The string to disable the feature.
@ -321,15 +326,6 @@ class ExperimentalFeature implements Feature {
@override
String get experimentalFlag => isExpired ? null : enableString;
@override
Version get firstSupportedVersion {
if (_firstSupportedVersion == null) {
return null;
} else {
return Version.parse(_firstSupportedVersion);
}
}
@override
FeatureStatus get status {
if (isExpired) {

View file

@ -16,7 +16,6 @@ import 'package:analyzer/src/dart/analysis/driver.dart' as driver;
import 'package:analyzer/src/dart/analysis/uri_converter.dart';
import 'package:analyzer/src/dart/element/class_hierarchy.dart';
import 'package:analyzer/src/dart/element/inheritance_manager3.dart';
import 'package:analyzer/src/dart/element/type_provider.dart';
import 'package:analyzer/src/dart/element/type_system.dart';
import 'package:analyzer/src/generated/engine.dart' show AnalysisOptionsImpl;
import 'package:analyzer/src/generated/source.dart';
@ -27,12 +26,6 @@ class AnalysisSessionImpl implements AnalysisSession {
/// The analysis driver performing analysis for this session.
final driver.AnalysisDriver _driver;
/// The type provider being used by the analysis driver.
TypeProvider _typeProvider;
/// The type system being used by the analysis driver.
TypeSystemImpl _typeSystem;
/// The URI converter used to convert between URI's and file paths.
UriConverter _uriConverter;
@ -54,41 +47,6 @@ class AnalysisSessionImpl implements AnalysisSession {
@override
ResourceProvider get resourceProvider => _driver.resourceProvider;
@override
SourceFactory get sourceFactory => _driver.sourceFactory;
@Deprecated('Use LibraryElement.typeProvider')
@override
Future<TypeProvider> get typeProvider async {
_checkConsistency();
if (_typeProvider == null) {
LibraryElement coreLibrary = await _driver.getLibraryByUri('dart:core');
LibraryElement asyncLibrary = await _driver.getLibraryByUri('dart:async');
_typeProvider = TypeProviderImpl(
coreLibrary: coreLibrary,
asyncLibrary: asyncLibrary,
isNonNullableByDefault: false,
);
}
return _typeProvider;
}
@Deprecated('Use LibraryElement.typeSystem')
@override
Future<TypeSystemImpl> get typeSystem async {
_checkConsistency();
if (_typeSystem == null) {
var typeProvider = await this.typeProvider;
_typeSystem = TypeSystemImpl(
implicitCasts: true,
isNonNullableByDefault: false,
strictInference: false,
typeProvider: typeProvider,
);
}
return _typeSystem;
}
@override
UriConverter get uriConverter {
return _uriConverter ??= DriverBasedUriConverter(_driver);
@ -126,14 +84,6 @@ class AnalysisSessionImpl implements AnalysisSession {
return libraryElement;
}
@deprecated
@override
Future<ParseResult> getParsedAst(String path) async => getParsedUnit(path);
@deprecated
@override
ParseResult getParsedAstSync(String path) => getParsedUnit(path);
@override
ParsedLibraryResult getParsedLibrary(String path) {
_checkConsistency();
@ -153,10 +103,6 @@ class AnalysisSessionImpl implements AnalysisSession {
return _driver.parseFileSync(path);
}
@deprecated
@override
Future<ResolveResult> getResolvedAst(String path) => getResolvedUnit(path);
@override
Future<ResolvedLibraryResult> getResolvedLibrary(String path) {
_checkConsistency();
@ -244,9 +190,6 @@ class SynchronousSession {
);
}
@Deprecated('Use LibraryElement.typeProvider')
TypeProvider get typeProvider => _typeProviderLegacy;
TypeProvider get typeProviderLegacy {
return _typeProviderLegacy;
}
@ -255,11 +198,6 @@ class SynchronousSession {
return _typeProviderNonNullableByDefault;
}
@Deprecated('Use LibraryElement.typeSystem')
TypeSystemImpl get typeSystem {
return typeSystemLegacy;
}
TypeSystemImpl get typeSystemLegacy {
return _typeSystemLegacy;
}

View file

@ -2304,16 +2304,6 @@ class ConfigurationImpl extends AstNodeImpl implements Configuration {
@override
Token get endToken => _uri.endToken;
@deprecated
@override
StringLiteral get libraryUri => _uri;
@deprecated
@override
set libraryUri(StringLiteral libraryUri) {
_uri = _becomeParentOf(libraryUri as StringLiteralImpl);
}
@override
DottedName get name => _name;
@ -2485,12 +2475,6 @@ class ConstructorDeclarationImpl extends ClassMemberImpl
..add(_redirectedConstructor)
..add(_body);
@deprecated
@override
set element(ConstructorElement element) {
declaredElement = element;
}
@override
Token get endToken {
if (_body != null) {
@ -4346,7 +4330,7 @@ abstract class FormalParameterImpl extends AstNodeImpl
@override
bool get isRequiredPositional => kind.isRequiredPositional;
@override
/// Return the kind of this parameter.
ParameterKind get kind;
}
@ -4930,12 +4914,6 @@ class FunctionExpressionImpl extends ExpressionImpl
Iterable<SyntacticEntity> get childEntities =>
ChildEntities()..add(_parameters)..add(_body);
@deprecated
@override
set element(ExecutableElement element) {
declaredElement = element;
}
@override
Token get endToken {
if (_body != null) {
@ -6051,14 +6029,6 @@ class InstanceCreationExpressionImpl extends ExpressionImpl
@override
Precedence get precedence => Precedence.primary;
@Deprecated('Use constructorName.staticElement')
@override
ConstructorElement get staticElement => constructorName.staticElement;
@Deprecated('Use constructorName.staticElement')
@override
set staticElement(ConstructorElement staticElement) {}
/// Return the type arguments associated with the constructor, rather than
/// with the class in which the constructor is defined. It is always an error
/// if there are type arguments because Dart doesn't currently support generic
@ -7384,16 +7354,6 @@ abstract class NamespaceDirectiveImpl extends UriBasedDirectiveImpl
@override
Token get firstTokenAfterCommentAndMetadata => keyword;
@deprecated
@override
Source get source => selectedSource;
@deprecated
@override
set source(Source source) {
selectedSource = source;
}
@override
LibraryElement get uriElement;
}
@ -7498,7 +7458,7 @@ class NativeFunctionBodyImpl extends FunctionBodyImpl
/// A list of AST nodes that have a common parent.
class NodeListImpl<E extends AstNode> with ListMixin<E> implements NodeList<E> {
/// The node that is the parent of each of the elements in the list.
AstNodeImpl _owner;
final AstNodeImpl _owner;
/// The elements contained in the list.
List<E> _elements = <E>[];
@ -7530,7 +7490,6 @@ class NodeListImpl<E extends AstNode> with ListMixin<E> implements NodeList<E> {
@override
int get length => _elements.length;
@deprecated // Never intended for public use.
@override
set length(int newLength) {
throw UnsupportedError("Cannot resize NodeList.");
@ -7539,11 +7498,6 @@ class NodeListImpl<E extends AstNode> with ListMixin<E> implements NodeList<E> {
@override
AstNode get owner => _owner;
@override
set owner(AstNode value) {
_owner = value as AstNodeImpl;
}
@override
E operator [](int index) {
if (index < 0 || index >= _elements.length) {
@ -10398,16 +10352,6 @@ abstract class UriBasedDirectiveImpl extends DirectiveImpl
_uri = _becomeParentOf(uri);
}
@deprecated
@override
Source get source => uriSource;
@deprecated
@override
set source(Source source) {
uriSource = source;
}
@override
StringLiteral get uri => _uri;

View file

@ -386,16 +386,6 @@ class AstFactoryImpl extends AstFactory {
@required ArgumentList argumentList}) =>
ExtensionOverrideImpl(extensionName, typeArguments, argumentList);
@override
FieldDeclaration fieldDeclaration(
Comment comment,
List<Annotation> metadata,
Token staticKeyword,
VariableDeclarationList fieldList,
Token semicolon) =>
FieldDeclarationImpl(comment, metadata, null, null, null, staticKeyword,
fieldList, semicolon);
@override
FieldDeclaration fieldDeclaration2(
{Comment comment,
@ -409,20 +399,6 @@ class AstFactoryImpl extends AstFactory {
FieldDeclarationImpl(comment, metadata, abstractKeyword, covariantKeyword,
externalKeyword, staticKeyword, fieldList, semicolon);
@override
FieldFormalParameter fieldFormalParameter(
Comment comment,
List<Annotation> metadata,
Token keyword,
TypeAnnotation type,
Token thisKeyword,
Token period,
SimpleIdentifier identifier,
TypeParameterList typeParameters,
FormalParameterList parameters) =>
FieldFormalParameterImpl(comment, metadata, null, null, keyword, type,
thisKeyword, period, identifier, typeParameters, parameters, null);
@override
FieldFormalParameter fieldFormalParameter2(
{Comment comment,
@ -558,17 +534,6 @@ class AstFactoryImpl extends AstFactory {
FunctionTypeAliasImpl(comment, metadata, keyword, returnType, name,
typeParameters, parameters, semicolon);
@override
FunctionTypedFormalParameter functionTypedFormalParameter(
Comment comment,
List<Annotation> metadata,
TypeAnnotation returnType,
SimpleIdentifier identifier,
TypeParameterList typeParameters,
FormalParameterList parameters) =>
FunctionTypedFormalParameterImpl(comment, metadata, null, null,
returnType, identifier, typeParameters, parameters, null);
@override
FunctionTypedFormalParameter functionTypedFormalParameter2(
{Comment comment,
@ -673,13 +638,6 @@ class AstFactoryImpl extends AstFactory {
combinators,
semicolon);
@override
@Deprecated('Use indexExpressionForCascade2')
IndexExpression indexExpressionForCascade(Token period, Token leftBracket,
Expression index, Token rightBracket) =>
IndexExpressionImpl.forCascade(
period, null, leftBracket, index, rightBracket);
@override
IndexExpression indexExpressionForCascade2(
{@required Token period,
@ -690,13 +648,6 @@ class AstFactoryImpl extends AstFactory {
IndexExpressionImpl.forCascade(
period, question, leftBracket, index, rightBracket);
@override
@Deprecated('Use indexExpressionForTarget2')
IndexExpression indexExpressionForTarget(Expression target, Token leftBracket,
Expression index, Token rightBracket) =>
IndexExpressionImpl.forTarget(
target, null, leftBracket, index, rightBracket);
@override
IndexExpression indexExpressionForTarget2(
{@required Expression target,
@ -925,16 +876,6 @@ class AstFactoryImpl extends AstFactory {
Token keyword, List<SimpleIdentifier> shownNames) =>
ShowCombinatorImpl(keyword, shownNames);
@override
SimpleFormalParameter simpleFormalParameter(
Comment comment,
List<Annotation> metadata,
Token keyword,
TypeAnnotation type,
SimpleIdentifier identifier) =>
SimpleFormalParameterImpl(
comment, metadata, null, null, keyword, type, identifier);
@override
SimpleFormalParameter simpleFormalParameter2(
{Comment comment,

View file

@ -17,40 +17,6 @@ class FromEnvironmentEvaluator {
FromEnvironmentEvaluator(this._typeSystem, this._declaredVariables);
/// Return the value of the variable with the given [name] interpreted as a
/// 'boolean' value. If the variable is not defined (or [name] is `null`), a
/// DartObject representing "unknown" is returned. If the value cannot be
/// parsed as a boolean, a DartObject representing 'null' is returned.
@Deprecated("Clients don't need this functionality")
DartObject getBool(String name) {
String value = _declaredVariables.get(name);
if (value == null) {
return DartObjectImpl(
_typeSystem,
_typeSystem.typeProvider.boolType,
BoolState.UNKNOWN_VALUE,
);
}
if (value == "true") {
return DartObjectImpl(
_typeSystem,
_typeSystem.typeProvider.boolType,
BoolState.TRUE_STATE,
);
} else if (value == "false") {
return DartObjectImpl(
_typeSystem,
_typeSystem.typeProvider.boolType,
BoolState.FALSE_STATE,
);
}
return DartObjectImpl(
_typeSystem,
_typeSystem.typeProvider.nullType,
NullState.NULL_STATE,
);
}
/// Return the value of the variable with the given [name] interpreted as a
/// 'boolean' value. If the variable is not defined, or the value cannot be
/// parsed as a boolean, return the default value from [namedValues]. If no
@ -84,37 +50,6 @@ class FromEnvironmentEvaluator {
return _defaultValueDefaultValue(constructor);
}
/// Return the value of the variable with the given [name] interpreted as an
/// integer value. If the variable is not defined (or [name] is `null`), a
/// DartObject representing "unknown" is returned. If the value cannot be
/// parsed as an integer, a DartObject representing 'null' is returned.
@Deprecated("Clients don't need this functionality")
DartObject getInt(String name) {
String value = _declaredVariables.get(name);
if (value == null) {
return DartObjectImpl(
_typeSystem,
_typeSystem.typeProvider.intType,
IntState.UNKNOWN_VALUE,
);
}
int bigInteger;
try {
bigInteger = int.parse(value);
} on FormatException {
return DartObjectImpl(
_typeSystem,
_typeSystem.typeProvider.nullType,
NullState.NULL_STATE,
);
}
return DartObjectImpl(
_typeSystem,
_typeSystem.typeProvider.intType,
IntState(bigInteger),
);
}
/// Return the value of the variable with the given [name] interpreted as an
/// integer value. If the variable is not defined, or the value cannot be
/// parsed as an integer, return the default value from [namedValues]. If no
@ -157,28 +92,6 @@ class FromEnvironmentEvaluator {
return defaultDefault;
}
/// Return the value of the variable with the given [name] interpreted as a
/// String value, or `null` if the variable is not defined. Return the value
/// of the variable with the given name interpreted as a String value. If the
/// variable is not defined (or [name] is `null`), a DartObject representing
/// "unknown" is returned.
@Deprecated("Clients don't need this functionality")
DartObject getString(String name) {
String value = _declaredVariables.get(name);
if (value == null) {
return DartObjectImpl(
_typeSystem,
_typeSystem.typeProvider.stringType,
StringState.UNKNOWN_VALUE,
);
}
return DartObjectImpl(
_typeSystem,
_typeSystem.typeProvider.stringType,
StringState(value),
);
}
/// Return the value of the variable with the given [name] interpreted as a
/// string value. If the variable is not defined, or the value cannot be
/// parsed as a boolean, return the default value from [namedValues]. If no

View file

@ -215,20 +215,6 @@ abstract class AbstractClassElementImpl extends ElementImpl
);
}
@Deprecated('Use TypeSystem.instantiateToBounds2() instead')
@override
InterfaceType instantiateToBounds({
@required NullabilitySuffix nullabilitySuffix,
}) {
var typeArguments = typeParameters.map((typeParameter) {
return (typeParameter as TypeParameterElementImpl).defaultType;
}).toList();
return instantiate(
typeArguments: typeArguments,
nullabilitySuffix: nullabilitySuffix,
);
}
@override
MethodElement lookUpConcreteMethod(
String methodName, LibraryElement library) =>
@ -470,9 +456,6 @@ class ClassElementImpl extends AbstractClassElementImpl
/// The superclass of the class, or `null` for [Object].
InterfaceType _supertype;
/// The type defined by the class.
InterfaceType _type;
/// A list containing all of the mixins that are applied to the class being
/// extended in order to derive the superclass of this class.
List<InterfaceType> _mixins;
@ -688,16 +671,6 @@ class ClassElementImpl extends AbstractClassElementImpl
return definingClass != null && !definingClass.isDartCoreObject;
}
@Deprecated('It was used internally, should not be part of API')
@override
bool get hasReferenceToSuper => hasModifier(Modifier.REFERENCES_SUPER);
/// Set whether this class references 'super'.
/// TODO(scheglov) Remove it.
set hasReferenceToSuper(bool isReferencedSuper) {
setModifier(Modifier.REFERENCES_SUPER, isReferencedSuper);
}
@override
bool get hasStaticMember {
for (MethodElement method in methods) {
@ -771,12 +744,6 @@ class ClassElementImpl extends AbstractClassElementImpl
setModifier(Modifier.MIXIN_APPLICATION, isMixinApplication);
}
@override
bool get isOrInheritsProxy => false;
@override
bool get isProxy => false;
@override
bool get isSimplyBounded {
if (linkedNode != null) {
@ -910,22 +877,6 @@ class ClassElementImpl extends AbstractClassElementImpl
_supertype = supertype;
}
@override
@deprecated
InterfaceType get type {
if (_type == null) {
var typeArguments = typeParameters
.map((e) => e.instantiate(nullabilitySuffix: _noneOrStarSuffix))
.toList();
_type = InterfaceTypeImpl(
element: this,
typeArguments: typeArguments,
nullabilitySuffix: NullabilitySuffix.star,
);
}
return _type;
}
/// Set the type parameters defined for this class to the given
/// [typeParameters].
set typeParameters(List<TypeParameterElement> typeParameters) {
@ -2177,7 +2128,6 @@ class ConstructorElementImpl extends ExecutableElementImpl
parameters: parameters,
returnType: returnType,
nullabilitySuffix: _noneOrStarSuffix,
element: this,
);
}
@ -2317,9 +2267,6 @@ class DynamicElementImpl extends ElementImpl implements TypeDefiningElement {
@override
ElementKind get kind => ElementKind.DYNAMIC;
@override
DartType get type => DynamicTypeImpl.instance;
@override
T accept<T>(ElementVisitor<T> visitor) => null;
}
@ -3039,16 +2986,6 @@ abstract class ElementImpl implements Element {
}
}
@Deprecated('Use either thisOrAncestorMatching or thisOrAncestorOfType')
@override
E getAncestor<E extends Element>(Predicate<Element> predicate) {
var ancestor = _enclosingElement;
while (ancestor != null && !predicate(ancestor)) {
ancestor = ancestor.enclosingElement;
}
return ancestor as E;
}
/// Return the child of this element that is uniquely identified by the given
/// [identifier], or `null` if there is no such child.
ElementImpl getChild(String identifier) => null;
@ -3311,9 +3248,6 @@ class ElementLocationImpl implements ElementLocation {
/// An [AbstractClassElementImpl] which is an enum.
class EnumElementImpl extends AbstractClassElementImpl {
/// The type defined by the enum.
InterfaceType _type;
/// Initialize a newly created class element to have the given [name] at the
/// given [offset] in the file that contains the declaration of this element.
EnumElementImpl(String name, int offset) : super(name, offset);
@ -3397,10 +3331,6 @@ class EnumElementImpl extends AbstractClassElementImpl {
@override
bool get hasNonFinalField => false;
@Deprecated('It was used internally, should not be part of API')
@override
bool get hasReferenceToSuper => false;
@override
bool get hasStaticMember => true;
@ -3416,12 +3346,6 @@ class EnumElementImpl extends AbstractClassElementImpl {
@override
bool get isMixinApplication => false;
@override
bool get isOrInheritsProxy => false;
@override
bool get isProxy => false;
@override
bool get isSimplyBounded => true;
@ -3464,20 +3388,6 @@ class EnumElementImpl extends AbstractClassElementImpl {
@override
InterfaceType get supertype => library.typeProvider.objectType;
@override
@deprecated
InterfaceType get type {
if (_type == null) {
var typeArguments = const <DartType>[];
_type = InterfaceTypeImpl(
element: this,
typeArguments: typeArguments,
nullabilitySuffix: NullabilitySuffix.star,
);
}
return _type;
}
@override
List<TypeParameterElement> get typeParameters =>
const <TypeParameterElement>[];
@ -3767,7 +3677,6 @@ abstract class ExecutableElementImpl extends ElementImpl
FunctionType get typeInternal {
if (_type != null) return _type;
// TODO(scheglov) Remove "element" in the breaking changes branch.
return _type = FunctionTypeImpl(
typeFormals: typeParameters,
parameters: parameters,
@ -4570,7 +4479,6 @@ class GenericFunctionTypeElementImpl extends ElementImpl
FunctionType get typeInternal {
if (_type != null) return _type;
// TODO(scheglov) Remove "element" in the breaking changes branch.
return _type = FunctionTypeImpl(
typeFormals: typeParameters,
parameters: parameters,
@ -4625,13 +4533,10 @@ class GenericFunctionTypeElementImpl extends ElementImpl
/// Clients may not extend, implement or mix-in this class.
class GenericTypeAliasElementImpl extends ElementImpl
with TypeParameterizedElementMixin
implements GenericTypeAliasElement, ElementImplWithFunctionType {
implements GenericTypeAliasElement {
/// The element representing the generic function type.
GenericFunctionTypeElementImpl _function;
/// The type of function defined by this type alias.
FunctionType _type;
/// Initialize a newly created type alias element to have the given [name].
GenericTypeAliasElementImpl(String name, int offset) : super(name, offset);
@ -4755,48 +4660,6 @@ class GenericTypeAliasElementImpl extends ElementImpl
return super.nameOffset;
}
@override
List<ParameterElement> get parameters =>
function?.parameters ?? const <ParameterElement>[];
@override
DartType get returnType =>
ElementTypeProvider.current.getExecutableReturnType(this);
@override
DartType get returnTypeInternal {
if (function == null) {
return DynamicTypeImpl.instance;
}
return function?.returnType;
}
@override
@deprecated
FunctionType get type => ElementTypeProvider.current.getExecutableType(this);
set type(FunctionType type) {
_type = type;
}
@override
@deprecated
FunctionType get typeInternal {
_type ??= FunctionTypeImpl.synthetic(
function.returnType,
typeParameters,
function.parameters,
element: this,
typeArguments: typeParameters.map((e) {
return e.instantiate(
nullabilitySuffix: NullabilitySuffix.star,
);
}).toList(),
nullabilitySuffix: NullabilitySuffix.star,
);
return _type;
}
/// Set the type parameters defined for this type to the given
/// [typeParameters].
set typeParameters(List<TypeParameterElement> typeParameters) {
@ -4857,32 +4720,6 @@ class GenericTypeAliasElementImpl extends ElementImpl
);
}
@override
@deprecated
FunctionType instantiate2({
@required List<DartType> typeArguments,
@required NullabilitySuffix nullabilitySuffix,
}) {
return instantiate(
typeArguments: typeArguments,
nullabilitySuffix: nullabilitySuffix,
);
}
@Deprecated('Use TypeSystem.instantiateToBounds2() instead')
@override
FunctionType instantiateToBounds({
@required NullabilitySuffix nullabilitySuffix,
}) {
var typeArguments = typeParameters.map((typeParameter) {
return (typeParameter as TypeParameterElementImpl).defaultType;
}).toList();
return instantiate(
typeArguments: typeArguments,
nullabilitySuffix: nullabilitySuffix,
);
}
@override
void visitChildren(ElementVisitor visitor) {
super.visitChildren(visitor);
@ -5536,18 +5373,6 @@ class LibraryElementImpl extends ElementImpl implements LibraryElement {
return _languageVersion;
}
@Deprecated("Use 'languageVersion'")
@override
int get languageVersionMajor {
return languageVersion.effective.major;
}
@Deprecated("Use 'languageVersion'")
@override
int get languageVersionMinor {
return languageVersion.effective.minor;
}
@override
LibraryElement get library => this;
@ -6038,20 +5863,17 @@ class Modifier implements Comparable<Modifier> {
/// Indicates that a class is a mixin application.
static const Modifier MIXIN_APPLICATION = Modifier('MIXIN_APPLICATION', 14);
/// Indicates that a class contains an explicit reference to 'super'.
static const Modifier REFERENCES_SUPER = Modifier('REFERENCES_SUPER', 15);
/// Indicates that the pseudo-modifier 'set' was applied to the element.
static const Modifier SETTER = Modifier('SETTER', 16);
static const Modifier SETTER = Modifier('SETTER', 15);
/// Indicates that the modifier 'static' was applied to the element.
static const Modifier STATIC = Modifier('STATIC', 17);
static const Modifier STATIC = Modifier('STATIC', 16);
/// Indicates that the element does not appear in the source code but was
/// implicitly created. For example, if a class does not define any
/// constructors, an implicit zero-argument constructor will be created and it
/// will be marked as being synthetic.
static const Modifier SYNTHETIC = Modifier('SYNTHETIC', 18);
static const Modifier SYNTHETIC = Modifier('SYNTHETIC', 17);
static const List<Modifier> values = [
ABSTRACT,
@ -6069,7 +5891,6 @@ class Modifier implements Comparable<Modifier> {
IMPLICIT_TYPE,
LATE,
MIXIN_APPLICATION,
REFERENCES_SUPER,
SETTER,
STATIC,
SYNTHETIC
@ -6219,17 +6040,10 @@ class MultiplyDefinedElementImpl implements MultiplyDefinedElement {
@override
Source get source => null;
@override
DartType get type => DynamicTypeImpl.instance;
@override
T accept<T>(ElementVisitor<T> visitor) =>
visitor.visitMultiplyDefinedElement(this);
@Deprecated('Use either thisOrAncestorMatching or thisOrAncestorOfType')
@override
E getAncestor<E extends Element>(Predicate<Element> predicate) => null;
@override
String getDisplayString({@required bool withNullability}) {
var elementsStr = conflictingElements.map((e) {
@ -6311,11 +6125,6 @@ class NeverElementImpl extends ElementImpl implements TypeDefiningElement {
@override
ElementKind get kind => ElementKind.NEVER;
@override
DartType get type {
throw StateError('Should not be accessed.');
}
@override
T accept<T>(ElementVisitor<T> visitor) => null;
@ -7177,7 +6986,6 @@ class PropertyAccessorElementImpl_ImplicitGetter
FunctionType get typeInternal {
if (_type != null) return _type;
// TODO(scheglov) Remove "element" in the breaking changes branch.
var type = FunctionTypeImpl(
typeFormals: const <TypeParameterElement>[],
parameters: const <ParameterElement>[],
@ -7247,7 +7055,6 @@ class PropertyAccessorElementImpl_ImplicitSetter
FunctionType get typeInternal {
if (_type != null) return _type;
// TODO(scheglov) Remove "element" in the breaking changes branch.
var type = FunctionTypeImpl(
typeFormals: const <TypeParameterElement>[],
parameters: parameters,
@ -7473,9 +7280,6 @@ class TypeParameterElementImpl extends ElementImpl
/// fall-back type value in type inference.
DartType _defaultType;
/// The type defined by this type parameter.
TypeParameterType _type;
/// The type representing the bound associated with this parameter, or `null`
/// if this parameter does not have an explicit bound.
DartType _bound;
@ -7582,23 +7386,6 @@ class TypeParameterElementImpl extends ElementImpl
return super.nameOffset;
}
@override
@deprecated
TypeParameterType get type {
// Note: TypeParameterElement.type has nullability suffix `star` regardless
// of whether it appears in a migrated library. This is because for type
// parameters of synthetic function types, the ancestor chain is broken and
// we can't find the enclosing library to tell whether it is migrated.
return _type ??= TypeParameterTypeImpl(
element: this,
nullabilitySuffix: NullabilitySuffix.star,
);
}
set type(TypeParameterType type) {
_type = type;
}
Variance get variance {
if (_variance != null) return _variance;

View file

@ -540,11 +540,6 @@ abstract class Member implements Element {
/// Append a textual representation of this element to the given [builder].
void appendTo(ElementDisplayStringBuilder builder);
@Deprecated('Use either thisOrAncestorMatching or thisOrAncestorOfType')
@override
E getAncestor<E extends Element>(Predicate<Element> predicate) =>
declaration.getAncestor(predicate);
@override
String getDisplayString({@required bool withNullability}) {
var builder = ElementDisplayStringBuilder(
@ -819,16 +814,6 @@ class ParameterMember extends VariableMember
builder.writeFormalParameter(this);
}
@Deprecated('Use either thisOrAncestorMatching or thisOrAncestorOfType')
@override
E getAncestor<E extends Element>(Predicate<Element> predicate) {
Element element = declaration.getAncestor(predicate);
if (element is ExecutableElement) {
return ExecutableMember.from2(element, _substitution) as E;
}
return element as E;
}
@override
void visitChildren(ElementVisitor visitor) {
super.visitChildren(visitor);

View file

@ -86,19 +86,6 @@ class DynamicTypeImpl extends TypeImpl implements DynamicType {
builder.writeDynamicType();
}
@override
@deprecated
DartType substitute2(
List<DartType> argumentTypes, List<DartType> parameterTypes) {
int length = parameterTypes.length;
for (int i = 0; i < length; i++) {
if (parameterTypes[i] == this) {
return argumentTypes[i];
}
}
return this;
}
@override
TypeImpl withNullability(NullabilitySuffix nullabilitySuffix) {
// The dynamic type is always nullable.
@ -148,10 +135,6 @@ class FunctionTypeImpl extends TypeImpl implements FunctionType {
nullabilitySuffix = nullabilitySuffix,
super(element);
@deprecated
@override
List<TypeParameterElement> get boundTypeParameters => typeFormals;
@override
FunctionTypedElement get element {
var element = super.element;
@ -234,9 +217,6 @@ class FunctionTypeImpl extends TypeImpl implements FunctionType {
return types;
}
@override
List<TypeParameterElement> get typeParameters => const [] /*TODO(paulberry)*/;
@override
bool operator ==(Object other) {
if (identical(other, this)) {
@ -315,27 +295,6 @@ class FunctionTypeImpl extends TypeImpl implements FunctionType {
);
}
@override
@deprecated
FunctionType substitute2(
List<DartType> argumentTypes, List<DartType> parameterTypes) {
if (argumentTypes.length != parameterTypes.length) {
throw ArgumentError("argumentTypes.length (${argumentTypes.length}) != "
"parameterTypes.length (${parameterTypes.length})");
}
var substitution = Substitution.fromPairs(
parameterTypes.map<TypeParameterElement>((t) => t.element).toList(),
argumentTypes,
);
return substitution.substituteType(this);
}
@override
@deprecated
FunctionTypeImpl substitute3(List<DartType> argumentTypes) =>
substitute2(argumentTypes, typeArguments);
@override
TypeImpl withNullability(NullabilitySuffix nullabilitySuffix) {
if (this.nullabilitySuffix == nullabilitySuffix) return this;
@ -804,10 +763,6 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType {
return element.name == "Symbol" && element.library.isDartCore;
}
@Deprecated('Use isDartCoreObject')
@override
bool get isObject => element.supertype == null && !element.isMixin;
@override
List<MethodElement> get methods {
if (_methods == null) {
@ -847,9 +802,6 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType {
return _instantiateSuperTypes(constraints);
}
@override
List<TypeParameterElement> get typeParameters => element.typeParameters;
InheritanceManager3 get _inheritanceManager =>
(element.library.session as AnalysisSessionImpl).inheritanceManager;
@ -916,11 +868,6 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType {
PropertyAccessorElement getSetter(String setterName) =>
PropertyAccessorMember.from(element.getSetter(setterName), this);
@override
@deprecated
InterfaceTypeImpl instantiate(List<DartType> argumentTypes) =>
substitute2(argumentTypes, typeArguments);
@override
ConstructorElement lookUpConstructor(
String constructorName, LibraryElement library) {
@ -1357,33 +1304,6 @@ class InterfaceTypeImpl extends TypeImpl implements InterfaceType {
return null;
}
@override
@deprecated
InterfaceTypeImpl substitute2(
List<DartType> argumentTypes, List<DartType> parameterTypes) {
if (argumentTypes.length != parameterTypes.length) {
throw ArgumentError(
"argumentTypes.length (${argumentTypes.length}) != parameterTypes.length (${parameterTypes.length})");
}
if (argumentTypes.isEmpty || typeArguments.isEmpty) {
return this;
}
List<DartType> newTypeArguments =
TypeImpl.substitute(typeArguments, argumentTypes, parameterTypes);
return InterfaceTypeImpl(
element: element,
typeArguments: newTypeArguments,
nullabilitySuffix: nullabilitySuffix,
);
}
@deprecated
@override
InterfaceTypeImpl substitute4(List<DartType> argumentTypes) =>
instantiate(argumentTypes);
@override
TypeImpl withNullability(NullabilitySuffix nullabilitySuffix) {
if (this.nullabilitySuffix == nullabilitySuffix) return this;
@ -1665,12 +1585,6 @@ class NeverTypeImpl extends TypeImpl implements NeverType {
builder.writeNeverType(this);
}
@override
@deprecated
NeverTypeImpl substitute2(
List<DartType> argumentTypes, List<DartType> parameterTypes) =>
this;
@override
TypeImpl withNullability(NullabilitySuffix nullabilitySuffix) {
switch (nullabilitySuffix) {
@ -1758,10 +1672,6 @@ abstract class TypeImpl implements DartType {
@override
bool get isDynamic => false;
@Deprecated('Use isDartCoreObject')
@override
bool get isObject => false;
@override
bool get isVoid => false;
@ -1777,7 +1687,7 @@ abstract class TypeImpl implements DartType {
@override
String getDisplayString({
bool skipAllDynamicArguments = false,
bool withNullability = false,
@required bool withNullability,
}) {
var builder = ElementDisplayStringBuilder(
skipAllDynamicArguments: skipAllDynamicArguments,
@ -1790,16 +1700,9 @@ abstract class TypeImpl implements DartType {
@override
DartType resolveToBound(DartType objectType) => this;
/// Return the type resulting from substituting the given [argumentTypes] for
/// the given [parameterTypes] in this type.
@override
@deprecated
DartType substitute2(
List<DartType> argumentTypes, List<DartType> parameterTypes);
@override
String toString() {
return getDisplayString(withNullability: false);
return getDisplayString(withNullability: true);
}
/// Return the same type, but with the given [nullabilitySuffix].
@ -1836,23 +1739,6 @@ abstract class TypeImpl implements DartType {
}
return true;
}
/// Return a list containing the results of using the given [argumentTypes]
/// and [parameterTypes] to perform a substitution on all of the given
/// [types].
@deprecated
static List<DartType> substitute(List<DartType> types,
List<DartType> argumentTypes, List<DartType> parameterTypes) {
int length = types.length;
if (length == 0) {
return types;
}
List<DartType> newTypes = List<DartType>(length);
for (int i = 0; i < length; i++) {
newTypes[i] = types[i].substitute2(argumentTypes, parameterTypes);
}
return newTypes;
}
}
/// A concrete implementation of a [TypeParameterType].
@ -1976,55 +1862,6 @@ class TypeParameterTypeImpl extends TypeImpl implements TypeParameterType {
.withNullability(newNullabilitySuffix);
}
@override
@deprecated
DartType substitute2(
List<DartType> argumentTypes, List<DartType> parameterTypes) {
int length = parameterTypes.length;
for (int i = 0; i < length; i++) {
var parameterType = parameterTypes[i];
if (parameterType is TypeParameterTypeImpl && parameterType == this) {
TypeImpl argumentType = argumentTypes[i];
// TODO(scheglov) It should not happen, but sometimes arguments are
// null.
if (argumentType == null) {
return argumentType;
}
// TODO(scheglov) Proposed substitution rules for nullability.
NullabilitySuffix resultNullability;
NullabilitySuffix parameterNullability =
parameterType.nullabilitySuffix;
NullabilitySuffix argumentNullability = argumentType.nullabilitySuffix;
if (parameterNullability == NullabilitySuffix.none) {
if (argumentNullability == NullabilitySuffix.question ||
nullabilitySuffix == NullabilitySuffix.question) {
resultNullability = NullabilitySuffix.question;
} else if (argumentNullability == NullabilitySuffix.star ||
nullabilitySuffix == NullabilitySuffix.star) {
resultNullability = NullabilitySuffix.star;
} else {
resultNullability = NullabilitySuffix.none;
}
} else if (parameterNullability == NullabilitySuffix.star) {
if (argumentNullability == NullabilitySuffix.question ||
nullabilitySuffix == NullabilitySuffix.question) {
resultNullability = NullabilitySuffix.question;
} else {
resultNullability = argumentNullability;
}
} else {
// We should never be substituting for `T?`.
throw StateError('Tried to substitute for T?');
}
return argumentType.withNullability(resultNullability);
}
}
return this;
}
@override
TypeImpl withNullability(NullabilitySuffix nullabilitySuffix) {
if (this.nullabilitySuffix == nullabilitySuffix) return this;
@ -2034,22 +1871,6 @@ class TypeParameterTypeImpl extends TypeImpl implements TypeParameterType {
promotedBound: promotedBound,
);
}
/// Return a list containing the type parameter types defined by the given
/// array of type parameter elements ([typeParameters]).
@deprecated
static List<TypeParameterType> getTypes(
List<TypeParameterElement> typeParameters) {
int count = typeParameters.length;
if (count == 0) {
return const <TypeParameterType>[];
}
List<TypeParameterType> types = List<TypeParameterType>(count);
for (int i = 0; i < count; i++) {
types[i] = typeParameters[i].type;
}
return types;
}
}
/// A concrete implementation of a [VoidType].
@ -2094,12 +1915,6 @@ class VoidTypeImpl extends TypeImpl implements VoidType {
builder.writeVoidType();
}
@override
@deprecated
VoidTypeImpl substitute2(
List<DartType> argumentTypes, List<DartType> parameterTypes) =>
this;
@override
TypeImpl withNullability(NullabilitySuffix nullabilitySuffix) {
// The void type is always nullable.

View file

@ -249,7 +249,6 @@ class _FreshTypeParametersSubstitutor extends _TypeSubstitutor {
var freshType = freshElement.instantiate(
nullabilitySuffix: NullabilitySuffix.none,
);
freshElement.type = freshType;
substitution[element] = freshType;
if (!element.isLegacyCovariant) {

View file

@ -6,24 +6,12 @@ import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/nullability_suffix.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/dart/element/type_provider.dart';
import 'package:analyzer/src/dart/constant/value.dart';
import 'package:analyzer/src/dart/element/type.dart';
import 'package:analyzer/src/dart/element/type_system.dart';
import 'package:meta/meta.dart';
/// Provide common functionality shared by the various TypeProvider
/// implementations.
abstract class TypeProviderBase implements TypeProvider {
@override
List<InterfaceType> get nonSubtypableTypes => <InterfaceType>[
boolType,
doubleType,
intType,
nullType,
numType,
stringType
];
@override
bool isObjectGetter(String id) {
PropertyAccessorElement element = objectType.element.getGetter(id);
@ -73,23 +61,15 @@ class TypeProviderImpl extends TypeProviderBase {
InterfaceType _futureDynamicType;
InterfaceType _futureNullType;
InterfaceType _futureOrNullType;
InterfaceType _futureOrType;
InterfaceType _futureType;
InterfaceType _intType;
InterfaceType _iterableDynamicType;
InterfaceType _iterableObjectType;
InterfaceType _iterableType;
InterfaceType _listType;
InterfaceType _mapType;
InterfaceType _mapObjectObjectType;
DartObjectImpl _nullObject;
InterfaceType _nullType;
InterfaceType _numType;
InterfaceType _objectType;
InterfaceType _setType;
InterfaceType _stackTraceType;
InterfaceType _streamDynamicType;
InterfaceType _streamType;
InterfaceType _stringType;
InterfaceType _symbolType;
InterfaceType _typeType;
@ -217,18 +197,6 @@ class TypeProviderImpl extends TypeProviderBase {
return _futureOrNullType;
}
@override
InterfaceType get futureOrType {
_futureOrType ??= _getType(_asyncLibrary, "FutureOr");
return _futureOrType;
}
@override
InterfaceType get futureType {
_futureType ??= _getType(_asyncLibrary, "Future");
return _futureType;
}
@override
ClassElement get intElement {
return _intElement ??= _getClassElement(_coreLibrary, "int");
@ -265,23 +233,11 @@ class TypeProviderImpl extends TypeProviderBase {
return _iterableObjectType;
}
@override
InterfaceType get iterableType {
_iterableType ??= _getType(_coreLibrary, "Iterable");
return _iterableType;
}
@override
ClassElement get listElement {
return _listElement ??= _getClassElement(_coreLibrary, 'List');
}
@override
InterfaceType get listType {
_listType ??= _getType(_coreLibrary, "List");
return _listType;
}
@override
ClassElement get mapElement {
return _mapElement ??= _getClassElement(_coreLibrary, 'Map');
@ -297,12 +253,6 @@ class TypeProviderImpl extends TypeProviderBase {
return _mapObjectObjectType;
}
@override
InterfaceType get mapType {
_mapType ??= _getType(_coreLibrary, "Map");
return _mapType;
}
@override
DartType get neverType => isNonNullableByDefault
? NeverTypeImpl.instance
@ -324,21 +274,6 @@ class TypeProviderImpl extends TypeProviderBase {
return _nullElement ??= _getClassElement(_coreLibrary, 'Null');
}
@deprecated
@override
DartObjectImpl get nullObject {
return _nullObject ??= DartObjectImpl(
TypeSystemImpl(
implicitCasts: false,
isNonNullableByDefault: false,
strictInference: false,
typeProvider: this,
),
nullType,
NullState.NULL_STATE,
);
}
InterfaceTypeImpl get nullStar {
return _nullStar ??= nullElement.instantiate(
typeArguments: const [],
@ -378,11 +313,6 @@ class TypeProviderImpl extends TypeProviderBase {
return _setElement ??= _getClassElement(_coreLibrary, 'Set');
}
@override
InterfaceType get setType {
return _setType ??= _getType(_coreLibrary, "Set");
}
@override
InterfaceType get stackTraceType {
_stackTraceType ??= _getType(_coreLibrary, "StackTrace");
@ -404,12 +334,6 @@ class TypeProviderImpl extends TypeProviderBase {
return _streamElement ??= _getClassElement(_asyncLibrary, 'Stream');
}
@override
InterfaceType get streamType {
_streamType ??= _getType(_asyncLibrary, "Stream");
return _streamType;
}
@override
ClassElement get stringElement {
return _stringElement ??= _getClassElement(_coreLibrary, 'String');

View file

@ -65,18 +65,6 @@ class UnknownInferredType extends TypeImpl {
builder.writeUnknownInferredType();
}
@override
DartType substitute2(
List<DartType> argumentTypes, List<DartType> parameterTypes) {
int length = parameterTypes.length;
for (int i = 0; i < length; i++) {
if (parameterTypes[i] == this) {
return argumentTypes[i];
}
}
return this;
}
@override
TypeImpl withNullability(NullabilitySuffix nullabilitySuffix) => this;

View file

@ -35,12 +35,12 @@ import 'package:meta/meta.dart';
/// way for a possible future where we may wish to make the type system
/// pluggable.
// TODO(brianwilkerson) Rename this class to TypeSystemImpl.
abstract class TypeSystem implements public.TypeSystem {
abstract class TypeSystem2 implements public.TypeSystem {
/// If `true`, then NNBD type rules should be used.
/// If `false`, then legacy type rules should be used.
final bool isNonNullableByDefault;
TypeSystem({@required this.isNonNullableByDefault});
TypeSystem2({@required this.isNonNullableByDefault});
/// The provider of types for the system
TypeProvider get typeProvider;
@ -394,7 +394,7 @@ abstract class TypeSystem implements public.TypeSystem {
}
/// The [public.TypeSystem] implementation.
class TypeSystemImpl extends TypeSystem {
class TypeSystemImpl extends TypeSystem2 {
/// False if implicit casts should always be disallowed.
///
/// This affects the behavior of [isAssignableTo].

View file

@ -139,14 +139,13 @@ class _MicroAnalysisContextImpl implements AnalysisContext {
}
class _MicroAnalysisSessionImpl extends AnalysisSessionImpl {
@override
_MicroAnalysisContextImpl analysisContext;
@override
final DeclaredVariables declaredVariables;
final SourceFactory sourceFactory;
@override
SourceFactory sourceFactory;
_MicroAnalysisContextImpl analysisContext;
_MicroAnalysisSessionImpl(
this.declaredVariables,

View file

@ -84,10 +84,6 @@ class ResolutionVisitor extends RecursiveAstVisitor<void> {
/// enclosing element.
ElementHolder _elementHolder;
/// The flag specifying if currently visited class references 'super'
/// expression.
bool _hasReferenceToSuper = false;
factory ResolutionVisitor({
@required CompilationUnitElementImpl unitElement,
@required AnalysisErrorListener errorListener,
@ -241,13 +237,9 @@ class ResolutionVisitor extends RecursiveAstVisitor<void> {
_resolveWithClause(withClause);
_resolveImplementsClause(node.implementsClause);
_hasReferenceToSuper = false;
_defineElements(element.accessors);
_defineElements(element.methods);
node.members.accept(this);
element.hasReferenceToSuper = _hasReferenceToSuper;
});
});
@ -904,12 +896,6 @@ class ResolutionVisitor extends RecursiveAstVisitor<void> {
_setElementAnnotations(node.metadata, element.metadata);
}
@override
void visitSuperExpression(SuperExpression node) {
_hasReferenceToSuper = true;
super.visitSuperExpression(node);
}
@override
void visitSwitchCase(SwitchCase node) {
_buildLabelElements(node.labels, false, true);

View file

@ -3410,7 +3410,7 @@ class AstBuilder extends StackListener {
handleRecoverableError(
templateExperimentNotEnabled.withArguments(
feature.enableString,
_versionAsString(feature.firstSupportedVersion),
_versionAsString(feature.releaseVersion),
),
spreadToken,
spreadToken,
@ -3633,7 +3633,7 @@ class AstBuilder extends StackListener {
handleRecoverableError(
templateExperimentNotEnabled.withArguments(
feature.enableString,
_versionAsString(feature.firstSupportedVersion),
_versionAsString(feature.releaseVersion),
),
forToken,
forToken,
@ -3666,7 +3666,7 @@ class AstBuilder extends StackListener {
handleRecoverableError(
templateExperimentNotEnabled.withArguments(
feature.enableString,
_versionAsString(feature.firstSupportedVersion),
_versionAsString(feature.releaseVersion),
),
ifToken,
ifToken,

View file

@ -1,18 +0,0 @@
// 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.
/// This library is deprecated. Please convert all references to this library to
/// reference one of the following public libraries:
/// * package:analyzer/dart/ast/ast.dart
/// * package:analyzer/dart/ast/visitor.dart
///
/// If your code is using APIs not available in these public libraries, please
/// contact the analyzer team to either find an alternate API or have the API
/// you depend on added to the public API.
@deprecated
library analyzer.src.generated.ast;
export 'package:analyzer/dart/ast/ast.dart';
export 'package:analyzer/dart/ast/visitor.dart';
export 'package:analyzer/src/dart/ast/utilities.dart';

View file

@ -1,22 +0,0 @@
// 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.
/// This library is deprecated. Please convert all references to this library to
/// reference one of the following public libraries:
/// * package:analyzer/dart/element/element.dart
/// * package:analyzer/dart/element/type.dart
/// * package:analyzer/dart/element/visitor.dart
///
/// If your code is using APIs not available in these public libraries, please
/// contact the analyzer team to either find an alternate API or have the API
/// you depend on added to the public API.
@deprecated
library analyzer.src.generated.element;
export 'package:analyzer/dart/element/element.dart';
export 'package:analyzer/dart/element/type.dart';
export 'package:analyzer/dart/element/visitor.dart';
export 'package:analyzer/src/dart/element/element.dart';
export 'package:analyzer/src/dart/element/member.dart';
export 'package:analyzer/src/dart/element/type.dart';

View file

@ -6,13 +6,10 @@ import 'dart:typed_data';
import 'package:_fe_analyzer_shared/src/scanner/token_impl.dart';
import 'package:analyzer/dart/analysis/features.dart';
import 'package:analyzer/dart/element/type_provider.dart';
import 'package:analyzer/error/error.dart';
import 'package:analyzer/exception/exception.dart';
import 'package:analyzer/instrumentation/instrumentation.dart';
import 'package:analyzer/source/error_processor.dart';
import 'package:analyzer/src/dart/analysis/experiments.dart';
import 'package:analyzer/src/dart/element/type_system.dart';
import 'package:analyzer/src/generated/constant.dart';
import 'package:analyzer/src/generated/java_engine.dart';
import 'package:analyzer/src/generated/source.dart';
@ -87,15 +84,6 @@ abstract class AnalysisContext {
/// this context to the given source [factory]. Clients can safely assume that
/// all analysis results have been invalidated.
set sourceFactory(SourceFactory factory);
/// Return a type provider for this context or throw [AnalysisException] if
/// either `dart:core` or `dart:async` cannot be resolved.
@Deprecated('Use LibraryElement.typeProvider')
TypeProvider get typeProvider;
/// Return a type system for this context.
@Deprecated('Use LibraryElement.typeSystem')
TypeSystem get typeSystem;
}
/// The entry point for the functionality provided by the analysis engine. There
@ -215,18 +203,6 @@ class AnalysisErrorInfoImpl implements AnalysisErrorInfo {
/// A set of analysis options used to control the behavior of an analysis
/// context.
abstract class AnalysisOptions {
/// Function that returns `true` if analysis is to parse and analyze function
/// bodies for a given source.
@deprecated
AnalyzeFunctionBodiesPredicate get analyzeFunctionBodiesPredicate;
/// Return the maximum number of sources for which AST structures should be
/// kept in the cache.
///
/// DEPRECATED: This setting no longer has any effect.
@deprecated
int get cacheSize;
/// A flag indicating whether to run checks on AndroidManifest.xml file to
/// see if it is complaint with Chrome OS.
bool get chromeOsManifestChecks;
@ -234,63 +210,13 @@ abstract class AnalysisOptions {
/// The set of features that are globally enabled for this context.
FeatureSet get contextFeatures;
/// Return `true` if cache flushing should be disabled. Setting this option to
/// `true` can improve analysis speed at the expense of memory usage. It may
/// also be useful for working around bugs.
///
/// This option should not be used when the analyzer is part of a long running
/// process (such as the analysis server) because it has the potential to
/// prevent memory from being reclaimed.
@deprecated
bool get disableCacheFlushing;
/// Return `true` if the parser is to parse asserts in the initializer list of
/// a constructor.
@deprecated
bool get enableAssertInitializer;
/// Return `true` to enable custom assert messages (DEP 37).
@deprecated
bool get enableAssertMessage;
/// Return `true` to if analysis is to enable async support.
@deprecated
bool get enableAsync;
/// Return `true` to enable interface libraries (DEP 40).
@deprecated
bool get enableConditionalDirectives;
/// Return a list of the names of the packages for which, if they define a
/// plugin, the plugin should be enabled.
List<String> get enabledPluginNames;
/// Return `true` to enable generic methods (DEP 22).
@deprecated
bool get enableGenericMethods => null;
/// Return `true` if access to field formal parameters should be allowed in a
/// constructor's initializer list.
@deprecated
bool get enableInitializingFormalAccess;
/// Return `true` to enable the lazy compound assignment operators '&&=' and
/// '||='.
@deprecated
bool get enableLazyAssignmentOperators;
/// Return `true` if mixins are allowed to inherit from types other than
/// Object, and are allowed to reference `super`.
@deprecated
bool get enableSuperMixins;
/// Return `true` if timing data should be gathered during execution.
bool get enableTiming;
/// Return `true` to enable the use of URIs in part-of directives.
@deprecated
bool get enableUriInPartOf;
/// Return a list of error processors that are to be used when reporting
/// errors in some analysis context.
List<ErrorProcessor> get errorProcessors;
@ -299,16 +225,6 @@ abstract class AnalysisOptions {
/// analysis.
List<String> get excludePatterns;
/// Return `true` if errors, warnings and hints should be generated for sources
/// that are implicitly being analyzed. The default value is `true`.
@deprecated
bool get generateImplicitErrors;
/// Return `true` if errors, warnings and hints should be generated for sources
/// in the SDK. The default value is `false`.
@deprecated
bool get generateSdkErrors;
/// Return `true` if analysis is to generate hint results (e.g. type inference
/// based information and pub best practices).
bool get hint;
@ -320,22 +236,6 @@ abstract class AnalysisOptions {
/// if [lint] returns `true`.
List<Linter> get lintRules;
/// A mapping from Dart SDK library name (e.g. "dart:core") to a list of paths
/// to patch files that should be applied to the library.
@deprecated
Map<String, List<String>> get patchPaths;
/// Return `true` if analysis is to parse comments.
@deprecated
bool get preserveComments;
/// Return `true` if analyzer should enable the use of Dart 2.0 features.
///
/// This getter is deprecated, and is hard-coded to always return true.
@Deprecated(
'This getter is deprecated and is hard-coded to always return true.')
bool get previewDart2;
/// The version range for the SDK specified in `pubspec.yaml`, or `null` if
/// there is no `pubspec.yaml` or if it does not contain an SDK range.
VersionConstraint get sdkVersionConstraint;
@ -345,35 +245,12 @@ abstract class AnalysisOptions {
/// The length of the list is guaranteed to equal [signatureLength].
Uint32List get signature;
/// Return `true` if strong mode analysis should be used.
///
/// This getter is deprecated, and is hard-coded to always return true.
@Deprecated(
'This getter is deprecated and is hard-coded to always return true.')
bool get strongMode;
/// Return `true` if dependencies between computed results should be tracked
/// by analysis cache. This option should only be set to `false` if analysis
/// is performed in such a way that none of the inputs is ever changed
/// during the life time of the context.
@deprecated
bool get trackCacheDependencies;
/// Return `true` if analyzer should use the Dart 2.0 Front End parser.
bool get useFastaParser;
/// Return `true` the lint with the given [name] is enabled.
bool isLintEnabled(String name);
/// Reset the state of this set of analysis options to its original state.
@deprecated
void resetToDefaults();
/// Set the values of the cross-context options to match those in the given set
/// of [options].
@deprecated
void setCrossContextOptionsFrom(AnalysisOptions options);
/// Determine whether two signatures returned by [signature] are equal.
static bool signaturesEqual(Uint32List a, Uint32List b) {
assert(a.length == AnalysisOptionsImpl.signatureLength);
@ -396,19 +273,6 @@ class AnalysisOptionsImpl implements AnalysisOptions {
/// The length of the list returned by `signature` getters.
static const int signatureLength = 4;
/// DEPRECATED: The maximum number of sources for which data should be kept in
/// the cache.
///
/// This constant no longer has any effect.
@deprecated
static const int DEFAULT_CACHE_SIZE = 64;
/// A predicate indicating whether analysis is to parse and analyze function
/// bodies.
@deprecated
AnalyzeFunctionBodiesPredicate _analyzeFunctionBodiesPredicate =
_analyzeAllFunctionBodies;
/// The cached [unlinkedSignature].
Uint32List _unlinkedSignature;
@ -421,10 +285,6 @@ class AnalysisOptionsImpl implements AnalysisOptions {
@override
VersionConstraint sdkVersionConstraint;
@override
@deprecated
int cacheSize = 64;
ExperimentStatus _contextFeatures = ExperimentStatus();
/// The set of features to use for libraries that are not in a package.
@ -437,10 +297,6 @@ class AnalysisOptionsImpl implements AnalysisOptions {
@override
List<String> enabledPluginNames = const <String>[];
@deprecated
@override
bool enableLazyAssignmentOperators = false;
@override
bool enableTiming = false;
@ -451,14 +307,6 @@ class AnalysisOptionsImpl implements AnalysisOptions {
/// A list of exclude patterns used to exclude some sources from analysis.
List<String> _excludePatterns;
@deprecated
@override
bool generateImplicitErrors = true;
@deprecated
@override
bool generateSdkErrors = false;
@override
bool hint = true;
@ -469,25 +317,9 @@ class AnalysisOptionsImpl implements AnalysisOptions {
/// `true`.
List<Linter> _lintRules;
@deprecated
@override
Map<String, List<String>> patchPaths = {};
@deprecated
@override
bool preserveComments = true;
@deprecated
@override
bool trackCacheDependencies = true;
@override
bool useFastaParser = true;
@deprecated
@override
bool disableCacheFlushing = false;
/// A flag indicating whether implicit casts are allowed in [strongMode]
/// (they are always allowed in Dart 1.0 mode).
///
@ -526,24 +358,14 @@ class AnalysisOptionsImpl implements AnalysisOptions {
/// Initialize a newly created set of analysis options to have the same values
/// as those in the given set of analysis [options].
AnalysisOptionsImpl.from(AnalysisOptions options) {
// ignore: deprecated_member_use_from_same_package
analyzeFunctionBodiesPredicate = options.analyzeFunctionBodiesPredicate;
contextFeatures = options.contextFeatures;
enabledPluginNames = options.enabledPluginNames;
// ignore: deprecated_member_use_from_same_package
enableLazyAssignmentOperators = options.enableLazyAssignmentOperators;
enableTiming = options.enableTiming;
errorProcessors = options.errorProcessors;
excludePatterns = options.excludePatterns;
// ignore: deprecated_member_use_from_same_package
generateImplicitErrors = options.generateImplicitErrors;
// ignore: deprecated_member_use_from_same_package
generateSdkErrors = options.generateSdkErrors;
hint = options.hint;
lint = options.lint;
lintRules = options.lintRules;
// ignore: deprecated_member_use_from_same_package
preserveComments = options.preserveComments;
useFastaParser = options.useFastaParser;
if (options is AnalysisOptionsImpl) {
implicitCasts = options.implicitCasts;
@ -551,49 +373,9 @@ class AnalysisOptionsImpl implements AnalysisOptions {
strictInference = options.strictInference;
strictRawTypes = options.strictRawTypes;
}
// ignore: deprecated_member_use_from_same_package
trackCacheDependencies = options.trackCacheDependencies;
// ignore: deprecated_member_use_from_same_package
disableCacheFlushing = options.disableCacheFlushing;
// ignore: deprecated_member_use_from_same_package
patchPaths = options.patchPaths;
sdkVersionConstraint = options.sdkVersionConstraint;
}
@deprecated
bool get analyzeFunctionBodies {
if (identical(analyzeFunctionBodiesPredicate, _analyzeAllFunctionBodies)) {
return true;
} else if (identical(
analyzeFunctionBodiesPredicate, _analyzeNoFunctionBodies)) {
return false;
} else {
throw StateError('analyzeFunctionBodiesPredicate in use');
}
}
@deprecated
set analyzeFunctionBodies(bool value) {
if (value) {
analyzeFunctionBodiesPredicate = _analyzeAllFunctionBodies;
} else {
analyzeFunctionBodiesPredicate = _analyzeNoFunctionBodies;
}
}
@deprecated
@override
AnalyzeFunctionBodiesPredicate get analyzeFunctionBodiesPredicate =>
_analyzeFunctionBodiesPredicate;
@deprecated
set analyzeFunctionBodiesPredicate(AnalyzeFunctionBodiesPredicate value) {
if (value == null) {
throw ArgumentError.notNull('analyzeFunctionBodiesPredicate');
}
_analyzeFunctionBodiesPredicate = value;
}
@override
FeatureSet get contextFeatures => _contextFeatures;
@ -602,69 +384,11 @@ class AnalysisOptionsImpl implements AnalysisOptions {
nonPackageFeatureSet = featureSet;
}
@deprecated
@override
bool get enableAssertInitializer => true;
@deprecated
set enableAssertInitializer(bool enable) {}
@override
@deprecated
bool get enableAssertMessage => true;
@deprecated
set enableAssertMessage(bool enable) {}
@deprecated
@override
bool get enableAsync => true;
@deprecated
set enableAsync(bool enable) {}
/// A flag indicating whether interface libraries are to be supported (DEP 40).
@override
bool get enableConditionalDirectives => true;
@deprecated
set enableConditionalDirectives(_) {}
@deprecated
set enabledExperiments(List<String> enabledExperiments) {
_contextFeatures = ExperimentStatus.fromStrings(enabledExperiments);
}
@override
@deprecated
bool get enableGenericMethods => true;
@deprecated
set enableGenericMethods(bool enable) {}
@deprecated
@override
bool get enableInitializingFormalAccess => true;
@deprecated
set enableInitializingFormalAccess(bool enable) {}
@override
@deprecated
bool get enableSuperMixins => false;
@deprecated
set enableSuperMixins(bool enable) {
// Ignored.
}
@deprecated
@override
bool get enableUriInPartOf => true;
@deprecated
set enableUriInPartOf(bool enable) {}
@override
List<ErrorProcessor> get errorProcessors =>
_errorProcessors ??= const <ErrorProcessor>[];
@ -687,14 +411,6 @@ class AnalysisOptionsImpl implements AnalysisOptions {
/// The set of enabled experiments.
ExperimentStatus get experimentStatus => _contextFeatures;
/// Return `true` to enable mixin declarations.
/// https://github.com/dart-lang/language/issues/12
@deprecated
bool get isMixinSupportEnabled => true;
@deprecated
set isMixinSupportEnabled(bool value) {}
@override
List<Linter> get lintRules => _lintRules ??= const <Linter>[];
@ -704,13 +420,6 @@ class AnalysisOptionsImpl implements AnalysisOptions {
_lintRules = rules;
}
@deprecated
@override
bool get previewDart2 => true;
@deprecated
set previewDart2(bool value) {}
@override
Uint32List get signature {
if (_signature == null) {
@ -723,7 +432,6 @@ class AnalysisOptionsImpl implements AnalysisOptions {
// Append boolean flags.
// ignore: deprecated_member_use_from_same_package
buffer.addBool(enableLazyAssignmentOperators);
buffer.addBool(implicitCasts);
buffer.addBool(implicitDynamic);
buffer.addBool(strictInference);
@ -779,13 +487,6 @@ class AnalysisOptionsImpl implements AnalysisOptions {
return _signatureForElements;
}
@override
bool get strongMode => true;
@Deprecated(
"The strongMode field is deprecated, and shouldn't be assigned to")
set strongMode(bool value) {}
/// Return the opaque signature of the options that affect unlinked data.
///
/// The length of the list is guaranteed to equal [unlinkedSignatureLength].
@ -794,8 +495,6 @@ class AnalysisOptionsImpl implements AnalysisOptions {
ApiSignature buffer = ApiSignature();
// Append boolean flags.
// ignore: deprecated_member_use_from_same_package
buffer.addBool(enableLazyAssignmentOperators);
buffer.addBool(useFastaParser);
// Append the current language version.
@ -819,45 +518,4 @@ class AnalysisOptionsImpl implements AnalysisOptions {
bool isLintEnabled(String name) {
return lintRules.any((rule) => rule.name == name);
}
@deprecated
@override
void resetToDefaults() {
contextFeatures = ExperimentStatus();
disableCacheFlushing = false;
enabledPluginNames = const <String>[];
enableLazyAssignmentOperators = false;
enableTiming = false;
_errorProcessors = null;
_excludePatterns = null;
generateImplicitErrors = true;
generateSdkErrors = false;
hint = true;
implicitCasts = true;
implicitDynamic = true;
strictInference = false;
strictRawTypes = false;
lint = false;
_lintRules = null;
patchPaths = {};
preserveComments = true;
trackCacheDependencies = true;
useFastaParser = true;
}
@deprecated
@override
void setCrossContextOptionsFrom(AnalysisOptions options) {
enableLazyAssignmentOperators = options.enableLazyAssignmentOperators;
}
/// Predicate used for [analyzeFunctionBodiesPredicate] when
/// [analyzeFunctionBodies] is set to `true`.
@deprecated
static bool _analyzeAllFunctionBodies(Source _) => true;
/// Predicate used for [analyzeFunctionBodiesPredicate] when
/// [analyzeFunctionBodies] is set to `false`.
@deprecated
static bool _analyzeNoFunctionBodies(Source _) => false;
}

View file

@ -1,10 +0,0 @@
// 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.
@deprecated
library analyzer.src.generated.error;
export 'package:analyzer/error/error.dart';
export 'package:analyzer/error/listener.dart';
export 'package:analyzer/src/error/codes.dart';

View file

@ -53,12 +53,6 @@ import 'package:analyzer/src/generated/type_promotion_manager.dart';
import 'package:analyzer/src/generated/variable_type_provider.dart';
import 'package:meta/meta.dart';
export 'package:analyzer/dart/element/type_provider.dart';
export 'package:analyzer/src/dart/constant/constant_verifier.dart';
export 'package:analyzer/src/dart/element/type_system.dart';
export 'package:analyzer/src/dart/resolver/exit_detector.dart';
export 'package:analyzer/src/dart/resolver/scope.dart';
/// Maintains and manages contextual type information used for
/// inferring types.
class InferenceContext {
@ -2013,7 +2007,7 @@ class ResolverVisitorForMigration extends ResolverVisitor {
Source source,
TypeProvider typeProvider,
AnalysisErrorListener errorListener,
TypeSystem typeSystem,
TypeSystemImpl typeSystem,
FeatureSet featureSet,
MigrationResolutionHooks migrationResolutionHooks)
: _migrationResolutionHooks = migrationResolutionHooks,
@ -2427,7 +2421,7 @@ abstract class ScopedVisitor extends UnifyingAstVisitor<void> {
} else if (parent is FunctionTypeAlias) {
nameScope = FormalParameterScope(
nameScope,
parent.declaredElement.parameters,
parent.declaredElement.function.parameters,
);
} else if (parent is MethodDeclaration) {
nameScope = FormalParameterScope(

View file

@ -1,11 +0,0 @@
// 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.
@deprecated
library analyzer.src.generated.scanner;
export 'package:analyzer/dart/ast/token.dart';
export 'package:analyzer/src/dart/ast/token.dart' hide SimpleToken;
export 'package:analyzer/src/dart/scanner/reader.dart';
export 'package:analyzer/src/dart/scanner/scanner.dart';

View file

@ -1,184 +0,0 @@
// 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.
@deprecated
library analyzer.src.generated.sdk_io;
import 'dart:collection';
import 'package:analyzer/exception/exception.dart';
import 'package:analyzer/src/context/context.dart';
import 'package:analyzer/src/generated/engine.dart';
import 'package:analyzer/src/generated/java_io.dart';
import 'package:analyzer/src/generated/sdk.dart';
import 'package:analyzer/src/generated/source_io.dart';
import 'package:analyzer/src/summary/idl.dart' show PackageBundle;
/// An abstract implementation of a Dart SDK in which the available libraries
/// are stored in a library map. Subclasses are responsible for populating the
/// library map.
@deprecated
abstract class AbstractDartSdk implements DartSdk {
/// A mapping from Dart library URI's to the library represented by that URI.
LibraryMap libraryMap = LibraryMap();
/// The [AnalysisOptions] to use to create the [context].
AnalysisOptions _analysisOptions;
/// The [AnalysisContext] which is used for all of the sources in this SDK.
SdkAnalysisContext _analysisContext;
/// The mapping from Dart URI's to the corresponding sources.
final Map<String, Source> _uriToSourceMap = HashMap<String, Source>();
/// Set the [options] for this SDK analysis context. Throw [StateError] if
/// the context has been already created.
set analysisOptions(AnalysisOptions options) {
if (_analysisContext != null) {
throw StateError(
'Analysis options cannot be changed after context creation.');
}
_analysisOptions = options;
}
@override
AnalysisContext get context {
if (_analysisContext == null) {
var factory = SourceFactory([DartUriResolver(this)]);
_analysisContext = SdkAnalysisContext(_analysisOptions, factory);
}
return _analysisContext;
}
@override
List<SdkLibrary> get sdkLibraries => libraryMap.sdkLibraries;
@override
List<String> get uris => libraryMap.uris;
/// Add the extensions from one or more sdk extension files to this sdk. The
/// [extensions] should be a table mapping the names of extensions to the
/// paths where those extensions can be found.
void addExtensions(Map<String, String> extensions) {
extensions.forEach((String uri, String path) {
String shortName = uri.substring(uri.indexOf(':') + 1);
SdkLibraryImpl library = SdkLibraryImpl(shortName);
library.path = path;
libraryMap.setLibrary(uri, library);
});
}
@override
Source fromFileUri(Uri uri) {
JavaFile file = JavaFile.fromUri(uri);
String path = _getPath(file);
if (path == null) {
return null;
}
try {
return FileBasedSource(file, Uri.parse(path));
} on FormatException catch (exception, stackTrace) {
AnalysisEngine.instance.instrumentationService.logInfo(
"Failed to create URI: $path",
CaughtException(exception, stackTrace));
}
return null;
}
String getRelativePathFromFile(JavaFile file);
@override
SdkLibrary getSdkLibrary(String dartUri) => libraryMap.getLibrary(dartUri);
/// Return the [PackageBundle] for this SDK, if it exists, or `null`
/// otherwise. This method should not be used outside of `analyzer` and
/// `analyzer_cli` packages.
@deprecated
PackageBundle getSummarySdkBundle(bool _);
FileBasedSource internalMapDartUri(String dartUri) {
// TODO(brianwilkerson) Figure out how to unify the implementations in the
// two subclasses.
String libraryName;
String relativePath;
int index = dartUri.indexOf('/');
if (index >= 0) {
libraryName = dartUri.substring(0, index);
relativePath = dartUri.substring(index + 1);
} else {
libraryName = dartUri;
relativePath = "";
}
SdkLibrary library = getSdkLibrary(libraryName);
if (library == null) {
return null;
}
String srcPath;
if (relativePath.isEmpty) {
srcPath = library.path;
} else {
String libraryPath = library.path;
int index = libraryPath.lastIndexOf(JavaFile.separator);
if (index == -1) {
index = libraryPath.lastIndexOf('/');
if (index == -1) {
return null;
}
}
String prefix = libraryPath.substring(0, index + 1);
srcPath = '$prefix$relativePath';
}
String filePath = srcPath.replaceAll('/', JavaFile.separator);
try {
JavaFile file = JavaFile(filePath);
return FileBasedSource(file, Uri.parse(dartUri));
} on FormatException {
return null;
}
}
@override
Source mapDartUri(String dartUri) {
Source source = _uriToSourceMap[dartUri];
if (source == null) {
source = internalMapDartUri(dartUri);
_uriToSourceMap[dartUri] = source;
}
return source;
}
String _getPath(JavaFile file) {
List<SdkLibrary> libraries = libraryMap.sdkLibraries;
int length = libraries.length;
List<String> paths = List(length);
String filePath = getRelativePathFromFile(file);
if (filePath == null) {
return null;
}
for (int i = 0; i < length; i++) {
SdkLibrary library = libraries[i];
String libraryPath = library.path.replaceAll('/', JavaFile.separator);
if (filePath == libraryPath) {
return library.shortName;
}
paths[i] = libraryPath;
}
for (int i = 0; i < length; i++) {
SdkLibrary library = libraries[i];
String libraryPath = paths[i];
int index = libraryPath.lastIndexOf(JavaFile.separator);
if (index >= 0) {
String prefix = libraryPath.substring(0, index + 1);
if (filePath.startsWith(prefix)) {
String relPath = filePath
.substring(prefix.length)
.replaceAll(JavaFile.separator, '/');
return '${library.shortName}/$relPath';
}
}
}
return null;
}
}

View file

@ -2,14 +2,10 @@
// 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 'dart:collection';
import 'package:analyzer/file_system/file_system.dart';
import 'package:analyzer/src/context/source.dart';
import 'package:analyzer/src/generated/engine.dart';
import 'package:analyzer/src/generated/java_io.dart' show JavaFile;
import 'package:analyzer/src/generated/sdk.dart' show DartSdk;
import 'package:analyzer/src/generated/source_io.dart' show FileBasedSource;
import 'package:analyzer/src/task/api/model.dart';
import 'package:path/path.dart' as pathos;
@ -53,12 +49,12 @@ abstract class BasicSource extends Source {
class ContentCache {
/// A table mapping the full path of sources to the contents of those sources.
/// This is used to override the default contents of a source.
final Map<String, String> _contentMap = HashMap<String, String>();
final Map<String, String> _contentMap = {};
/// A table mapping the full path of sources to the modification stamps of
/// those sources. This is used when the default contents of a source has been
/// overridden.
final Map<String, int> _stampMap = HashMap<String, int>();
final Map<String, int> _stampMap = {};
int _nextStamp = 0;
@ -70,8 +66,8 @@ class ContentCache {
});
}
/// Return the contents of the given [source], or `null` if this cache does
/// not override the contents of the source.
/// Return the contents of the given [source], or `null` if this cache does not
/// override the contents of the source.
///
/// <b>Note:</b> This method is not intended to be used except by
/// [AnalysisContext.getContents].
@ -119,25 +115,6 @@ class ContentCache {
}
}
@deprecated
class CustomUriResolver extends UriResolver {
final Map<String, String> _urlMappings;
CustomUriResolver(this._urlMappings);
@override
Source resolveAbsolute(Uri uri, [Uri actualUri]) {
String mapping = _urlMappings[uri.toString()];
if (mapping == null) return null;
Uri fileUri = Uri.file(mapping);
if (!fileUri.isAbsolute) return null;
JavaFile javaFile = JavaFile.fromUri(fileUri);
return FileBasedSource(javaFile, actualUri ?? uri);
}
}
/// Instances of the class `DartUriResolver` resolve `dart` URI's.
class DartUriResolver extends UriResolver {
/// The name of the `dart` scheme.

View file

@ -4,53 +4,12 @@
import 'dart:collection';
import 'package:analyzer/exception/exception.dart';
import 'package:analyzer/src/generated/engine.dart';
import 'package:analyzer/src/generated/java_io.dart';
import 'package:analyzer/src/generated/source.dart';
import 'package:path/path.dart' as path;
export 'package:analyzer/src/generated/source.dart';
/// Instances of the class [ExplicitSourceResolver] map URIs to files on disk
/// using a fixed mapping provided at construction time.
@deprecated
class ExplicitSourceResolver extends UriResolver {
final Map<Uri, JavaFile> uriToFileMap;
final Map<String, Uri> pathToUriMap;
/// Construct an [ExplicitSourceResolver] based on the given [uriToFileMap].
ExplicitSourceResolver(Map<Uri, JavaFile> uriToFileMap)
: uriToFileMap = uriToFileMap,
pathToUriMap = _computePathToUriMap(uriToFileMap);
@override
Source resolveAbsolute(Uri uri, [Uri actualUri]) {
JavaFile file = uriToFileMap[uri];
actualUri ??= uri;
if (file == null) {
return null;
} else {
return FileBasedSource(file, actualUri);
}
}
@override
Uri restoreAbsolute(Source source) {
return pathToUriMap[source.fullName];
}
/// Build the inverse mapping of [uriToSourceMap].
static Map<String, Uri> _computePathToUriMap(
Map<Uri, JavaFile> uriToSourceMap) {
Map<String, Uri> pathToUriMap = <String, Uri>{};
uriToSourceMap.forEach((Uri uri, JavaFile file) {
pathToUriMap[file.getAbsolutePath()] = uri;
});
return pathToUriMap;
}
}
/// Instances of the class `FileBasedSource` implement a source that represents
/// a file.
class FileBasedSource extends Source {
@ -158,273 +117,3 @@ class FileBasedSource extends Source {
return file.getAbsolutePath();
}
}
/// Instances of the class `FileUriResolver` resolve `file` URI's.
///
/// This class is now deprecated, 'new FileUriResolver()' is equivalent to
/// 'new ResourceUriResolver(PhysicalResourceProvider.INSTANCE)'.
@deprecated
class FileUriResolver extends UriResolver {
/// The name of the `file` scheme.
static String FILE_SCHEME = "file";
@override
Source resolveAbsolute(Uri uri, [Uri actualUri]) {
if (!isFileUri(uri)) {
return null;
}
return FileBasedSource(JavaFile.fromUri(uri), actualUri ?? uri);
}
@override
Uri restoreAbsolute(Source source) {
return Uri.file(source.fullName);
}
/// Return `true` if the given URI is a `file` URI.
///
/// @param uri the URI being tested
/// @return `true` if the given URI is a `file` URI
static bool isFileUri(Uri uri) => uri.scheme == FILE_SCHEME;
}
/// Instances of interface `LocalSourcePredicate` are used to determine if the
/// given [Source] is "local" in some sense, so can be updated.
abstract class LocalSourcePredicate {
/// Instance of [LocalSourcePredicate] that always returns `false`.
static final LocalSourcePredicate FALSE = LocalSourcePredicate_FALSE();
/// Instance of [LocalSourcePredicate] that always returns `true`.
static final LocalSourcePredicate TRUE = LocalSourcePredicate_TRUE();
/// Instance of [LocalSourcePredicate] that returns `true` for all [Source]s
/// except of SDK.
static final LocalSourcePredicate NOT_SDK = LocalSourcePredicate_NOT_SDK();
/// Determines if the given [Source] is local.
///
/// @param source the [Source] to analyze
/// @return `true` if the given [Source] is local
bool isLocal(Source source);
}
class LocalSourcePredicate_FALSE implements LocalSourcePredicate {
@override
bool isLocal(Source source) => false;
}
class LocalSourcePredicate_NOT_SDK implements LocalSourcePredicate {
@override
bool isLocal(Source source) => source.uriKind != UriKind.DART_URI;
}
class LocalSourcePredicate_TRUE implements LocalSourcePredicate {
@override
bool isLocal(Source source) => true;
}
/// Instances of the class `PackageUriResolver` resolve `package` URI's in the
/// context of an application.
///
/// For the purposes of sharing analysis, the path to each package under the
/// "packages" directory should be canonicalized, but to preserve relative links
/// within a package, the remainder of the path from the package directory to
/// the leaf should not.
@deprecated
class PackageUriResolver extends UriResolver {
/// The name of the `package` scheme.
static String PACKAGE_SCHEME = "package";
/// Log exceptions thrown with the message "Required key not available" only
/// once.
static bool _CanLogRequiredKeyIoException = true;
/// The package directories that `package` URI's are assumed to be relative
/// to.
final List<JavaFile> _packagesDirectories;
/// Initialize a newly created resolver to resolve `package` URI's relative to
/// the given package directories.
///
/// @param packagesDirectories the package directories that `package` URI's
/// are assumed to be relative to
PackageUriResolver(this._packagesDirectories) {
if (_packagesDirectories.isEmpty) {
throw ArgumentError("At least one package directory must be provided");
}
}
/// If the list of package directories contains one element, return it.
/// Otherwise raise an exception. Intended for testing.
String get packagesDirectory_forTesting {
int length = _packagesDirectories.length;
if (length != 1) {
throw Exception('Expected 1 package directory, found $length');
}
return _packagesDirectories[0].getPath();
}
/// Answer the canonical file for the specified package.
///
/// @param packagesDirectory the "packages" directory (not `null`)
/// @param pkgName the package name (not `null`, not empty)
/// @param relPath the path relative to the package directory (not `null`, no
/// leading slash, but may be empty string)
/// @return the file (not `null`)
JavaFile getCanonicalFile(
JavaFile packagesDirectory, String pkgName, String relPath) {
JavaFile pkgDir = JavaFile.relative(packagesDirectory, pkgName);
try {
pkgDir = pkgDir.getCanonicalFile();
} catch (exception, stackTrace) {
if (!exception.toString().contains("Required key not available")) {
// TODO(39284): should this exception be silent?
AnalysisEngine.instance.instrumentationService.logException(
SilentException(
"Canonical failed: $pkgDir", exception, stackTrace));
} else if (_CanLogRequiredKeyIoException) {
_CanLogRequiredKeyIoException = false;
// TODO(39284): should this exception be silent?
AnalysisEngine.instance.instrumentationService.logException(
SilentException(
"Canonical failed: $pkgDir", exception, stackTrace));
}
}
return JavaFile.relative(pkgDir,
relPath.replaceAll('/', String.fromCharCode(JavaFile.separatorChar)));
}
@override
Source resolveAbsolute(Uri uri, [Uri actualUri]) {
if (!isPackageUri(uri)) {
return null;
}
String path = uri.path;
if (path == null) {
path = uri.path;
if (path == null) {
return null;
}
}
String pkgName;
String relPath;
int index = path.indexOf('/');
if (index == -1) {
// No slash
pkgName = path;
relPath = "";
} else if (index == 0) {
// Leading slash is invalid
return null;
} else {
// <pkgName>/<relPath>
pkgName = path.substring(0, index);
relPath = path.substring(index + 1);
}
for (JavaFile packagesDirectory in _packagesDirectories) {
JavaFile resolvedFile = JavaFile.relative(packagesDirectory, path);
if (resolvedFile.exists()) {
JavaFile canonicalFile =
getCanonicalFile(packagesDirectory, pkgName, relPath);
if (actualUri != null) {
return FileBasedSource(canonicalFile, actualUri);
}
if (_isSelfReference(packagesDirectory, canonicalFile)) {
uri = canonicalFile.toURI();
}
return FileBasedSource(canonicalFile, uri);
}
}
return FileBasedSource(
getCanonicalFile(_packagesDirectories[0], pkgName, relPath),
actualUri ?? uri);
}
@override
Uri restoreAbsolute(Source source) {
String sourceUri = _toFileUri(source.fullName);
for (JavaFile packagesDirectory in _packagesDirectories) {
List<JavaFile> pkgFolders = packagesDirectory.listFiles();
if (pkgFolders != null) {
for (JavaFile pkgFolder in pkgFolders) {
try {
String pkgCanonicalUri = _toFileUri(pkgFolder.getCanonicalPath());
if (sourceUri.startsWith(pkgCanonicalUri)) {
String relPath = sourceUri.substring(pkgCanonicalUri.length);
return Uri.parse(
"$PACKAGE_SCHEME:${pkgFolder.getName()}$relPath");
}
} catch (_) {}
}
}
}
return null;
}
/// @return `true` if "file" was found in "packagesDir", and it is part of
/// the "lib" folder of the application that contains in this
/// "packagesDir".
bool _isSelfReference(JavaFile packagesDir, JavaFile file) {
JavaFile rootDir = packagesDir.getParentFile();
if (rootDir == null) {
return false;
}
String rootPath = rootDir.getAbsolutePath();
String filePath = file.getAbsolutePath();
return filePath.startsWith("$rootPath/lib");
}
/// Convert the given file path to a "file:" URI. On Windows, this transforms
/// backslashes to forward slashes.
String _toFileUri(String filePath) => path.context.toUri(filePath).toString();
/// Return `true` if the given URI is a `package` URI.
///
/// @param uri the URI being tested
/// @return `true` if the given URI is a `package` URI
static bool isPackageUri(Uri uri) => PACKAGE_SCHEME == uri.scheme;
}
/// Instances of the class `RelativeFileUriResolver` resolve `file` URI's.
///
/// This class is now deprecated, file URI resolution should be done with
/// ResourceUriResolver, i.e.
/// 'new ResourceUriResolver(PhysicalResourceProvider.INSTANCE)'.
@deprecated
class RelativeFileUriResolver extends UriResolver {
/// The name of the `file` scheme.
static String FILE_SCHEME = "file";
/// The directories for the relatvie URI's
final List<JavaFile> _relativeDirectories;
/// The root directory for all the source trees
final JavaFile _rootDirectory;
/// Initialize a newly created resolver to resolve `file` URI's relative to
/// the given root directory.
RelativeFileUriResolver(this._rootDirectory, this._relativeDirectories)
: super();
@override
Source resolveAbsolute(Uri uri, [Uri actualUri]) {
String rootPath = _rootDirectory.toURI().path;
String uriPath = uri.path;
if (uriPath != null && uriPath.startsWith(rootPath)) {
String filePath = uri.path.substring(rootPath.length);
for (JavaFile dir in _relativeDirectories) {
JavaFile file = JavaFile.relative(dir, filePath);
if (file.exists()) {
return FileBasedSource(file, actualUri ?? uri);
}
}
}
return null;
}
/// Return `true` if the given URI is a `file` URI.
///
/// @param uri the URI being tested
/// @return `true` if the given URI is a `file` URI
static bool isFileUri(Uri uri) => uri.scheme == FILE_SCHEME;
}

View file

@ -1,8 +0,0 @@
// Copyright (c) 2015, 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.
@deprecated
library analyzer.src.generated.visitors;
export 'package:analyzer/dart/ast/visitor.dart' show DelegatingAstVisitor;

View file

@ -13,6 +13,7 @@ import 'package:analyzer/dart/ast/token.dart';
import 'package:analyzer/file_system/file_system.dart';
import 'package:analyzer/source/line_info.dart';
import 'package:analyzer/src/dart/analysis/byte_store.dart';
import 'package:analyzer/src/dart/analysis/driver.dart';
import 'package:analyzer/src/dart/analysis/session.dart';
import 'package:analyzer/src/dart/ast/ast.dart';
import 'package:analyzer/src/dart/ast/token.dart';
@ -171,6 +172,12 @@ class DeclarationsContext {
return _analysisContext.analysisOptions.contextFeatures;
}
AnalysisDriver get _analysisDriver {
var session = _analysisContext.currentSession as AnalysisSessionImpl;
// ignore: deprecated_member_use_from_same_package
return session.getDriver();
}
/// Return libraries that are available to the file with the given [path].
///
/// With `Pub`, files below the `pubspec.yaml` file can access libraries
@ -434,11 +441,7 @@ class DeclarationsContext {
}
void _scheduleKnownFiles() {
var session = _analysisContext.currentSession as AnalysisSessionImpl;
// ignore: deprecated_member_use_from_same_package
var analysisDriver = session.getDriver();
for (var path in analysisDriver.knownFiles) {
for (var path in _analysisDriver.knownFiles) {
if (_knownPathSet.add(path)) {
if (!path.contains(r'/lib/src/') && !path.contains(r'\lib\src\')) {
_knownPathList.add(path);
@ -449,8 +452,7 @@ class DeclarationsContext {
}
void _scheduleSdkLibraries() {
// ignore: deprecated_member_use_from_same_package
var sdk = _analysisContext.currentSession.sourceFactory.dartSdk;
var sdk = _analysisDriver.sourceFactory.dartSdk;
for (var uriStr in sdk.uris) {
if (!uriStr.startsWith('dart:_')) {
var uri = Uri.parse(uriStr);

View file

@ -1,8 +0,0 @@
// Copyright (c) 2015, 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.
@deprecated
library task.model;
export 'package:analyzer/src/task/api/model.dart';

View file

@ -1,5 +1,5 @@
name: analyzer
version: 0.39.18-dev
version: 0.40.0
description: This package provides a library that performs static analysis of Dart code.
homepage: https://github.com/dart-lang/sdk/tree/master/pkg/analyzer
@ -7,7 +7,7 @@ environment:
sdk: '>=2.7.0 <3.0.0'
dependencies:
_fe_analyzer_shared: ^7.0.0
_fe_analyzer_shared: ^8.0.0
args: ^1.0.0
charcode: ^1.1.0
cli_util: '>=0.1.4 <0.3.0'

View file

@ -3,7 +3,6 @@
// BSD-style license that can be found in the LICENSE file.
import 'package:analyzer/dart/analysis/declared_variables.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/dart/element/type_provider.dart';
import 'package:analyzer/src/dart/constant/from_environment_evaluator.dart';
import 'package:analyzer/src/dart/element/type_system.dart';
@ -21,133 +20,244 @@ void main() {
@reflectiveTest
class FromEnvironmentEvaluatorTest {
static const String _defaultValue = 'defaultValue';
TypeProvider typeProvider;
TypeSystemImpl typeSystem;
DartObjectImpl get _boolValueFalse {
return DartObjectImpl(
typeSystem,
typeProvider.boolType,
BoolState.FALSE_STATE,
);
}
DartObjectImpl get _boolValueTrue {
return DartObjectImpl(
typeSystem,
typeProvider.boolType,
BoolState.TRUE_STATE,
);
}
DartObjectImpl get _nullValue {
return DartObjectImpl(
typeSystem,
typeProvider.nullType,
NullState.NULL_STATE,
);
}
void setUp() {
var analysisContext = TestAnalysisContext();
typeProvider = analysisContext.typeProviderLegacy;
typeSystem = analysisContext.typeSystemLegacy;
}
@deprecated
void test_getBool_default() {
var name = 'foo';
var variables = FromEnvironmentEvaluator(
typeSystem,
DeclaredVariables.fromMap({}),
);
var object = _getBool(
variables,
name,
{_defaultValue: _boolValueFalse},
);
expect(object, _boolValueFalse);
}
void test_getBool_false() {
String variableName = "var";
var name = 'foo';
var variables = FromEnvironmentEvaluator(
typeSystem,
DeclaredVariables.fromMap({variableName: 'false'}),
DeclaredVariables.fromMap({name: 'false'}),
);
DartObject object = variables.getBool(variableName);
expect(object, isNotNull);
expect(object.toBoolValue(), false);
var object = _getBool(
variables,
name,
{_defaultValue: _boolValueFalse},
);
expect(object, _boolValueFalse);
}
@deprecated
void test_getBool_invalid() {
String variableName = "var";
var name = 'foo';
var variables = FromEnvironmentEvaluator(
typeSystem,
DeclaredVariables.fromMap({variableName: 'not true'}),
DeclaredVariables.fromMap({name: 'not bool'}),
);
_assertNullDartObject(
variables.getBool(variableName),
var object = _getBool(
variables,
name,
{_defaultValue: _boolValueFalse},
);
expect(object, _boolValueFalse);
}
@deprecated
void test_getBool_true() {
String variableName = "var";
var name = 'foo';
var variables = FromEnvironmentEvaluator(
typeSystem,
DeclaredVariables.fromMap({variableName: 'true'}),
DeclaredVariables.fromMap({name: 'true'}),
);
DartObject object = variables.getBool(variableName);
expect(object, isNotNull);
expect(object.toBoolValue(), true);
var object = _getBool(
variables,
name,
{_defaultValue: _boolValueFalse},
);
expect(object, _boolValueTrue);
}
@deprecated
void test_getBool_undefined() {
String variableName = "var";
var variables = FromEnvironmentEvaluator(
typeSystem,
DeclaredVariables(),
);
_assertUnknownDartObject(
typeProvider.boolType,
variables.getBool(variableName),
);
}
@deprecated
void test_getInt_invalid() {
String variableName = "var";
var name = 'foo';
var variables = FromEnvironmentEvaluator(
typeSystem,
DeclaredVariables.fromMap({variableName: 'four score and seven years'}),
DeclaredVariables.fromMap({name: 'four score and seven years'}),
);
_assertNullDartObject(
variables.getInt(variableName),
var object = _getInt(
variables,
name,
{_defaultValue: _intValue(0)},
);
expect(object, _intValue(0));
}
@deprecated
void test_getInt_undefined() {
String variableName = "var";
void test_getInt_undefined_defaultNull() {
var name = 'foo';
var variables = FromEnvironmentEvaluator(
typeSystem,
DeclaredVariables(),
);
_assertUnknownDartObject(
typeProvider.intType,
variables.getInt(variableName),
var object = _getInt(
variables,
name,
{_defaultValue: _nullValue},
);
expect(object, _nullValue);
}
void test_getInt_undefined_defaultZero() {
var name = 'foo';
var variables = FromEnvironmentEvaluator(
typeSystem,
DeclaredVariables(),
);
var object = _getInt(
variables,
name,
{_defaultValue: _intValue(0)},
);
expect(object, _intValue(0));
}
@deprecated
void test_getInt_valid() {
String variableName = "var";
var name = 'foo';
var variables = FromEnvironmentEvaluator(
typeSystem,
DeclaredVariables.fromMap({variableName: '23'}),
DeclaredVariables.fromMap({name: '23'}),
);
DartObject object = variables.getInt(variableName);
expect(object, isNotNull);
expect(object.toIntValue(), 23);
var object = _getInt(
variables,
name,
{_defaultValue: _intValue(0)},
);
expect(object, _intValue(23));
}
@deprecated
void test_getString_defined() {
String variableName = "var";
String value = "value";
var name = 'foo';
var variables = FromEnvironmentEvaluator(
typeSystem,
DeclaredVariables.fromMap({variableName: value}),
DeclaredVariables.fromMap({name: 'bar'}),
);
DartObject object = variables.getString(variableName);
expect(object, isNotNull);
expect(object.toStringValue(), value);
var object = _getString(
variables,
name,
{_defaultValue: _nullValue},
);
expect(object, _stringValue('bar'));
}
@deprecated
void test_getString_undefined() {
String variableName = "var";
void test_getString_undefined_defaultEmpty() {
var name = 'foo';
var variables = FromEnvironmentEvaluator(
typeSystem,
DeclaredVariables(),
);
_assertUnknownDartObject(
typeProvider.stringType,
variables.getString(variableName),
var object = _getString(
variables,
name,
{_defaultValue: _stringValue('')},
);
expect(object, _stringValue(''));
}
void test_getString_undefined_defaultNull() {
var name = 'foo';
var variables = FromEnvironmentEvaluator(
typeSystem,
DeclaredVariables(),
);
var object = _getString(
variables,
name,
{_defaultValue: _nullValue},
);
expect(object, _nullValue);
}
DartObjectImpl _getBool(
FromEnvironmentEvaluator variables,
String name,
Map<String, DartObjectImpl> namedValues,
) {
return variables.getBool2(
name,
namedValues,
typeProvider.boolElement.getNamedConstructor('fromEnvironment'),
);
}
void _assertNullDartObject(DartObject result) {
expect(result.type, typeProvider.nullType);
DartObjectImpl _getInt(
FromEnvironmentEvaluator variables,
String name,
Map<String, DartObjectImpl> namedValues,
) {
return variables.getInt2(
name,
namedValues,
typeProvider.intElement.getNamedConstructor('fromEnvironment'),
);
}
void _assertUnknownDartObject(DartType expectedType, DartObject result) {
expect((result as DartObjectImpl).isUnknown, isTrue);
expect(result.type, expectedType);
DartObjectImpl _getString(
FromEnvironmentEvaluator variables,
String name,
Map<String, DartObjectImpl> namedValues,
) {
return variables.getString2(
name,
namedValues,
typeProvider.stringElement.getNamedConstructor('fromEnvironment'),
);
}
DartObjectImpl _intValue(int value) {
return DartObjectImpl(
typeSystem,
typeProvider.intType,
IntState(value),
);
}
DartObjectImpl _stringValue(String value) {
return DartObjectImpl(
typeSystem,
typeProvider.stringType,
StringState(value),
);
}
}

View file

@ -21,8 +21,6 @@ import 'test_support.dart';
main() {
defineReflectiveSuite(() {
defineReflectiveTests(ContentCacheTest);
// ignore: deprecated_member_use_from_same_package
defineReflectiveTests(CustomUriResolverTest);
defineReflectiveTests(DartUriResolverTest);
defineReflectiveTests(ErrorSeverityTest);
defineReflectiveTests(FileBasedSourceTest);
@ -50,33 +48,6 @@ class ContentCacheTest {
}
}
@deprecated
@reflectiveTest
class CustomUriResolverTest {
void test_creation() {
expect(CustomUriResolver({}), isNotNull);
}
void test_resolve_unknown_uri() {
UriResolver resolver = CustomUriResolver({
'custom:library': '/path/to/library.dart',
});
Source result = resolver.resolveAbsolute(Uri.parse("custom:non_library"));
expect(result, isNull);
}
void test_resolve_uri() {
String filePath =
FileUtilities2.createFile("/path/to/library.dart").getAbsolutePath();
UriResolver resolver = CustomUriResolver({
'custom:library': filePath,
});
Source result = resolver.resolveAbsolute(Uri.parse("custom:library"));
expect(result, isNotNull);
expect(result.fullName, filePath);
}
}
@reflectiveTest
class DartUriResolverTest extends _SimpleDartSdkTest {
DartUriResolver resolver;

View file

@ -652,20 +652,6 @@ void main() {
);
}
@Deprecated('It was used internally, should not be part of API')
test_hasReferenceToSuper() async {
await assertNoErrorsInCode(r'''
class A {}
class B {toString() => super.toString();}''');
verifyTestResolved();
var a = findElement.class_('A');
expect(a.hasReferenceToSuper, isFalse);
var b = findElement.class_('B');
expect(b.hasReferenceToSuper, isTrue);
}
test_import_hide() async {
newFile('$testPackageLibPath/lib1.dart', content: r'''
set foo(value) {}

View file

@ -709,7 +709,10 @@ class StaticTypeAnalyzerTest with ResourceProviderMixin, ElementsTypesMixin {
void _assertType(
InterfaceTypeImpl expectedType, InterfaceTypeImpl actualType) {
expect(actualType.getDisplayString(), expectedType.getDisplayString());
expect(
actualType.getDisplayString(withNullability: false),
expectedType.getDisplayString(withNullability: false),
);
expect(actualType.element, expectedType.element);
List<DartType> expectedArguments = expectedType.typeArguments;
int length = expectedArguments.length;

View file

@ -68,10 +68,6 @@ class TestAnalysisContext implements AnalysisContext {
AnalysisSessionImpl get analysisSession => _analysisSession;
@Deprecated('Use LibraryElement.typeProvider')
@override
TypeProvider get typeProvider => typeProviderLegacy;
TypeProvider get typeProviderLegacy {
return _typeProviderLegacy;
}
@ -80,10 +76,6 @@ class TestAnalysisContext implements AnalysisContext {
return _typeProviderNonNullableByDefault;
}
@Deprecated('Use LibraryElement.typeSystem')
@override
TypeSystemImpl get typeSystem => typeSystemLegacy;
TypeSystemImpl get typeSystemLegacy {
return _typeSystemLegacy;
}

View file

@ -1,168 +0,0 @@
// Copyright (c) 2015, 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.
@deprecated
library analyzer.test.source.embedder_test;
import 'dart:core';
import 'package:analyzer/file_system/file_system.dart';
import 'package:analyzer/source/embedder.dart';
import 'package:analyzer/src/generated/sdk.dart';
import 'package:analyzer/src/generated/source.dart';
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
import '../embedder_tests.dart';
import '../resource_utils.dart';
main() {
defineReflectiveSuite(() {
defineReflectiveTests(DartUriResolverTest);
defineReflectiveTests(EmbedderSdkTest);
defineReflectiveTests(EmbedderUriResolverTest);
});
}
@reflectiveTest
class DartUriResolverTest extends EmbedderRelatedTest {
void test_embedderYaml() {
EmbedderYamlLocator locator = EmbedderYamlLocator({
'fox': <Folder>[pathTranslator.getResource(foxLib)]
});
EmbedderSdk sdk = EmbedderSdk(locator.embedderYamls);
DartUriResolver resolver = DartUriResolver(sdk);
void expectResolved(dartUri, posixPath) {
Source source = resolver.resolveAbsolute(Uri.parse(dartUri));
expect(source, isNotNull, reason: dartUri);
expect(source.fullName, posixToOSPath(posixPath));
}
// Check that they map to the correct paths.
expectResolved('dart:core', '$foxLib/core/core.dart');
expectResolved('dart:fox', '$foxLib/slippy.dart');
expectResolved('dart:bear', '$foxLib/grizzly.dart');
expectResolved('dart:relative', '$foxPath/relative.dart');
expectResolved('dart:deep', '$foxLib/deep/directory/file.dart');
}
}
@reflectiveTest
class EmbedderSdkTest extends EmbedderRelatedTest {
void test_creation() {
EmbedderYamlLocator locator = EmbedderYamlLocator({
'fox': <Folder>[pathTranslator.getResource(foxLib)]
});
EmbedderSdk sdk = EmbedderSdk(locator.embedderYamls);
expect(sdk.urlMappings, hasLength(5));
}
void test_fromFileUri() {
EmbedderYamlLocator locator = EmbedderYamlLocator({
'fox': <Folder>[pathTranslator.getResource(foxLib)]
});
EmbedderSdk sdk = EmbedderSdk(locator.embedderYamls);
expectSource(String posixPath, String dartUri) {
Uri uri = Uri.parse(posixToOSFileUri(posixPath));
Source source = sdk.fromFileUri(uri);
expect(source, isNotNull, reason: posixPath);
expect(source.uri.toString(), dartUri);
expect(source.fullName, posixToOSPath(posixPath));
}
expectSource('$foxLib/slippy.dart', 'dart:fox');
expectSource('$foxLib/deep/directory/file.dart', 'dart:deep');
expectSource('$foxLib/deep/directory/part.dart', 'dart:deep/part.dart');
}
void test_getSdkLibrary() {
EmbedderYamlLocator locator = EmbedderYamlLocator({
'fox': <Folder>[pathTranslator.getResource(foxLib)]
});
EmbedderSdk sdk = EmbedderSdk(locator.embedderYamls);
SdkLibrary lib = sdk.getSdkLibrary('dart:fox');
expect(lib, isNotNull);
expect(lib.path, posixToOSPath('$foxLib/slippy.dart'));
expect(lib.shortName, 'dart:fox');
}
void test_mapDartUri() {
EmbedderYamlLocator locator = EmbedderYamlLocator({
'fox': <Folder>[pathTranslator.getResource(foxLib)]
});
EmbedderSdk sdk = EmbedderSdk(locator.embedderYamls);
void expectSource(String dartUri, String posixPath) {
Source source = sdk.mapDartUri(dartUri);
expect(source, isNotNull, reason: posixPath);
expect(source.uri.toString(), dartUri);
expect(source.fullName, posixToOSPath(posixPath));
}
expectSource('dart:core', '$foxLib/core/core.dart');
expectSource('dart:fox', '$foxLib/slippy.dart');
expectSource('dart:deep', '$foxLib/deep/directory/file.dart');
expectSource('dart:deep/part.dart', '$foxLib/deep/directory/part.dart');
}
}
@reflectiveTest
class EmbedderUriResolverTest extends EmbedderRelatedTest {
void test_embedderYaml() {
var locator = EmbedderYamlLocator({
'fox': <Folder>[pathTranslator.getResource(foxLib)]
});
var resolver = EmbedderUriResolver(locator.embedderYamls);
expectResolved(dartUri, posixPath) {
Source source = resolver.resolveAbsolute(Uri.parse(dartUri));
expect(source, isNotNull, reason: dartUri);
expect(source.fullName, posixToOSPath(posixPath));
}
// We have five mappings.
expect(resolver, hasLength(5));
// Check that they map to the correct paths.
expectResolved('dart:core', '$foxLib/core/core.dart');
expectResolved('dart:fox', '$foxLib/slippy.dart');
expectResolved('dart:bear', '$foxLib/grizzly.dart');
expectResolved('dart:relative', '$foxPath/relative.dart');
expectResolved('dart:deep', '$foxLib/deep/directory/file.dart');
}
void test_nullEmbedderYamls() {
var resolver = EmbedderUriResolver(null);
expect(resolver, hasLength(0));
}
void test_restoreAbsolute() {
var locator = EmbedderYamlLocator({
'fox': <Folder>[pathTranslator.getResource(foxLib)]
});
var resolver = EmbedderUriResolver(locator.embedderYamls);
expectRestore(String dartUri, [String expected]) {
var parsedUri = Uri.parse(dartUri);
var source = resolver.resolveAbsolute(parsedUri);
expect(source, isNotNull);
// Restore source's uri.
var restoreUri = resolver.restoreAbsolute(source);
expect(restoreUri, isNotNull, reason: dartUri);
// Verify that it is 'dart:fox'.
expect(restoreUri.toString(), expected ?? dartUri);
List<String> split = (expected ?? dartUri).split(':');
expect(restoreUri.scheme, split[0]);
expect(restoreUri.path, split[1]);
}
expectRestore('dart:deep');
expectRestore('dart:deep/file.dart', 'dart:deep');
expectRestore('dart:deep/part.dart');
expectRestore('dart:deep/deep/file.dart');
}
}

View file

@ -5,8 +5,6 @@
import 'package:test_reflective_loader/test_reflective_loader.dart';
import 'analysis_options_provider_test.dart' as analysis_options_provider_test;
import 'embedder_test.dart' // ignore: deprecated_member_use_from_same_package
as embedder_test;
import 'error_processor_test.dart' as error_processor_test;
import 'package_map_resolver_test.dart' as package_map_resolver_test;
import 'path_filter_test.dart' as path_filter_test;
@ -14,7 +12,6 @@ import 'path_filter_test.dart' as path_filter_test;
main() {
defineReflectiveSuite(() {
analysis_options_provider_test.main();
embedder_test.main();
error_processor_test.main();
package_map_resolver_test.main();
path_filter_test.main();

View file

@ -60,7 +60,6 @@ class ArgumentsTest with ResourceProviderMixin {
AnalysisOptionsImpl defaultOptions = options.defaultOptions;
expect(defaultOptions, isNotNull);
expect(defaultOptions.strongMode, true);
expect(defaultOptions.implicitCasts, false);
expect(defaultOptions.implicitDynamic, false);
}
@ -79,7 +78,6 @@ class ArgumentsTest with ResourceProviderMixin {
expect(options.defaultPackageFilePath, isNull);
AnalysisOptionsImpl defaultOptions = options.defaultOptions;
expect(defaultOptions, isNotNull);
expect(defaultOptions.strongMode, true);
expect(defaultOptions.implicitCasts, true);
expect(defaultOptions.implicitDynamic, true);
}

View file

@ -766,7 +766,6 @@ environment:
actual.lintRules.map((l) => l.name),
unorderedEquals(expected.lintRules.map((l) => l.name)),
);
expect(actual.strongMode, expected.strongMode);
expect(actual.implicitCasts, expected.implicitCasts);
expect(actual.implicitDynamic, expected.implicitDynamic);
expect(actual.strictInference, expected.strictInference);

View file

@ -949,8 +949,6 @@ main() {
itemElement1 = itemElement;
expect(closureElement.returnType, typeProvider.nullType);
// TODO(scheglov) Make this null.
// expect(closureElement.type.element, same(closureElement));
assertType(closureElement.type, closureTypeStr);
expect(closure.staticType, same(closureElement.type));
@ -991,7 +989,6 @@ main() {
expect(itemElement, isNot(same(itemElement1)));
expect(closureElement.returnType, typeProvider.nullType);
expect(closureElement.type.element, same(closureElement));
assertType(closureElement.type, closureTypeStr);
expect(closure.staticType, same(closureElement.type));

View file

@ -4,6 +4,7 @@
import 'package:analyzer/src/dart/analysis/experiments.dart';
import 'package:analyzer/src/dart/analysis/experiments_impl.dart';
import 'package:pub_semver/pub_semver.dart';
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
@ -54,7 +55,8 @@ class ExperimentsTest {
isEnabledByDefault: false,
isExpired: false,
documentation: 'a',
firstSupportedVersion: null,
experimentalReleaseVersion: null,
releaseVersion: null,
);
expect(getFlags(fromStrings(['no-a', 'a'])), [true]);
}
@ -67,7 +69,8 @@ class ExperimentsTest {
isEnabledByDefault: false,
isExpired: false,
documentation: 'a',
firstSupportedVersion: null,
experimentalReleaseVersion: null,
releaseVersion: null,
);
expect(getFlags(fromStrings(['a', 'no-a'])), [false]);
}
@ -79,7 +82,8 @@ class ExperimentsTest {
isEnabledByDefault: false,
isExpired: false,
documentation: 'a',
firstSupportedVersion: null,
experimentalReleaseVersion: null,
releaseVersion: null,
);
knownFeatures['b'] = ExperimentalFeature(
index: 1,
@ -87,7 +91,8 @@ class ExperimentsTest {
isEnabledByDefault: true,
isExpired: false,
documentation: 'b',
firstSupportedVersion: '1.0.0',
experimentalReleaseVersion: null,
releaseVersion: Version.parse('1.0.0'),
);
expect(getFlags(fromStrings([])), [false, true]);
}
@ -99,7 +104,8 @@ class ExperimentsTest {
isEnabledByDefault: false,
isExpired: false,
documentation: 'a',
firstSupportedVersion: null,
experimentalReleaseVersion: null,
releaseVersion: null,
);
expect(getFlags(fromStrings(['no-a'])), [false]);
}
@ -111,7 +117,8 @@ class ExperimentsTest {
isEnabledByDefault: true,
isExpired: false,
documentation: 'a',
firstSupportedVersion: '1.0.0',
experimentalReleaseVersion: null,
releaseVersion: Version.parse('1.0.0'),
);
expect(getFlags(fromStrings(['no-a'])), [false]);
}
@ -123,7 +130,8 @@ class ExperimentsTest {
isEnabledByDefault: false,
isExpired: false,
documentation: 'a',
firstSupportedVersion: null,
experimentalReleaseVersion: null,
releaseVersion: null,
);
expect(getFlags(fromStrings(['a'])), [true]);
}
@ -135,7 +143,8 @@ class ExperimentsTest {
isEnabledByDefault: true,
isExpired: false,
documentation: 'a',
firstSupportedVersion: '1.0.0',
experimentalReleaseVersion: null,
releaseVersion: Version.parse('1.0.0'),
);
expect(getFlags(fromStrings(['a'])), [true]);
}
@ -148,7 +157,8 @@ class ExperimentsTest {
isEnabledByDefault: true,
isExpired: true,
documentation: 'a',
firstSupportedVersion: '1.0.0',
experimentalReleaseVersion: null,
releaseVersion: Version.parse('1.0.0'),
);
expect(getFlags(fromStrings(['no-a'])), [true]);
}
@ -161,7 +171,8 @@ class ExperimentsTest {
isEnabledByDefault: false,
isExpired: true,
documentation: 'a',
firstSupportedVersion: null,
experimentalReleaseVersion: null,
releaseVersion: null,
);
expect(getFlags(fromStrings(['a'])), [false]);
}
@ -174,7 +185,8 @@ class ExperimentsTest {
isEnabledByDefault: false,
isExpired: true,
documentation: 'a',
firstSupportedVersion: null,
experimentalReleaseVersion: null,
releaseVersion: null,
);
expect(getFlags(fromStrings(['no-a'])), [false]);
}
@ -187,7 +199,8 @@ class ExperimentsTest {
isEnabledByDefault: true,
isExpired: true,
documentation: 'a',
firstSupportedVersion: '1.0.0',
experimentalReleaseVersion: null,
releaseVersion: Version.parse('1.0.0'),
);
expect(getFlags(fromStrings(['a'])), [true]);
}
@ -204,7 +217,8 @@ class ExperimentsTest {
isEnabledByDefault: false,
isExpired: false,
documentation: 'a',
firstSupportedVersion: null,
experimentalReleaseVersion: null,
releaseVersion: null,
);
knownFeatures['b'] = ExperimentalFeature(
index: 1,
@ -212,7 +226,8 @@ class ExperimentsTest {
isEnabledByDefault: false,
isExpired: false,
documentation: 'b',
firstSupportedVersion: null,
experimentalReleaseVersion: null,
releaseVersion: null,
);
knownFeatures['c'] = ExperimentalFeature(
index: 2,
@ -220,7 +235,8 @@ class ExperimentsTest {
isEnabledByDefault: false,
isExpired: false,
documentation: 'c',
firstSupportedVersion: null,
experimentalReleaseVersion: null,
releaseVersion: null,
);
var validationResult =
getValidateCombinationResult(['a', 'no-c'], ['no-b', 'c']);
@ -237,7 +253,8 @@ class ExperimentsTest {
isEnabledByDefault: false,
isExpired: false,
documentation: 'a',
firstSupportedVersion: null,
experimentalReleaseVersion: null,
releaseVersion: null,
);
knownFeatures['b'] = ExperimentalFeature(
index: 1,
@ -245,7 +262,8 @@ class ExperimentsTest {
isEnabledByDefault: false,
isExpired: false,
documentation: 'b',
firstSupportedVersion: null,
experimentalReleaseVersion: null,
releaseVersion: null,
);
knownFeatures['c'] = ExperimentalFeature(
index: 2,
@ -253,7 +271,8 @@ class ExperimentsTest {
isEnabledByDefault: false,
isExpired: false,
documentation: 'c',
firstSupportedVersion: null,
experimentalReleaseVersion: null,
releaseVersion: null,
);
var validationResult =
getValidateCombinationResult(['a', 'c'], ['no-b', 'no-c']);
@ -270,7 +289,8 @@ class ExperimentsTest {
isEnabledByDefault: false,
isExpired: false,
documentation: 'a',
firstSupportedVersion: null,
experimentalReleaseVersion: null,
releaseVersion: null,
);
knownFeatures['b'] = ExperimentalFeature(
index: 1,
@ -278,7 +298,8 @@ class ExperimentsTest {
isEnabledByDefault: false,
isExpired: false,
documentation: 'b',
firstSupportedVersion: null,
experimentalReleaseVersion: null,
releaseVersion: null,
);
knownFeatures['c'] = ExperimentalFeature(
index: 2,
@ -286,7 +307,8 @@ class ExperimentsTest {
isEnabledByDefault: false,
isExpired: false,
documentation: 'c',
firstSupportedVersion: null,
experimentalReleaseVersion: null,
releaseVersion: null,
);
expect(getValidateCombinationResult(['a', 'c'], ['no-b', 'c']), isEmpty);
}
@ -298,7 +320,8 @@ class ExperimentsTest {
isEnabledByDefault: false,
isExpired: false,
documentation: 'a',
firstSupportedVersion: null,
experimentalReleaseVersion: null,
releaseVersion: null,
);
var validationResult = getValidationResult(['no-a', 'a']);
expect(validationResult, hasLength(1));
@ -318,7 +341,8 @@ class ExperimentsTest {
isEnabledByDefault: false,
isExpired: false,
documentation: 'a',
firstSupportedVersion: null,
experimentalReleaseVersion: null,
releaseVersion: null,
);
var validationResult = getValidationResult(['a', 'no-a']);
expect(validationResult, hasLength(1));
@ -338,7 +362,8 @@ class ExperimentsTest {
isEnabledByDefault: true,
isExpired: false,
documentation: 'a',
firstSupportedVersion: '1.0.0',
experimentalReleaseVersion: null,
releaseVersion: Version.parse('1.0.0'),
);
expect(getValidationResult(['no-a', 'no-a']), isEmpty);
}
@ -350,7 +375,8 @@ class ExperimentsTest {
isEnabledByDefault: false,
isExpired: false,
documentation: 'a',
firstSupportedVersion: null,
experimentalReleaseVersion: null,
releaseVersion: null,
);
expect(getValidationResult(['a', 'a']), isEmpty);
}
@ -362,7 +388,8 @@ class ExperimentsTest {
isEnabledByDefault: true,
isExpired: true,
documentation: 'a',
firstSupportedVersion: '1.0.0',
experimentalReleaseVersion: null,
releaseVersion: Version.parse('1.0.0'),
);
var validationResult = getValidationResult(['no-a']);
expect(validationResult, hasLength(1));
@ -380,7 +407,8 @@ class ExperimentsTest {
isEnabledByDefault: false,
isExpired: true,
documentation: 'a',
firstSupportedVersion: null,
experimentalReleaseVersion: null,
releaseVersion: null,
);
var validationResult = getValidationResult(['a']);
expect(validationResult, hasLength(1));
@ -398,7 +426,8 @@ class ExperimentsTest {
isEnabledByDefault: false,
isExpired: true,
documentation: 'a',
firstSupportedVersion: null,
experimentalReleaseVersion: null,
releaseVersion: null,
);
var validationResult = getValidationResult(['no-a']);
expect(validationResult, hasLength(1));
@ -416,7 +445,8 @@ class ExperimentsTest {
isEnabledByDefault: true,
isExpired: true,
documentation: 'a',
firstSupportedVersion: '1.0.0',
experimentalReleaseVersion: null,
releaseVersion: Version.parse('1.0.0'),
);
var validationResult = getValidationResult(['a']);
expect(validationResult, hasLength(1));

View file

@ -493,20 +493,4 @@ class B {}
test_resourceProvider() async {
expect(session.resourceProvider, resourceProvider);
}
@deprecated
test_typeProvider() async {
var typeProvider = await session.typeProvider;
expect(typeProvider.intType.element.name, 'int');
}
@deprecated
test_typeSystem() async {
var typeSystem = await session.typeSystem;
var typeProvider = typeSystem.typeProvider;
expect(
typeSystem.isSubtypeOf(typeProvider.intType, typeProvider.numType),
isTrue,
);
}
}

View file

@ -1191,71 +1191,6 @@ class FunctionTypeImplTest extends AbstractTypeTest {
expect(type.resolveToBound(null), same(type));
}
@deprecated
void test_substitute2_equal() {
ClassElementImpl definingClass = ElementFactory.classElement2("C", ["E"]);
TypeParameterType parameterType =
typeParameterTypeStar(definingClass.typeParameters[0]);
MethodElementImpl functionElement = MethodElementImpl('m', -1);
String namedParameterName = "c";
functionElement.parameters = <ParameterElement>[
ElementFactory.requiredParameter2("a", parameterType),
ElementFactory.positionalParameter2("b", parameterType),
ElementFactory.namedParameter2(namedParameterName, parameterType)
];
functionElement.returnType = parameterType;
definingClass.methods = <MethodElement>[functionElement];
FunctionTypeImpl functionType = functionElement.type;
InterfaceTypeImpl argumentType =
interfaceTypeStar(ClassElementImpl('D', -1));
FunctionType result = functionType
.substitute2(<DartType>[argumentType], <DartType>[parameterType]);
expect(result.returnType, argumentType);
List<DartType> normalParameters = result.normalParameterTypes;
expect(normalParameters, hasLength(1));
expect(normalParameters[0], argumentType);
List<DartType> optionalParameters = result.optionalParameterTypes;
expect(optionalParameters, hasLength(1));
expect(optionalParameters[0], argumentType);
Map<String, DartType> namedParameters = result.namedParameterTypes;
expect(namedParameters, hasLength(1));
expect(namedParameters[namedParameterName], argumentType);
}
@deprecated
void test_substitute2_notEqual() {
DartType returnType = interfaceTypeStar(ClassElementImpl('R', -1));
DartType normalParameterType = interfaceTypeStar(ClassElementImpl('A', -1));
DartType optionalParameterType =
interfaceTypeStar(ClassElementImpl('B', -1));
DartType namedParameterType = interfaceTypeStar(ClassElementImpl('C', -1));
FunctionElementImpl functionElement = FunctionElementImpl('f', -1);
String namedParameterName = "c";
functionElement.parameters = <ParameterElement>[
ElementFactory.requiredParameter2("a", normalParameterType),
ElementFactory.positionalParameter2("b", optionalParameterType),
ElementFactory.namedParameter2(namedParameterName, namedParameterType)
];
functionElement.returnType = returnType;
FunctionTypeImpl functionType = functionElement.type;
InterfaceTypeImpl argumentType =
interfaceTypeStar(ClassElementImpl('D', -1));
TypeParameterTypeImpl parameterType =
typeParameterTypeStar(TypeParameterElementImpl('E', -1));
FunctionType result = functionType
.substitute2(<DartType>[argumentType], <DartType>[parameterType]);
expect(result.returnType, returnType);
List<DartType> normalParameters = result.normalParameterTypes;
expect(normalParameters, hasLength(1));
expect(normalParameters[0], normalParameterType);
List<DartType> optionalParameters = result.optionalParameterTypes;
expect(optionalParameters, hasLength(1));
expect(optionalParameters[0], optionalParameterType);
Map<String, DartType> namedParameters = result.namedParameterTypes;
expect(namedParameters, hasLength(1));
expect(namedParameters[namedParameterName], namedParameterType);
}
void test_toString_recursive() {
var t = ElementFactory.genericTypeAliasElement("t");
var s = ElementFactory.genericTypeAliasElement("s");
@ -2096,44 +2031,6 @@ class InterfaceTypeImplTest extends AbstractTypeTest {
// Returns this.
expect(type.resolveToBound(null), same(type));
}
@deprecated
void test_substitute_exception() {
try {
var classA = class_(name: 'A');
InterfaceTypeImpl type = interfaceTypeStar(classA);
InterfaceType argumentType = interfaceTypeStar(class_(name: 'B'));
type.substitute2(<DartType>[argumentType], <DartType>[]);
fail(
"Expected to encounter exception, argument and parameter type array lengths not equal.");
} catch (e) {
// Expected result
}
}
@deprecated
void test_substitute_notEqual() {
// The [test_substitute_equals] above has a slightly higher level
// implementation.
var classA = class_(name: 'A');
TypeParameterElementImpl parameterElement =
TypeParameterElementImpl('E', -1);
TypeParameterTypeImpl parameter = typeParameterTypeStar(parameterElement);
InterfaceTypeImpl type = InterfaceTypeImpl(
element: classA,
typeArguments: <DartType>[parameter],
nullabilitySuffix: NullabilitySuffix.star,
);
InterfaceType argumentType = interfaceTypeStar(class_(name: 'B'));
TypeParameterTypeImpl parameterType =
typeParameterTypeStar(TypeParameterElementImpl('F', -1));
InterfaceType result =
type.substitute2(<DartType>[argumentType], <DartType>[parameterType]);
expect(result.element, classA);
List<DartType> resultArguments = result.typeArguments;
expect(resultArguments, hasLength(1));
expect(resultArguments[0], parameter);
}
}
@reflectiveTest
@ -2386,27 +2283,6 @@ class TypeParameterTypeImplTest extends AbstractTypeTest {
same(VoidTypeImpl.instance));
}
@deprecated
void test_substitute_equal() {
TypeParameterElementImpl element = TypeParameterElementImpl('E', -1);
TypeParameterTypeImpl type = typeParameterTypeStar(element);
InterfaceTypeImpl argument = interfaceTypeStar(ClassElementImpl('A', -1));
TypeParameterTypeImpl parameter = typeParameterTypeStar(element);
expect(type.substitute2(<DartType>[argument], <DartType>[parameter]),
same(argument));
}
@deprecated
void test_substitute_notEqual() {
TypeParameterTypeImpl type =
typeParameterTypeStar(TypeParameterElementImpl('E', -1));
InterfaceTypeImpl argument = interfaceTypeStar(ClassElementImpl('A', -1));
TypeParameterTypeImpl parameter =
typeParameterTypeStar(TypeParameterElementImpl('F', -1));
expect(type.substitute2(<DartType>[argument], <DartType>[parameter]),
same(type));
}
void _assert_asInstanceOf(
DartType type,
ClassElement element,

View file

@ -408,55 +408,6 @@ class FunctionTypeTest with ElementsTypesMixin {
returnType: same(objectType));
}
@deprecated
test_synthetic_substitute() {
// Map<T, U> Function<U extends T>(T x, U y)
var t = typeParameter('T');
var u = typeParameter('U', bound: typeParameterTypeNone(t));
var x = requiredParameter(name: 'x', type: typeParameterTypeNone(t));
var y = requiredParameter(name: 'y', type: typeParameterTypeNone(u));
FunctionType f = FunctionTypeImpl.synthetic(
mapOf(typeParameterTypeNone(t), typeParameterTypeNone(u)), [u], [x, y],
nullabilitySuffix: NullabilitySuffix.star);
FunctionType substituted =
f.substitute2([objectType], [typeParameterTypeNone(t)]);
var uSubstituted = substituted.typeFormals[0];
basicChecks(substituted,
element: isNull,
displayName: 'Map<Object, U> Function<U extends Object>(Object, U)',
returnType: mapOf(objectType, typeParameterTypeNone(uSubstituted)),
typeFormals: [uSubstituted],
normalParameterNames: ['x', 'y'],
normalParameterTypes: [
same(objectType),
typeParameterTypeNone(uSubstituted)
],
parameters: hasLength(2));
}
@deprecated
test_synthetic_substitute_argument_length_mismatch() {
// dynamic Function()
var t = typeParameter('T');
FunctionType f = FunctionTypeImpl.synthetic(dynamicType, [], [],
nullabilitySuffix: NullabilitySuffix.star);
expect(() => f.substitute2([], [typeParameterTypeStar(t)]),
throwsA(TypeMatcher<ArgumentError>()));
}
@deprecated
test_synthetic_substitute_unchanged() {
// dynamic Function<U>(U x)
var t = typeParameter('T');
var u = typeParameter('U');
var x = requiredParameter(name: 'x', type: typeParameterTypeStar(u));
FunctionType f = FunctionTypeImpl.synthetic(dynamicType, [u], [x],
nullabilitySuffix: NullabilitySuffix.star);
FunctionType substituted =
f.substitute2([objectType], [typeParameterTypeStar(t)]);
expect(substituted, same(f));
}
test_synthetic_typeFormals() {
var t = typeParameter('T');
FunctionType f = FunctionTypeImpl(

View file

@ -560,8 +560,10 @@ f() {
}
''');
var invocation = findNode.functionExpressionInvocation('1(2)');
expect(invocation.staticInvokeType.element,
same(findElement.method('call', of: 'E')));
expect(
invocation.staticElement,
same(findElement.method('call', of: 'E')),
);
assertInvokeType(invocation, 'int Function(int)');
}

View file

@ -44,13 +44,13 @@ Annotation
literal: 0
staticType: int
constructorName: ConstructorName
staticElement: self::@class::A::@constructor::
type: TypeName
name: SimpleIdentifier
staticElement: self::@class::A
staticType: null
token: A
type: A
staticElement: self::@class::A::@constructor::
staticType: A
element: self::@class::A::@constructor::
name: SimpleIdentifier

View file

@ -336,6 +336,7 @@ class ResolvedAstPrinter extends ThrowingAstVisitor<void> {
_writeln('ConstructorName');
_withIndent(() {
_writeNode('name', node.name);
_writeElement('staticElement', node.staticElement);
_writeNode('type', node.type);
});
}
@ -792,7 +793,6 @@ class ResolvedAstPrinter extends ThrowingAstVisitor<void> {
properties.addNode('constructorName', node.constructorName);
properties.addToken('keyword', node.keyword);
_addExpression(properties, node);
_addConstructorReferenceNode(properties, node);
_writeProperties(properties);
});
}
@ -1477,14 +1477,6 @@ class ResolvedAstPrinter extends ThrowingAstVisitor<void> {
_addAstNode(properties, node);
}
void _addConstructorReferenceNode(
_Properties properties,
ConstructorReferenceNode node,
) {
properties.addElement('staticElement', node.staticElement);
_addAstNode(properties, node);
}
void _addDeclaration(_Properties properties, Declaration node) {
properties.addElement('declaredElement', node.declaredElement);
_addAnnotatedNode(properties, node);

View file

@ -8,7 +8,6 @@ import 'package:analyzer/dart/analysis/declared_variables.dart';
import 'package:analyzer/dart/analysis/features.dart';
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/nullability_suffix.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/file_system/file_system.dart';
import 'package:analyzer/src/dart/element/element.dart';
@ -10556,42 +10555,6 @@ Never d;
annotateNullability: true);
}
@deprecated
test_type_param_generic_function_type_nullability_legacy() async {
featureSet = disableNnbd;
var library = await checkLibrary('''
T f<T>(T t) {}
var g = f;
''');
checkElementText(library, '''
T Function<T>(T) g;
T f<T>(T t) {}
''');
var g = library.definingCompilationUnit.topLevelVariables[0];
var t = (g.type as FunctionType).typeFormals[0];
// TypeParameterElement.type has a nullability suffix of `star` regardless
// of whether it appears in a migrated library.
expect(t.type.nullabilitySuffix, NullabilitySuffix.star);
}
@deprecated
test_type_param_generic_function_type_nullability_migrated() async {
featureSet = enableNnbd;
var library = await checkLibrary('''
T f<T>(T t) {}
var g = f;
''');
checkElementText(library, '''
T Function<T>(T) g;
T f<T>(T t) {}
''');
var g = library.definingCompilationUnit.topLevelVariables[0];
var t = (g.type as FunctionType).typeFormals[0];
// TypeParameterElement.type has a nullability suffix of `star` regardless
// of whether it appears in a migrated library.
expect(t.type.nullabilitySuffix, NullabilitySuffix.star);
}
test_type_param_ref_nullability_none() async {
featureSet = enableNnbd;
var library = await checkLibrary('''
@ -11828,15 +11791,15 @@ const A<int> a;
InstanceCreationExpression
argumentList: ArgumentList
constructorName: ConstructorName
staticElement: ConstructorMember
base: self::@class::A::@constructor::
substitution: {T: int}
type: TypeName
name: SimpleIdentifier
staticElement: self::@class::A
staticType: null
token: A
type: A<int>
staticElement: ConstructorMember
base: self::@class::A::@constructor::
substitution: {T: int}
staticType: A<int>
''',
withFullyResolvedAst: true);

View file

@ -169,18 +169,19 @@ class ExperimentalFeatures {
var enabledIn = (features[key] as YamlMap)['enabledIn'];
out.write('''
static const $id = ExperimentalFeature(
static final $id = ExperimentalFeature(
index: $index,
enableString: EnableString.$id,
isEnabledByDefault: IsEnabledByDefault.$id,
isExpired: IsExpired.$id,
documentation: '$help',
''');
out.write("experimentalReleaseVersion: null,");
if (enabledIn != null) {
enabledIn = _versionNumberAsString(enabledIn);
out.write("firstSupportedVersion: '$enabledIn',");
out.write("releaseVersion: Version.parse('$enabledIn'),");
} else {
out.write("firstSupportedVersion: null,");
out.write("releaseVersion: null,");
}
out.writeln(');');
++index;
@ -236,7 +237,7 @@ class IsExpired {
out.write('''
/// A map containing information about all known experimental flags.
const _knownFeatures = <String, ExperimentalFeature>{
final _knownFeatures = <String, ExperimentalFeature>{
''');
for (var key in keysSorted) {
var id = keyToIdentifier(key);

View file

@ -102,7 +102,8 @@ void main() {
isEnabledByDefault: false,
isExpired: false,
documentation: 'a',
firstSupportedVersion: null,
experimentalReleaseVersion: null,
releaseVersion: null,
),
'b': ExperimentalFeature(
index: 1,
@ -110,7 +111,8 @@ void main() {
isEnabledByDefault: false,
isExpired: false,
documentation: 'b',
firstSupportedVersion: null,
experimentalReleaseVersion: null,
releaseVersion: null,
),
'c': ExperimentalFeature(
index: 2,
@ -118,7 +120,8 @@ void main() {
isEnabledByDefault: false,
isExpired: false,
documentation: 'c',
firstSupportedVersion: null,
experimentalReleaseVersion: null,
releaseVersion: null,
),
};

View file

@ -27,7 +27,7 @@ import 'package:yaml/yaml.dart';
/// then adds or removes a '?' trailing the named type as appropriate.
class NonNullableFix {
// TODO(srawlins): Refactor to use
// `Feature.non_nullable.firstSupportedVersion` when this becomes non-null.
// `Feature.non_nullable.releaseVersion` when this becomes non-null.
static const String _intendedMinimumSdkVersion = '2.9.0';
// In the package_config.json file, the patch number is omitted.