Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 5acaa5f

Browse files
author
Dart CI
committed
Version 2.12.0-104.0.dev
Merge commit '95ad66642eab0c1dbd97d8743276391e1cd56af1' into 'dev'
2 parents e9a03fd + 95ad666 commit 5acaa5f

File tree

52 files changed

+452
-1145
lines changed

Some content is hidden

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

52 files changed

+452
-1145
lines changed

pkg/analysis_server/lib/src/services/completion/yaml/yaml_completion_generator.dart

Lines changed: 1 addition & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import 'package:analysis_server/src/protocol_server.dart';
66
import 'package:analysis_server/src/services/completion/yaml/producer.dart';
7+
import 'package:analysis_server/src/utilities/extensions/yaml.dart';
78
import 'package:analyzer/file_system/file_system.dart';
89
import 'package:yaml/yaml.dart';
910

@@ -182,62 +183,3 @@ class YamlCompletionResults {
182183
replacementOffset = 0,
183184
replacementLength = 0;
184185
}
185-
186-
extension on YamlMap {
187-
/// Return the node representing the key that corresponds to the value
188-
/// represented by the [value] node.
189-
YamlNode keyAtValue(YamlNode value) {
190-
for (var entry in nodes.entries) {
191-
if (entry.value == value) {
192-
return entry.key;
193-
}
194-
}
195-
return null;
196-
}
197-
}
198-
199-
extension on YamlNode {
200-
/// Return the child of this node that contains the given [offset], or `null`
201-
/// if none of the children contains the offset.
202-
YamlNode childContainingOffset(int offset) {
203-
var node = this;
204-
if (node is YamlList) {
205-
for (var element in node.nodes) {
206-
if (element.containsOffset(offset)) {
207-
return element;
208-
}
209-
}
210-
for (var element in node.nodes) {
211-
if (element is YamlScalar && element.value == null) {
212-
// TODO(brianwilkerson) Testing for a null value probably gets
213-
// confused when there are multiple null values.
214-
return element;
215-
}
216-
}
217-
} else if (node is YamlMap) {
218-
for (var entry in node.nodes.entries) {
219-
if ((entry.key as YamlNode).containsOffset(offset)) {
220-
return entry.key;
221-
}
222-
var value = entry.value;
223-
if (value.containsOffset(offset) ||
224-
(value is YamlScalar && value.value == null)) {
225-
// TODO(brianwilkerson) Testing for a null value probably gets
226-
// confused when there are multiple null values or when there is a
227-
// null value before the node that actually contains the offset.
228-
return entry.value;
229-
}
230-
}
231-
}
232-
return null;
233-
}
234-
235-
/// Return `true` if this node contains the given [offset].
236-
bool containsOffset(int offset) {
237-
// TODO(brianwilkerson) Nodes at the end of the file contain any trailing
238-
// whitespace. This needs to be accounted for, here or elsewhere.
239-
var nodeOffset = span.start.offset;
240-
var nodeEnd = nodeOffset + span.length;
241-
return nodeOffset <= offset && offset <= nodeEnd;
242-
}
243-
}

pkg/analysis_server/lib/src/services/correction/fix/data_driven/transform_set_parser.dart

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1033,18 +1033,3 @@ class TransformSetParser {
10331033
}
10341034
}
10351035
}
1036-
1037-
extension on YamlMap {
1038-
// TODO(brianwilkerson) Copied from YamlCompletionGenerator. Refactor to a
1039-
// utility file that is shared between them.
1040-
/// Return the node representing the key that corresponds to the value
1041-
/// represented by the [value] node.
1042-
YamlNode keyAtValue(YamlNode value) {
1043-
for (var entry in nodes.entries) {
1044-
if (entry.value == value) {
1045-
return entry.key;
1046-
}
1047-
}
1048-
return null;
1049-
}
1050-
}

pkg/analysis_server/lib/src/utilities/extensions/yaml.dart

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@
55
import 'package:yaml/yaml.dart';
66

