Version 2.13.0-97.0.dev
Merge commit '5f7e027c27d1c59df044bea435d61ff706e08019' into 'dev'
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/relevance_tables.g.dart b/pkg/analysis_server/lib/src/services/completion/dart/relevance_tables.g.dart
index cb79f01..25f3857 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/relevance_tables.g.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/relevance_tables.g.dart
@@ -11,9 +11,7 @@
import 'package:analysis_server/src/services/completion/dart/probability_range.dart';
import 'package:analyzer_plugin/protocol/protocol_common.dart';
-/// A table keyed by completion location and element kind whose values are the
-/// ranges of the relevance of those element kinds in those locations.
-const elementKindRelevance = {
+const defaultElementKindRelevance = {
'Annotation_name': {
ElementKind.CONSTRUCTOR: ProbabilityRange(lower: 0.000, upper: 0.041),
ElementKind.TOP_LEVEL_VARIABLE:
@@ -1029,9 +1027,7 @@
},
};
-/// A table keyed by completion location and keyword whose values are the
-/// ranges of the relevance of those keywords in those locations.
-const keywordRelevance = {
+const defaultKeywordRelevance = {
'ArgumentList_annotation_named': {
'false': ProbabilityRange(lower: 0.159, upper: 0.517),
'true': ProbabilityRange(lower: 0.517, upper: 1.000),
@@ -1557,3 +1553,13 @@
'await': ProbabilityRange(lower: 0.049, upper: 0.073),
},
};
+
+/// A table keyed by completion location and element kind whose values are the
+/// ranges of the relevance of those element kinds in those locations.
+Map<String, Map<ElementKind, ProbabilityRange>> elementKindRelevance =
+ defaultElementKindRelevance;
+
+/// A table keyed by completion location and keyword whose values are the
+/// ranges of the relevance of those keywords in those locations.
+Map<String, Map<String, ProbabilityRange>> keywordRelevance =
+ defaultKeywordRelevance;
diff --git a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
index eeecbf0..e8bc6be 100644
--- a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
+++ b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
@@ -180,8 +180,9 @@
try {
var processor = FixProcessor(context);
var fixes = await processor.compute();
- // todo (pq): add fixes from FixInFileProcessor
- // https://github.com/dart-lang/sdk/issues/45026
+ var fixInFileProcessor = FixInFileProcessor(context);
+ var fixInFileFixes = await fixInFileProcessor.compute();
+ fixes.addAll(fixInFileFixes);
return fixes;
} on CancelCorrectionException {
return const <Fix>[];
@@ -286,13 +287,13 @@
}
}
} else {
- // todo (pq): update to a new nonLintProducerMap2
- var generators = FixProcessor.nonLintProducerMap[errorCode];
- if (generators != null) {
- if (generators != null) {
- producers.addAll(generators);
- }
- }
+ // todo (pq): add support for non-lint producers and update to a new nonLintProducerMap2
+ // var generators = FixProcessor.nonLintProducerMap[errorCode];
+ // if (generators != null) {
+ // if (generators != null) {
+ // producers.addAll(generators);
+ // }
+ // }
// todo (pq): consider support for multiGenerators
}
return producers;
diff --git a/pkg/analysis_server/tool/code_completion/completion_metrics.dart b/pkg/analysis_server/tool/code_completion/completion_metrics.dart
index 38e22d5..2a9e75d 100644
--- a/pkg/analysis_server/tool/code_completion/completion_metrics.dart
+++ b/pkg/analysis_server/tool/code_completion/completion_metrics.dart
@@ -13,6 +13,8 @@
import 'package:analysis_server/src/services/completion/completion_core.dart';
import 'package:analysis_server/src/services/completion/completion_performance.dart';
import 'package:analysis_server/src/services/completion/dart/completion_manager.dart';
+import 'package:analysis_server/src/services/completion/dart/probability_range.dart';
+import 'package:analysis_server/src/services/completion/dart/relevance_tables.g.dart';
import 'package:analysis_server/src/services/completion/dart/suggestion_builder.dart';
import 'package:analysis_server/src/services/completion/dart/utilities.dart';
import 'package:analysis_server/src/status/pages.dart';
@@ -598,6 +600,20 @@
CompletionMetricsComputer(this.rootPath, this.options);
+ /// Compare the relevance [tables] to the default relevance tables.
+ void compareRelevanceTables(List<RelevanceTables> tables) {
+ assert(tables.isNotEmpty);
+ for (var tablePair in tables) {
+ targetMetrics.add(CompletionMetrics(tablePair.name, enableFunction: () {
+ elementKindRelevance = tablePair.elementKindRelevance;
+ keywordRelevance = tablePair.keywordRelevance;
+ }, disableFunction: () {
+ elementKindRelevance = defaultElementKindRelevance;
+ keywordRelevance = defaultKeywordRelevance;
+ }));
+ }
+ }
+
Future<int> computeMetrics() async {
resultCode = 0;
// To compare two or more changes to completions, add a `CompletionMetrics`
@@ -605,6 +621,11 @@
targetMetrics.add(CompletionMetrics('shipping',
enableFunction: null, disableFunction: null));
+ // To compare two or more relevance tables, uncomment the line below and
+ // add the `RelevanceTable`s to the list. The default relevance tables
+ // should not be included in the list.
+// compareRelevanceTables([]);
+
final collection = AnalysisContextCollection(
includedPaths: [rootPath],
resourceProvider: PhysicalResourceProvider.INSTANCE,
@@ -1760,6 +1781,22 @@
}
}
+/// A description of a pair of relevance tables to be used in an experiment.
+class RelevanceTables {
+ /// The name of the experiment using the tables.
+ final String name;
+
+ /// The relevance table used for element kinds.
+ final Map<String, Map<protocol.ElementKind, ProbabilityRange>>
+ elementKindRelevance;
+
+ /// The relevance table used for keywords.
+ final Map<String, Map<String, ProbabilityRange>> keywordRelevance;
+
+ /// Initialize a newly created description of a pair of relevance tables.
+ RelevanceTables(this.name, this.elementKindRelevance, this.keywordRelevance);
+}
+
/// The information being remembered about an individual suggestion.
class SuggestionData {
/// The suggestion that was produced.
diff --git a/pkg/analysis_server/tool/code_completion/relevance_table_generator.dart b/pkg/analysis_server/tool/code_completion/relevance_table_generator.dart
index b1d7d79..4b2ee62e 100644
--- a/pkg/analysis_server/tool/code_completion/relevance_table_generator.dart
+++ b/pkg/analysis_server/tool/code_completion/relevance_table_generator.dart
@@ -1542,14 +1542,13 @@
writeFileHeader();
writeElementKindTable(data);
writeKeywordTable(data);
+ writeFileFooter();
}
void writeElementKindTable(RelevanceData data) {
sink.writeln();
sink.write('''
-/// A table keyed by completion location and element kind whose values are the
-/// ranges of the relevance of those element kinds in those locations.
-const elementKindRelevance = {
+const defaultElementKindRelevance = {
''');
var byKind = data.byKind;
@@ -1589,6 +1588,20 @@
sink.writeln('};');
}
+ void writeFileFooter() {
+ sink.write('''
+/// A table keyed by completion location and element kind whose values are the
+/// ranges of the relevance of those element kinds in those locations.
+Map<String, Map<ElementKind, ProbabilityRange>> elementKindRelevance =
+ defaultElementKindRelevance;
+
+/// A table keyed by completion location and keyword whose values are the
+/// ranges of the relevance of those keywords in those locations.
+Map<String, Map<String, ProbabilityRange>> keywordRelevance =
+ defaultKeywordRelevance;
+''');
+ }
+
void writeFileHeader() {
sink.write('''
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
@@ -1609,9 +1622,7 @@
void writeKeywordTable(RelevanceData data) {
sink.writeln();
sink.write('''
-/// A table keyed by completion location and keyword whose values are the
-/// ranges of the relevance of those keywords in those locations.
-const keywordRelevance = {
+const defaultKeywordRelevance = {
''');
var byKind = data.byKind;
diff --git a/pkg/analyzer/lib/src/context/builder.dart b/pkg/analyzer/lib/src/context/builder.dart
index 0c6052a..cb27bce 100644
--- a/pkg/analyzer/lib/src/context/builder.dart
+++ b/pkg/analyzer/lib/src/context/builder.dart
@@ -13,11 +13,8 @@
import 'package:analyzer/src/context/context_root.dart';
import 'package:analyzer/src/context/packages.dart';
import 'package:analyzer/src/dart/analysis/byte_store.dart';
-import 'package:analyzer/src/dart/analysis/context_locator.dart';
import 'package:analyzer/src/dart/analysis/driver.dart'
show AnalysisDriver, AnalysisDriverScheduler;
-import 'package:analyzer/src/dart/analysis/driver_based_analysis_context.dart'
- as api;
import 'package:analyzer/src/dart/analysis/file_state.dart';
import 'package:analyzer/src/dart/analysis/performance_logger.dart';
import 'package:analyzer/src/dart/sdk/sdk.dart';
@@ -139,22 +136,6 @@
retainDataForTesting: retainDataForTesting,
);
- // Set API AnalysisContext for the driver.
- var apiContextRoots = ContextLocatorImpl(
- resourceProvider: resourceProvider,
- ).locateRoots(
- includedPaths: [contextRoot.root],
- excludedPaths: contextRoot.exclude,
- overrideWorkspace: workspace,
- );
- driver.configure(
- analysisContext: api.DriverBasedAnalysisContext(
- resourceProvider,
- apiContextRoots.first,
- driver,
- ),
- );
-
declareVariablesInDriver(driver);
return driver;
}
diff --git a/pkg/analyzer/lib/src/dart/analysis/context_builder.dart b/pkg/analyzer/lib/src/dart/analysis/context_builder.dart
index 7353694..7ec4bfb 100644
--- a/pkg/analyzer/lib/src/dart/analysis/context_builder.dart
+++ b/pkg/analyzer/lib/src/dart/analysis/context_builder.dart
@@ -104,6 +104,8 @@
DriverBasedAnalysisContext context =
DriverBasedAnalysisContext(resourceProvider, contextRoot, driver);
+ driver.configure(analysisContext: context);
+
return context;
}
diff --git a/pkg/vm_service/test/capture_stdio_test.dart b/pkg/vm_service/test/capture_stdio_test.dart
new file mode 100644
index 0000000..2edf76c
--- /dev/null
+++ b/pkg/vm_service/test/capture_stdio_test.dart
@@ -0,0 +1,88 @@
+// Copyright (c) 2021, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'dart:async';
+import 'dart:convert';
+import 'dart:developer';
+import 'dart:io';
+import 'package:vm_service/vm_service.dart';
+import 'package:test/test.dart';
+import 'common/service_test_common.dart';
+import 'common/test_helper.dart';
+
+void test() {
+ debugger();
+ print('stdout');
+
+ debugger();
+ print('print');
+
+ debugger();
+ stderr.write('stderr');
+}
+
+var tests = <IsolateTest>[
+ hasStoppedAtBreakpoint,
+ (VmService service, IsolateRef isolateRef) async {
+ final completer = Completer<void>();
+ late StreamSubscription stdoutSub;
+ stdoutSub = service.onStdoutEvent.listen((event) async {
+ expect(event.kind, EventKind.kWriteEvent);
+ expect(utf8.decode(base64Decode(event.bytes!)), 'stdout');
+ await stdoutSub.cancel();
+ await service.streamCancel(EventStreams.kStdout);
+ completer.complete();
+ });
+ await service.streamListen(EventStreams.kStdout);
+ await service.resume(isolateRef.id!);
+ await completer.future;
+ },
+ hasStoppedAtBreakpoint,
+ (VmService service, IsolateRef isolateRef) async {
+ final completer = Completer<void>();
+ int eventNumber = 1;
+ late StreamSubscription stdoutSub;
+ stdoutSub = service.onStdoutEvent.listen((event) async {
+ expect(event.kind, EventKind.kWriteEvent);
+ final decoded = utf8.decode(base64Decode(event.bytes!));
+
+ if (eventNumber == 1) {
+ expect(decoded, 'print');
+ } else if (eventNumber == 2) {
+ expect(decoded, '\n');
+ await service.streamCancel(EventStreams.kStdout);
+ await stdoutSub.cancel();
+ completer.complete();
+ } else {
+ fail('Unreachable');
+ }
+ eventNumber++;
+ });
+ await service.streamListen(EventStreams.kStdout);
+ await service.resume(isolateRef.id!);
+ await completer.future;
+ },
+ hasStoppedAtBreakpoint,
+ (VmService service, IsolateRef isolateRef) async {
+ final completer = Completer<void>();
+ late StreamSubscription stderrSub;
+ stderrSub = service.onStderrEvent.listen((event) async {
+ expect(event.kind, EventKind.kWriteEvent);
+ expect(utf8.decode(base64Decode(event.bytes!)), 'stderr');
+ await service.streamCancel(EventStreams.kStderr);
+ await stderrSub.cancel();
+ completer.complete();
+ });
+ await service.streamListen(EventStreams.kStderr);
+ await service.resume(isolateRef.id!);
+ await completer.future;
+ },
+];
+
+main(args) => runIsolateTests(
+ args,
+ tests,
+ 'capture_stdio_test.dart',
+ testeeConcurrent: test,
+ );
diff --git a/runtime/tests/vm/dart_2/isolates/reload_utils.dart b/runtime/tests/vm/dart_2/isolates/reload_utils.dart
index 36f8fa9..853d2f0 100644
--- a/runtime/tests/vm/dart_2/isolates/reload_utils.dart
+++ b/runtime/tests/vm/dart_2/isolates/reload_utils.dart
@@ -25,7 +25,7 @@
await File(testFile).writeAsString(version);
final dillFile = path.join(tempDir, 'test.dart.${i++}.dill');
await compile(testFile, dillFile);
- dills.add(dillFile);
+ dills.add(Uri.file(dillFile).toString());
}
return dills;
}
diff --git a/runtime/vm/service.cc b/runtime/vm/service.cc
index b026035..ee7a7ec 100644
--- a/runtime/vm/service.cc
+++ b/runtime/vm/service.cc
@@ -4314,9 +4314,6 @@
const char* event_kind,
const uint8_t* bytes,
intptr_t bytes_len) {
- if (!Service::debug_stream.enabled()) {
- return;
- }
ServiceEvent event(isolate, ServiceEvent::kEmbedder);
event.set_embedder_kind(event_kind);
event.set_embedder_stream_id(stream_id);
diff --git a/tools/VERSION b/tools/VERSION
index 2740a21..5ab8887 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 13
PATCH 0
-PRERELEASE 96
+PRERELEASE 97
PRERELEASE_PATCH 0
\ No newline at end of file