Skip to content

Commit 0668399

Browse files
committed
WIP3
Signed-off-by: Koichi Shiraishi <[email protected]>
1 parent 07dcae9 commit 0668399

23 files changed

+13054
-1193
lines changed

client.go

Lines changed: 137 additions & 200 deletions
Large diffs are not rendered by default.

go.mod

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,16 @@ module go.lsp.dev/protocol
33
go 1.22.2
44

55
require (
6+
github.com/google/go-cmp v0.6.0
7+
github.com/segmentio/encoding v0.4.0
68
go.lsp.dev/jsonrpc2 v0.10.0
9+
go.lsp.dev/pkg v0.0.0-20210717090340-384b27a52fb2
710
go.lsp.dev/uri v0.3.0
811
go.uber.org/zap v1.27.0
912
)
1013

1114
require (
12-
github.com/google/go-cmp v0.6.0 // indirect
1315
github.com/segmentio/asm v1.1.3 // indirect
14-
github.com/segmentio/encoding v0.4.0 // indirect
1516
go.uber.org/multierr v1.10.0 // indirect
1617
golang.org/x/sys v0.0.0-20220319134239-a9b59b0215f8 // indirect
1718
)

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKs
1313
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
1414
go.lsp.dev/jsonrpc2 v0.10.0 h1:Pr/YcXJoEOTMc/b6OTmcR1DPJ3mSWl/SWiU1Cct6VmI=
1515
go.lsp.dev/jsonrpc2 v0.10.0/go.mod h1:fmEzIdXPi/rf6d4uFcayi8HpFP1nBF99ERP1htC72Ac=
16+
go.lsp.dev/pkg v0.0.0-20210717090340-384b27a52fb2 h1:hCzQgh6UcwbKgNSRurYWSqh8MufqRRPODRBblutn4TE=
17+
go.lsp.dev/pkg v0.0.0-20210717090340-384b27a52fb2/go.mod h1:gtSHRuYfbCT0qnbLnovpie/WEmqyJ7T4n6VXiFMBtcw=
1618
go.lsp.dev/uri v0.3.0 h1:KcZJmh6nFIBeJzTugn5JTU6OOyG0lDOo3R9KwTxTYbo=
1719
go.lsp.dev/uri v0.3.0/go.mod h1:P5sbO1IQR+qySTWOCnhnK7phBx+W3zbLqSMDJNTw88I=
1820
go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto=

protocol/base.go

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// Copyright 2024 The Go Language Server Authors
2+
// SPDX-License-Identifier: BSD-3-Clause
3+
4+
package protocol
5+
6+
// ErrorCodes predefined error codes.
7+
type ErrorCodes int32
8+
9+
const (
10+
ParseErrorErrorCodes ErrorCodes = -32700
11+
12+
InvalidRequestErrorCodes ErrorCodes = -32600
13+
14+
MethodNotFoundErrorCodes ErrorCodes = -32601
15+
16+
InvalidParamsErrorCodes ErrorCodes = -32602
17+
18+
InternalErrorErrorCodes ErrorCodes = -32603
19+
20+
// ServerNotInitializedErrorCodes error code indicating that a server received a notification or request before the server has received the `initialize` request.
21+
ServerNotInitializedErrorCodes ErrorCodes = -32002
22+
23+
UnknownErrorCodeErrorCodes ErrorCodes = -32001
24+
)
25+
26+
type LSPErrorCodes int32
27+
28+
const (
29+
// RequestFailedLSPErrorCodes a request failed but it was syntactically correct, e.g the method name was known and the parameters were valid. The error message should contain human readable information about why the request failed.
30+
//
31+
// @since 3.17.0
32+
RequestFailedLSPErrorCodes LSPErrorCodes = -32803
33+
34+
// ServerCancelledLSPErrorCodes the server cancelled the request. This error code should only be used for requests that explicitly support being server cancellable.
35+
//
36+
// @since 3.17.0
37+
ServerCancelledLSPErrorCodes LSPErrorCodes = -32802
38+
39+
// ContentModifiedLSPErrorCodes the server detected that the content of a document got modified outside normal conditions. A server should NOT send this error code if it detects a content change in it unprocessed messages. The result even computed on an older state might still be useful for the client. If a client decides that a result is not of any use anymore the client should cancel the request.
40+
ContentModifiedLSPErrorCodes LSPErrorCodes = -32801
41+
42+
// RequestCancelledLSPErrorCodes the client has canceled a request and a server as detected the cancel.
43+
RequestCancelledLSPErrorCodes LSPErrorCodes = -32800
44+
)
45+
46+
type CancelParams struct {
47+
// ID the request id to cancel.
48+
ID CancelParamsID `json:"id"`
49+
}
50+
51+
type ProgressParams struct {
52+
// Token the progress token provided by the client or server.
53+
Token ProgressToken `json:"token"`
54+
55+
// Value the progress data.
56+
Value any `json:"value"`
57+
}

0 commit comments

Comments
 (0)