Skip to content

Commit 139385c

Browse files
scheglovCommit Bot
authored andcommitted
Breaking changes for analyzer version 4.0.0
Change-Id: I26961f29f9171e94db2f5c95f1f8af5fd01bb9b9 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/233681 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Reviewed-by: Jens Johansen <jensj@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
1 parent 560579b commit 139385c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+130
-2216
lines changed

pkg/_fe_analyzer_shared/lib/src/scanner/error_token.dart

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,11 +101,6 @@ abstract class ErrorToken extends SimpleToken {
101101
int? get endOffset => null;
102102

103103
BeginToken? get begin => null;
104-
105-
@override
106-
Token copy() {
107-
throw 'unsupported operation';
108-
}
109104
}
110105

111106
/// Represents an encoding error.

pkg/_fe_analyzer_shared/lib/src/scanner/token.dart

Lines changed: 0 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@ class BeginToken extends SimpleToken {
5454
type == TokenType.STRING_INTERPOLATION_EXPRESSION);
5555
}
5656

57-
@override
58-
Token copy() => new BeginToken(type, offset, copyComments(precedingComments));
59-
6057
@override
6158
Token? get endGroup => endToken;
6259

@@ -83,25 +80,6 @@ class CommentToken extends StringToken {
8380
*/
8481
CommentToken(TokenType type, String value, int offset)
8582
: super(type, value, offset);
86-
87-
@override
88-
CommentToken copy() => new CommentToken(type, _value, offset);
89-
90-
/**
91-
* Remove this comment token from the list.
92-
*
93-
* This is used when we decide to interpret the comment as syntax.
94-
*/
95-
void remove() {
96-
Token? previous = this.previous;
97-
if (previous != null) {
98-
previous.setNextWithoutSettingPrevious(next);
99-
next?.previous = previous;
100-
} else {
101-
assert(parent!.precedingComments == this);
102-
parent!.precedingComments = next as CommentToken?;
103-
}
104-
}
10583
}
10684

10785
/**
@@ -114,9 +92,6 @@ class DocumentationCommentToken extends CommentToken {
11492
*/
11593
DocumentationCommentToken(TokenType type, String value, int offset)
11694
: super(type, value, offset);
117-
118-
@override
119-
CommentToken copy() => new DocumentationCommentToken(type, _value, offset);
12095
}
12196

12297
enum KeywordStyle {
@@ -481,10 +456,6 @@ class KeywordToken extends SimpleToken {
481456
KeywordToken(this.keyword, int offset, [CommentToken? precedingComment])
482457
: super(keyword, offset, precedingComment);
483458

484-
@override
485-
Token copy() =>
486-
new KeywordToken(keyword, offset, copyComments(precedingComments));
487-
488459
@override
489460
bool get isIdentifier => keyword.isPseudo || keyword.isBuiltIn;
490461

@@ -515,10 +486,6 @@ class LanguageVersionToken extends CommentToken {
515486

516487
LanguageVersionToken.from(String text, int offset, this.major, this.minor)
517488
: super(TokenType.SINGLE_LINE_COMMENT, text, offset);
518-
519-
@override
520-
LanguageVersionToken copy() =>
521-
new LanguageVersionToken.from(lexeme, offset, major, minor);
522489
}
523490

524491
/**
@@ -633,25 +600,6 @@ class SimpleToken implements Token {
633600
@override
634601
String? get stringValue => type.stringValue;
635602

636-
@override
637-
Token copy() =>
638-
new SimpleToken(type, offset, copyComments(precedingComments));
639-
640-
@override
641-
CommentToken? copyComments(CommentToken? token) {
642-
if (token == null) {
643-
return null;
644-
}
645-
CommentToken head = token.copy();
646-
Token tail = head;
647-
token = token.next as CommentToken?;
648-
while (token != null) {
649-
tail = tail.setNext(token.copy());
650-
token = token.next as CommentToken?;
651-
}
652-
return head;
653-
}
654-
655603
@override
656604
bool matchesAny(List<TokenType> types) {
657605
for (TokenType type in types) {
@@ -718,10 +666,6 @@ class StringToken extends SimpleToken {
718666
@override
719667
String get lexeme => _value;
720668

721-
@override
722-
Token copy() =>
723-
new StringToken(type, _value, offset, copyComments(precedingComments));
724-
725669
@override
726670
String value() => _value;
727671
}
@@ -741,10 +685,6 @@ class SyntheticBeginToken extends BeginToken {
741685
@override
742686
Token? beforeSynthetic;
743687

744-
@override
745-
Token copy() =>
746-
new SyntheticBeginToken(type, offset, copyComments(precedingComments));
747-
748688
@override
749689
bool get isSynthetic => true;
750690

@@ -767,9 +707,6 @@ class SyntheticKeywordToken extends KeywordToken {
767707

768708
@override
769709
int get length => 0;
770-
771-
@override
772-
Token copy() => new SyntheticKeywordToken(keyword, offset);
773710
}
774711

775712
/**
@@ -794,9 +731,6 @@ class SyntheticStringToken extends StringToken {
794731

795732
@override
796733
int get length => _length ?? super.length;
797-
798-
@override
799-
Token copy() => new SyntheticStringToken(type, _value, offset, _length);
800734
}
801735

802736
/**
@@ -813,9 +747,6 @@ class SyntheticToken extends SimpleToken {
813747

814748
@override
815749
int get length => 0;
816-
817-
@override
818-
Token copy() => new SyntheticToken(type, offset);
819750
}
820751

821752
/// A token used to replace another token in the stream, while still keeping the
@@ -839,9 +770,6 @@ class ReplacementToken extends SyntheticToken {
839770

840771
@override
841772
int get length => 0;
842-
843-
@override
844-
Token copy() => new ReplacementToken(type, replacedToken);
845773
}
846774

847775
/**
@@ -1041,18 +969,6 @@ abstract class Token implements SyntacticEntity {
1041969
*/
1042970
TokenType get type;
1043971

1044-
/**
1045-
* Return a newly created token that is a copy of this tokens
1046-
* including any [preceedingComment] tokens,
1047-
* but that is not a part of any token stream.
1048-
*/
1049-
Token copy();
1050-
1051-
/**
1052-
* Copy a linked list of comment tokens identical to the given comment tokens.
1053-
*/
1054-
CommentToken? copyComments(CommentToken? token);
1055-
1056972
/**
1057973
* Return `true` if this token has any one of the given [types].
1058974
*/

pkg/_fe_analyzer_shared/lib/src/scanner/token_impl.dart

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
library _fe_analyzer_shared.scanner.token;
66

77
import 'token.dart' as analyzer;
8-
import 'token.dart' show Token, TokenType;
8+
import 'token.dart' show TokenType;
99

1010
import 'token_constants.dart' show IDENTIFIER_TOKEN;
1111

@@ -115,10 +115,6 @@ class StringToken extends analyzer.SimpleToken implements analyzer.StringToken {
115115
return canonicalizer.canonicalize(data, start, end, asciiOnly);
116116
}
117117

118-
@override
119-
Token copy() => new StringToken._(
120-
type, valueOrLazySubstring, charOffset, copyComments(precedingComments));
121-
122118
@override
123119
String value() => lexeme;
124120
}
@@ -134,10 +130,6 @@ class SyntheticStringToken extends StringToken
134130

135131
@override
136132
int get length => 0;
137-
138-
@override
139-
Token copy() => new SyntheticStringToken(
140-
type, valueOrLazySubstring, offset, copyComments(precedingComments));
141133
}
142134

