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

Commit f527ddd

Browse files
author
Dart CI
committed
Version 2.13.0-97.0.dev
Merge commit '5f7e027c27d1c59df044bea435d61ff706e08019' into 'dev'
2 parents 9812cc3 + 5f7e027 commit f527ddd

File tree

10 files changed

+168
-45
lines changed

10 files changed

+168
-45
lines changed

pkg/analysis_server/lib/src/services/completion/dart/relevance_tables.g.dart

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@
1111
import 'package:analysis_server/src/services/completion/dart/probability_range.dart';
1212
import 'package:analyzer_plugin/protocol/protocol_common.dart';
1313

14-
/// A table keyed by completion location and element kind whose values are the
15-
/// ranges of the relevance of those element kinds in those locations.
16-
const elementKindRelevance = {
14+
const defaultElementKindRelevance = {
1715
'Annotation_name': {
1816
ElementKind.CONSTRUCTOR: ProbabilityRange(lower: 0.000, upper: 0.041),
1917
ElementKind.TOP_LEVEL_VARIABLE:
@@ -1029,9 +1027,7 @@ const elementKindRelevance = {
10291027
},
10301028
};
10311029

1032-
/// A table keyed by completion location and keyword whose values are the
1033-
/// ranges of the relevance of those keywords in those locations.
1034-
const keywordRelevance = {
1030+
const defaultKeywordRelevance = {
10351031
'ArgumentList_annotation_named': {
10361032
'false': ProbabilityRange(lower: 0.159, upper: 0.517),
10371033
'true': ProbabilityRange(lower: 0.517, upper: 1.000),
@@ -1557,3 +1553,13 @@ const keywordRelevance = {
15571553
'await': ProbabilityRange(lower: 0.049, upper: 0.073),
15581554
},
15591555
};
1556+
1557+
/// A table keyed by completion location and element kind whose values are the
1558+
/// ranges of the relevance of those element kinds in those locations.
1559+
Map<String, Map<ElementKind, ProbabilityRange>> elementKindRelevance =
1560+
defaultElementKindRelevance;
1561+
1562+
/// A table keyed by completion location and keyword whose values are the
1563+
/// ranges of the relevance of those keywords in those locations.
1564+
Map<String, Map<String, ProbabilityRange>> keywordRelevance =
1565+
defaultKeywordRelevance;

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

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -180,8 +180,9 @@ class DartFixContributor implements FixContributor {
180180
try {
181181
var processor = FixProcessor(context);
182182
var fixes = await processor.compute();
183-
// todo (pq): add fixes from FixInFileProcessor
184-
// https://github.com/dart-lang/sdk/issues/45026
183+
var fixInFileProcessor = FixInFileProcessor(context);
184+
var fixInFileFixes = await fixInFileProcessor.compute();
185+
fixes.addAll(fixInFileFixes);
185186
return fixes;
186187
} on CancelCorrectionException {
187188
return const <Fix>[];
@@ -286,13 +287,13 @@ class FixInFileProcessor {
286287
}
287288
}
288289
} else {
289-
// todo (pq): update to a new nonLintProducerMap2
290-
var generators = FixProcessor.nonLintProducerMap[errorCode];
291-
if (generators != null) {
292-
if (generators != null) {
293-
producers.addAll(generators);
294-
}
295-
}
290+
// todo (pq): add support for non-lint producers and update to a new nonLintProducerMap2
291+
// var generators = FixProcessor.nonLintProducerMap[errorCode];
292+
// if (generators != null) {
293+
// if (generators != null) {
294+
// producers.addAll(generators);
295+
// }
296+
// }
296297
// todo (pq): consider support for multiGenerators
297298
}
298299
return producers;

pkg/analysis_server/tool/code_completion/completion_metrics.dart

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import 'package:analysis_server/src/protocol_server.dart' as protocol;
1313
import 'package:analysis_server/src/services/completion/completion_core.dart';
1414
import 'package:analysis_server/src/services/completion/completion_performance.dart';
1515
import 'package:analysis_server/src/services/completion/dart/completion_manager.dart';
16+
import 'package:analysis_server/src/services/completion/dart/probability_range.dart';
17+
import 'package:analysis_server/src/services/completion/dart/relevance_tables.g.dart';
1618
import 'package:analysis_server/src/services/completion/dart/suggestion_builder.dart';
1719
import 'package:analysis_server/src/services/completion/dart/utilities.dart';
1820
import 'package:analysis_server/src/status/pages.dart';
@@ -598,13 +600,32 @@ class CompletionMetricsComputer {
598600

599601
CompletionMetricsComputer(this.rootPath, this.options);
600602

603+
/// Compare the relevance [tables] to the default relevance tables.
604+
void compareRelevanceTables(List<RelevanceTables> tables) {
605+
assert(tables.isNotEmpty);
606+
for (var tablePair in tables) {
607+
targetMetrics.add(CompletionMetrics(tablePair.name, enableFunction: () {
608+
elementKindRelevance = tablePair.elementKindRelevance;
609+
keywordRelevance = tablePair.keywordRelevance;
610+
}, disableFunction: () {
611+
elementKindRelevance = defaultElementKindRelevance;
612+
keywordRelevance = defaultKeywordRelevance;
613+
}));
614+
}
615+
}
616+
601617
Future<int> computeMetrics() async {
602618
resultCode = 0;
603619
// To compare two or more changes to completions, add a `CompletionMetrics`
604620
// object with enable and disable functions to the list of `targetMetrics`.
605621
targetMetrics.add(CompletionMetrics('shipping',
606622
enableFunction: null, disableFunction: null));
607623

624+
// To compare two or more relevance tables, uncomment the line below and
625+
// add the `RelevanceTable`s to the list. The default relevance tables
626+
// should not be included in the list.
627+
// compareRelevanceTables([]);
628+
608629
final collection = AnalysisContextCollection(
609630
includedPaths: [rootPath],
610631
resourceProvider: PhysicalResourceProvider.INSTANCE,
@@ -1760,6 +1781,22 @@ class MetricsSuggestionListener implements SuggestionListener {
17601781
}
17611782
}
17621783

1784+
/// A description of a pair of relevance tables to be used in an experiment.
1785+
class RelevanceTables {
1786+
/// The name of the experiment using the tables.
1787+
final String name;
1788+
1789+
/// The relevance table used for element kinds.
1790+
final Map<String, Map<protocol.ElementKind, ProbabilityRange>>
1791+
elementKindRelevance;
1792+
1793+
/// The relevance table used for keywords.
1794+
final Map<String, Map<String, ProbabilityRange>> keywordRelevance;
1795+
1796+
/// Initialize a newly created description of a pair of relevance tables.
1797+
RelevanceTables(this.name, this.elementKindRelevance, this.keywordRelevance);
1798+
}
1799+
17631800
/// The information being remembered about an individual suggestion.
17641801
class SuggestionData {
17651802
/// The suggestion that was produced.

pkg/analysis_server/tool/code_completion/relevance_table_generator.dart

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1542,14 +1542,13 @@ class RelevanceTableWriter {
15421542
writeFileHeader();
15431543
writeElementKindTable(data);
15441544
writeKeywordTable(data);
1545+
writeFileFooter();
15451546
}
15461547

15471548
void writeElementKindTable(RelevanceData data) {
15481549
sink.writeln();
15491550
sink.write('''
1550-
/// A table keyed by completion location and element kind whose values are the
1551-
/// ranges of the relevance of those element kinds in those locations.
1552-
const elementKindRelevance = {
1551+
const defaultElementKindRelevance = {
15531552
''');
15541553

15551554
var byKind = data.byKind;
@@ -1589,6 +1588,20 @@ const elementKindRelevance = {
15891588
sink.writeln('};');
15901589
}
15911590

1591+
void writeFileFooter() {
1592+
sink.write('''
1593+
/// A table keyed by completion location and element kind whose values are the
1594+
/// ranges of the relevance of those element kinds in those locations.
1595+
Map<String, Map<ElementKind, ProbabilityRange>> elementKindRelevance =
1596+
defaultElementKindRelevance;
1597+
1598+
/// A table keyed by completion location and keyword whose values are the
1599+
/// ranges of the relevance of those keywords in those locations.
1600+
Map<String, Map<String, ProbabilityRange>> keywordRelevance =
1601+
defaultKeywordRelevance;
1602+
''');
1603+
}
1604+
15921605
void writeFileHeader() {
15931606
sink.write('''
15941607
// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
@@ -1609,9 +1622,7 @@ import 'package:analyzer_plugin/protocol/protocol_common.dart';
16091622
void writeKeywordTable(RelevanceData data) {
16101623
sink.writeln();
16111624
sink.write('''
1612-
/// A table keyed by completion location and keyword whose values are the
1613-
/// ranges of the relevance of those keywords in those locations.
1614-
const keywordRelevance = {
1625+
const defaultKeywordRelevance = {
16151626
''');
16161627

16171628
var byKind = data.byKind;

pkg/analyzer/lib/src/context/builder.dart

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,8 @@ import 'package:analyzer/src/command_line/arguments.dart'
1313
import 'package:analyzer/src/context/context_root.dart';
1414
import 'package:analyzer/src/context/packages.dart';
1515
import 'package:analyzer/src/dart/analysis/byte_store.dart';
16-
import 'package:analyzer/src/dart/analysis/context_locator.dart';
1716
import 'package:analyzer/src/dart/analysis/driver.dart'
1817
show AnalysisDriver, AnalysisDriverScheduler;
19-
import 'package:analyzer/src/dart/analysis/driver_based_analysis_context.dart'
20-
as api;
2118
import 'package:analyzer/src/dart/analysis/file_state.dart';
2219
import 'package:analyzer/src/dart/analysis/performance_logger.dart';
2320
import 'package:analyzer/src/dart/sdk/sdk.dart';
@@ -139,22 +136,6 @@ class ContextBuilder {
139136
retainDataForTesting: retainDataForTesting,
140137
);
141138

142-
// Set API AnalysisContext for the driver.
143-
var apiContextRoots = ContextLocatorImpl(
144-
resourceProvider: resourceProvider,
145-
).locateRoots(
146-
includedPaths: [contextRoot.root],
147-
excludedPaths: contextRoot.exclude,
148-
overrideWorkspace: workspace,
149-
);
150-
driver.configure(
151-
analysisContext: api.DriverBasedAnalysisContext(
152-
resourceProvider,
153-
apiContextRoots.first,
154-
driver,
155-
),
156-
);
157-
158139
declareVariablesInDriver(driver);
159140
return driver;
160141
}

pkg/analyzer/lib/src/dart/analysis/context_builder.dart

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ class ContextBuilderImpl implements ContextBuilder {
104104

105105
DriverBasedAnalysisContext context =
106106
DriverBasedAnalysisContext(resourceProvider, contextRoot, driver);
107+
driver.configure(analysisContext: context);
108+
107109
return context;
108110
}
109111

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
// Copyright (c) 2021, 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 'dart:async';
6+
import 'dart:convert';
7+
import 'dart:developer';
8+
import 'dart:io';
9+
import 'package:vm_service/vm_service.dart';
10+
import 'package:test/test.dart';
11+
import 'common/service_test_common.dart';
12+
import 'common/test_helper.dart';
13+
14+
void test() {
15+
debugger();
16+
print('stdout');
17+
18+
debugger();
19+
print('print');
20+
21+
debugger();
22+
stderr.write('stderr');
23+
}
24+
25+
var tests = <IsolateTest>[
26+
hasStoppedAtBreakpoint,
27+
(VmService service, IsolateRef isolateRef) async {
28+
final completer = Completer<void>();
29+
late StreamSubscription stdoutSub;
30+
stdoutSub = service.onStdoutEvent.listen((event) async {
31+
expect(event.kind, EventKind.kWriteEvent);
32+
expect(utf8.decode(base64Decode(event.bytes!)), 'stdout');
33+
await stdoutSub.cancel();
34+
await service.streamCancel(EventStreams.kStdout);
35+
completer.complete();
36+
});
37+
await service.streamListen(EventStreams.kStdout);
38+
await service.resume(isolateRef.id!);
39+
await completer.future;
40+
},
41+
hasStoppedAtBreakpoint,
42+
(VmService service, IsolateRef isolateRef) async {
43+
final completer = Completer<void>();
44+
int eventNumber = 1;
45+
late StreamSubscription stdoutSub;
46+
stdoutSub = service.onStdoutEvent.listen((event) async {
47+
expect(event.kind, EventKind.kWriteEvent);
48+
final decoded = utf8.decode(base64Decode(event.bytes!));
49+
50+
if (eventNumber == 1) {
51+
expect(decoded, 'print');
52+
} else if (eventNumber == 2) {
53+
expect(decoded, '\n');
54+
await service.streamCancel(EventStreams.kStdout);
55+
await stdoutSub.cancel();
56+
completer.complete();
57+
} else {
58+
fail('Unreachable');
59+
}
60+
eventNumber++;
61+
});
62+
await service.streamListen(EventStreams.kStdout);
63+
await service.resume(isolateRef.id!);
64+
await completer.future;
65+
},
66+
hasStoppedAtBreakpoint,
67+
(VmService service, IsolateRef isolateRef) async {
68+
final completer = Completer<void>();
69+
late StreamSubscription stderrSub;
70+
stderrSub = service.onStderrEvent.listen((event) async {
71+
expect(event.kind, EventKind.kWriteEvent);
72+
expect(utf8.decode(base64Decode(event.bytes!)), 'stderr');
73+
await service.streamCancel(EventStreams.kStderr);
74+
await stderrSub.cancel();
75+
completer.complete();
76+
});
77+
await service.streamListen(EventStreams.kStderr);
78+
await service.resume(isolateRef.id!);
79+
await completer.future;
80+
},
81+
];
82+
83+
main(args) => runIsolateTests(
84+
args,
85+
tests,
86+
'capture_stdio_test.dart',
87+
testeeConcurrent: test,
88+
);

runtime/tests/vm/dart_2/isolates/reload_utils.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Future<List<String>> generateDills(String tempDir, String testDartFile) async {
2525
await File(testFile).writeAsString(version);
2626
final dillFile = path.join(tempDir, 'test.dart.${i++}.dill');
2727
await compile(testFile, dillFile);
28-
dills.add(dillFile);
28+
dills.add(Uri.file(dillFile).toString());
2929
}
3030
return dills;
3131
}

runtime/vm/service.cc

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4314,9 +4314,6 @@ void Service::SendEmbedderEvent(Isolate* isolate,
43144314
const char* event_kind,
43154315
const uint8_t* bytes,
43164316
intptr_t bytes_len) {
4317-
if (!Service::debug_stream.enabled()) {
4318-
return;
4319-
}
43204317
ServiceEvent event(isolate, ServiceEvent::kEmbedder);
43214318
event.set_embedder_kind(event_kind);
43224319
event.set_embedder_stream_id(stream_id);

tools/VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ CHANNEL dev
2727
MAJOR 2
2828
MINOR 13
2929
PATCH 0
30-
PRERELEASE 96
30+
PRERELEASE 97
3131
PRERELEASE_PATCH 0

0 commit comments

Comments
 (0)