Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 151cc0c

Browse files
srawlinsCommit Queue
authored and
Commit Queue
committed
analyzer_plugin: Remove remaining deprecated elements
Change-Id: Ia984b4462eba7d565ffe59ee07129118d8c399d6 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/461524 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Samuel Rawlins <srawlins@google.com>
1 parent 2da102b commit 151cc0c

File tree

9 files changed

+17
-248
lines changed

9 files changed

+17
-248
lines changed

‎pkg/analyzer_plugin/CHANGELOG.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
- Require version `9.0.1` of the `analyzer` package.
44
- `AssistContributorMixin` is now a mixin.
55
- Remove deprecated `methodBeingCopied` parameters on various methods.
6+
- Remove `ChangeBuilder.new`'s deprecated `eol` parameter.
7+
- Remove `ChangeBuilder.addDartFileEdit`'s deprecated `importPrefixGenerator` parameter.
8+
- Remove the deprecated `ChangeBuilder.copy` method.
9+
- Remove the deprecated `RangeFactory.error` method.
610

711
## 0.13.11
812

‎pkg/analyzer_plugin/api.txt‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1687,14 +1687,13 @@ package:analyzer_plugin/utilities/assist/assist_contributor_mixin.dart:
16871687
addAssist (method: void Function(AssistKind, ChangeBuilder, {List<Object>? args}))
16881688
package:analyzer_plugin/utilities/change_builder/change_builder_core.dart:
16891689
ChangeBuilder (class extends Object):
1690-
new (constructor: ChangeBuilder Function({String? defaultEol, deprecated String? eol, AnalysisSession session, ChangeWorkspace workspace}))
1690+
new (constructor: ChangeBuilder Function({String? defaultEol, AnalysisSession session, ChangeWorkspace workspace}))
16911691
defaultEol (getter: String)
16921692
selectionRange (getter: SourceRange?)
16931693
sourceChange (getter: SourceChange)
1694-
addDartFileEdit (method: Future<void> Function(String, FutureOr<void> Function(DartFileEditBuilder), {bool createEditsForImports, deprecated String Function(Uri) importPrefixGenerator}))
1694+
addDartFileEdit (method: Future<void> Function(String, FutureOr<void> Function(DartFileEditBuilder), {bool createEditsForImports}))
16951695
addGenericFileEdit (method: Future<void> Function(String, void Function(FileEditBuilder)))
16961696
addYamlFileEdit (method: Future<void> Function(String, void Function(YamlFileEditBuilder)))
1697-
copy (method: ChangeBuilder Function(), deprecated)
16981697
hasEditsFor (method: bool Function(String))
16991698
setSelection (method: void Function(Position))
17001699
EditBuilder (class extends Object):
@@ -1774,7 +1773,7 @@ package:analyzer_plugin/utilities/change_builder/change_builder_dart.dart:
17741773
ImportLibraryElementResult (class extends Object):
17751774
new (constructor: ImportLibraryElementResult Function())
17761775
prefix (getter: String?)
1777-
ImportPrefixGenerator (type alias for String Function(Uri))
1776+
ImportPrefixGenerator (type alias for String Function(Uri), deprecated)
17781777
package:analyzer_plugin/utilities/change_builder/change_builder_yaml.dart:
17791778
YamlEditBuilder (class extends Object implements EditBuilder):
17801779
new (constructor: YamlEditBuilder Function())
@@ -2028,7 +2027,6 @@ package:analyzer_plugin/utilities/range_factory.dart:
20282027
endLength (method: SourceRange Function(SyntacticEntity, int))
20292028
endStart (method: SourceRange Function(SyntacticEntity, SyntacticEntity))
20302029
entity (method: SourceRange Function(SyntacticEntity))
2031-
error (method: SourceRange Function(Diagnostic), deprecated)
20322030
fragmentName (method: SourceRange? Function(Fragment))
20332031
node (method: SourceRange Function(AstNode))
20342032
nodeInList (method: SourceRange Function<T extends AstNode>(NodeList<T>, T))

‎pkg/analyzer_plugin/lib/src/utilities/change_builder/change_builder_core.dart‎

