Skip to content

Commit 67c75e3

Browse files
author
Dart CI
committed
Version 2.10.0-13.0.dev
Merge commit 'aba88b6ed42b963a2a74fed935da8b317051d898' into 'dev'
2 parents 1e23121 + aba88b6 commit 67c75e3

File tree

18 files changed

+3864
-3036
lines changed

18 files changed

+3864
-3036
lines changed

CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,10 @@ Updated the Linter to `0.1.117`, which includes:
151151
### Pub
152152
* `pub run` and `pub global run` accepts a `--enable-experiment` flag enabling
153153
experiments in the Dart VM (and language).
154+
* `pub run` and `pub global run` accepts a `--(no-)-sound-null-safety flag, that
155+
is passed to the VM.
154156
* Warn when publishing the first null-safe version of a package.
155157
* `pub outdated`:
156-
* Introduce `--mode=null-safety` flag that will report which of your
157-
dependencies you can upgrade to fully support null safety.
158158
* If the current version of a dependency is a prerelease
159159
version, use prereleases for latest if there is no newer stable.
160160
* Don't require a `pubspec.lock` file. When the lockfile is missing, the
@@ -172,6 +172,7 @@ Updated the Linter to `0.1.117`, which includes:
172172
* Fix git folder names in cache, allowing for ssh-style git
173173
dependencies.
174174
* Fix: Avoid precompilation of dependencies of global packages.
175+
* Fix: avoid multiple recompilation of binaries in global packages.
175176

176177
## 2.8.4 - 2020-06-04
177178

DEPS

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ vars = {
128128
"ply_rev": "604b32590ffad5cbb82e4afef1d305512d06ae93",
129129
"pool_rev": "eedbd5fde84f9a1a8da643b475305a81841da599",
130130
"protobuf_rev": "3746c8fd3f2b0147623a8e3db89c3ff4330de760",
131-
"pub_rev": "04b054b62cc437cf23451785fdc50e49cd9de139",
131+
"pub_rev": "0d185a398a1684c15ea16a0facc17f5d170e5d51",
132132
"pub_semver_tag": "v1.4.4",
133133
"quiver-dart_tag": "246e754fe45cecb6aa5f3f13b4ed61037ff0d784",
134134
"resource_rev": "f8e37558a1c4f54550aa463b88a6a831e3e33cd6",
@@ -483,16 +483,6 @@ deps = {
483483
"dep_type": "cipd",
484484
},
485485

486-
Var("dart_root") + "/pkg/analysis_server/language_model": {
487-
"packages": [
488-
{
489-
"package": "dart/language_model",
490-
"version": "lIRt14qoA1Cocb8j3yw_Fx5cfYou2ddam6ArBm4AI6QC",
491-
}
492-
],
493-
"dep_type": "cipd",
494-
},
495-
496486
Var("dart_root") + "/buildtools": {
497487
"packages": [
498488
{

pkg/analysis_server/lib/src/services/correction/bulk_fix_processor.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import 'dart:core';
88
import 'package:analysis_server/plugin/edit/fix/fix_dart.dart';
99
import 'package:analysis_server/src/services/correction/change_workspace.dart';
1010
import 'package:analysis_server/src/services/correction/dart/abstract_producer.dart';
11+
import 'package:analysis_server/src/services/correction/dart/add_await.dart';
1112
import 'package:analysis_server/src/services/correction/dart/add_override.dart';
1213
import 'package:analysis_server/src/services/correction/dart/convert_add_all_to_spread.dart';
1314
import 'package:analysis_server/src/services/correction/dart/convert_conditional_expression_to_if_element.dart';
@@ -88,6 +89,7 @@ class BulkFixProcessor {
8889
LintNames.prefer_spread_collections: ConvertAddAllToSpread.newInstance,
8990
LintNames.slash_for_doc_comments: ConvertDocumentationIntoLine.newInstance,
9091
LintNames.type_init_formals: RemoveTypeAnnotation.newInstance,
92+
LintNames.unawaited_futures: AddAwait.newInstance,
9193
LintNames.unnecessary_const: RemoveUnnecessaryConst.newInstance,
9294
LintNames.unnecessary_lambdas: ReplaceWithTearOff.newInstance,
9395
LintNames.unnecessary_new: RemoveUnnecessaryNew.newInstance,

pkg/analysis_server/lib/src/services/correction/organize_imports.dart

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,34 @@ class ImportOrganizer {
6464
var priority = getDirectivePriority(directive);
6565
if (priority != null) {
6666
var offset = directive.offset;
67+
if (directive.beginToken.precedingComments != null) {
68+
var firstComment = directive.beginToken.precedingComments;
69+
var comment = firstComment;
70+
// Don't connect comments that have a blank line between them
71+
while (comment.next != null) {
72+
var currentLine = lineInfo.getLocation(comment.offset).lineNumber;
73+
var nextLine =
74+
lineInfo.getLocation(comment.next.offset).lineNumber;
75+
if (nextLine - currentLine > 1) {
76+
firstComment = comment.next;
77+
}
78+
79+
comment = comment.next;
80+
}
81+
// Check if the comment is the first comment in the document
82+
if (firstComment != unit.beginToken.precedingComments) {
83+
var previousLine = lineInfo
84+
.getLocation(directive.beginToken.previous.end)
85+
.lineNumber;
86+
87+
// Check if the comment is after the last token of the previous line
88+
// Only connect, if it's not on the same line as the last token of the previous line
89+
if (lineInfo.getLocation(firstComment.offset).lineNumber !=
90+
previousLine) {
91+
offset = firstComment.offset;
92+
}
93+
}
94+
}
6795

6896
var end = directive.end;
6997
var line = lineInfo.getLocation(end).lineNumber;

pkg/analysis_server/test/services/completion/dart/completion_ranking_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ void main() {
2121
tokenize('if (list == null) { return; } for (final i = 0; i < list.');
2222
final response = await ranking.makePredictRequest(tokens);
2323
expect(response['data']['length'], greaterThan(0.9));
24-
});
24+
}, skip: 'https://github.com/dart-lang/sdk/issues/42988');
2525
}
2626

2727
final directory = path.join(File.fromUri(Platform.script).parent.path, '..',

pkg/analysis_server/test/services/completion/dart/language_model_test.dart

Lines changed: 48 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -15,60 +15,62 @@ void main() {
1515
return;
1616
}
1717

18-
LanguageModel model;
18+
group('LanguageModel', () {
19+
LanguageModel model;
1920

20-
setUp(() {
21-
model = LanguageModel.load(directory);
22-
});
21+
setUp(() {
22+
model = LanguageModel.load(directory);
23+
});
2324

24-
tearDown(() {
25-
model.close();
26-
});
25+
tearDown(() {
26+
model.close();
27+
});
2728

28-
test('calculates lookback', () {
29-
expect(model.lookback, expectedLookback);
30-
});
29+
test('calculates lookback', () {
30+
expect(model.lookback, expectedLookback);
31+
});
3132

32-
test('predict with defaults', () {
33-
final tokens =
34-
tokenize('if (list == null) { return; } for (final i = 0; i < list.');
35-
final suggestions = model.predict(tokens);
36-
expect(suggestions.first, 'length');
37-
});
33+
test('predict with defaults', () {
34+
final tokens =
35+
tokenize('if (list == null) { return; } for (final i = 0; i < list.');
36+
final suggestions = model.predict(tokens);
37+
expect(suggestions.first, 'length');
38+
});
3839

39-
test('predict with confidence scores', () {
40-
final tokens =
41-
tokenize('if (list == null) { return; } for (final i = 0; i < list.');
42-
final suggestions = model.predictWithScores(tokens);
43-
final best = suggestions.entries.first;
44-
expect(best.key, 'length');
45-
expect(best.value, greaterThan(0.9));
46-
});
40+
test('predict with confidence scores', () {
41+
final tokens =
42+
tokenize('if (list == null) { return; } for (final i = 0; i < list.');
43+
final suggestions = model.predictWithScores(tokens);
44+
final best = suggestions.entries.first;
45+
expect(best.key, 'length');
46+
expect(best.value, greaterThan(0.9));
47+
});
4748

48-
test('predict when no previous tokens', () {
49-
final tokens = <String>[];
50-
final suggestions = model.predict(tokens);
51-
expect(suggestions.first, isNotEmpty);
52-
});
49+
test('predict when no previous tokens', () {
50+
final tokens = <String>[];
51+
final suggestions = model.predict(tokens);
52+
expect(suggestions.first, isNotEmpty);
53+
});
5354

54-
test('load fail', () {
55-
try {
56-
LanguageModel.load('doesnotexist');
57-
fail('Failure to load language model should throw an exception');
58-
} catch (e) {
59-
expect(
60-
e.toString(), equals('Invalid argument(s): Unable to create model.'));
61-
}
62-
});
55+
test('load fail', () {
56+
try {
57+
LanguageModel.load('doesnotexist');
58+
fail('Failure to load language model should throw an exception');
59+
} catch (e) {
60+
expect(e.toString(),
61+
equals('Invalid argument(s): Unable to create model.'));
62+
}
63+
});
6364

64-
test('isNumber', () {
65-
expect(model.isNumber('0xCAb005E'), true);
66-
expect(model.isNumber('foo'), false);
67-
expect(model.isNumber('3.1415'), true);
68-
expect(model.isNumber('1337'), true);
69-
expect(model.isNumber('"four score and seven years ago"'), false);
70-
expect(model.isNumber('0.0'), true);
71-
});
65+
test('isNumber', () {
66+
expect(model.isNumber('0xCAb005E'), true);
67+
expect(model.isNumber('foo'), false);
68+
expect(model.isNumber('3.1415'), true);
69+
expect(model.isNumber('1337'), true);
70+
expect(model.isNumber('"four score and seven years ago"'), false);
71+
expect(model.isNumber('0.0'), true);
72+
});
73+
}, skip: 'https://github.com/dart-lang/sdk/issues/42988');
7274
}
7375

7476
const expectedLookback = 100;

pkg/analysis_server/test/services/correction/organize_directives_test.dart

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,53 @@ main() {
290290
''');
291291
}
292292

293+
Future<void>
294+
test_sort_imports_dontConnectFirstCommentsWithBlankLinesBetween() async {
295+
await _computeUnitAndErrors(r'''
296+
// Copyright...
297+
298+
// Some comment related to the line below
299+
import 'package:b/a.dart';
300+
import 'package:a/b.dart';''');
301+
_assertOrganize(r'''
302+
// Copyright...
303+
304+
import 'package:a/b.dart';
305+
// Some comment related to the line below
306+
import 'package:b/a.dart';''');
307+
}
308+
309+
Future<void> test_sort_imports_keepFirstCommentUntouched() async {
310+
await _computeUnitAndErrors(r'''
311+
// Copyright
312+
// Copyright2
313+
// Copyright3
314+
import 'package:b/a.dart';
315+
import 'package:a/b.dart';''');
316+
317+
_assertOrganize(r'''
318+
// Copyright
319+
// Copyright2
320+
// Copyright3
321+
import 'package:a/b.dart';
322+
import 'package:b/a.dart';''');
323+
}
324+
325+
Future<void> test_sort_imports_keepSubsequentComments() async {
326+
await _computeUnitAndErrors(r'''
327+
/// Copyright...
328+
library lib;
329+
330+
import 'package:b/a.dart'; // We are keeping this because ...
331+
import 'package:a/b.dart';''');
332+
_assertOrganize(r'''
333+
/// Copyright...
334+
library lib;
335+
336+
import 'package:a/b.dart';
337+
import 'package:b/a.dart'; // We are keeping this because ...''');
338+
}
339+
293340
Future<void> test_sort_imports_packageAndPath() async {
294341
await _computeUnitAndErrors(r'''
295342
library lib;
@@ -314,6 +361,36 @@ import 'package:product2.client/entity.dart';
314361
''');
315362
}
316363

364+
Future<void> test_sort_imports_with_library_keepPrecedingComments() async {
365+
await _computeUnitAndErrors(r'''
366+
/// Copyright...
367+
library lib;
368+
369+
// Test comment
370+
371+
// We are keeping this because ... l1
372+
// We are keeping this because ... l2
373+
// We are keeping this because ... l3
374+
import 'package:b/a.dart';
375+
// Comment for a
376+
377+
import 'package:a/b.dart';''');
378+
379+
_assertOrganize(r'''
380+
/// Copyright...
381+
library lib;
382+
383+
// Test comment
384+
385+
// Comment for a
386+
387+
import 'package:a/b.dart';
388+
// We are keeping this because ... l1
389+
// We are keeping this because ... l2
390+
// We are keeping this because ... l3
391+
import 'package:b/a.dart';''');
392+
}
393+
317394
void _assertOrganize(String expectedCode, {bool removeUnused = false}) {
318395
var organizer = ImportOrganizer(testCode, testUnit, testErrors,
319396
removeUnused: removeUnused);
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
import 'package:analysis_server/src/services/linter/lint_names.dart';
6+
import 'package:test_reflective_loader/test_reflective_loader.dart';
7+
8+
import 'bulk_fix_processor.dart';
9+
10+
void main() {
11+
defineReflectiveSuite(() {
12+
defineReflectiveTests(AddAwaitTest);
13+
});
14+
}
15+
16+
@reflectiveTest
17+
class AddAwaitTest extends BulkFixProcessorTest {
18+
@override
19+
String get lintCode => LintNames.unawaited_futures;
20+
21+
Future<void> test_singleFile() async {
22+
await resolveTestUnit('''
23+
Future doSomething() => new Future.value('');
24+
Future doSomethingElse() => new Future.value('');
25+
26+
void main() async {
27+
doSomething();
28+
doSomethingElse();
29+
}
30+
''');
31+
await assertHasFix('''
32+
Future doSomething() => new Future.value('');
33+
Future doSomethingElse() => new Future.value('');
34+
35+
void main() async {
36+
await doSomething();
37+
await doSomethingElse();
38+
}
39+
''');
40+
}
41+
}

pkg/analysis_server/test/src/services/correction/fix/bulk/test_all.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import 'package:test_reflective_loader/test_reflective_loader.dart';
66

7+
import 'add_await_test.dart' as add_await;
78
import 'add_override_test.dart' as add_override;
89
import 'convert_documentation_into_line_test.dart'
910
as convert_documentation_into_line;
@@ -41,6 +42,7 @@ import 'use_is_not_empty_test.dart' as use_is_not_empty;
4142

4243
void main() {
4344
defineReflectiveSuite(() {
45+
add_await.main();
4446
add_override.main();
4547
convert_documentation_into_line.main();
4648
convert_to_contains.main();

0 commit comments

Comments
 (0)