Skip to content

Commit a2e1434

Browse files
committed
Breaking changes for analyzer version 0.37
Change-Id: I65a16ab2d2ca05de701c27f08300de85a6316b41 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/99880 Reviewed-by: Paul Berry <paulberry@google.com> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
1 parent 6694aa8 commit a2e1434

File tree

30 files changed

+148
-634
lines changed

30 files changed

+148
-634
lines changed

pkg/analysis_server/test/protocol_server_test.dart

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -257,9 +257,6 @@ class MockAnalysisError implements engine.AnalysisError {
257257
@override
258258
String correction = null;
259259

260-
@override
261-
bool isStaticOnly;
262-
263260
@override
264261
int length;
265262

pkg/analyzer/CHANGELOG.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,31 @@
1+
## 0.37.0-dev (not yet published - breaking changes)
2+
* Removed deprecated getter `DartType.isUndefined`.
3+
* Removed deprecated class `SdkLibrariesReader`.
4+
* Removed deprecated method `InstanceCreationExpressionImpl.canBeConst`.
5+
* The `AstFactory.compilationUnit` method now uses named parameters. Clients
6+
that prepared for this change by switching to `AstFactory.compilationUnit2`
7+
should now switch back to `AstFactory.compilationUnit`.
8+
* Removed `AstNode.getAncestor`. Please use `AstNode.thisOrAncestorMatching` or
9+
`AstNode.thisOrAncestorOfType`.
10+
* Removed deprecated getter `TypeSystem.isStrong`, and its override
11+
`Dart2TypeSystem.isStrong`.
12+
* Removed the deprecated getter `AnalysisError.isStaticOnly` and the deprecated
13+
setters `AnalysisError.isStaticOnly` and `AnalysisError.offset`.
14+
* Removed the `abstract` setter in `ClassElementImpl`, `EnumElementImpl`,
15+
`MethodElementImpl`, and `PropertyAccessorElementImpl`. `isAbstract` should
16+
be used instead.
17+
* Removed methods `AstVisitor.ForStatement2`, `ListLiteral.elements2`,
18+
`SetOrMapLiteral.elements2`, `AstFactory.forStatement2`, and
19+
`NodeLintRegistry.addForStatement2`, as well as class `ForStatement2`. Use
20+
the variants with out the "2" suffix instead.
21+
* Changed the signature and behavior of `parseFile` to match `parseFile2`.
22+
Clients that switched to using `parseFile2` when `parseFile` was deprecated
23+
should now switch back to `parseFile`.
24+
* Removed Parser setters `enableControlFlowCollections`, `enableNonNullable`,
25+
`enableSpreadCollections`, and `enableTripleShift`, and the method
26+
`configureFeatures`. Made the `featureSet` parameter of the Parser
27+
constructor a required parameter.
28+
129
## 0.36.4
230
* Deprecated the `isNonNullableUnit` parameter of the `TypeResolverVisitor`
331
constructor. TypeResolverVisitor should now be configured using the

pkg/analyzer/lib/dart/analysis/utilities.dart

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,36 @@ import 'package:meta/meta.dart';
2323
///
2424
/// If a [resourceProvider] is given, it will be used to access the file system.
2525
///
26-
/// Note that if more than one file is going to be parsed then this function is
27-
/// inefficient. Clients should instead use [AnalysisContextCollection] to
28-
/// create one or more contexts and use those contexts to parse the files.
26+
/// [featureSet] determines what set of features will be assumed by the parser.
27+
/// This parameter is required because the analyzer does not yet have a
28+
/// performant way of computing the correct feature set for a single file to be
29+
/// parsed. Callers that need the feature set to be strictly correct must
30+
/// create an [AnalysisContextCollection], query it to get an [AnalysisContext],
31+
/// query it to get an [AnalysisSession], and then call `getParsedUnit`.
2932
///
30-
/// Deprecated: please use [parseFile2] instead.
31-
@Deprecated('Use parseFile2')
32-
ParsedUnitResult parseFile(
33-
{@required String path, ResourceProvider resourceProvider}) {
34-
AnalysisContext context =
35-
_createAnalysisContext(path: path, resourceProvider: resourceProvider);
36-
return context.currentSession.getParsedUnit(path);
33+
/// Callers that don't need the feature set to be strictly correct can pass in
34+
/// `FeatureSet.fromEnableFlags([])` to enable the default set of features; this
35+
/// is much more performant than using an analysis session, because it doesn't
36+
/// require the analyzer to process the SDK.
37+
///
38+
/// If [throwIfDiagnostics] is `true` (the default), then if any diagnostics are
39+
/// produced because of syntactic errors in the [content] an `ArgumentError`
40+
/// will be thrown. If the parameter is `false`, then the caller can check the
41+
/// result to see whether there are any errors.
42+
ParseStringResult parseFile(
43+
{@required String path,
44+
ResourceProvider resourceProvider,
45+
@required FeatureSet featureSet,
46+
bool throwIfDiagnostics: true}) {
47+
if (featureSet == null) {
48+
throw ArgumentError('A non-null feature set must be provided.');
49+
}
50+
resourceProvider ??= PhysicalResourceProvider.INSTANCE;
51+
var content = (resourceProvider.getResource(path) as File).readAsStringSync();
52+
return parseString(
53+
content: content,
54+
featureSet: featureSet,
55+
throwIfDiagnostics: throwIfDiagnostics);
3756
}
3857

3958
/// Return the result of parsing the file at the given [path].
@@ -56,18 +75,15 @@ ParsedUnitResult parseFile(
5675
/// produced because of syntactic errors in the [content] an `ArgumentError`
5776
/// will be thrown. If the parameter is `false`, then the caller can check the
5877
/// result to see whether there are any errors.
78+
@Deprecated('Use parseFile')
5979
ParseStringResult parseFile2(
6080
{@required String path,
6181
ResourceProvider resourceProvider,
6282
@required FeatureSet featureSet,
6383
bool throwIfDiagnostics: true}) {
64-
if (featureSet == null) {
65-
throw ArgumentError('A non-null feature set must be provided.');
66-
}
67-
resourceProvider ??= PhysicalResourceProvider.INSTANCE;
68-
var content = (resourceProvider.getResource(path) as File).readAsStringSync();
69-
return parseString(
70-
content: content,
84+
return parseFile(
85+
path: path,
86+
resourceProvider: resourceProvider,
7187
featureSet: featureSet,
7288
throwIfDiagnostics: throwIfDiagnostics);
7389
}

pkg/analyzer/lib/dart/ast/ast.dart

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -378,12 +378,6 @@ abstract class AstNode implements SyntacticEntity {
378378
/// Return the token before [target] or `null` if it cannot be found.
379379
Token findPrevious(Token target);
380380

381-
/// Return the most immediate ancestor of this node for which the [predicate]
382-
/// returns `true`, or `null` if there is no such ancestor. Note that this
383-
/// node will never be returned.
384-
@deprecated
385-
E getAncestor<E extends AstNode>(Predicate<AstNode> predicate);
386-
387381
/// Return the value of the property with the given [name], or `null` if this
388382
/// node does not have a property with the given name.
389383
E getProperty<E>(String name);
@@ -520,9 +514,6 @@ abstract class AstVisitor<R> {
520514

521515
R visitForStatement(ForStatement node);
522516

523-
@Deprecated('Replaced by visitForStatement')
524-
R visitForStatement2(ForStatement2 node);
525-
526517
R visitFunctionDeclaration(FunctionDeclaration node);
527518

528519
R visitFunctionDeclarationStatement(FunctionDeclarationStatement node);
@@ -2569,26 +2560,6 @@ abstract class ForStatement implements Statement {
25692560
Token get rightParenthesis;
25702561
}
25712562

2572-
/// A for or for-each statement.
2573-
///
2574-
/// forStatement ::=
2575-
/// 'for' '(' forLoopParts ')' [Statement]
2576-
///
2577-
/// forLoopParts ::=
2578-
/// [VariableDeclaration] ';' [Expression]? ';' expressionList?
2579-
/// | [Expression]? ';' [Expression]? ';' expressionList?
2580-
/// | [DeclaredIdentifier] 'in' [Expression]
2581-
/// | [SimpleIdentifier] 'in' [Expression]
2582-
///
2583-
/// This is the class that is used to represent a for loop when either the
2584-
/// 'control-flow-collections' or 'spread-collections' experiments are enabled.
2585-
/// If neither of those experiments are enabled, then either `ForStatement` or
2586-
/// `ForEachStatement` will be used.
2587-
///
2588-
/// Clients may not extend, implement or mix-in this class.
2589-
@Deprecated('Replaced by ForStatement')
2590-
abstract class ForStatement2 extends ForStatement {}
2591-
25922563
/// A node representing the body of a function or method.
25932564
///
25942565
/// functionBody ::=
@@ -3682,10 +3653,6 @@ abstract class ListLiteral implements TypedLiteral {
36823653
/// Return the syntactic elements used to compute the elements of the list.
36833654
NodeList<CollectionElement> get elements;
36843655

3685-
/// Return the syntactic elements used to compute the elements of the list.
3686-
@Deprecated('Replaced by elements')
3687-
NodeList<CollectionElement> get elements2;
3688-
36893656
/// Return the left square bracket.
36903657
Token get leftBracket;
36913658

@@ -4558,11 +4525,6 @@ abstract class SetOrMapLiteral implements TypedLiteral {
45584525
/// map.
45594526
NodeList<CollectionElement> get elements;
45604527

4561-
/// Return the syntactic elements used to compute the elements of the set or
4562-
/// map.
4563-
@Deprecated('Replaced by elements')
4564-
NodeList<CollectionElement> get elements2;
4565-
45664528
/// Return `true` if this literal represents a map literal.
45674529
///
45684530
/// This getter will always return `false` if [isSet] returns `true`.

pkg/analyzer/lib/dart/ast/ast_factory.dart

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -151,19 +151,21 @@ abstract class AstFactory {
151151
/// can be `null` if the reference is not to a constructor.
152152
CommentReference commentReference(Token newKeyword, Identifier identifier);
153153

154-
/// Returns a newly created compilation unit to have the given directives
155-
/// and declarations. The [scriptTag] can be `null` if there is no script tag
156-
/// in the compilation unit. The list of [directives] can be `null` if there
157-
/// are no directives in the compilation unit. The list of [declarations] can
158-
/// be `null` if there are no declarations in the compilation unit.
159-
@Deprecated('Use compilationUnit2')
154+
/// Returns a newly created compilation unit to have the given directives and
155+
/// declarations. The [scriptTag] can be `null` (or omitted) if there is no
156+
/// script tag in the compilation unit. The list of [declarations] can be
157+
/// `null` (or omitted) if there are no directives in the compilation unit.
158+
/// The list of `declarations` can be `null` (or omitted) if there are no
159+
/// declarations in the compilation unit. The [featureSet] can be `null` if
160+
/// the set of features for this compilation unit is not known (this
161+
/// restricts what analysis can be done of the compilation unit).
160162
CompilationUnit compilationUnit(
161-
Token beginToken,
163+
{@required Token beginToken,
162164
ScriptTag scriptTag,
163165
List<Directive> directives,
164166
List<CompilationUnitMember> declarations,
165-
Token endToken,
166-
[FeatureSet featureSet]);
167+
@required Token endToken,
168+
@required FeatureSet featureSet});
167169

168170
/// Returns a newly created compilation unit to have the given directives and
169171
/// declarations. The [scriptTag] can be `null` (or omitted) if there is no
@@ -173,6 +175,7 @@ abstract class AstFactory {
173175
/// declarations in the compilation unit. The [featureSet] can be `null` if
174176
/// the set of features for this compilation unit is not known (this
175177
/// restricts what analysis can be done of the compilation unit).
178+
@Deprecated('Use compilationUnit')
176179
CompilationUnit compilationUnit2(
177180
{@required Token beginToken,
178181
ScriptTag scriptTag,
@@ -470,16 +473,6 @@ abstract class AstFactory {
470473
Token rightParenthesis,
471474
Statement body});
472475

473-
/// Returns a newly created for statement.
474-
@Deprecated('Replaced by forStatement')
475-
ForStatement forStatement2(
476-
{Token awaitKeyword,
477-
Token forKeyword,
478-
Token leftParenthesis,
479-
ForLoopParts forLoopParts,
480-
Token rightParenthesis,
481-
Statement body});
482-
483476
/// Returns a newly created function declaration. Either or both of the
484477
/// [comment] and [metadata] can be `null` if the function does not have the
485478
/// corresponding attribute. The [externalKeyword] can be `null` if the

pkg/analyzer/lib/dart/ast/visitor.dart

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import 'dart:collection';
2323

2424
import 'package:analyzer/dart/ast/ast.dart';
25-
import 'package:analyzer/src/dart/ast/utilities.dart' show UIAsCodeVisitorMixin;
2625

2726
/// An AST visitor that will recursively visit all of the nodes in an AST
2827
/// structure, similar to [GeneralizingAstVisitor]. This visitor uses a
@@ -128,9 +127,7 @@ class DelegatingAstVisitor<T> extends UnifyingAstVisitor<T> {
128127
/// invoked and will cause the children of the visited node to not be visited.
129128
///
130129
/// Clients may extend this class.
131-
class GeneralizingAstVisitor<R>
132-
with UIAsCodeVisitorMixin<R>
133-
implements AstVisitor<R> {
130+
class GeneralizingAstVisitor<R> implements AstVisitor<R> {
134131
@override
135132
R visitAdjacentStrings(AdjacentStrings node) => visitStringLiteral(node);
136133

@@ -605,9 +602,7 @@ class GeneralizingAstVisitor<R>
605602
/// visited.
606603
///
607604
/// Clients may extend this class.
608-
class RecursiveAstVisitor<R>
609-
with UIAsCodeVisitorMixin<R>
610-
implements AstVisitor<R> {
605+
class RecursiveAstVisitor<R> implements AstVisitor<R> {
611606
@override
612607
R visitAdjacentStrings(AdjacentStrings node) {
613608
node.visitChildren(this);
@@ -1336,9 +1331,7 @@ class RecursiveAstVisitor<R>
13361331
/// a whole structure) and that only need to visit a small number of node types.
13371332
///
13381333
/// Clients may extend this class.
1339-
class SimpleAstVisitor<R>
1340-
with UIAsCodeVisitorMixin<R>
1341-
implements AstVisitor<R> {
1334+
class SimpleAstVisitor<R> implements AstVisitor<R> {
13421335
@override
13431336
R visitAdjacentStrings(AdjacentStrings node) => null;
13441337

@@ -1713,9 +1706,7 @@ class SimpleAstVisitor<R>
17131706
/// want to catch when any other visit methods have been invoked.
17141707
///
17151708
/// Clients may extend this class.
1716-
class ThrowingAstVisitor<R>
1717-
with UIAsCodeVisitorMixin<R>
1718-
implements AstVisitor<R> {
1709+
class ThrowingAstVisitor<R> implements AstVisitor<R> {
17191710
@override
17201711
R visitAdjacentStrings(AdjacentStrings node) => _throw(node);
17211712

@@ -2097,7 +2088,7 @@ class ThrowingAstVisitor<R>
20972088
/// An AST visitor that captures visit call timings.
20982089
///
20992090
/// Clients may not extend, implement or mix-in this class.
2100-
class TimedAstVisitor<T> with UIAsCodeVisitorMixin<T> implements AstVisitor<T> {
2091+
class TimedAstVisitor<T> implements AstVisitor<T> {
21012092
/// The base visitor whose visit methods will be timed.
21022093
final AstVisitor<T> _baseVisitor;
21032094

@@ -3082,9 +3073,7 @@ class TimedAstVisitor<T> with UIAsCodeVisitorMixin<T> implements AstVisitor<T> {
30823073
/// visited.
30833074
///
30843075
/// Clients may extend this class.
3085-
class UnifyingAstVisitor<R>
3086-
with UIAsCodeVisitorMixin<R>
3087-
implements AstVisitor<R> {
3076+
class UnifyingAstVisitor<R> implements AstVisitor<R> {
30883077
@override
30893078
R visitAdjacentStrings(AdjacentStrings node) => visitNode(node);
30903079

pkg/analyzer/lib/dart/element/type.dart

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,6 @@ abstract class DartType {
8181
/// Return `true` if this type represents the type 'Object'.
8282
bool get isObject;
8383

84-
/// Return `true` if this type represents a typename that couldn't be
85-
/// resolved.
86-
@deprecated
87-
bool get isUndefined;
88-
8984
/// Return `true` if this type represents the type 'void'.
9085
bool get isVoid;
9186

pkg/analyzer/lib/error/error.dart

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -876,18 +876,6 @@ class AnalysisError implements Diagnostic {
876876
return hashCode;
877877
}
878878

879-
/**
880-
* Return `true` if this error can be shown to be a non-issue because of the
881-
* result of type propagation.
882-
*/
883-
@Deprecated(
884-
'Type propagation is no longer performed, so this will never be true')
885-
bool get isStaticOnly => false;
886-
887-
@Deprecated(
888-
'Type propagation is no longer performed, so this can never be true')
889-
void set isStaticOnly(bool value) {}
890-
891879
/**
892880
* The number of characters from the offset to the end of the source which
893881
* encompasses the compilation error.
@@ -906,13 +894,6 @@ class AnalysisError implements Diagnostic {
906894
*/
907895
int get offset => _problemMessage.offset;
908896

909-
/**
910-
* The character offset from the beginning of the source (zero based) where
911-
* the error occurred.
912-
*/
913-
@Deprecated('Set the offset when the error is created')
914-
set offset(int offset) {}
915-
916897
@override
917898
DiagnosticMessage get problemMessage => _problemMessage;
918899

pkg/analyzer/lib/src/dart/analysis/file_state.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ class FileState {
686686

687687
CompilationUnit _createEmptyCompilationUnit(FeatureSet featureSet) {
688688
var token = new Token.eof(0);
689-
return astFactory.compilationUnit2(
689+
return astFactory.compilationUnit(
690690
beginToken: token, endToken: token, featureSet: featureSet)
691691
..lineInfo = new LineInfo(const <int>[0]);
692692
}

0 commit comments

Comments
 (0)