Skip to content

Commit 0d099f2

Browse files
committed
Version 2.17.0-266.5.beta
* Cherry-pick 2badd2e to beta * Cherry-pick 54af2c5 to beta * Cherry-pick 29f9b20 to beta * Cherry-pick 3d8290d to beta
2 parents f694709 + e3c2291 commit 0d099f2

File tree

5 files changed

+156
-81
lines changed

5 files changed

+156
-81
lines changed

DEPS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ vars = {
110110
"dart_style_rev": "d7b73536a8079331c888b7da539b80e6825270ea",
111111

112112
"dartdoc_rev" : "334072b0cad436c05f6bcecf8a1a59f2f0809b84",
113-
"devtools_rev" : "2a707ca56c1a9d5eeef212c28c573548a051fdd2",
113+
"devtools_rev" : "8c525828ba33029ed664bf8ea2829b6e5370535f",
114114
"ffi_rev": "4dd32429880a57b64edaf54c9d5af8a9fa9a4ffb",
115115
"fixnum_rev": "848341f061359ef7ddc0cad472c2ecbb036b28ac",
116116
"file_rev": "1ebc38852ffed24b564910317982298b56c2cedd",
@@ -176,7 +176,7 @@ vars = {
176176
"webkit_inspection_protocol_rev": "dd6fb5d8b536e19cedb384d0bbf1f5631923f1e8",
177177
"yaml_edit_rev": "4fadb43801b07f90b3f0c6065dbce4efc6d8d55e",
178178
"yaml_rev": "ad0779d1baa25c6b10a192d080efc45de02b6a32",
179-
"zlib_rev": "bf44340d1b6be1af8950bbdf664fec0cf5a831cc",
179+
"zlib_rev": "faff052b6b6edcd6dd548513fe44ac0941427bf0",
180180
"crashpad_rev": "bf327d8ceb6a669607b0dbab5a83a275d03f99ed",
181181
"minichromium_rev": "8d641e30a8b12088649606b912c2bc4947419ccc",
182182
"googletest_rev": "f854f1d27488996dc8a6db3c9453f80b02585e12",

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

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -52,23 +52,26 @@ class FieldFormalContributor extends DartCompletionContributor {
5252
}
5353
}
5454

55-
var enclosingClass = constructor.thisOrAncestorOfType<ClassDeclaration>();
55+
ClassElement? enclosingClass;
56+
var constructorParent = constructor.parent;
57+
if (constructorParent is ClassDeclaration) {
58+
enclosingClass = constructorParent.declaredElement;
59+
} else if (constructorParent is EnumDeclaration) {
60+
enclosingClass = constructorParent.declaredElement;
61+
} else {
62+
return;
63+
}
5664
if (enclosingClass == null) {
5765
return;
5866
}
5967

6068
// Add suggestions for fields that are not already referenced.
61-
for (var member in enclosingClass.members) {
62-
if (member is FieldDeclaration && !member.isStatic) {
63-
for (var variable in member.fields.variables) {
64-
var field = variable.name.staticElement;
65-
if (field is FieldElement) {
66-
var fieldName = field.name;
67-
if (fieldName.isNotEmpty) {
68-
if (!referencedFields.contains(fieldName)) {
69-
builder.suggestFieldFormalParameter(field);
70-
}
71-
}
69+
for (var field in enclosingClass.fields) {
70+
if (!field.isSynthetic && !field.isEnumConstant && !field.isStatic) {
71+
var fieldName = field.name;
72+
if (fieldName.isNotEmpty) {
73+
if (!referencedFields.contains(fieldName)) {
74+
builder.suggestFieldFormalParameter(field);
7275
}
7376
}
7477
}

pkg/analysis_server/test/services/completion/dart/location/field_formal_parameter_test.dart

Lines changed: 132 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -30,66 +30,63 @@ class FieldFormalParameterTest2 extends AbstractCompletionDriverTest
3030
}
3131

3232
mixin SuperFormalParameterTestCases on AbstractCompletionDriverTest {
33-
/// https://github.com/dart-lang/sdk/issues/39028
34-
Future<void> test_mixin_constructor() async {
35-
var response = await getTestCodeSuggestions('''
36-
mixin M {
37-
var field = 0;
38-
M(this.^);
39-
}
40-
''');
41-
42-
check(response).suggestions.isEmpty;
43-
}
44-
45-
Future<void> test_replacement_left() async {
46-
var response = await getTestCodeSuggestions('''
47-
class A {
48-
var field = 0;
49-
A(this.f^);
50-
}
51-
''');
52-
53-
check(response)
54-
..hasReplacement(left: 1)
55-
..suggestions.matchesInAnyOrder([
56-
(suggestion) => suggestion
57-
..completion.isEqualTo('field')
58-
..isField
59-
..returnType.isEqualTo('int'),
60-
]);
33+
Future<void> test_class_replacement_left() async {
34+
_checkContainers(
35+
declarations: 'var field = 0;',
36+
constructorParameters: 'this.f^',
37+
validator: (response) {
38+
check(response)
39+
..hasReplacement(left: 1)
40+
..suggestions.matchesInAnyOrder([
41+
(suggestion) => suggestion
42+
..completion.isEqualTo('field')
43+
..isField
44+
..returnType.isEqualTo('int'),
45+
]);
46+
},
47+
);
6148
}
6249

63-
Future<void> test_replacement_right() async {
64-
var response = await getTestCodeSuggestions('''
65-
class A {
66-
var field = 0;
67-
A(this.^f);
68-
}
69-
''');
70-
71-
check(response)
72-
..hasReplacement(right: 1)
73-
..suggestions.matchesInAnyOrder([
74-
(suggestion) => suggestion
75-
..completion.isEqualTo('field')
76-
..isField
77-
..returnType.isEqualTo('int'),
78-
]);
50+
Future<void> test_class_replacement_right() async {
51+
_checkContainers(
52+
declarations: 'var field = 0;',
53+
constructorParameters: 'this.^f',
54+
validator: (response) {
55+
check(response)
56+
..hasReplacement(right: 1)
57+
..suggestions.matchesInAnyOrder([
58+
(suggestion) => suggestion
59+
..completion.isEqualTo('field')
60+
..isField
61+
..returnType.isEqualTo('int'),
62+
]);
63+
},
64+
);
7965
}
8066

81-
Future<void> test_suggestions_onlyLocal() async {
67+
Future<void> test_class_suggestions_instanceFields_local() async {
8268
var response = await getTestCodeSuggestions('''
8369
class A {
70+
static final superStatic = 0;
8471
var inherited = 0;
72+
73+
void superMethod() {}
74+
int get superGetter => 0;
75+
void superSetter(int _) {}
8576
}
8677
8778
class B extends A {
79+
static final thisStatic = 0;
80+
8881
var first = 0;
8982
var second = 1.2;
83+
9084
B(this.^);
91-
B.constructor() {}
92-
void method() {}
85+
B.otherConstructor() {}
86+
87+
void thisMethod() {}
88+
int get thisGetter => 0;
89+
void thisSetter(int _) {}
9390
}
9491
''');
9592

@@ -107,41 +104,110 @@ class B extends A {
107104
]);
108105
}
109106

110-
Future<void> test_suggestions_onlyNotSpecified_optionalNamed() async {
107+
Future<void> test_class_suggestions_onlyNotSpecified_optionalNamed() async {
108+
_checkContainers(
109+
declarations: 'final int x; final int y;',
110+
constructorParameters: '{this.x, this.^}',
111+
validator: (response) {
112+
check(response)
113+
..hasEmptyReplacement()
114+
..suggestions.matchesInAnyOrder([
115+
(suggestion) => suggestion
116+
..completion.isEqualTo('y')
117+
..isField
118+
..returnType.isEqualTo('int'),
119+
]);
120+
},
121+
);
122+
}
123+
124+
Future<void>
125+
test_class_suggestions_onlyNotSpecified_requiredPositional() async {
126+
_checkContainers(
127+
declarations: 'final int x; final int y;',
128+
constructorParameters: 'this.x, this.^',
129+
validator: (response) {
130+
check(response)
131+
..hasEmptyReplacement()
132+
..suggestions.matchesInAnyOrder([
133+
(suggestion) => suggestion
134+
..completion.isEqualTo('y')
135+
..isField
136+
..returnType.isEqualTo('int'),
137+
]);
138+
},
139+
);
140+
}
141+
142+
Future<void> test_enum_suggestions_instanceFields() async {
111143
var response = await getTestCodeSuggestions('''
112-
class Point {
113-
final int x;
114-
final int y;
115-
Point({this.x, this.^});
144+
enum E {
145+
v();
146+
147+
static final zero = 0;
148+
final int first;
149+
final double second;
150+
151+
E(this.^);
152+
E.otherConstructor();
153+
154+
void myMethod() {}
155+
int get myGetter => 0;
156+
void mySetter(int _) {}
116157
}
117158
''');
118159

119160
check(response)
120161
..hasEmptyReplacement()
121162
..suggestions.matchesInAnyOrder([
122163
(suggestion) => suggestion
123-
..completion.isEqualTo('y')
164+
..completion.isEqualTo('first')
124165
..isField
125166
..returnType.isEqualTo('int'),
167+
(suggestion) => suggestion
168+
..completion.isEqualTo('second')
169+
..isField
170+
..returnType.isEqualTo('double'),
126171
]);
127172
}
128173

129-
Future<void> test_suggestions_onlyNotSpecified_requiredPositional() async {
174+
/// https://github.com/dart-lang/sdk/issues/39028
175+
Future<void> test_mixin_constructor() async {
130176
var response = await getTestCodeSuggestions('''
131-
class Point {
132-
final int x;
133-
final int y;
134-
Point(this.x, this.^);
177+
mixin M {
178+
var field = 0;
179+
M(this.^);
135180
}
136181
''');
137182

138-
check(response)
139-
..hasEmptyReplacement()
140-
..suggestions.matchesInAnyOrder([
141-
(suggestion) => suggestion
142-
..completion.isEqualTo('y')
143-
..isField
144-
..returnType.isEqualTo('int'),
145-
]);
183+
check(response).suggestions.isEmpty;
184+
}
185+
186+
Future<void> _checkContainers({
187+
required String declarations,
188+
required String constructorParameters,
189+
required void Function(CompletionResponseForTesting response) validator,
190+
}) async {
191+
// class
192+
{
193+
var response = await getTestCodeSuggestions('''
194+
class A {
195+
$declarations
196+
A($constructorParameters);
197+
}
198+
''');
199+
validator(response);
200+
}
201+
// enum
202+
{
203+
var response = await getTestCodeSuggestions('''
204+
enum E {
205+
v;
206+
$declarations
207+
E($constructorParameters);
208+
}
209+
''');
210+
validator(response);
211+
}
146212
}
147213
}

runtime/vm/os_macos.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,12 @@ int64_t OS::GetCurrentMonotonicMicros() {
106106
}
107107

108108
int64_t OS::GetCurrentThreadCPUMicros() {
109+
if (__builtin_available(macOS 10.12, iOS 10.0, *)) {
110+
// This is more efficient when available.
111+
return clock_gettime_nsec_np(CLOCK_THREAD_CPUTIME_ID) /
112+
kNanosecondsPerMicrosecond;
113+
}
114+
109115
mach_msg_type_number_t count = THREAD_BASIC_INFO_COUNT;
110116
thread_basic_info_data_t info_data;
111117
thread_basic_info_t info = &info_data;

tools/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,4 +28,4 @@ MAJOR 2
2828
MINOR 17
2929
PATCH 0
3030
PRERELEASE 266
31-
PRERELEASE_PATCH 1
31+
PRERELEASE_PATCH 5

0 commit comments

Comments
 (0)