143135
class CommentToken extends StringToken implements analyzer.CommentToken {
@@ -167,24 +159,6 @@ class CommentToken extends StringToken implements analyzer.CommentToken {
167159
CommentToken.fromUtf8Bytes(TokenType type, List<int> data, int start, int end,
168160
bool asciiOnly, int charOffset)
169161
: super.fromUtf8Bytes(type, data, start, end, asciiOnly, charOffset);
170-
171-
CommentToken._(TokenType type, valueOrLazySubstring, int charOffset)
172-
: super._(type, valueOrLazySubstring, charOffset);
173-
174-
@override
175-
CommentToken copy() =>
176-
new CommentToken._(type, valueOrLazySubstring, charOffset);
177-
178-
@override
179-
void remove() {
180-
if (previous != null) {
181-
previous!.setNextWithoutSettingPrevious(next);
182-
next?.previous = previous;
183-
} else {
184-
assert(parent!.precedingComments == this);
185-
parent!.precedingComments = next as CommentToken;
186-
}
187-
}
188162
}
189163

190164
class LanguageVersionToken extends CommentToken
@@ -209,10 +183,6 @@ class LanguageVersionToken extends CommentToken
209183
int tokenStart, this.major, this.minor)
210184
: super.fromUtf8Bytes(
211185
TokenType.SINGLE_LINE_COMMENT, bytes, start, end, true, tokenStart);
212-
213-
@override
214-
LanguageVersionToken copy() =>
215-
new LanguageVersionToken.from(lexeme, offset, major, minor);
216186
}
217187

218188
class DartDocToken extends CommentToken
@@ -234,13 +204,6 @@ class DartDocToken extends CommentToken
234204
DartDocToken.fromUtf8Bytes(TokenType type, List<int> data, int start, int end,
235205
bool asciiOnly, int charOffset)
236206
: super.fromUtf8Bytes(type, data, start, end, asciiOnly, charOffset);
237-
238-
DartDocToken._(TokenType type, valueOrLazySubstring, int charOffset)
239-
: super._(type, valueOrLazySubstring, charOffset);
240-
241-
@override
242-
DartDocToken copy() =>
243-
new DartDocToken._(type, valueOrLazySubstring, charOffset);
244207
}
245208

