Skip to content

Commit 6586faf

Browse files
authored
update to the latest sdk; update lints (dart-archive/yaml_edit#68)
1 parent 5e7e143 commit 6586faf

File tree

13 files changed

+97
-78
lines changed

13 files changed

+97
-78
lines changed

pkgs/yaml_edit/.github/workflows/test-package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
matrix:
4848
# Add macos-latest and/or windows-latest if relevant for this package.
4949
os: [ubuntu-latest]
50-
sdk: [2.19.0, stable, dev]
50+
sdk: ['3.0', stable, dev]
5151
platform: [vm, chrome]
5252
steps:
5353
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11

pkgs/yaml_edit/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.2.1-wip
2+
3+
- Require Dart 3.0
4+
15
## 2.2.0
26

37
- Fix inconsistent line endings when inserting maps into a document using `\r\n`.

pkgs/yaml_edit/analysis_options.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,8 @@
11
include: package:dart_flutter_team_lints/analysis_options.yaml
2+
3+
analyzer:
4+
errors:
5+
inference_failure_on_collection_literal: ignore
6+
inference_failure_on_function_invocation: ignore
7+
inference_failure_on_function_return_type: ignore
8+
inference_failure_on_instance_creation: ignore

pkgs/yaml_edit/lib/src/editor.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
// BSD-style license that can be found in the LICENSE file.
44

55
import 'package:meta/meta.dart';
6+
import 'package:source_span/source_span.dart';
67
import 'package:yaml/yaml.dart';
78

89
import 'equality.dart';

pkgs/yaml_edit/lib/src/errors.dart

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ class PathError extends ArgumentError {
4444
/// Exception thrown when the path contains an alias along the way.
4545
///
4646
/// When a path contains an aliased node, the behavior becomes less well-defined
47-
/// because we cannot be certain if the user wishes for the change to
48-
/// propagate throughout all the other aliased nodes, or if the user wishes
49-
/// for only that particular node to be modified. As such, [AliasError] reflects
50-
/// the detection that our change will impact an alias, and we do not intend
51-
/// on supporting such changes for the foreseeable future.
47+
/// because we cannot be certain if the user wishes for the change to propagate
48+
/// throughout all the other aliased nodes, or if the user wishes for only that
49+
/// particular node to be modified. As such, [AliasException] reflects the
50+
/// detection that our change will impact an alias, and we do not intend on
51+
/// supporting such changes for the foreseeable future.
5252
@sealed
5353
class AliasException extends FormatException {
5454
/// The path that caused the error
@@ -70,7 +70,7 @@ class AliasException extends FormatException {
7070
/// Error thrown when an assertion about the YAML fails. Extends
7171
/// [AssertionError] to override the [toString] method for pretty printing.
7272
class _YamlAssertionError extends AssertionError {
73-
_YamlAssertionError(message) : super(message);
73+
_YamlAssertionError(super.message);
7474

7575
@override
7676
String toString() {

pkgs/yaml_edit/lib/src/list_mutations.dart

Lines changed: 31 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,9 @@ import 'strings.dart';
1010
import 'utils.dart';
1111
import 'wrap.dart';
1212

13-
/// Returns a [SourceEdit] describing the change to be made on [yaml] to achieve
14-
/// the effect of setting the element at [index] to [newValue] when re-parsed.
13+
/// Returns a [SourceEdit] describing the change to be made on [yamlEdit] to
14+
/// achieve the effect of setting the element at [index] to [newValue] when
15+
/// re-parsed.
1516
SourceEdit updateInList(
1617
YamlEditor yamlEdit, YamlList list, int index, YamlNode newValue) {
1718
RangeError.checkValueInInterval(index, 0, list.length - 1);
@@ -56,8 +57,8 @@ SourceEdit updateInList(
5657
}
5758
}
5859

59-
/// Returns a [SourceEdit] describing the change to be made on [yaml] to achieve
60-
/// the effect of appending [item] to the list.
60+
/// Returns a [SourceEdit] describing the change to be made on [yamlEdit] to
61+
/// achieve the effect of appending [item] to the list.
6162
SourceEdit appendIntoList(YamlEditor yamlEdit, YamlList list, YamlNode item) {
6263
if (list.style == CollectionStyle.FLOW) {
6364
return _appendToFlowList(yamlEdit, list, item);
@@ -66,8 +67,8 @@ SourceEdit appendIntoList(YamlEditor yamlEdit, YamlList list, YamlNode item) {
6667
}
6768
}
6869

69-
/// Returns a [SourceEdit] describing the change to be made on [yaml] to achieve
70-
/// the effect of inserting [item] to the list at [index].
70+
/// Returns a [SourceEdit] describing the change to be made on [yamlEdit] to
71+
/// achieve the effect of inserting [item] to the list at [index].
7172
SourceEdit insertInList(
7273
YamlEditor yamlEdit, YamlList list, int index, YamlNode item) {
7374
RangeError.checkValueInInterval(index, 0, list.length);
@@ -85,8 +86,8 @@ SourceEdit insertInList(
8586
}
8687
}
8788

88-
/// Returns a [SourceEdit] describing the change to be made on [yaml] to achieve
89-
/// the effect of removing the element at [index] when re-parsed.
89+
/// Returns a [SourceEdit] describing the change to be made on [yamlEdit] to
90+
/// achieve the effect of removing the element at [index] when re-parsed.
9091
SourceEdit removeInList(YamlEditor yamlEdit, YamlList list, int index) {
9192
final nodeToRemove = list.nodes[index];
9293

@@ -97,17 +98,18 @@ SourceEdit removeInList(YamlEditor yamlEdit, YamlList list, int index) {
9798
}
9899
}
99100

100-
/// Returns a [SourceEdit] describing the change to be made on [yaml] to achieve
101-
/// the effect of addition [item] into [nodes], noting that this is a flow list.
101+
/// Returns a [SourceEdit] describing the change to be made on [yamlEdit] to
102+
/// achieve the effect of addition [item] into [list], noting that this is a
103+
/// flow list.
102104
SourceEdit _appendToFlowList(
103105
YamlEditor yamlEdit, YamlList list, YamlNode item) {
104106
final valueString = _formatNewFlow(list, item, true);
105107
return SourceEdit(list.span.end.offset - 1, 0, valueString);
106108
}
107109

108-
/// Returns a [SourceEdit] describing the change to be made on [yaml] to achieve
109-
/// the effect of addition [item] into [nodes], noting that this is a block
110-
/// list.
110+
/// Returns a [SourceEdit] describing the change to be made on [yamlEdit] to
111+
/// achieve the effect of addition [item] into [list], noting that this is a
112+
/// block list.
111113
SourceEdit _appendToBlockList(
112114
YamlEditor yamlEdit, YamlList list, YamlNode item) {
113115
var formattedValue = _formatNewBlock(yamlEdit, list, item);
@@ -159,11 +161,11 @@ String _formatNewFlow(YamlList list, YamlNode item, [bool isLast = false]) {
159161
return valueString;
160162
}
161163

162-
/// Returns a [SourceEdit] describing the change to be made on [yaml] to achieve
163-
/// the effect of inserting [item] into [nodes] at [index], noting that this is
164-
/// a block list.
164+
/// Returns a [SourceEdit] describing the change to be made on [yamlEdit] to
165+
/// achieve the effect of inserting [item] into [list] at [index], noting that
166+
/// this is a block list.
165167
///
166-
/// [index] should be non-negative and less than or equal to [length].
168+
/// [index] should be non-negative and less than or equal to `list.length`.
167169
SourceEdit _insertInBlockList(
168170
YamlEditor yamlEdit, YamlList list, int index, YamlNode item) {
169171
RangeError.checkValueInInterval(index, 0, list.length);
@@ -180,11 +182,11 @@ SourceEdit _insertInBlockList(
180182
return SourceEdit(start, 0, formattedValue);
181183
}
182184

183-
/// Returns a [SourceEdit] describing the change to be made on [yaml] to achieve
184-
/// the effect of inserting [item] into [nodes] at [index], noting that this is
185-
/// a flow list.
185+
/// Returns a [SourceEdit] describing the change to be made on [yamlEdit] to
186+
/// achieve the effect of inserting [item] into [list] at [index], noting that
187+
/// this is a flow list.
186188
///
187-
/// [index] should be non-negative and less than or equal to [length].
189+
/// [index] should be non-negative and less than or equal to `list.length`.
188190
SourceEdit _insertInFlowList(
189191
YamlEditor yamlEdit, YamlList list, int index, YamlNode item) {
190192
RangeError.checkValueInInterval(index, 0, list.length);
@@ -202,11 +204,11 @@ SourceEdit _insertInFlowList(
202204
return SourceEdit(start, 0, formattedValue);
203205
}
204206

205-
/// Returns a [SourceEdit] describing the change to be made on [yaml] to achieve
206-
/// the effect of removing [nodeToRemove] from [nodes], noting that this is a
207-
/// block list.
207+
/// Returns a [SourceEdit] describing the change to be made on [yamlEdit] to
208+
/// achieve the effect of removing [nodeToRemove] from [list], noting that this
209+
/// is a block list.
208210
///
209-
/// [index] should be non-negative and less than or equal to [length].
211+
/// [index] should be non-negative and less than or equal to `list.length`.
210212
SourceEdit _removeFromBlockList(
211213
YamlEditor yamlEdit, YamlList list, YamlNode nodeToRemove, int index) {
212214
RangeError.checkValueInInterval(index, 0, list.length - 1);
@@ -277,11 +279,11 @@ SourceEdit _removeFromBlockList(
277279
return SourceEdit(start, end - start, '');
278280
}
279281

280-
/// Returns a [SourceEdit] describing the change to be made on [yaml] to achieve
281-
/// the effect of removing [nodeToRemove] from [nodes], noting that this is a
282-
/// flow list.
282+
/// Returns a [SourceEdit] describing the change to be made on [yamlEdit] to
283+
/// achieve the effect of removing [nodeToRemove] from [list], noting that this
284+
/// is a flow list.
283285
///
284-
/// [index] should be non-negative and less than or equal to [length].
286+
/// [index] should be non-negative and less than or equal to `list.length`.
285287
SourceEdit _removeFromFlowList(
286288
YamlEditor yamlEdit, YamlList list, YamlNode nodeToRemove, int index) {
287289
RangeError.checkValueInInterval(index, 0, list.length - 1);

pkgs/yaml_edit/lib/src/map_mutations.dart

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import 'strings.dart';
1111
import 'utils.dart';
1212
import 'wrap.dart';
1313

14-
/// Performs the string operation on [yaml] to achieve the effect of setting
14+
/// Performs the string operation on [yamlEdit] to achieve the effect of setting
1515
/// the element at [key] to [newValue] when re-parsed.
1616
SourceEdit updateInMap(
1717
YamlEditor yamlEdit, YamlMap map, Object? key, YamlNode newValue) {
@@ -32,8 +32,8 @@ SourceEdit updateInMap(
3232
}
3333
}
3434

35-
/// Performs the string operation on [yaml] to achieve the effect of removing
36-
/// the element at [key] when re-parsed.
35+
/// Performs the string operation on [yamlEdit] to achieve the effect of
36+
/// removing the element at [key] when re-parsed.
3737
SourceEdit removeInMap(YamlEditor yamlEdit, YamlMap map, Object? key) {
3838
assert(containsKey(map, key));
3939
final keyNode = getKeyNode(map, key);
@@ -46,7 +46,7 @@ SourceEdit removeInMap(YamlEditor yamlEdit, YamlMap map, Object? key) {
4646
}
4747
}
4848

49-
/// Performs the string operation on [yaml] to achieve the effect of adding
49+
/// Performs the string operation on [yamlEdit] to achieve the effect of adding
5050
/// the [key]:[newValue] pair when reparsed, bearing in mind that this is a
5151
/// block map.
5252
SourceEdit _addToBlockMap(
@@ -95,7 +95,7 @@ SourceEdit _addToBlockMap(
9595
return SourceEdit(offset, 0, formattedValue);
9696
}
9797

98-
/// Performs the string operation on [yaml] to achieve the effect of adding
98+
/// Performs the string operation on [yamlEdit] to achieve the effect of adding
9999
/// the [key]:[newValue] pair when reparsed, bearing in mind that this is a flow
100100
/// map.
101101
SourceEdit _addToFlowMap(
@@ -120,9 +120,9 @@ SourceEdit _addToFlowMap(
120120
return SourceEdit(insertionOffset, 0, '$keyString: $valueString, ');
121121
}
122122

123-
/// Performs the string operation on [yaml] to achieve the effect of replacing
124-
/// the value at [key] with [newValue] when reparsed, bearing in mind that this
125-
/// is a block map.
123+
/// Performs the string operation on [yamlEdit] to achieve the effect of
124+
/// replacing the value at [key] with [newValue] when reparsed, bearing in mind
125+
/// that this is a block map.
126126
SourceEdit _replaceInBlockMap(
127127
YamlEditor yamlEdit, YamlMap map, Object? key, YamlNode newValue) {
128128
final yaml = yamlEdit.toString();
@@ -156,9 +156,9 @@ SourceEdit _replaceInBlockMap(
156156
return SourceEdit(start, end - start, valueAsString);
157157
}
158158

159-
/// Performs the string operation on [yaml] to achieve the effect of replacing
160-
/// the value at [key] with [newValue] when reparsed, bearing in mind that this
161-
/// is a flow map.
159+
/// Performs the string operation on [yamlEdit] to achieve the effect of
160+
/// replacing the value at [key] with [newValue] when reparsed, bearing in mind
161+
/// that this is a flow map.
162162
SourceEdit _replaceInFlowMap(
163163
YamlEditor yamlEdit, YamlMap map, Object? key, YamlNode newValue) {
164164
final valueSpan = map.nodes[key]!.span;
@@ -167,8 +167,9 @@ SourceEdit _replaceInFlowMap(
167167
return SourceEdit(valueSpan.start.offset, valueSpan.length, valueString);
168168
}
169169

170-
/// Performs the string operation on [yaml] to achieve the effect of removing
171-
/// the [key] from the map, bearing in mind that this is a block map.
170+
/// Performs the string operation on [yamlEdit] to achieve the effect of
171+
/// removing the [keyNode] from the map, bearing in mind that this is a block
172+
/// map.
172173
SourceEdit _removeFromBlockMap(
173174
YamlEditor yamlEdit, YamlMap map, YamlNode keyNode, YamlNode valueNode) {
174175
final keySpan = keyNode.span;
@@ -214,8 +215,9 @@ SourceEdit _removeFromBlockMap(
214215
return SourceEdit(start, end - start, '');
215216
}
216217

217-
/// Performs the string operation on [yaml] to achieve the effect of removing
218-
/// the [key] from the map, bearing in mind that this is a flow map.
218+
/// Performs the string operation on [yamlEdit] to achieve the effect of
219+
/// removing the [keyNode] from the map, bearing in mind that this is a flow
220+
/// map.
219221
SourceEdit _removeFromFlowMap(
220222
YamlEditor yamlEdit, YamlMap map, YamlNode keyNode, YamlNode valueNode) {
221223
var start = keyNode.span.start.offset;

pkgs/yaml_edit/lib/src/source_edit.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ class SourceEdit {
7373
return SourceEdit(offset, length, replacement);
7474
}
7575

76-
throw FormatException('Invalid JSON passed to SourceEdit');
76+
throw const FormatException('Invalid JSON passed to SourceEdit');
7777
}
7878

7979
/// Encodes this object as JSON-compatible structure.

pkgs/yaml_edit/lib/src/strings.dart

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,10 @@ String _tryYamlEncodeLiteral(
131131
/// Returns [value] with the necessary formatting applied in a flow context
132132
/// if possible.
133133
///
134-
/// If [value] is a [YamlScalar], we try to respect its [style] parameter where
135-
/// possible. Certain cases make this impossible (e.g. a plain string scalar
136-
/// that starts with '>'), in which case we will produce [value] with default
137-
/// styling options.
134+
/// If [value] is a [YamlScalar], we try to respect its [YamlScalar.style]
135+
/// parameter where possible. Certain cases make this impossible (e.g. a plain
136+
/// string scalar that starts with '>'), in which case we will produce [value]
137+
/// with default styling options.
138138
String _yamlEncodeFlowScalar(YamlNode value) {
139139
if (value is YamlScalar) {
140140
assertValidScalar(value.value);
@@ -161,10 +161,10 @@ String _yamlEncodeFlowScalar(YamlNode value) {
161161
/// Returns [value] with the necessary formatting applied in a block context
162162
/// if possible.
163163
///
164-
/// If [value] is a [YamlScalar], we try to respect its [style] parameter where
165-
/// possible. Certain cases make this impossible (e.g. a folded string scalar
166-
/// 'null'), in which case we will produce [value] with default styling
167-
/// options.
164+
/// If [value] is a [YamlScalar], we try to respect its [YamlScalar.style]
165+
/// parameter where possible. Certain cases make this impossible (e.g. a folded
166+
/// string scalar 'null'), in which case we will produce [value] with default
167+
/// styling options.
168168
String yamlEncodeBlockScalar(
169169
YamlNode value,
170170
int indentation,
@@ -207,10 +207,11 @@ String yamlEncodeBlockScalar(
207207

208208
/// Returns [value] with the necessary formatting applied in a flow context.
209209
///
210-
/// If [value] is a [YamlNode], we try to respect its [style] parameter where
211-
/// possible. Certain cases make this impossible (e.g. a plain string scalar
212-
/// that starts with '>', a child having a block style parameters), in which
213-
/// case we will produce [value] with default styling options.
210+
/// If [value] is a [YamlNode], we try to respect its [YamlScalar.style]
211+
/// parameter where possible. Certain cases make this impossible (e.g. a plain
212+
/// string scalar that starts with '>', a child having a block style
213+
/// parameters), in which case we will produce [value] with default styling
214+
/// options.
214215
String yamlEncodeFlowString(YamlNode value) {
215216
if (value is YamlList) {
216217
final list = value.nodes;
@@ -231,8 +232,6 @@ String yamlEncodeFlowString(YamlNode value) {
231232
}
232233

233234
/// Returns [value] with the necessary formatting applied in a block context.
234-
///
235-
/// If [value] is a [YamlNode], we respect its [style] parameter.
236235
String yamlEncodeBlockString(
237236
YamlNode value,
238237
int indentation,

pkgs/yaml_edit/lib/src/utils.dart

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import 'package:source_span/source_span.dart';
66
import 'package:yaml/yaml.dart';
77

88
import 'editor.dart';
9+
import 'wrap.dart';
910

1011
/// Determines if [string] is dangerous by checking if parsing the plain string
1112
/// can return a result different from [string].
@@ -137,13 +138,13 @@ int getMapInsertionIndex(YamlMap map, Object newKey) {
137138
return map.length;
138139
}
139140

140-
/// Returns the detected indentation step used in [yaml], or
141-
/// defaults to a value of `2` if no indentation step can be detected.
141+
/// Returns the detected indentation step used in [editor], or defaults to a
142+
/// value of `2` if no indentation step can be detected.
142143
///
143144
/// Indentation step is determined by the difference in indentation of the
144145
/// first block-styled yaml collection in the second level as compared to the
145146
/// top-level elements. In the case where there are multiple possible
146-
/// candidates, we choose the candidate closest to the start of [yaml].
147+
/// candidates, we choose the candidate closest to the start of [editor].
147148
int getIndentation(YamlEditor editor) {
148149
final node = editor.parseAt([]);
149150
Iterable<YamlNode>? children;

0 commit comments

Comments
 (0)