-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhandler.go
51 lines (40 loc) · 1.58 KB
/
handler.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package lsp
import "github.com/armsnyder/lsp/types"
//go:generate go run go.uber.org/mock/mockgen@v0.4.0 -source handler.go -destination internal/mocks/handler.go -package mocks
// Handler is an interface for handling LSP requests.
type Handler interface {
Capabilities() types.ServerCapabilities
HandleOpen(params types.DidOpenTextDocumentParams) error
HandleClose(params types.DidCloseTextDocumentParams) error
HandleChange(params types.DidChangeTextDocumentParams) error
HandleDefinition(params types.DefinitionParams) ([]types.Location, error)
HandleReferences(params types.ReferenceParams) ([]types.Location, error)
}
// NopHandler can be embedded in a struct to provide no-op implementations of
// ununsed Handler methods.
type NopHandler struct{}
// Capabilities implements Handler.
func (NopHandler) Capabilities() types.ServerCapabilities {
return types.ServerCapabilities{}
}
// HandleOpen implements Handler.
func (NopHandler) HandleOpen(types.DidOpenTextDocumentParams) error {
return nil
}
// HandleClose implements Handler.
func (NopHandler) HandleClose(types.DidCloseTextDocumentParams) error {
return nil
}
// HandleChange implements Handler.
func (NopHandler) HandleChange(types.DidChangeTextDocumentParams) error {
return nil
}
// HandleDefinition implements Handler.
func (NopHandler) HandleDefinition(types.DefinitionParams) ([]types.Location, error) {
return []types.Location{}, nil
}
// HandleReferences implements Handler.
func (NopHandler) HandleReferences(types.ReferenceParams) ([]types.Location, error) {
return []types.Location{}, nil
}
var _ Handler = NopHandler{}