Lines changed: 5 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -80,22 +80,17 @@ class ChangeBuilderImpl implements ChangeBuilder {
8080
/// called.
8181
final _ChangeBuilderRevertData _revertData = _ChangeBuilderRevertData();
8282

83-
/// Initialize a newly created change builder. If the builder will be used to
84-
/// create changes for Dart files, then either a [session] or a [workspace]
85-
/// must be provided (but not both).
83+
/// Initializes a newly created change builder.
84+
///
85+
/// If the builder will be used to create changes for Dart files, then either
86+
/// a [session] or a [workspace] must be provided (but not both).
8687
ChangeBuilderImpl({
8788
AnalysisSession? session,
8889
ChangeWorkspace? workspace,
89-
@Deprecated(
90-
'Use defaultEol instead, as this is only a '
91-
'default for files without existing EOLs',
92-
)
93-
String? eol,
9490
String? defaultEol,
9591
}) : assert(session == null || workspace == null),
96-
assert(eol == null || defaultEol == null),
9792
workspace = workspace ?? _SingleSessionWorkspace(session!),
98-
defaultEol = defaultEol ?? eol ??Platform.lineTerminator;
93+
defaultEol = defaultEol ?? Platform.lineTerminator;
9994

10095
/// Return `true` if this builder has edits to be applied.
10196
bool get hasEdits {
@@ -146,8 +141,6 @@ class ChangeBuilderImpl implements ChangeBuilder {
146141
Future<void> addDartFileEdit(
147142
String path,
148143
FutureOr<void> Function(DartFileEditBuilder builder) buildFileEdit, {
149-
@Deprecated('No longer supported')
150-
ImportPrefixGenerator? importPrefixGenerator,
151144
bool createEditsForImports = true,
152145
}) async {
153146
assert(file_paths.isDart(workspace.resourceProvider.pathContext, path));
@@ -183,7 +176,6 @@ class ChangeBuilderImpl implements ChangeBuilder {
183176
}
184177
}
185178
if (builder != null) {
186-
builder.importPrefixGenerator = importPrefixGenerator;
187179
builder.currentChangeDescription = currentChangeDescription;
188180
await buildFileEdit(builder);
189181
}
@@ -301,56 +293,6 @@ class ChangeBuilderImpl implements ChangeBuilder {
301293
}
302294
}
303295

304-
@Deprecated(
305-
'Copying change builders is expensive. Internal users of this '
306-
'method now use `commit` and `revert` instead.',
307-
)
308-
@override
309-
ChangeBuilder copy() {
310-
var copy = ChangeBuilderImpl(workspace: workspace, defaultEol: defaultEol);
311-
for (var entry in _linkedEditGroups.entries) {
312-
copy._linkedEditGroups[entry.key] = _copyLinkedEditGroup(entry.value);
313-
}
314-
var selection = _selection;
315-
if (selection != null) {
316-
copy._selection = _copyPosition(selection);
317-
}
318-
copy._selectionRange = _selectionRange;
319-
copy._lockedPositions.addAll(_lockedPositions);
320-
for (var entry in _genericFileEditBuilders.entries) {
321-
copy._genericFileEditBuilders[entry.key] = entry.value.copyWith(copy);
322-
}
323-
//
324-
// The file edit builders for libraries (those whose [libraryChangeBuilder]
325-
// is `null`) are copied first so that the copies exist when we copy the
326-
// builders for parts and the structure can be preserved.
327-
//
328-
var editBuilderMap = <DartFileEditBuilderImpl, DartFileEditBuilderImpl>{};
329-
for (var entry in _dartFileEditBuilders.entries) {
330-
var oldBuilder = entry.value;
331-
if (oldBuilder.libraryChangeBuilder == null) {
332-
var newBuilder = oldBuilder.copyWith(copy);
333-
copy._dartFileEditBuilders[entry.key] = newBuilder;
334-
editBuilderMap[oldBuilder] = newBuilder;
335-
}
336-
}
337-
for (var entry in _dartFileEditBuilders.entries) {
338-
var oldBuilder = entry.value;
339-
if (oldBuilder.libraryChangeBuilder != null) {
340-
var newBuilder = oldBuilder.copyWith(
341-
copy,
342-
editBuilderMap: editBuilderMap,
343-
);
344-
copy._dartFileEditBuilders[entry.key] = newBuilder;
345-
}
346-
}
347-
for (var entry in _yamlFileEditBuilders.entries) {
348-
copy._yamlFileEditBuilders[entry.key] = entry.value.copyWith(copy);
349-
}
350-
copy.modificationCount = modificationCount;
351-
return copy;
352-
}
353-
354296
/// Return the linked edit group with the given [groupName], creating it if it
355297
/// did not already exist.
356298
LinkedEditGroup getLinkedEditGroup(String groupName) {
@@ -436,20 +378,6 @@ class ChangeBuilderImpl implements ChangeBuilder {
436378
_selectionRange = null;
437379
}
438380

439-
/// Return a copy of the linked edit [group].
440-
LinkedEditGroup _copyLinkedEditGroup(LinkedEditGroup group) {
441-
return LinkedEditGroup(
442-
group.positions.map(_copyPosition).toList(),
443-
group.length,
444-
group.suggestions.toList(),
445-
);
446-
}
447-
448-
/// Return a copy of the [position].
449-
Position _copyPosition(Position position) {
450-
return Position(position.file, position.offset);
451-
}
452-
453381
/// Create and return a [DartFileEditBuilder] that can be used to build edits
454382
/// to the Dart file with the given [path].
455383
Future<DartFileEditBuilderImpl?> _createDartFileEditBuilder(
@@ -799,22 +727,6 @@ class FileEditBuilderImpl implements FileEditBuilder {
799727
_revertData._addedEdits.clear();
800728
}
801729

802-
@Deprecated(
803-
'Copying change builders is expensive. Internal users of this '
804-
'method now use `commit` and `revert` instead.',
805-
)
806-
FileEditBuilderImpl copyWith(ChangeBuilderImpl changeBuilder) {
807-
var copy = FileEditBuilderImpl(
808-
changeBuilder,
809-
fileEdit.file,
810-
fileEdit.fileStamp,
811-
eol: eol,
812-
);
813-
copy.fileEdit.edits.addAll(fileEdit.edits);
814-
copy.currentChangeDescription = currentChangeDescription;
815-
return copy;
816-
}
817-
818730
EditBuilderImpl createEditBuilder(int offset, int length) {
819731
return EditBuilderImpl(
820732
this,

‎pkg/analyzer_plugin/lib/src/utilities/change_builder/change_builder_dart.dart‎

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,9 +1672,6 @@ class DartFileEditBuilderImpl extends FileEditBuilderImpl
16721672
/// not already imported.
16731673
final bool _createEditsForImports;
16741674

1675-
/// The optional generator of prefixes for new imports.
1676-
ImportPrefixGenerator? importPrefixGenerator;
1677-
16781675
/// A mapping from libraries that need to be imported in order to make visible
16791676
/// the names used in generated code, to information about these imports.
16801677
final Map<Uri, _LibraryImport> _librariesToImport = {};
@@ -1806,36 +1803,6 @@ class DartFileEditBuilderImpl extends FileEditBuilderImpl
18061803
);
18071804
}
18081805

1809-
@Deprecated(
1810-
'Copying change builders is expensive. Internal users of this '
1811-
'method now use `commit` and `revert` instead.',
1812-
)
1813-
@override
1814-
DartFileEditBuilderImpl copyWith(
1815-
ChangeBuilderImpl changeBuilder, {
1816-
Map<DartFileEditBuilderImpl, DartFileEditBuilderImpl> editBuilderMap =
1817-
const {},
1818-
}) {
1819-
var copy = DartFileEditBuilderImpl(
1820-
changeBuilder,
1821-
resolvedLibrary,
1822-
resolvedUnit,
1823-
fileEdit.fileStamp,
1824-
editBuilderMap[libraryChangeBuilder],
1825-
eol: eol,
1826-
createEditsForImports: _createEditsForImports,
1827-
);
1828-
copy.fileEdit.edits.addAll(fileEdit.edits);
1829-
copy.importPrefixGenerator = importPrefixGenerator;
1830-
for (var entry in _librariesToImport.entries) {
1831-
copy._librariesToImport[entry.key] = entry.value;
1832-
}
1833-
for (var entry in _elementLibrariesToImport.entries) {
1834-
copy._elementLibrariesToImport[entry.key] = entry.value;
1835-
}
1836-
return copy;
1837-
}
1838-
18391806
@override
18401807
DartEditBuilderImpl createEditBuilder(int offset, int length) {
18411808
return DartEditBuilderImpl(
@@ -2580,9 +2547,6 @@ class DartFileEditBuilderImpl extends FileEditBuilderImpl
25802547
}
25812548

25822549
String _defaultImportPrefixFor(Uri uri) {
2583-
if (importPrefixGenerator != null) {
2584-
return importPrefixGenerator!(uri);
2585-
}
25862550
// TODO(FMorschel): Think of a way to identify if the current editing range
25872551
// already contains a variable with the same name as the generated prefix.
25882552
// This only accounts for top-level names.
@@ -2733,8 +2697,6 @@ class DartFileEditBuilderImpl extends FileEditBuilderImpl
27332697
/// `true`.
27342698
///
27352699
/// If [prefix] is an empty string, adds the import without a prefix.
2736-
/// If [prefix] is null, will use [importPrefixGenerator] to generate one or
2737-
/// reuse an existing prefix for this import.
27382700
///
27392701
/// If [showName] is supplied then any new import will show only this
27402702
/// element, or if an import already exists it will be added to 'show' or
@@ -2799,9 +2761,6 @@ class DartFileEditBuilderImpl extends FileEditBuilderImpl
27992761
}
28002762
}
28012763
}
2802-
prefix ??= importPrefixGenerator != null
2803-
? importPrefixGenerator!(uri)
2804-
: null;
28052764
import = _LibraryImport(
28062765
uriText: uriText,
28072766
prefix: prefix ?? '',

‎pkg/analyzer_plugin/lib/src/utilities/change_builder/change_builder_yaml.dart‎

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -76,27 +76,6 @@ class YamlFileEditBuilderImpl extends FileEditBuilderImpl
7676
(builder) => buildEdit(builder as YamlEditBuilder),
7777
);
7878

79-
@Deprecated(
80-
'Copying change builders is expensive. Internal users of this '
81-
'method now use `commit` and `revert` instead.',
82-
)
83-
@override
84-
YamlFileEditBuilderImpl copyWith(
85-
ChangeBuilderImpl changeBuilder, {
86-
Map<YamlFileEditBuilderImpl, YamlFileEditBuilderImpl> editBuilderMap =
87-
const {},
88-
}) {
89-
var copy = YamlFileEditBuilderImpl(
90-
changeBuilder,
91-
fileEdit.file,
92-
document,
93-
fileEdit.fileStamp,
94-
eol: eol,
95-
);
96-
copy.fileEdit.edits.addAll(fileEdit.edits);
97-
return copy;
98-
}
99-
10079
@override
10180
EditBuilderImpl createEditBuilder(int offset, int length) {
10281
return YamlEditBuilderImpl(

‎pkg/analyzer_plugin/lib/utilities/change_builder/change_builder_core.dart‎

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
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+
/// @docImport 'dart:io';
6+
library;
7+
58
import 'dart:async';
69

710
import 'package:analyzer/dart/analysis/session.dart';
@@ -23,16 +26,11 @@ abstract class ChangeBuilder {
2326
///
2427
/// [defaultEol] is the default EOL to be used for new files and files that do
2528
/// not have EOLs. Existing files with EOL markers will always have the same
26-
/// EOL in inserted text. If not specified, Platform.lineTerminator will be
29+
/// EOL in inserted text. If not specified, [Platform.lineTerminator] will be
2730
/// used.
2831
factory ChangeBuilder({
2932
AnalysisSession session,
3033
ChangeWorkspace workspace,
31-
@Deprecated(
32-
'Use defaultEol instead, as this is only a '
33-
'default for files without existing EOLs',
34-
)
35-
String? eol,
3634
String? defaultEol,
3735
}) = ChangeBuilderImpl;
3836

@@ -62,8 +60,6 @@ abstract class ChangeBuilder {
6260
Future<void> addDartFileEdit(
6361
String path,
6462
FutureOr<void> Function(DartFileEditBuilder builder) buildFileEdit, {
65-
@Deprecated('No longer supported')
66-
ImportPrefixGenerator importPrefixGenerator,
6763
bool createEditsForImports = true,
6864
});
6965

@@ -89,14 +85,6 @@ abstract class ChangeBuilder {
8985
void Function(YamlFileEditBuilder builder) buildFileEdit,
9086
);
9187

92-
/// Return a copy of this change builder that is constructed in such as was
93-
/// that changes to the copy will not effect this change builder.
94-
@Deprecated(
95-
'Copying change builders is expensive, so it is no longer '
96-
'supported. There is no replacement.',
97-
)
98-
ChangeBuilder copy();
99-
10088
/// Return `true` if this builder already has edits for the file with the
10189
/// given [path].
10290
bool hasEditsFor(String path);

‎pkg/analyzer_plugin/lib/utilities/change_builder/change_builder_dart.dart‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import 'package:analyzer/source/source_range.dart';
1414
import 'package:analyzer_plugin/utilities/change_builder/change_builder_core.dart';
1515

1616
/// The optional generator for prefix that should be used for new imports.
17+
@Deprecated('This type is no longer used or necessary')
1718
typedef ImportPrefixGenerator = String Function(Uri);
1819

1920
/// An [EditBuilder] used to build edits in Dart files.

‎pkg/analyzer_plugin/lib/utilities/range_factory.dart‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,6 @@ class RangeFactory {
136136
return SourceRange(node.offset, node.length);
137137
}
138138

139-
@Deprecated("Use 'diagnostic' instead")
140-
SourceRange error(Diagnostic d) => diagnostic(d);
141-
142139
/// Returns a source range that covers the name of the given [fragment].
143140
///
144141
/// Returns `null` if the [fragment] does not have an explicit name location,

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /