Skip to content

Commit 8ce74be

Browse files
committed
Version 1.19.0-dev.6.0
Merge 1196cf5 into dev
2 parents d5bd704 + 1196cf5 commit 8ce74be

File tree

763 files changed

+6004
-40801
lines changed

Some content is hidden

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

763 files changed

+6004
-40801
lines changed

CHANGELOG.md

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
* Breaking change - infer generic type arguments from the
3232
constructor invocation arguments
33-
(SDK issue [25220](https://github.com/dart-lang/sdk/issues/25220))
33+
(SDK issue [25220](https://github.com/dart-lang/sdk/issues/25220)).
3434

3535
```dart
3636
var map = new Map<String, String>();
@@ -40,7 +40,7 @@
4040
```
4141
4242
* Breaking change - infer local function return type
43-
(SDK issue [26414](https://github.com/dart-lang/sdk/issues/26414))
43+
(SDK issue [26414](https://github.com/dart-lang/sdk/issues/26414)).
4444
4545
```dart
4646
void main() {
@@ -52,7 +52,7 @@
5252
```
5353
5454
* Breaking change - allow type promotion from a generic type parameter
55-
(SDK issue [26414](https://github.com/dart-lang/sdk/issues/26965))
55+
(SDK issue [26414](https://github.com/dart-lang/sdk/issues/26965)).
5656
5757
```dart
5858
void fn/*<T>*/(/*=T*/ object) {
@@ -64,6 +64,31 @@
6464
}
6565
```
6666
67+
* Breaking change - smarter inference for Future.then
68+
(SDK issue [25944](https://github.com/dart-lang/sdk/issues/25944)).
69+
Previous workarounds that use async/await or `.then/*<Future<SomeType>>*/`
70+
should no longer be necessary.
71+
72+
```dart
73+
// This will now infer correctly.
74+
Future<List<int>> t2 = f.then((_) => [3]);
75+
// This infers too.
76+
Future<int> t2 = f.then((_) => new Future.value(42));
77+
```
78+
79+
* Breaking change - smarter inference for async functions
80+
(SDK issue [25322](https://github.com/dart-lang/sdk/issues/25322)).
81+
82+
```dart
83+
void test() async {
84+
List<int> x = await [4]; // was previously inferred
85+
List<int> y = await new Future.value([4]); // now inferred too
86+
}
87+
```
88+
89+
* Breaking change - sideways casts are no longer allowed
90+
(SDK issue [26120](https://github.com/dart-lang/sdk/issues/26120)).
91+
6792
### Dart VM
6893
6994
* The dependency on BoringSSL has been rolled forward. Going forward, builds

pkg/analysis_server/lib/src/analysis_server.dart

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ import 'package:analyzer/src/generated/sdk.dart';
4040
import 'package:analyzer/src/generated/source.dart';
4141
import 'package:analyzer/src/generated/source_io.dart';
4242
import 'package:analyzer/src/generated/utilities_general.dart';
43+
import 'package:analyzer/src/summary/package_bundle_reader.dart';
4344
import 'package:analyzer/src/summary/pub_summary.dart';
4445
import 'package:analyzer/src/task/dart.dart';
4546
import 'package:analyzer/src/util/glob.dart';
@@ -1544,6 +1545,7 @@ class AnalysisServer {
15441545
class AnalysisServerOptions {
15451546
bool enableIncrementalResolutionApi = false;
15461547
bool enableIncrementalResolutionValidation = false;
1548+
bool enablePubSummaryManager = false;
15471549
bool finerGrainedInvalidation = false;
15481550
bool noErrorNotification = false;
15491551
bool noIndex = false;
@@ -1603,8 +1605,19 @@ class ServerContextManagerCallbacks extends ContextManagerCallbacks {
16031605
_createSourceFactory(context, options, disposition, folder);
16041606
context.analysisOptions = options;
16051607

1606-
// TODO(scheglov) use linked bundles
1607-
// analysisServer.pubSummaryManager.getLinkedBundles(context);
1608+
if (analysisServer.options.enablePubSummaryManager) {
1609+
List<LinkedPubPackage> linkedBundles =
1610+
analysisServer.pubSummaryManager.getLinkedBundles(context);
1611+
if (linkedBundles.isNotEmpty) {
1612+
SummaryDataStore store = new SummaryDataStore([]);
1613+
for (LinkedPubPackage package in linkedBundles) {
1614+
store.addBundle(null, package.unlinked);
1615+
store.addBundle(null, package.linked);
1616+
}
1617+
context.resultProvider =
1618+
new InputPackagesResultProvider(context, store);
1619+
}
1620+
}
16081621

16091622
analysisServer._onContextsChangedController
16101623
.add(new ContextsChangedEvent(added: [context]));

pkg/analysis_server/lib/src/search/type_hierarchy.dart

Lines changed: 34 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -76,42 +76,41 @@ class TypeHierarchyComputer {
7676
}
7777

7878
Future _createSubclasses(
79-
TypeHierarchyItem item, int itemId, InterfaceType type) {
80-
var future = getDirectSubClasses(_searchEngine, type.element);
81-
return future.then((Set<ClassElement> subElements) {
82-
List<int> subItemIds = <int>[];
83-
for (ClassElement subElement in subElements) {
84-
// check for recursion
85-
TypeHierarchyItem subItem = _elementItemMap[subElement];
86-
if (subItem != null) {
87-
int id = _items.indexOf(subItem);
88-
item.subclasses.add(id);
89-
continue;
90-
}
91-
// create a subclass item
92-
ExecutableElement subMemberElement = _findMemberElement(subElement);
93-
subItem = new TypeHierarchyItem(convertElement(subElement),
94-
memberElement: subMemberElement != null
95-
? convertElement(subMemberElement)
96-
: null,
97-
superclass: itemId);
98-
int subItemId = _items.length;
99-
// remember
100-
_elementItemMap[subElement] = subItem;
101-
_items.add(subItem);
102-
_itemClassElements.add(subElement);
103-
// add to hierarchy
104-
item.subclasses.add(subItemId);
105-
subItemIds.add(subItemId);
79+
TypeHierarchyItem item, int itemId, InterfaceType type) async {
80+
Set<ClassElement> subElements =
81+
await getDirectSubClasses(_searchEngine, type.element);
82+
List<int> subItemIds = <int>[];
83+
for (ClassElement subElement in subElements) {
84+
// check for recursion
85+
TypeHierarchyItem subItem = _elementItemMap[subElement];
86+
if (subItem != null) {
87+
int id = _items.indexOf(subItem);
88+
item.subclasses.add(id);
89+
continue;
10690
}
107-
// compute subclasses of subclasses
108-
return Future.forEach(subItemIds, (int subItemId) {
109-
TypeHierarchyItem subItem = _items[subItemId];
110-
ClassElement subItemElement = _itemClassElements[subItemId];
111-
InterfaceType subType = subItemElement.type;
112-
return _createSubclasses(subItem, subItemId, subType);
113-
});
114-
});
91+
// create a subclass item
92+
ExecutableElement subMemberElement = _findMemberElement(subElement);
93+
subItem = new TypeHierarchyItem(convertElement(subElement),
94+
memberElement: subMemberElement != null
95+
? convertElement(subMemberElement)
96+
: null,
97+
superclass: itemId);
98+
int subItemId = _items.length;
99+
// remember
100+
_elementItemMap[subElement] = subItem;
101+
_items.add(subItem);
102+
_itemClassElements.add(subElement);
103+
// add to hierarchy
104+
item.subclasses.add(subItemId);
105+
subItemIds.add(subItemId);
106+
}
107+
// compute subclasses of subclasses
108+
for (int subItemId in subItemIds) {
109+
TypeHierarchyItem subItem = _items[subItemId];
110+
ClassElement subItemElement = _itemClassElements[subItemId];
111+
InterfaceType subType = subItemElement.type;
112+
await _createSubclasses(subItem, subItemId, subType);
113+
}
115114
}
116115

117116
int _createSuperItem(InterfaceType type) {

pkg/analysis_server/lib/src/server/driver.dart

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,10 @@ import 'package:analyzer/file_system/physical_file_system.dart';
2020
import 'package:analyzer/instrumentation/file_instrumentation.dart';
2121
import 'package:analyzer/instrumentation/instrumentation.dart';
2222
import 'package:analyzer/plugin/resolver_provider.dart';
23+
import 'package:analyzer/src/dart/sdk/sdk.dart';
2324
import 'package:analyzer/src/generated/engine.dart';
2425
import 'package:analyzer/src/generated/incremental_logger.dart';
25-
import 'package:analyzer/src/generated/java_io.dart';
2626
import 'package:analyzer/src/generated/sdk.dart';
27-
import 'package:analyzer/src/generated/sdk_io.dart';
2827
import 'package:args/args.dart';
2928
import 'package:linter/src/plugin/linter_plugin.dart';
3029
import 'package:plugin/manager.dart';
@@ -243,6 +242,11 @@ class Driver implements ServerStarter {
243242
static const String INCREMENTAL_RESOLUTION_VALIDATION =
244243
"incremental-resolution-validation";
245244

245+
/**
246+
* The name of the option used to enable using pub summary manager.
247+
*/
248+
static const String ENABLE_PUB_SUMMARY_MANAGER = 'enable-pub-summary-manager';
249+
246250
/**
247251
* The name of the option used to enable fined grained invalidation.
248252
*/
@@ -379,6 +383,8 @@ class Driver implements ServerStarter {
379383
results[ENABLE_INCREMENTAL_RESOLUTION_API];
380384
analysisServerOptions.enableIncrementalResolutionValidation =
381385
results[INCREMENTAL_RESOLUTION_VALIDATION];
386+
analysisServerOptions.enablePubSummaryManager =
387+
results[ENABLE_PUB_SUMMARY_MANAGER];
382388
analysisServerOptions.finerGrainedInvalidation =
383389
results[FINER_GRAINED_INVALIDATION];
384390
analysisServerOptions.noErrorNotification = results[NO_ERROR_NOTIFICATION];
@@ -405,26 +411,30 @@ class Driver implements ServerStarter {
405411
ExtensionManager manager = new ExtensionManager();
406412
manager.processPlugins(plugins);
407413

408-
JavaFile defaultSdkDirectory;
414+
String defaultSdkPath;
409415
if (results[SDK_OPTION] != null) {
410-
defaultSdkDirectory = new JavaFile(results[SDK_OPTION]);
416+
defaultSdkPath = results[SDK_OPTION];
411417
} else {
412418
// No path to the SDK was provided.
413419
// Use DirectoryBasedDartSdk.defaultSdkDirectory, which will make a guess.
414-
defaultSdkDirectory = DirectoryBasedDartSdk.defaultSdkDirectory;
420+
defaultSdkPath = FolderBasedDartSdk
421+
.defaultSdkDirectory(PhysicalResourceProvider.INSTANCE)
422+
.path;
415423
}
416424
bool useSummaries = analysisServerOptions.fileReadMode == 'as-is';
417425
SdkCreator defaultSdkCreator = (AnalysisOptions options) {
418-
DirectoryBasedDartSdk sdk =
419-
new DirectoryBasedDartSdk(defaultSdkDirectory);
426+
PhysicalResourceProvider resourceProvider =
427+
PhysicalResourceProvider.INSTANCE;
428+
FolderBasedDartSdk sdk = new FolderBasedDartSdk(resourceProvider,
429+
FolderBasedDartSdk.defaultSdkDirectory(resourceProvider));
420430
sdk.analysisOptions = options;
421431
sdk.useSummary = useSummaries;
422432
return sdk;
423433
};
424434
// TODO(brianwilkerson) It would be nice to avoid creating an SDK that
425435
// cannot be re-used, but the SDK is needed to create a package map provider
426436
// in the case where we need to run `pub` in order to get the package map.
427-
DirectoryBasedDartSdk defaultSdk = defaultSdkCreator(null);
437+
DartSdk defaultSdk = defaultSdkCreator(null);
428438
//
429439
// Initialize the instrumentation service.
430440
//
@@ -448,8 +458,7 @@ class Driver implements ServerStarter {
448458
//
449459
socketServer = new SocketServer(
450460
analysisServerOptions,
451-
new DartSdkManager(defaultSdkDirectory.getAbsolutePath(), useSummaries,
452-
defaultSdkCreator),
461+
new DartSdkManager(defaultSdkPath, useSummaries, defaultSdkCreator),
453462
defaultSdk,
454463
service,
455464
serverPlugin,
@@ -532,6 +541,10 @@ class Driver implements ServerStarter {
532541
help: "enable validation of incremental resolution results (slow)",
533542
defaultsTo: false,
534543
negatable: false);
544+
parser.addFlag(ENABLE_PUB_SUMMARY_MANAGER,
545+
help: "enable using summaries for pub cache packages",
546+
defaultsTo: false,
547+
negatable: false);
535548
parser.addFlag(FINER_GRAINED_INVALIDATION,
536549
help: "enable finer grained invalidation",
537550
defaultsTo: false,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ bool hasFix(ErrorCode errorCode) =>
8080
errorCode ==
8181
CompileTimeErrorCode.UNDEFINED_CONSTRUCTOR_IN_INITIALIZER_DEFAULT ||
8282
errorCode == CompileTimeErrorCode.URI_DOES_NOT_EXIST ||
83+
errorCode == CompileTimeErrorCode.URI_HAS_NOT_BEEN_GENERATED ||
8384
errorCode == HintCode.CAN_BE_NULL_AFTER_NULL_AWARE ||
8485
errorCode == HintCode.DEAD_CODE ||
8586
errorCode == HintCode.DIVISION_OPTIMIZATION ||

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,9 @@ class FixProcessor {
190190
_addFix_createPartUri();
191191
_addFix_replaceImportUri();
192192
}
193+
if (errorCode == CompileTimeErrorCode.URI_HAS_NOT_BEEN_GENERATED) {
194+
_addFix_replaceImportUri();
195+
}
193196
if (errorCode == HintCode.CAN_BE_NULL_AFTER_NULL_AWARE) {
194197
_addFix_canBeNullAfterNullAware();
195198
}

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ class DirectiveOrganizer {
4747

4848
bool _isUnresolvedUri(UriBasedDirective directive) {
4949
for (AnalysisError error in errors) {
50-
if (error.errorCode == CompileTimeErrorCode.URI_DOES_NOT_EXIST &&
50+
ErrorCode errorCode = error.errorCode;
51+
if ((errorCode == CompileTimeErrorCode.URI_DOES_NOT_EXIST ||
52+
errorCode == CompileTimeErrorCode.URI_HAS_NOT_BEEN_GENERATED) &&
5153
directive.uri.offset == error.offset) {
5254
return true;
5355
}

pkg/analysis_server/lib/src/services/refactoring/extract_method.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class ExtractMethodRefactoringImpl extends RefactoringImpl
7070
implements ExtractMethodRefactoring {
7171
static const ERROR_EXITS =
7272
'Selected statements contain a return statement, but not all possible '
73-
'execuion flows exit. Semantics may not be preserved.';
73+
'execution flows exit. Semantics may not be preserved.';
7474

7575
final SearchEngine searchEngine;
7676
final CompilationUnit unit;

0 commit comments

Comments
 (0)