246209
/**

pkg/analysis_server/lib/src/analysis_server_abstract.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,7 @@ abstract class AbstractAnalysisServer {
503503

504504
try {
505505
await driver.applyPendingFileChanges();
506-
return driver.resolveForCompletion(
506+
return await driver.resolveForCompletion(
507507
path: path,
508508
offset: offset,
509509
performance: performance,

pkg/analysis_server/lib/src/services/completion/dart/not_imported_contributor.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class NotImportedContributor extends DartCompletionContributor {
7373
continue;
7474
}
7575

76-
var element = analysisDriver.getLibraryByFile(file);
76+
var element = await analysisDriver.getLibraryByFile(file);
7777
if (element == null || importedLibraries.contains(element)) {
7878
continue;
7979
}

pkg/analysis_server/lib/src/services/correction/fix/dart/extensions.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ class Extensions {
3636
continue;
3737
}
3838

39-
var libraryElement = analysisDriver.getLibraryByFile(file);
39+
var libraryElement = await analysisDriver.getLibraryByFile(file);
4040
if (libraryElement == null) {
4141
continue;
4242
}

pkg/analysis_server/lib/src/services/correction/fix/dart/top_level_declarations.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class TopLevelDeclarations {
3939
continue;
4040
}
4141

42-
var libraryElement = analysisDriver.getLibraryByFile(file);
42+
var libraryElement = await analysisDriver.getLibraryByFile(file);
4343
if (libraryElement == null) {
4444
continue;
4545
}

pkg/analyzer/CHANGELOG.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
1+
## 4.0.0 (Not yet released - breaking changes)
2+
* Removed deprecated `UriKind` and `Source.uriKind`.
3+
* Removed deprecated `LibraryElement.hasExtUri`.
4+
* Removed deprecated `LibraryElement.hasLoadLibraryFunction`.
5+
* Removed deprecated `ImportElement.prefixOffset`.
6+
* Removed deprecated `CompilationUnitElement.types`.
7+
* Removed deprecated `Source.encoding`.
8+
* Removed deprecated `Source.isInSystemLibrary`.
9+
* Removed deprecated `Source.modificationStamp`.
10+
* Removed deprecated `stamp` in `MemoryResourceProvider`.
11+
* Removed deprecated `SourceFactory.restoreUri`, use `pathToUri` instead.
12+
* Removed deprecated `AnalysisContext.workspace`.
13+
* The `isNonNullableByDefault` parameter in `ErrorReporter` is now required.
14+
* Removed `Element.SORT_BY_OFFSET`, it is not used.
15+
* Changed synchronous `AnalysisSession.getFile` and `getParsedUnit` to fail
16+
if there are pending file changes, instead of reading. As for any other
17+
`AnalysisSession` method, await `AnalysisContext.applyPendingFileChanges()`.
18+
* Removed `Token.copy()` and `copyComments()`.
19+
* Removed `CommentToken.remove()`.
20+
* Removed deprecated `astFactory` and `AstFactory`.
21+
* Removed `AnalysisOptions.signature` and `signaturesEqual`.
22+
* Removed deprecated `buildSdkSummary()`.
23+
124
## 3.4.1
225
* Remove checks for consistency after operations in `AnalysisSession`.
326

pkg/analyzer/lib/dart/analysis/analysis_context.dart

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import 'package:analyzer/dart/analysis/context_root.dart';
66
import 'package:analyzer/dart/analysis/session.dart';
77
import 'package:analyzer/file_system/file_system.dart';
88
import 'package:analyzer/src/generated/engine.dart';
9-
import 'package:analyzer/src/workspace/workspace.dart';
109

1110
/// A representation of a body of code and the context in which the code is to
1211
/// be analyzed.
@@ -32,10 +31,6 @@ abstract class AnalysisContext {
3231
/// analyzed, or `null` if the SDK is not directory based.
3332
Folder? get sdkRoot;
3433

35-
/// Return the workspace for containing the context root.
36-
@Deprecated('Use contextRoot.workspace instead')
37-
Workspace get workspace;
38-
3934
/// Return a [Future] that completes after pending file changes are applied,
4035
/// so that [currentSession] can be used to compute results.
4136
///

pkg/analyzer/lib/dart/analysis/analysis_options.dart

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
import 'dart:typed_data';
6-
75
import 'package:analyzer/dart/analysis/code_style_options.dart';
86
import 'package:analyzer/dart/analysis/features.dart';
97
import 'package:analyzer/source/error_processor.dart';
@@ -52,22 +50,6 @@ abstract class AnalysisOptions {
5250
/// there is no `pubspec.yaml` or if it does not contain an SDK range.
5351
VersionConstraint? get sdkVersionConstraint;
5452

55-
/// Return the opaque signature of the options.
56-
Uint32List get signature;
57-
5853
/// Return `true` the lint with the given [name] is enabled.
5954
bool isLintEnabled(String name);
60-
61-
/// Determine whether two signatures returned by [signature] are equal.
62-
static bool signaturesEqual(Uint32List a, Uint32List b) {
63-
if (a.length != b.length) {
64-
return false;
65-
}
66-
for (int i = 0; i < a.length; i++) {
67-
if (a[i] != b[i]) {
68-
return false;
69-
}
70-
}
71-
return true;
72-
}
7355
}

0 commit comments

Comments
 (0)