Skip to content

Commit

Permalink
split extend server interface from default Server
Browse files Browse the repository at this point in the history
Signed-off-by: Ian Zhang <[email protected]>
  • Loading branch information
ianzhang366 committed Apr 13, 2022
1 parent 65f1d35 commit 5782cc9
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
1 change: 0 additions & 1 deletion internal/lsp/acmelsp/metadata.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (
//metdata is implemented due to the https://github.com/OmniSharp/omnisharp-roslyn/issues/2238

func convertFilePath(p string) (path string) {
fmt.Println(os.TempDir())
path = strings.Replace(p, "$metadata$", fmt.Sprintf("%s/csharp-metadata/", os.TempDir()), 1) //os.TempDir
return
}
Expand Down
2 changes: 2 additions & 0 deletions internal/lsp/acmelsp/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ type proxyServer struct {
fm *FileManager
}

var _ proxy.Server = (*proxyServer)(nil)

func (s *proxyServer) Version(ctx context.Context) (int, error) {
return proxy.Version, nil
}
Expand Down
10 changes: 9 additions & 1 deletion internal/lsp/protocol/tsserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import (
"github.com/fhs/acme-lsp/internal/golang_org_x_tools/xcontext"
)

type Server interface {
type server interface {
DidChangeWorkspaceFolders(context.Context, *DidChangeWorkspaceFoldersParams) error
Initialized(context.Context, *InitializedParams) error
Exit(context.Context) error
Expand Down Expand Up @@ -53,9 +53,17 @@ type Server interface {
Rename(context.Context, *RenameParams) (*WorkspaceEdit, error)
PrepareRename(context.Context, *PrepareRenameParams) (*Range, error)
ExecuteCommand(context.Context, *ExecuteCommandParams) (interface{}, error)
}

type ExtendServer interface {
Metadata(context.Context, *MetadataParams) (*MetaSourceRsponse, error)
}

type Server interface {
server
ExtendServer
}

func (h serverHandler) Deliver(ctx context.Context, r *jsonrpc2.Request, delivered bool) bool {
if delivered {
return false
Expand Down
10 changes: 9 additions & 1 deletion internal/lsp/proxy/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const Version = 1

// Server implements a subset of an LSP protocol server as defined by protocol.Server and
// some custom acme-lsp specific methods.
type Server interface {
type subLspServer interface {
// Version returns the protocol version.
Version(context.Context) (int, error)

Expand Down Expand Up @@ -48,9 +48,17 @@ type Server interface {
SignatureHelp(context.Context, *protocol.SignatureHelpParams) (*protocol.SignatureHelp, error)
DocumentSymbol(context.Context, *protocol.DocumentSymbolParams) ([]protocol.DocumentSymbol, error)
TypeDefinition(context.Context, *protocol.TypeDefinitionParams) ([]protocol.Location, error)
}

type ExtendServer interface {
Metadata(context.Context, *protocol.MetadataParams) (*protocol.MetaSourceRsponse, error)
}

type Server interface {
subLspServer
ExtendServer
}

func (h serverHandler) Deliver(ctx context.Context, r *jsonrpc2.Request, delivered bool) bool {
if delivered {
return false
Expand Down

0 comments on commit 5782cc9

Please sign in to comment.