Skip to content

Commit 0aa0e9f

Browse files
committed
Moved protocol package to module root
1 parent 8a508a9 commit 0aa0e9f

34 files changed

Lines changed: 257 additions & 739 deletions
Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22
// Use of this source code is governed by a BSD-style
33
// license that can be found in the LICENSE file.
44

5-
package protocol_test
5+
package lsp_test
66

77
import (
88
"encoding/json"
99
"testing"
1010

11-
"github.com/TypeFox/go-lsp/protocol"
11+
"typefox.dev/lsp"
1212
)
1313

1414
// TestCancellationSupport tests the LSP cancellation protocol
1515
func TestCancellationSupport(t *testing.T) {
1616

1717
t.Run("CancelParams", func(t *testing.T) {
1818
// Test CancelParams structure
19-
cancelParams := protocol.CancelParams{
19+
cancelParams := lsp.CancelParams{
2020
ID: "test-request-123",
2121
}
2222

@@ -25,7 +25,7 @@ func TestCancellationSupport(t *testing.T) {
2525
t.Fatalf("Failed to marshal CancelParams: %v", err)
2626
}
2727

28-
var unmarshaled protocol.CancelParams
28+
var unmarshaled lsp.CancelParams
2929
err = json.Unmarshal(data, &unmarshaled)
3030
if err != nil {
3131
t.Fatalf("Failed to unmarshal CancelParams: %v", err)
@@ -38,7 +38,7 @@ func TestCancellationSupport(t *testing.T) {
3838

3939
t.Run("CancelNotificationStructure", func(t *testing.T) {
4040
// Test that cancel notification structure is correct
41-
cancelParams := protocol.CancelParams{
41+
cancelParams := lsp.CancelParams{
4242
ID: "request-to-cancel",
4343
}
4444

@@ -48,7 +48,7 @@ func TestCancellationSupport(t *testing.T) {
4848
t.Fatalf("Failed to marshal CancelParams: %v", err)
4949
}
5050

51-
var unmarshaled protocol.CancelParams
51+
var unmarshaled lsp.CancelParams
5252
err = json.Unmarshal(data, &unmarshaled)
5353
if err != nil {
5454
t.Fatalf("Failed to unmarshal CancelParams: %v", err)
@@ -65,7 +65,7 @@ func TestProgressSupport(t *testing.T) {
6565

6666
t.Run("ProgressParams", func(t *testing.T) {
6767
// Test ProgressParams structure
68-
progressParams := protocol.ProgressParams{
68+
progressParams := lsp.ProgressParams{
6969
Token: "progress-token-123",
7070
Value: map[string]interface{}{
7171
"kind": "begin",
@@ -79,7 +79,7 @@ func TestProgressSupport(t *testing.T) {
7979
t.Fatalf("Failed to marshal ProgressParams: %v", err)
8080
}
8181

82-
var unmarshaled protocol.ProgressParams
82+
var unmarshaled lsp.ProgressParams
8383
err = json.Unmarshal(data, &unmarshaled)
8484
if err != nil {
8585
t.Fatalf("Failed to unmarshal ProgressParams: %v", err)
@@ -92,7 +92,7 @@ func TestProgressSupport(t *testing.T) {
9292

9393
t.Run("WorkDoneProgressBegin", func(t *testing.T) {
9494
// Test WorkDoneProgressBegin structure
95-
begin := protocol.WorkDoneProgressBegin{
95+
begin := lsp.WorkDoneProgressBegin{
9696
Kind: "begin",
9797
Title: "Indexing",
9898
Cancellable: true,
@@ -105,7 +105,7 @@ func TestProgressSupport(t *testing.T) {
105105
t.Fatalf("Failed to marshal WorkDoneProgressBegin: %v", err)
106106
}
107107

108-
var unmarshaled protocol.WorkDoneProgressBegin
108+
var unmarshaled lsp.WorkDoneProgressBegin
109109
err = json.Unmarshal(data, &unmarshaled)
110110
if err != nil {
111111
t.Fatalf("Failed to unmarshal WorkDoneProgressBegin: %v", err)
@@ -121,7 +121,7 @@ func TestProgressSupport(t *testing.T) {
121121

122122
t.Run("WorkDoneProgressReport", func(t *testing.T) {
123123
// Test WorkDoneProgressReport structure
124-
report := protocol.WorkDoneProgressReport{
124+
report := lsp.WorkDoneProgressReport{
125125
Kind: "report",
126126
Cancellable: true,
127127
Message: "50% complete",
@@ -133,7 +133,7 @@ func TestProgressSupport(t *testing.T) {
133133
t.Fatalf("Failed to marshal WorkDoneProgressReport: %v", err)
134134
}
135135

136-
var unmarshaled protocol.WorkDoneProgressReport
136+
var unmarshaled lsp.WorkDoneProgressReport
137137
err = json.Unmarshal(data, &unmarshaled)
138138
if err != nil {
139139
t.Fatalf("Failed to unmarshal WorkDoneProgressReport: %v", err)
@@ -146,7 +146,7 @@ func TestProgressSupport(t *testing.T) {
146146

147147
t.Run("WorkDoneProgressEnd", func(t *testing.T) {
148148
// Test WorkDoneProgressEnd structure
149-
end := protocol.WorkDoneProgressEnd{
149+
end := lsp.WorkDoneProgressEnd{
150150
Kind: "end",
151151
Message: "Indexing complete",
152152
}
@@ -156,7 +156,7 @@ func TestProgressSupport(t *testing.T) {
156156
t.Fatalf("Failed to marshal WorkDoneProgressEnd: %v", err)
157157
}
158158

159-
var unmarshaled protocol.WorkDoneProgressEnd
159+
var unmarshaled lsp.WorkDoneProgressEnd
160160
err = json.Unmarshal(data, &unmarshaled)
161161
if err != nil {
162162
t.Fatalf("Failed to unmarshal WorkDoneProgressEnd: %v", err)
@@ -169,9 +169,9 @@ func TestProgressSupport(t *testing.T) {
169169

170170
t.Run("ProgressNotificationStructure", func(t *testing.T) {
171171
// Test progress notification structures
172-
beginParams := protocol.ProgressParams{
172+
beginParams := lsp.ProgressParams{
173173
Token: "test-progress",
174-
Value: protocol.WorkDoneProgressBegin{
174+
Value: lsp.WorkDoneProgressBegin{
175175
Kind: "begin",
176176
Title: "Test Operation",
177177
Cancellable: false,
@@ -185,7 +185,7 @@ func TestProgressSupport(t *testing.T) {
185185
t.Fatalf("Failed to marshal progress begin params: %v", err)
186186
}
187187

188-
var unmarshaled protocol.ProgressParams
188+
var unmarshaled lsp.ProgressParams
189189
err = json.Unmarshal(data, &unmarshaled)
190190
if err != nil {
191191
t.Fatalf("Failed to unmarshal progress begin params: %v", err)
@@ -201,11 +201,11 @@ func TestProgressSupport(t *testing.T) {
201201
func TestErrorHandling(t *testing.T) {
202202
t.Run("RequestCancelledError", func(t *testing.T) {
203203
// Test that RequestCancelledError is available
204-
err := protocol.RequestCancelledError
204+
err := lsp.RequestCancelledError
205205
if err == nil {
206206
t.Error("RequestCancelledError should not be nil")
207207
}
208-
208+
209209
// Test that it has the expected message
210210
expectedMsg := "JSON RPC cancelled"
211211
if err.Error() != expectedMsg {
@@ -215,11 +215,11 @@ func TestErrorHandling(t *testing.T) {
215215

216216
t.Run("ErrorCodes", func(t *testing.T) {
217217
// Test that RequestCancelledError exists and can be used
218-
err := protocol.RequestCancelledError
218+
err := lsp.RequestCancelledError
219219
if err == nil {
220220
t.Error("RequestCancelledError should be defined")
221221
}
222-
222+
223223
// Test that it's a proper error
224224
if err.Error() == "" {
225225
t.Error("RequestCancelledError should have a non-empty error message")
@@ -230,4 +230,4 @@ func TestErrorHandling(t *testing.T) {
230230
// Helper function for creating uint32 pointers
231231
func uintPtr(u uint32) *uint32 {
232232
return &u
233-
}
233+
}

0 commit comments

Comments
 (0)