Skip to content

Commit 79d1426

Browse files
authored
Bump Freezed (#319)
1 parent ab6a16a commit 79d1426

File tree

8 files changed

+651
-2145
lines changed

8 files changed

+651
-2145
lines changed

packages/custom_lint/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## Unreleased patch
2+
3+
- Upgrade Freezed to 3.0
4+
15
## 0.7.3 - 2025-02-08
26

37
- Bump analyzer_plugin

packages/custom_lint/lib/src/v2/custom_lint_analyzer_plugin.dart

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -397,8 +397,8 @@ class CustomLintServer {
397397
}
398398

399399
Future<void> _handleEvent(CustomLintEvent event) => _runner.run(() async {
400-
await event.map(
401-
analyzerPluginNotification: (event) async {
400+
switch (event) {
401+
case CustomLintEventAnalyzerPluginNotification():
402402
_analyzerPluginClientChannel.sendJson(event.notification.toJson());
403403

404404
final notification = event.notification;
@@ -414,8 +414,7 @@ class CustomLintServer {
414414
pluginContextRoots: await _allContextRoots,
415415
);
416416
}
417-
},
418-
error: (event) async {
417+
case CustomLintEventError():
419418
_analyzerPluginClientChannel.sendJson(
420419
PluginErrorParams(false, event.message, event.stackTrace)
421420
.toNotification()
@@ -428,15 +427,13 @@ class CustomLintServer {
428427
pluginName: event.pluginName ?? 'custom_lint client',
429428
pluginContextRoots: await _allContextRoots,
430429
);
431-
},
432-
print: (event) async {
430+
case CustomLintEventPrint():
433431
delegate.pluginMessage(
434432
this,
435433
event.message,
436434
pluginName: event.pluginName ?? 'custom_lint client',
437435
pluginContextRoots: await _allContextRoots,
438436
);
439-
},
440-
);
437+
}
441438
});
442439
}

packages/custom_lint/lib/src/v2/protocol.dart

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ part 'protocol.freezed.dart';
66

77
/// A base class shared between all custom_lint requests
88
@freezed
9-
class CustomLintRequest with _$CustomLintRequest {
9+
sealed class CustomLintRequest with _$CustomLintRequest {
1010
/// A request using the analyzer_plugin protocol
1111
factory CustomLintRequest.analyzerPluginRequest(
1212
Request request, {
@@ -17,10 +17,10 @@ class CustomLintRequest with _$CustomLintRequest {
1717
factory CustomLintRequest.awaitAnalysisDone({
1818
required String id,
1919
required bool reload,
20-
}) = _CustomLintRequestAwaitAnalysisDone;
20+
}) = CustomLintRequestAwaitAnalysisDone;
2121

2222
/// Sends a meaningless message to the client, waiting for a response.
23-
factory CustomLintRequest.ping({required String id}) = _CustomLintRequestPing;
23+
factory CustomLintRequest.ping({required String id}) = CustomLintRequestPing;
2424

2525
/// Decode a custom_lint request from JSON
2626
factory CustomLintRequest.fromJson(Map<String, Object?> json) =>
@@ -33,27 +33,27 @@ class CustomLintRequest with _$CustomLintRequest {
3333

3434
/// The base class for all responses to a custom_lint request.
3535
@freezed
36-
class CustomLintResponse with _$CustomLintResponse {
36+
sealed class CustomLintResponse with _$CustomLintResponse {
3737
/// The response for an analyzer_plugin request
3838
factory CustomLintResponse.analyzerPluginResponse(
3939
Response response, {
4040
required String id,
41-
}) = _CustomLintResponseAnalyzerPluginResponse;
41+
}) = CustomLintResponseAnalyzerPluginResponse;
4242

4343
/// The message sent when the client has completed its analysis
4444
factory CustomLintResponse.awaitAnalysisDone({required String id}) =
45-
_CustomLintResponseAwaitAnalysisDone;
45+
CustomLintResponseAwaitAnalysisDone;
4646

4747
/// The reply to a ping request
4848
factory CustomLintResponse.pong({required String id}) =
49-
_CustomLintResponsePong;
49+
CustomLintResponsePong;
5050

5151
/// A request failed
5252
factory CustomLintResponse.error({
5353
required String id,
5454
required String message,
5555
required String stackTrace,
56-
}) = _CustomLintResponseError;
56+
}) = CustomLintResponseError;
5757

5858
/// Decode a response from JSON
5959
factory CustomLintResponse.fromJson(Map<String, Object?> json) =>
@@ -65,8 +65,8 @@ class CustomLintResponse with _$CustomLintResponse {
6565

6666
/// A base class between all messages from the client, be it request responses,
6767
/// or spontaneous events.
68-
@freezed
69-
class CustomLintMessage with _$CustomLintMessage {
68+
@Freezed(copyWith: false)
69+
abstract class CustomLintMessage with _$CustomLintMessage {
7070
/// A spontaneous event, not associated with a request
7171
factory CustomLintMessage.event(CustomLintEvent event) =
7272
CustomLintMessageEvent;
@@ -102,25 +102,25 @@ class NotificationJsonConverter
102102

103103
/// A base class for all custom_lint events
104104
@freezed
105-
class CustomLintEvent with _$CustomLintEvent {
105+
sealed class CustomLintEvent with _$CustomLintEvent {
106106
/// The client sent a [Notification] using the analyzer_plugin protocol
107107
factory CustomLintEvent.analyzerPluginNotification(
108108
@NotificationJsonConverter() Notification notification,
109-
) = _CustomLintEventAnalyzerPluginNotification;
110-
// TOOD add source change event?
109+
) = CustomLintEventAnalyzerPluginNotification;
110+
// TODO add source change event?
111111

112112
/// A spontaneous error, unrelated to a request
113113
factory CustomLintEvent.error(
114114
String message,
115115
String stackTrace, {
116116
required String? pluginName,
117-
}) = _CustomLintEventError;
117+
}) = CustomLintEventError;
118118

119119
/// A log output
120120
factory CustomLintEvent.print(
121121
String message, {
122122
required String? pluginName,
123-
}) = _CustomLintEventPrint;
123+
}) = CustomLintEventPrint;
124124

125125
/// Decode an event from JSON
126126
factory CustomLintEvent.fromJson(Map<String, Object?> json) =>

0 commit comments

Comments
 (0)