Skip to content
This repository was archived by the owner on Jan 8, 2022. It is now read-only.

Commit 39a13eb

Browse files
committed
Drop uses of new Function type syntax
Fixes #20
1 parent 15cf6e1 commit 39a13eb

File tree

5 files changed

+46
-44
lines changed

5 files changed

+46
-44
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# 0.1.5+1
2+
3+
- Bug Fix: Remove usage of new Function type syntax so to restore compatibility
4+
with the stable SDK.
5+
16
# 0.1.5
27

38
- Only treat `pubspec.yaml` and `BUILD` files as indications of a package root.

lib/src/protocol/language_server/messages.dart

Lines changed: 34 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ class ApplyWorkspaceEditParams {
22
ApplyWorkspaceEditParams._(this.edit, this.label);
33

44
factory ApplyWorkspaceEditParams(
5-
void Function(ApplyWorkspaceEditParams$Builder) init) {
5+
void init(ApplyWorkspaceEditParams$Builder)) {
66
final b = new ApplyWorkspaceEditParams$Builder._();
77
init(b);
88
return new ApplyWorkspaceEditParams._(b.edit, b.label);
@@ -49,7 +49,7 @@ class ApplyWorkspaceEditParams$Builder {
4949
class ClientCapabilities {
5050
ClientCapabilities._(this.textDocument, this.workspace);
5151

52-
factory ClientCapabilities(void Function(ClientCapabilities$Builder) init) {
52+
factory ClientCapabilities(void init(ClientCapabilities$Builder)) {
5353
final b = new ClientCapabilities$Builder._();
5454
init(b);
5555
return new ClientCapabilities._(b.textDocument, b.workspace);
@@ -100,7 +100,7 @@ class ClientCapabilities$Builder {
100100
class CodeActionContext {
101101
CodeActionContext._(this.diagnostics);
102102

103-
factory CodeActionContext(void Function(CodeActionContext$Builder) init) {
103+
factory CodeActionContext(void init(CodeActionContext$Builder)) {
104104
final b = new CodeActionContext$Builder._();
105105
init(b);
106106
return new CodeActionContext._(b.diagnostics);
@@ -142,7 +142,7 @@ class CodeActionContext$Builder {
142142
class CodeLensOptions {
143143
CodeLensOptions._(this.resolveProvider);
144144

145-
factory CodeLensOptions(void Function(CodeLensOptions$Builder) init) {
145+
factory CodeLensOptions(void init(CodeLensOptions$Builder)) {
146146
final b = new CodeLensOptions$Builder._();
147147
init(b);
148148
return new CodeLensOptions._(b.resolveProvider);
@@ -179,7 +179,7 @@ class CodeLensOptions$Builder {
179179
class Command {
180180
Command._(this.arguments, this.command, this.title);
181181

182-
factory Command(void Function(Command$Builder) init) {
182+
factory Command(void init(Command$Builder)) {
183183
final b = new Command$Builder._();
184184
init(b);
185185
return new Command._(b.arguments, b.command, b.title);
@@ -230,8 +230,7 @@ class Command$Builder {
230230
class CompletionCapabilities {
231231
CompletionCapabilities._(this.completionItem, this.dynamicRegistration);
232232

233-
factory CompletionCapabilities(
234-
void Function(CompletionCapabilities$Builder) init) {
233+
factory CompletionCapabilities(void init(CompletionCapabilities$Builder)) {
235234
final b = new CompletionCapabilities$Builder._();
236235
init(b);
237236
return new CompletionCapabilities._(
@@ -297,7 +296,7 @@ class CompletionItem {
297296
this.sortText,
298297
this.textEdit);
299298

300-
factory CompletionItem(void Function(CompletionItem$Builder) init) {
299+
factory CompletionItem(void init(CompletionItem$Builder)) {
301300
final b = new CompletionItem$Builder._();
302301
init(b);
303302
return new CompletionItem._(
@@ -450,7 +449,7 @@ class CompletionItemCapabilities {
450449
CompletionItemCapabilities._(this.snippetSupport);
451450

452451
factory CompletionItemCapabilities(
453-
void Function(CompletionItemCapabilities$Builder) init) {
452+
void init(CompletionItemCapabilities$Builder)) {
454453
final b = new CompletionItemCapabilities$Builder._();
455454
init(b);
456455
return new CompletionItemCapabilities._(b.snippetSupport);
@@ -557,7 +556,7 @@ class CompletionItemKind {
557556
class CompletionList {
558557
CompletionList._(this.isIncomplete, this.items);
559558

560-
factory CompletionList(void Function(CompletionList$Builder) init) {
559+
factory CompletionList(void init(CompletionList$Builder)) {
561560
final b = new CompletionList$Builder._();
562561
init(b);
563562
return new CompletionList._(b.isIncomplete, b.items);
@@ -606,7 +605,7 @@ class CompletionList$Builder {
606605
class CompletionOptions {
607606
CompletionOptions._(this.resolveProvider, this.triggerCharacters);
608607

609-
factory CompletionOptions(void Function(CompletionOptions$Builder) init) {
608+
factory CompletionOptions(void init(CompletionOptions$Builder)) {
610609
final b = new CompletionOptions$Builder._();
611610
init(b);
612611
return new CompletionOptions._(b.resolveProvider, b.triggerCharacters);
@@ -655,7 +654,7 @@ class CompletionOptions$Builder {
655654
class Diagnostic {
656655
Diagnostic._(this.code, this.message, this.range, this.severity, this.source);
657656

658-
factory Diagnostic(void Function(Diagnostic$Builder) init) {
657+
factory Diagnostic(void init(Diagnostic$Builder)) {
659658
final b = new Diagnostic$Builder._();
660659
init(b);
661660
return new Diagnostic._(b.code, b.message, b.range, b.severity, b.source);
@@ -726,7 +725,7 @@ class Diagnostic$Builder {
726725
class Diagnostics {
727726
Diagnostics._(this.diagnostics, this.uri);
728727

729-
factory Diagnostics(void Function(Diagnostics$Builder) init) {
728+
factory Diagnostics(void init(Diagnostics$Builder)) {
730729
final b = new Diagnostics$Builder._();
731730
init(b);
732731
return new Diagnostics._(b.diagnostics, b.uri);
@@ -777,7 +776,7 @@ class Diagnostics$Builder {
777776
class DocumentLinkOptions {
778777
DocumentLinkOptions._(this.resolveProvider);
779778

780-
factory DocumentLinkOptions(void Function(DocumentLinkOptions$Builder) init) {
779+
factory DocumentLinkOptions(void init(DocumentLinkOptions$Builder)) {
781780
final b = new DocumentLinkOptions$Builder._();
782781
init(b);
783782
return new DocumentLinkOptions._(b.resolveProvider);
@@ -816,7 +815,7 @@ class DocumentOnTypeFormattingOptions {
816815
this.firstTriggerCharacter, this.moreTriggerCharacter);
817816

818817
factory DocumentOnTypeFormattingOptions(
819-
void Function(DocumentOnTypeFormattingOptions$Builder) init) {
818+
void init(DocumentOnTypeFormattingOptions$Builder)) {
820819
final b = new DocumentOnTypeFormattingOptions$Builder._();
821820
init(b);
822821
return new DocumentOnTypeFormattingOptions._(
@@ -871,7 +870,7 @@ class DynamicRegistrationCapability {
871870
DynamicRegistrationCapability._(this.dynamicRegistration);
872871

873872
factory DynamicRegistrationCapability(
874-
void Function(DynamicRegistrationCapability$Builder) init) {
873+
void init(DynamicRegistrationCapability$Builder)) {
875874
final b = new DynamicRegistrationCapability$Builder._();
876875
init(b);
877876
return new DynamicRegistrationCapability._(b.dynamicRegistration);
@@ -911,8 +910,7 @@ class DynamicRegistrationCapability$Builder {
911910
class ExecuteCommandOptions {
912911
ExecuteCommandOptions._(this.commands);
913912

914-
factory ExecuteCommandOptions(
915-
void Function(ExecuteCommandOptions$Builder) init) {
913+
factory ExecuteCommandOptions(void init(ExecuteCommandOptions$Builder)) {
916914
final b = new ExecuteCommandOptions$Builder._();
917915
init(b);
918916
return new ExecuteCommandOptions._(b.commands);
@@ -950,7 +948,7 @@ class ExecuteCommandOptions$Builder {
950948
class Hover {
951949
Hover._(this.contents, this.range);
952950

953-
factory Hover(void Function(Hover$Builder) init) {
951+
factory Hover(void init(Hover$Builder)) {
954952
final b = new Hover$Builder._();
955953
init(b);
956954
return new Hover._(b.contents, b.range);
@@ -1014,7 +1012,7 @@ class InsertTextFormat {
10141012
class Location {
10151013
Location._(this.range, this.uri);
10161014

1017-
factory Location(void Function(Location$Builder) init) {
1015+
factory Location(void init(Location$Builder)) {
10181016
final b = new Location$Builder._();
10191017
init(b);
10201018
return new Location._(b.range, b.uri);
@@ -1058,7 +1056,7 @@ class Location$Builder {
10581056
class Position {
10591057
Position._(this.character, this.line);
10601058

1061-
factory Position(void Function(Position$Builder) init) {
1059+
factory Position(void init(Position$Builder)) {
10621060
final b = new Position$Builder._();
10631061
init(b);
10641062
return new Position._(b.character, b.line);
@@ -1102,7 +1100,7 @@ class Position$Builder {
11021100
class Range {
11031101
Range._(this.end, this.start);
11041102

1105-
factory Range(void Function(Range$Builder) init) {
1103+
factory Range(void init(Range$Builder)) {
11061104
final b = new Range$Builder._();
11071105
init(b);
11081106
return new Range._(b.end, b.start);
@@ -1148,7 +1146,7 @@ class Range$Builder {
11481146
class ReferenceContext {
11491147
ReferenceContext._(this.includeDeclaration);
11501148

1151-
factory ReferenceContext(void Function(ReferenceContext$Builder) init) {
1149+
factory ReferenceContext(void init(ReferenceContext$Builder)) {
11521150
final b = new ReferenceContext$Builder._();
11531151
init(b);
11541152
return new ReferenceContext._(b.includeDeclaration);
@@ -1187,7 +1185,7 @@ class ReferenceContext$Builder {
11871185
class SaveOptions {
11881186
SaveOptions._(this.includeText);
11891187

1190-
factory SaveOptions(void Function(SaveOptions$Builder) init) {
1188+
factory SaveOptions(void init(SaveOptions$Builder)) {
11911189
final b = new SaveOptions$Builder._();
11921190
init(b);
11931191
return new SaveOptions._(b.includeText);
@@ -1241,7 +1239,7 @@ class ServerCapabilities {
12411239
this.textDocumentSync,
12421240
this.workspaceSymbolProvider);
12431241

1244-
factory ServerCapabilities(void Function(ServerCapabilities$Builder) init) {
1242+
factory ServerCapabilities(void init(ServerCapabilities$Builder)) {
12451243
final b = new ServerCapabilities$Builder._();
12461244
init(b);
12471245
return new ServerCapabilities._(
@@ -1459,8 +1457,7 @@ class ServerCapabilities$Builder {
14591457
class SignatureHelpOptions {
14601458
SignatureHelpOptions._(this.triggerCharacters);
14611459

1462-
factory SignatureHelpOptions(
1463-
void Function(SignatureHelpOptions$Builder) init) {
1460+
factory SignatureHelpOptions(void init(SignatureHelpOptions$Builder)) {
14641461
final b = new SignatureHelpOptions$Builder._();
14651462
init(b);
14661463
return new SignatureHelpOptions._(b.triggerCharacters);
@@ -1501,7 +1498,7 @@ class SynchronizationCapabilities {
15011498
this.willSave, this.willSaveWaitUntil);
15021499

15031500
factory SynchronizationCapabilities(
1504-
void Function(SynchronizationCapabilities$Builder) init) {
1501+
void init(SynchronizationCapabilities$Builder)) {
15051502
final b = new SynchronizationCapabilities$Builder._();
15061503
init(b);
15071504
return new SynchronizationCapabilities._(
@@ -1584,7 +1581,7 @@ class TextDocumentClientCapabilities {
15841581
this.synchronization);
15851582

15861583
factory TextDocumentClientCapabilities(
1587-
void Function(TextDocumentClientCapabilities$Builder) init) {
1584+
void init(TextDocumentClientCapabilities$Builder)) {
15881585
final b = new TextDocumentClientCapabilities$Builder._();
15891586
init(b);
15901587
return new TextDocumentClientCapabilities._(
@@ -1765,7 +1762,7 @@ class TextDocumentContentChangeEvent {
17651762
TextDocumentContentChangeEvent._(this.range, this.rangeLength, this.text);
17661763

17671764
factory TextDocumentContentChangeEvent(
1768-
void Function(TextDocumentContentChangeEvent$Builder) init) {
1765+
void init(TextDocumentContentChangeEvent$Builder)) {
17691766
final b = new TextDocumentContentChangeEvent$Builder._();
17701767
init(b);
17711768
return new TextDocumentContentChangeEvent._(b.range, b.rangeLength, b.text);
@@ -1820,8 +1817,7 @@ class TextDocumentContentChangeEvent$Builder {
18201817
class TextDocumentIdentifier {
18211818
TextDocumentIdentifier._(this.uri);
18221819

1823-
factory TextDocumentIdentifier(
1824-
void Function(TextDocumentIdentifier$Builder) init) {
1820+
factory TextDocumentIdentifier(void init(TextDocumentIdentifier$Builder)) {
18251821
final b = new TextDocumentIdentifier$Builder._();
18261822
init(b);
18271823
return new TextDocumentIdentifier._(b.uri);
@@ -1859,7 +1855,7 @@ class TextDocumentIdentifier$Builder {
18591855
class TextDocumentItem {
18601856
TextDocumentItem._(this.languageId, this.text, this.uri, this.version);
18611857

1862-
factory TextDocumentItem(void Function(TextDocumentItem$Builder) init) {
1858+
factory TextDocumentItem(void init(TextDocumentItem$Builder)) {
18631859
final b = new TextDocumentItem$Builder._();
18641860
init(b);
18651861
return new TextDocumentItem._(b.languageId, b.text, b.uri, b.version);
@@ -1942,8 +1938,7 @@ class TextDocumentSyncOptions {
19421938
TextDocumentSyncOptions._(this.change, this.openClose, this.save,
19431939
this.willSave, this.willSaveWaitUntil);
19441940

1945-
factory TextDocumentSyncOptions(
1946-
void Function(TextDocumentSyncOptions$Builder) init) {
1941+
factory TextDocumentSyncOptions(void init(TextDocumentSyncOptions$Builder)) {
19471942
final b = new TextDocumentSyncOptions$Builder._();
19481943
init(b);
19491944
return new TextDocumentSyncOptions._(
@@ -2021,7 +2016,7 @@ class TextDocumentSyncOptions$Builder {
20212016
class TextEdit {
20222017
TextEdit._(this.newText, this.range);
20232018

2024-
factory TextEdit(void Function(TextEdit$Builder) init) {
2019+
factory TextEdit(void init(TextEdit$Builder)) {
20252020
final b = new TextEdit$Builder._();
20262021
init(b);
20272022
return new TextEdit._(b.newText, b.range);
@@ -2066,7 +2061,7 @@ class VersionedTextDocumentIdentifier {
20662061
VersionedTextDocumentIdentifier._(this.uri, this.version);
20672062

20682063
factory VersionedTextDocumentIdentifier(
2069-
void Function(VersionedTextDocumentIdentifier$Builder) init) {
2064+
void init(VersionedTextDocumentIdentifier$Builder)) {
20702065
final b = new VersionedTextDocumentIdentifier$Builder._();
20712066
init(b);
20722067
return new VersionedTextDocumentIdentifier._(b.uri, b.version);
@@ -2113,7 +2108,7 @@ class WorkspaceClientCapabilities {
21132108
this.didChangeWatchedFiles, this.executeCommand, this.symbol);
21142109

21152110
factory WorkspaceClientCapabilities(
2116-
void Function(WorkspaceClientCapabilities$Builder) init) {
2111+
void init(WorkspaceClientCapabilities$Builder)) {
21172112
final b = new WorkspaceClientCapabilities$Builder._();
21182113
init(b);
21192114
return new WorkspaceClientCapabilities._(
@@ -2202,7 +2197,7 @@ class WorkspaceClientCapabilities$Builder {
22022197
class WorkspaceEdit {
22032198
WorkspaceEdit._(this.changes);
22042199

2205-
factory WorkspaceEdit(void Function(WorkspaceEdit$Builder) init) {
2200+
factory WorkspaceEdit(void init(WorkspaceEdit$Builder)) {
22062201
final b = new WorkspaceEdit$Builder._();
22072202
init(b);
22082203
return new WorkspaceEdit._(b.changes);

lib/src/utils/command_cache.dart

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,18 @@ import '../protocol/language_server/messages.dart' show Command;
44

55
const _size = 1000;
66

7+
typedef void Callback();
8+
79
class CommandCache {
810
/// Commands in insertion order
9-
final _commands = new LinkedHashMap<String, void Function()>();
11+
final _commands = new LinkedHashMap<String, Callback>();
1012

1113
/// Store [change] in the cache as a [Command] and return the command.
12-
Command add(Command command, void Function() callback) {
14+
Command add(Command command, Callback callback) {
1315
_commands[command.command] = callback;
1416
if (_commands.length > _size) _commands.remove(_commands.keys.first);
1517
return command;
1618
}
1719

18-
void Function() operator [](String key) => _commands[key];
20+
Callback operator [](String key) => _commands[key];
1921
}

lib/src/utils/per_file_pool.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,6 @@ import 'package:pool/pool.dart';
55
class PerFilePool {
66
final _pools = <String, Pool>{};
77

8-
Future<T> lock<T>(String path, FutureOr<T> Function() operation) =>
8+
Future<T> lock<T>(String path, FutureOr<T> operation()) =>
99
_pools.putIfAbsent(path, () => new Pool(1)).withResource(operation);
1010
}

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: dart_language_server
2-
version: 0.1.5
2+
version: 0.1.5+1
33
description: >-
44
A shim on the analysis server following the language server protocol
55
homepage: https://github.com/natebosch/dart_language_server

0 commit comments

Comments
 (0)