Skip to content

Commit

Permalink
Version 3.6.0-310.0.dev
Browse files Browse the repository at this point in the history
Merge c7f9914 into dev
  • Loading branch information
Dart CI committed Oct 2, 2024
2 parents 691701c + c7f9914 commit b4b806a
Show file tree
Hide file tree
Showing 16 changed files with 138 additions and 83 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ final class ClassSuggestion extends ImportableSuggestion
}

/// The information about a candidate suggestion based on a constructor.
final class ClosureSuggestion extends CandidateSuggestion {
final class ClosureSuggestion extends CandidateSuggestion with SuggestionData {
/// The type that the closure must conform to.
final FunctionType functionType;

Expand All @@ -76,8 +76,6 @@ final class ClosureSuggestion extends CandidateSuggestion {
/// The identation to be used for a multi-line completion.
final String indent;

_SuggestionData? _data;

/// Initialize a newly created candidate suggestion to suggest a closure that
/// conforms to the given [functionType].
///
Expand All @@ -98,19 +96,7 @@ final class ClosureSuggestion extends CandidateSuggestion {
return _data!.completion;
}

/// Text to be displayed in a completion pop-up.
String get displayText {
_init();
return _data!.displayText;
}

/// The offset, from the beginning of the inserted text, where the cursor
/// should be positioned.
int get selectionOffset {
_init();
return _data!.selectionOffset;
}

@override
void _init() {
if (_data != null) {
return;
Expand Down Expand Up @@ -142,8 +128,7 @@ final class ClosureSuggestion extends CandidateSuggestion {
stringBuffer.write(',');
}
var completion = stringBuffer.toString();
_data =
_SuggestionData(completion, selectionOffset, displayText: displayText);
_data = _Data(completion, selectionOffset, displayText: displayText);
}
}

Expand Down Expand Up @@ -655,7 +640,8 @@ final class MixinSuggestion extends ImportableSuggestion
}

/// Suggest the name of a named parameter in the argument list of an invocation.
final class NamedArgumentSuggestion extends CandidateSuggestion {
final class NamedArgumentSuggestion extends CandidateSuggestion
with SuggestionData {
/// The parameter whose name is to be suggested.
final ParameterElement parameter;

Expand All @@ -673,8 +659,6 @@ final class NamedArgumentSuggestion extends CandidateSuggestion {

String preferredQuoteForStrings;

_SuggestionData? _data;

NamedArgumentSuggestion({
required this.parameter,
required this.appendColon,
Expand All @@ -691,13 +675,10 @@ final class NamedArgumentSuggestion extends CandidateSuggestion {
return _data!.completion;
}

/// The offset, from the beginning of the inserted text, where the cursor
/// should be positioned.
int get selectionOffset {
_init();
return _data!.selectionOffset;
}
@override
String get displayText => completion;

@override
void _init() {
if (_data != null) {
return;
Expand Down Expand Up @@ -727,7 +708,7 @@ final class NamedArgumentSuggestion extends CandidateSuggestion {
if (appendComma) {
completion += ',';
}
_data = _SuggestionData(completion, selectionOffset);
_data = _Data(completion, selectionOffset);
}
}

Expand Down Expand Up @@ -852,13 +833,12 @@ final class RecordFieldSuggestion extends CandidateSuggestion {

/// The information about a candidate suggestion based on a named field of
/// a record type.
final class RecordLiteralNamedFieldSuggestion extends CandidateSuggestion {
final class RecordLiteralNamedFieldSuggestion extends CandidateSuggestion
with SuggestionData {
final RecordTypeNamedField field;
final bool appendColon;
final bool appendComma;

_SuggestionData? _data;

RecordLiteralNamedFieldSuggestion.newField({
required this.field,
required this.appendComma,
Expand All @@ -877,13 +857,10 @@ final class RecordLiteralNamedFieldSuggestion extends CandidateSuggestion {
return _data!.completion;
}

/// The offset, from the beginning of the inserted text, where the cursor
/// should be positioned.
int get selectionOffset {
_init();
return _data!.selectionOffset;
}
@override
String get displayText => completion;

@override
void _init() {
if (_data != null) {
return;
Expand All @@ -899,13 +876,13 @@ final class RecordLiteralNamedFieldSuggestion extends CandidateSuggestion {
if (appendComma) {
completion += ',';
}
_data = _SuggestionData(completion, selectionOffset);
_data = _Data(completion, selectionOffset);
}
}

/// The information about a candidate suggestion for Flutter's `setState` method.
final class SetStateMethodSuggestion extends ExecutableSuggestion
with MemberSuggestion {
with MemberSuggestion, SuggestionData {
@override
final MethodElement element;

Expand All @@ -917,8 +894,6 @@ final class SetStateMethodSuggestion extends ExecutableSuggestion
/// The identation to be used for a multi-line completion.
final String indent;

_SuggestionData? _data;

/// Initialize a newly created candidate suggestion to suggest the [element].
SetStateMethodSuggestion(
{required this.element,
Expand All @@ -934,19 +909,7 @@ final class SetStateMethodSuggestion extends ExecutableSuggestion
return _data!.completion;
}

/// Text to be displayed in a completion pop-up.
String get displayText {
_init();
return _data!.displayText;
}

/// The offset, from the beginning of the inserted text, where the cursor
/// should be positioned.
int get selectionOffset {
_init();
return _data!.selectionOffset;
}

@override
void _init() {
if (_data != null) {
return;
Expand All @@ -959,8 +922,7 @@ final class SetStateMethodSuggestion extends ExecutableSuggestion
buffer.writeln();
buffer.write('$indent});');
var completion = buffer.toString();
_data = _SuggestionData(completion, selectionOffset,
displayText: 'setState(() {});');
_data = _Data(completion, selectionOffset, displayText: 'setState(() {});');
}
}

Expand All @@ -985,6 +947,27 @@ final class StaticFieldSuggestion extends ImportableSuggestion
}
}

/// Behavior common to suggestions where completion text, [selectionOffset],
/// and [displayText] is computed.
mixin SuggestionData {
_Data? _data;

/// Text to be displayed in a completion pop-up.
String get displayText {
_init();
return _data!.displayText;
}

/// The offset, from the beginning of the inserted text, where the cursor
/// should be positioned.
int get selectionOffset {
_init();
return _data!.selectionOffset;
}

void _init();
}

/// The information about a candidate suggestion based on a parameter from a
/// super constructor.
final class SuperParameterSuggestion extends CandidateSuggestion
Expand Down Expand Up @@ -1094,15 +1077,14 @@ final class UriSuggestion extends CandidateSuggestion {
}

/// Information computed for some the code completion suggestions.
class _SuggestionData {
class _Data {
String displayText;

int selectionOffset;

String completion;

_SuggestionData(this.completion, this.selectionOffset,
{this.displayText = ''});
_Data(this.completion, this.selectionOffset, {this.displayText = ''});
}

extension on String {
Expand Down
6 changes: 3 additions & 3 deletions pkg/dtd/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ A package for communicating with the Dart Tooling Daemon.

## What is the Dart Tooling Daemon?

The Dart Tooling Daemon is a long running process meant to facilitate
The Dart Tooling Daemon is a long-running process meant to facilitate
communication between Dart tools and minimal file system access for a Dart
development workspace.

Expand All @@ -20,7 +20,7 @@ run process.
## Quick Start

```dart
import "package:dtd"
import 'package:dtd/dtd.dart';
/// Since the Dart Tooling Daemon exists within the context of a development
/// environment, any tool using DTD can expect a development environment to
Expand Down Expand Up @@ -52,7 +52,7 @@ final client = await DartToolingDaemon.connect(dtdUri);

`client` can then be used to interact with the Dart Tooling Daemon.

See the [Examples](#examples) for details on the built in interactions.
See the [Examples](#examples) for details on the built-in interactions.

## Examples

Expand Down
4 changes: 4 additions & 0 deletions pkg/dtd/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
include: package:dart_flutter_team_lints/analysis_options.yaml

analyzer:
language:
strict-raw-types: true

linter:
rules:
- avoid_void_async
Expand Down
4 changes: 2 additions & 2 deletions pkg/dtd/example/dtd_file_system_service_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ void main(List<String> args) async {

final dtdSecret = args.length >= 3 ? args[2] : null;

// Create the client that will be talking to the FileSystem service..
DartToolingDaemon? client = await DartToolingDaemon.connect(
// Create the client that will be talking to the FileSystem service.
final client = await DartToolingDaemon.connect(
Uri.parse(dtdUrl),
);

Expand Down
2 changes: 1 addition & 1 deletion pkg/dtd/example/dtd_service_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ void main(List<String> args) async {
// ExampleServer.getServerState.
final getStateRequest = GetStateRequest.fromParams(params);

final duration = const Duration(minutes: 45);
const duration = Duration(minutes: 45);
final status =
getStateRequest.verbose ? 'The server is running' : 'Running';

Expand Down
4 changes: 2 additions & 2 deletions pkg/dtd/lib/src/dart_tooling_daemon.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class DartToolingDaemon {
}

late final Peer _clientPeer;
late final Future _done;
late final Future<void> _done;
final _subscribedStreamControllers = <String, StreamController<DTDEvent>>{};

/// Terminates the connection with the Dart Tooling Daemon.
Expand Down Expand Up @@ -199,7 +199,7 @@ class DartToolingDaemon {
throw DartToolingDaemonConnectionException.callResponseMissingType(json);
}

//TODO(danchevalier): Find out how to get access to the id.
// TODO(danchevalier): Find out how to get access to the id.
return DTDResponse('-1', type, json);
}

Expand Down
10 changes: 5 additions & 5 deletions pkg/dtd/lib/src/response_types.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import 'package:json_rpc_2/json_rpc_2.dart' as json_rpc;
import 'dart_tooling_daemon.dart';

/// A DTD response that indicates success.
class Success extends _SuccessResponse {
class Success extends _SuccessResponse<Null> {
const Success();

factory Success.fromDTDResponse(DTDResponse response) {
Expand All @@ -18,7 +18,7 @@ class Success extends _SuccessResponse {
@override
String get type => _type;

static final _type = 'Success';
static const _type = 'Success';
}

/// A DTD response that indicates success and contains a single String value.
Expand All @@ -34,7 +34,7 @@ class StringResponse extends _SuccessResponse<String> {
@override
String get type => _type;

static final _type = 'StringResponse';
static const _type = 'StringResponse';
}

/// A DTD response that indicates success and contains a single boolean value.
Expand All @@ -50,7 +50,7 @@ class BoolResponse extends _SuccessResponse<bool> {
@override
String get type => _type;

static final _type = 'BoolResponse';
static const _type = 'BoolResponse';
}

/// A DTD response that indicates success and contains a single [List] of
Expand All @@ -68,7 +68,7 @@ class StringListResponse extends _SuccessResponse<List<String>> {
@override
String get type => _type;

static final _type = 'ListResponse';
static const _type = 'ListResponse';
}

/// A DTD response that indicates success and contains a single optional value
Expand Down
2 changes: 1 addition & 1 deletion pkg/dtd/lib/src/unified_analytics_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import 'response_types.dart';
///
/// This library lives under src/ and is intentionally not exported from lib/.
/// First party Dash products that use this service should import this library
/// from src/ and add an analyzer ignore to supress the warning.
/// from src/ and add an analyzer ignore to suppress the warning.
extension UnifiedAnalyticsExtension on DartToolingDaemon {
/// Gets the Dart and Flutter unified analytics consent message to prompt
/// users with on first run or when the message has been updated.
Expand Down
4 changes: 2 additions & 2 deletions pkg/dtd/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: dtd
version: 2.3.0
version: 2.3.1-wip
description: A package for communicating with the Dart Tooling Daemon.
repository: https://github.com/dart-lang/sdk/tree/main/pkg/dtd

environment:
sdk: ">=3.0.0 <4.0.0"
sdk: ^3.0.0

dependencies:
json_rpc_2: ^3.0.2
Expand Down
2 changes: 1 addition & 1 deletion pkg/dtd/test/file_system_service_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ void main() {
);
});

test('prevents access outide of workspace roots for relative paths',
test('prevents access outside of workspace roots for relative paths',
() async {
await client.setIDEWorkspaceRoots(dtdSecret, [fooDirectory.uri]);
expect(
Expand Down
2 changes: 1 addition & 1 deletion pkg/dtd/test/unified_analytics_service_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ void main() {
});

test('shouldShowMessage', () async {
var response = await client.analyticsShouldShowConsentMessage(tool);
final response = await client.analyticsShouldShowConsentMessage(tool);
// Since `clientShowedMessage` has already been called on the
// FakeAnalytics instance when we create it in package:dtd_impl, this will
// return false.
Expand Down
1 change: 1 addition & 0 deletions pkg/vm_service_interface/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## 2.0.0
- Provides version 4.16 of the Dart VM service protocol.
- Update `package:vm_service` constraint to `>=14.3.0 <15.0.0`.

## 1.1.0
- Provides version 4.15 of the Dart VM service protocol.
Expand Down
Loading

0 comments on commit b4b806a

Please sign in to comment.