Skip to content

Commit

Permalink
Version 3.1.0-67.0.dev
Browse files Browse the repository at this point in the history
Merge 12b7d25 into dev
  • Loading branch information
Dart CI committed May 2, 2023
2 parents 7c061d8 + 12b7d25 commit 4d084f5
Show file tree
Hide file tree
Showing 26 changed files with 508 additions and 272 deletions.
2 changes: 1 addition & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ vars = {
# revision.

"args_rev": "5ac2ba1d93f037c7aee2975703bf071f88597a76",
"async_rev": "ce650b0ce8fa95fc13d4744a293f3e9b00266bee",
"async_rev": "b9ed21948754001e31e209612b6ef8a5b2ad8e9f",
"bazel_worker_rev": "d5f88375b41def124aa65be1d4da8a2c9e82e076",
"benchmark_harness_rev": "e591ec4111be03bd80f890a07d1da50bf248efe4",
"boolean_selector_rev": "9fd3bae0574e947fc0ddd3cdcf153f951678f172",
Expand Down
2 changes: 1 addition & 1 deletion build/config/win/visual_studio_version.gni
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ declare_args() {
# Full path to the Windows SDK, not including a backslash at the end.
# This value is the default location, override if you have a different
# installation location.
windows_sdk_path = "C:\Program Files (x86)\Windows Kits\8.1"
windows_sdk_path = "C:\\Program Files (x86)\\Windows Kits\\8.1"
}

if (visual_studio_path == "") {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@

import 'package:analysis_server/src/services/correction/dart/abstract_producer.dart';
import 'package:analysis_server/src/services/correction/fix.dart';
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/src/dart/ast/ast.dart';
import 'package:analyzer_plugin/utilities/change_builder/change_builder_core.dart';
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:collection/collection.dart';

class AddSwitchCaseBreak extends CorrectionProducer {
@override
Expand All @@ -20,13 +21,28 @@ class AddSwitchCaseBreak extends CorrectionProducer {

@override
Future<void> compute(ChangeBuilder builder) async {
var node = this.node;
if (node is! SwitchCase) return;
final switchCase = node;
if (switchCase is! SwitchCaseImpl) {
return;
}

final switchStatement = switchCase.parent;
if (switchStatement is! SwitchStatementImpl) {
return;
}

final group = switchStatement.memberGroups.firstWhereOrNull(
(group) => group.members.contains(switchCase),
);
final lastStatement = group?.statements.lastOrNull;
if (lastStatement == null) {
return;
}

await builder.addDartFileEdit(file, (builder) {
builder.addInsertion(node.end, (builder) {
builder.addInsertion(lastStatement.end, (builder) {
builder.write(eol);
builder.write(utils.getNodePrefix(node.statements.last));
builder.write(utils.getNodePrefix(lastStatement));
builder.write('break;');
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,64 +21,34 @@ class AddSwitchCaseBreakMultiTest extends FixProcessorTest {
@override
FixKind get kind => DartFixKind.ADD_SWITCH_CASE_BREAK_MULTI;

@FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/49759')
Future<void> test_singleFile() async {
await resolveTestCode('''
void f(int i) {
switch(i) {
case 0:
i++;
case 1:
i++;
case 2:
i++;
}
}
''');
await assertHasFixAllFix(
CompileTimeErrorCode.SWITCH_CASE_COMPLETES_NORMALLY, '''
void f(int i) {
switch(i) {
case 0:
i++;
break;
case 1:
i++;
break;
case 2:
i++;
}
}
''');
}
@override
String? get testPackageLanguageVersion => '2.19';

Future<void> test_singleFile_language219() async {
Future<void> test_singleFile() async {
await resolveTestCode('''
// @dart=2.19
void f(int i) {
switch(i) {
void f(Object? x) {
switch (x) {
case 0:
i++;
0;
case 1:
i++;
1;
case 2:
i++;
2;
}
}
''');
await assertHasFixAllFix(
CompileTimeErrorCode.SWITCH_CASE_COMPLETES_NORMALLY, '''
// @dart=2.19
void f(int i) {
switch(i) {
void f(Object? x) {
switch (x) {
case 0:
i++;
0;
break;
case 1:
i++;
1;
break;
case 2:
i++;
2;
}
}
''');
Expand All @@ -90,52 +60,30 @@ class AddSwitchCaseBreakTest extends FixProcessorTest {
@override
FixKind get kind => DartFixKind.ADD_SWITCH_CASE_BREAK;

@FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/49759')
Future<void> test_indentation() async {
await resolveTestCode('''
void f(int i) {
switch(i) {
case 0:
i++;
case 1:
i++;
}
}
''');
await assertHasFix('''
void f(int i) {
switch(i) {
case 0:
i++;
break;
case 1:
i++;
}
}
''');
}
@override
String? get testPackageLanguageVersion => '2.19';

Future<void> test_indentation_language219() async {
Future<void> test_sharedCaseBody() async {
await resolveTestCode('''
// @dart=2.19
void f(int i) {
switch(i) {
case 0:
i++;
case 1:
i++;
void f(Object? x) {
switch (x) {
case 0:
case 1:
0;
case 2:
2;
}
}
''');
await assertHasFix('''
// @dart=2.19
void f(int i) {
switch(i) {
case 0:
i++;
break;
case 1:
i++;
void f(Object? x) {
switch (x) {
case 0:
case 1:
0;
break;
case 2:
2;
}
}
''');
Expand Down
18 changes: 11 additions & 7 deletions pkg/dds/lib/src/dap/adapters/dart.dart
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ abstract class DartDebugAdapter<TL extends LaunchRequestArguments,
}

logger?.call('Connecting to debugger at $uri');
sendConsoleOutput('Connecting to VM Service at $uri\n');
sendConsoleOutput('Connecting to VM Service at $uri');
final vmService = await _vmServiceConnectUri(uri.toString());
logger?.call('Connected to debugger at $uri!');

Expand Down Expand Up @@ -1065,10 +1065,9 @@ abstract class DartDebugAdapter<TL extends LaunchRequestArguments,
_hasSentTerminatedEvent = true;

// Always add a leading newline since the last written text might not have
// had one. Send directly via sendEvent and not sendOutput to ensure no
// async since we're about to terminate.
// had one.
final reason = isDetaching ? 'Detached' : 'Exited';
sendEvent(OutputEventBody(output: '\n$reason$exitSuffix.'));
sendConsoleOutput('\n$reason$exitSuffix.');
sendEvent(TerminatedEventBody());
}

Expand Down Expand Up @@ -1272,9 +1271,14 @@ abstract class DartDebugAdapter<TL extends LaunchRequestArguments,
sendResponse(ScopesResponseBody(scopes: scopes));
}

/// Sends an OutputEvent with a newline to the console.
void sendConsoleOutput(String message) {
sendOutput('console', '\n$message');
/// Sends an OutputEvent with a trailing newline to the console.
///
/// This method sends output directly and does not go through [sendOutput]
/// because that method is async and queues output. Console output is for
/// adapter-level output that does not require this and we want to ensure
/// it's sent immediately (for example during shutdown/exit).
void sendConsoleOutput(String? message) {
sendEvent(OutputEventBody(output: '$message\n'));
}

/// Sends an OutputEvent (without a newline, since calls to this method
Expand Down
7 changes: 3 additions & 4 deletions pkg/dds/lib/src/dap/adapters/dart_cli_adapter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -202,9 +202,8 @@ class DartCliDebugAdapter extends DartDebugAdapter<DartLaunchRequestArguments,
final vmServiceInfoFile = args.vmServiceInfoFile;

if ((vmServiceUri == null) == (vmServiceInfoFile == null)) {
sendOutput(
'console',
'\nTo attach, provide exactly one of vmServiceUri/vmServiceInfoFile',
sendConsoleOutput(
'To attach, provide exactly one of vmServiceUri/vmServiceInfoFile',
);
handleSessionTerminate();
return;
Expand Down Expand Up @@ -253,7 +252,7 @@ class DartCliDebugAdapter extends DartDebugAdapter<DartLaunchRequestArguments,
);
} catch (e) {
logger?.call('Client failed to spawn process $e');
sendOutput('console', '\nFailed to spawn process: $e');
sendConsoleOutput('Failed to spawn process: $e');
handleSessionTerminate();
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/dds/lib/src/dap/adapters/dart_test_adapter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ class DartTestDebugAdapter extends DartDebugAdapter<DartLaunchRequestArguments,
/// to be debugged.
@override
Future<void> attachImpl() async {
sendOutput('console', '\nAttach is not supported for test runs');
sendConsoleOutput('Attach is not supported for test runs');
handleSessionTerminate();
}

Expand Down
7 changes: 4 additions & 3 deletions pkg/dds/lib/src/dap/adapters/dds_hosted_adapter.dart
Original file line number Diff line number Diff line change
Expand Up @@ -105,18 +105,19 @@ class DdsHostedAdapter extends DartDebugAdapter<DartLaunchRequestArguments,
terminatePids(ProcessSignal.sigterm);
}

Future<Response> handleMessage(String message) async {
void handleMessage(String message, void Function(Response) responseWriter) {
final potentialException =
DebugAdapterException('Message does not conform to DAP spec: $message');

try {
final Map<String, Object?> json = jsonDecode(message);
final type = json['type'] as String;
if (type == 'request') {
return handleIncomingRequest(Request.fromJson(json));
handleIncomingRequest(Request.fromJson(json), responseWriter);
// TODO(helin24): Handle event and response?
} else {
throw potentialException;
}
throw potentialException;
} catch (e) {
throw potentialException;
}
Expand Down
Loading

0 comments on commit 4d084f5

Please sign in to comment.