77
extension YamlMapExtensions on YamlMap {
8+
/// Return the node representing the key that corresponds to the value
9+
/// represented by the [value] node.
10+
YamlNode keyAtValue(YamlNode value) {
11+
for (var entry in nodes.entries) {
12+
if (entry.value == value) {
13+
return entry.key;
14+
}
15+
}
16+
return null;
17+
}
18+
819
/// Return the value associated with the key whose value matches the given
920
/// [key], or `null` if there is no matching key.
1021
YamlNode valueAt(String key) {
@@ -16,3 +27,49 @@ extension YamlMapExtensions on YamlMap {
1627
return null;
1728
}
1829
}
30+
31+
extension YamlNodeExtensions on YamlNode {
32+
/// Return the child of this node that contains the given [offset], or `null`
33+
/// if none of the children contains the offset.
34+
YamlNode childContainingOffset(int offset) {
35+
var node = this;
36+
if (node is YamlList) {
37+
for (var element in node.nodes) {
38+
if (element.containsOffset(offset)) {
39+
return element;
40+
}
41+
}
42+
for (var element in node.nodes) {
43+
if (element is YamlScalar && element.value == null) {
44+
// TODO(brianwilkerson) Testing for a null value probably gets
45+
// confused when there are multiple null values.
46+
return element;
47+
}
48+
}
49+
} else if (node is YamlMap) {
50+
for (var entry in node.nodes.entries) {
51+
if ((entry.key as YamlNode).containsOffset(offset)) {
52+
return entry.key;
53+
}
54+
var value = entry.value;
55+
if (value.containsOffset(offset) ||
56+
(value is YamlScalar && value.value == null)) {
57+
// TODO(brianwilkerson) Testing for a null value probably gets
58+
// confused when there are multiple null values or when there is a
59+
// null value before the node that actually contains the offset.
60+
return entry.value;
61+
}
62+
}
63+
}
64+
return null;
65+
}
66+
67+
/// Return `true` if this node contains the given [offset].
68+
bool containsOffset(int offset) {
69+
// TODO(brianwilkerson) Nodes at the end of the file contain any trailing
70+
// whitespace. This needs to be accounted for, here or elsewhere.
71+
var nodeOffset = span.start.offset;
72+
var nodeEnd = nodeOffset + span.length;
73+
return nodeOffset <= offset && offset <= nodeEnd;
74+
}
75+
}

pkg/front_end/lib/src/fasta/kernel/body_builder.dart

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5950,11 +5950,12 @@ class BodyBuilder extends ScopeListener<JumpTarget>
59505950
if (builder?.next != null) {
59515951
// Duplicated name, already reported.
59525952
return <Initializer>[
5953-
new LocalInitializer(new VariableDeclaration.forValue(buildProblem(
5954-
fasta.templateDuplicatedDeclarationUse.withArguments(name),
5955-
fieldNameOffset,
5956-
name.length)))
5957-
..fileOffset = fieldNameOffset
5953+
buildInvalidInitializer(
5954+
buildProblem(
5955+
fasta.templateDuplicatedDeclarationUse.withArguments(name),
5956+
fieldNameOffset,
5957+
name.length),
5958+
fieldNameOffset)
59585959
];
59595960
} else if (builder is FieldBuilder && builder.isDeclarationInstanceMember) {
59605961
initializedFields ??= <String, int>{};

pkg/front_end/testcases/general/duplicated_field_initializer.dart.strong.expect

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class A extends core::Object {
2121
constructor •(core::int* a) → self::A*
2222
: final dynamic #t1 = invalid-expression "pkg/front_end/testcases/general/duplicated_field_initializer.dart:8:10: Error: Can't use 'a' because it is declared more than once.
2323
A(this.a);
24-
^", super core::Object::•()
24+
^"
2525
;
2626
abstract member-signature get _identityHashCode() → core::int*; -> core::Object::_identityHashCode
2727
abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*; -> core::Object::_instanceOf

pkg/front_end/testcases/general/duplicated_field_initializer.dart.strong.transformed.expect

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class A extends core::Object {
2121
constructor •(core::int* a) → self::A*
2222
: final dynamic #t1 = invalid-expression "pkg/front_end/testcases/general/duplicated_field_initializer.dart:8:10: Error: Can't use 'a' because it is declared more than once.
2323
A(this.a);
24-
^", super core::Object::•()
24+
^"
2525
;
2626
abstract member-signature get _identityHashCode() → core::int*; -> core::Object::_identityHashCode
2727
abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*; -> core::Object::_instanceOf

pkg/front_end/testcases/general/issue38938.dart.strong.expect

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class A extends core::Object {
2121
constructor •(core::int* v) → self::A*
2222
: final dynamic #t1 = invalid-expression "pkg/front_end/testcases/general/issue38938.dart:8:10: Error: Can't use 'v' because it is declared more than once.
2323
A(this.v);
24-
^", super core::Object::•()
24+
^"
2525
;
2626
constructor second() → self::A*
2727
: super core::Object::•()

pkg/front_end/testcases/general/issue38938.dart.strong.transformed.expect

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class A extends core::Object {
2121
constructor •(core::int* v) → self::A*
2222
: final dynamic #t1 = invalid-expression "pkg/front_end/testcases/general/issue38938.dart:8:10: Error: Can't use 'v' because it is declared more than once.
2323
A(this.v);
24-
^", super core::Object::•()
24+
^"
2525
;
2626
constructor second() → self::A*
2727
: super core::Object::•()
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
class E {
6+
final int x;
7+
final int y;
8+
E() : this.named(),
9+
this.x = 1;
10+
this.y = 2;
11+
12+
E.named() : this.x = 5,
13+
this.y = 6;
14+
}
15+
16+
main() {}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
library;
2+
//
3+
// Problems in library:
4+
//
5+
// pkg/front_end/testcases/general/issue43363.dart:10:9: Error: Expected a class member, but got 'this'.
6+
// this.y = 2;
7+
// ^^^^
8+
//
9+
// pkg/front_end/testcases/general/issue43363.dart:10:13: Error: Expected a class member, but got '.'.
10+
// this.y = 2;
11+
// ^
12+
//
13+
// pkg/front_end/testcases/general/issue43363.dart:10:14: Error: Variables must be declared using the keywords 'const', 'final', 'var' or a type name.
14+
// Try adding the name of the type of the variable or the keyword 'var'.
15+
// this.y = 2;
16+
// ^
17+
//
18+
// pkg/front_end/testcases/general/issue43363.dart:10:14: Error: 'y' is already declared in this scope.
19+
// this.y = 2;
20+
// ^
21+
// pkg/front_end/testcases/general/issue43363.dart:7:13: Context: Previous declaration of 'y'.
22+
// final int y;
23+
// ^
24+
//
25+
import self as self;
26+
import "dart:core" as core;
27+
28+
class E extends core::Object {
29+
final field core::int* x;
30+
final field core::int* y;
31+
constructor •() → self::E*
32+
;
33+
constructor named() → self::E*
34+
;
35+
abstract member-signature get _identityHashCode() → core::int*; -> core::Object::_identityHashCode
36+
abstract member-signature method _instanceOf(dynamic instantiatorTypeArguments, dynamic functionTypeArguments, dynamic type) → core::bool*; -> core::Object::_instanceOf
37+
abstract member-signature method _simpleInstanceOf(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOf
38+
abstract member-signature method _simpleInstanceOfTrue(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfTrue
39+
abstract member-signature method _simpleInstanceOfFalse(dynamic type) → core::bool*; -> core::Object::_simpleInstanceOfFalse
40+
abstract member-signature operator ==(dynamic other) → core::bool*; -> core::Object::==
41+
abstract member-signature get hashCode() → core::int*; -> core::Object::hashCode
42+
abstract member-signature method toString() → core::String*; -> core::Object::toString
43+
abstract member-signature method noSuchMethod(core::Invocation* invocation) → dynamic; -> core::Object::noSuchMethod
44+
abstract member-signature get runtimeType() → core::Type*; -> core::Object::runtimeType
45+
}
46+
static method main() → dynamic
47+
;

0 commit comments

Comments
 (0)