Skip to content

Commit a5d6bfd

Browse files
committed
More variable naming adjustments...
1 parent d46307c commit a5d6bfd

File tree

1 file changed

+51
-47
lines changed

1 file changed

+51
-47
lines changed

Diff for: ls/ls.go

+51-47
Original file line numberDiff line numberDiff line change
@@ -548,8 +548,7 @@ func (ls *INOLanguageServer) TextDocumentDefinitionReqFromIDE(ctx context.Contex
548548
ls.readLock(logger, true)
549549
defer ls.readUnlock(logger)
550550

551-
ideTextDocPosition := ideParams.TextDocumentPositionParams
552-
clangTextDocPosition, err := ls.ide2ClangTextDocumentPositionParams(logger, ideTextDocPosition)
551+
clangTextDocPosition, err := ls.ide2ClangTextDocumentPositionParams(logger, ideParams.TextDocumentPositionParams)
553552
if err != nil {
554553
logger.Logf("Error: %s", err)
555554
return nil, nil, &jsonrpc.ResponseError{Code: jsonrpc.ErrorCodesInternalError, Message: err.Error()}
@@ -589,95 +588,94 @@ func (ls *INOLanguageServer) TextDocumentDefinitionReqFromIDE(ctx context.Contex
589588
return ideLocations, ideLocationLinks, nil
590589
}
591590

592-
func (ls *INOLanguageServer) TextDocumentTypeDefinitionReqFromIDE(ctx context.Context, logger jsonrpc.FunctionLogger, inoParams *lsp.TypeDefinitionParams) ([]lsp.Location, []lsp.LocationLink, *jsonrpc.ResponseError) {
591+
func (ls *INOLanguageServer) TextDocumentTypeDefinitionReqFromIDE(ctx context.Context, logger jsonrpc.FunctionLogger, ideParams *lsp.TypeDefinitionParams) ([]lsp.Location, []lsp.LocationLink, *jsonrpc.ResponseError) {
592+
// XXX: This capability is not advertised in the initialization message (clangd
593+
// does not advetise it either, so maybe we should just not implement it)
593594
ls.readLock(logger, true)
594595
defer ls.readUnlock(logger)
595596

596-
inoTextDocumentPosition := inoParams.TextDocumentPositionParams
597-
598-
logger.Logf("%s", inoTextDocumentPosition)
599-
// inoURI := inoTextDocumentPosition.TextDocument.URI
600-
cppTextDocumentPosition, err := ls.ide2ClangTextDocumentPositionParams(logger, inoTextDocumentPosition)
597+
cppTextDocumentPosition, err := ls.ide2ClangTextDocumentPositionParams(logger, ideParams.TextDocumentPositionParams)
601598
if err != nil {
602599
logger.Logf("Error: %s", err)
603600
return nil, nil, &jsonrpc.ResponseError{Code: jsonrpc.ErrorCodesInternalError, Message: err.Error()}
604601
}
605602

606-
// cppURI := cppTextDocumentPosition.TextDocument.URI
607-
logger.Logf("-> %s", cppTextDocumentPosition)
608-
609-
cppParams := *inoParams
610-
cppParams.TextDocumentPositionParams = cppTextDocumentPosition
611-
cppLocations, cppLocationLinks, cppErr, err := ls.Clangd.conn.TextDocumentTypeDefinition(ctx, &cppParams)
603+
clangParams := &lsp.TypeDefinitionParams{
604+
TextDocumentPositionParams: cppTextDocumentPosition,
605+
WorkDoneProgressParams: ideParams.WorkDoneProgressParams,
606+
PartialResultParams: ideParams.PartialResultParams,
607+
}
608+
clangLocations, clangLocationLinks, clangErr, err := ls.Clangd.conn.TextDocumentTypeDefinition(ctx, clangParams)
612609
if err != nil {
613610
logger.Logf("clangd communication error: %v", err)
614611
ls.Close()
615612
return nil, nil, &jsonrpc.ResponseError{Code: jsonrpc.ErrorCodesInternalError, Message: err.Error()}
616613
}
617-
if cppErr != nil {
618-
logger.Logf("clangd response error: %v", cppErr.AsError())
619-
return nil, nil, &jsonrpc.ResponseError{Code: jsonrpc.ErrorCodesInternalError, Message: cppErr.AsError().Error()}
614+
if clangErr != nil {
615+
logger.Logf("clangd response error: %v", clangErr.AsError())
616+
return nil, nil, &jsonrpc.ResponseError{Code: jsonrpc.ErrorCodesInternalError, Message: clangErr.AsError().Error()}
620617
}
621618

622-
var inoLocations []lsp.Location
623-
if cppLocations != nil {
624-
inoLocations, err = ls.clang2IdeLocationsArray(logger, cppLocations)
619+
var ideLocations []lsp.Location
620+
if clangLocations != nil {
621+
ideLocations, err = ls.clang2IdeLocationsArray(logger, clangLocations)
625622
if err != nil {
623+
logger.Logf("Error: %v", err)
626624
ls.Close()
627625
return nil, nil, &jsonrpc.ResponseError{Code: jsonrpc.ErrorCodesInternalError, Message: err.Error()}
628626
}
629627
}
630628

631-
var inoLocationLinks []lsp.LocationLink
632-
if cppLocationLinks != nil {
629+
var ideLocationLinks []lsp.LocationLink
630+
if clangLocationLinks != nil {
633631
panic("unimplemented")
634632
}
635633

636-
return inoLocations, inoLocationLinks, nil
634+
return ideLocations, ideLocationLinks, nil
637635
}
638636

639-
func (ls *INOLanguageServer) TextDocumentImplementationReqFromIDE(ctx context.Context, logger jsonrpc.FunctionLogger, inoParams *lsp.ImplementationParams) ([]lsp.Location, []lsp.LocationLink, *jsonrpc.ResponseError) {
637+
func (ls *INOLanguageServer) TextDocumentImplementationReqFromIDE(ctx context.Context, logger jsonrpc.FunctionLogger, ideParams *lsp.ImplementationParams) ([]lsp.Location, []lsp.LocationLink, *jsonrpc.ResponseError) {
640638
ls.readLock(logger, true)
641639
defer ls.readUnlock(logger)
642640

643-
inoTextDocumentPosition := inoParams.TextDocumentPositionParams
644-
logger.Logf("%s", inoTextDocumentPosition)
645-
646-
cppTextDocumentPosition, err := ls.ide2ClangTextDocumentPositionParams(logger, inoTextDocumentPosition)
641+
cppTextDocumentPosition, err := ls.ide2ClangTextDocumentPositionParams(logger, ideParams.TextDocumentPositionParams)
647642
if err != nil {
648643
logger.Logf("Error: %s", err)
649644
return nil, nil, &jsonrpc.ResponseError{Code: jsonrpc.ErrorCodesInternalError, Message: err.Error()}
650645
}
651646

652-
logger.Logf("-> %s", cppTextDocumentPosition)
653-
cppParams := *inoParams
654-
cppParams.TextDocumentPositionParams = cppTextDocumentPosition
655-
cppLocations, cppLocationLinks, cppErr, err := ls.Clangd.conn.TextDocumentImplementation(ctx, &cppParams)
647+
clangParams := &lsp.ImplementationParams{
648+
TextDocumentPositionParams: cppTextDocumentPosition,
649+
WorkDoneProgressParams: ideParams.WorkDoneProgressParams,
650+
PartialResultParams: ideParams.PartialResultParams,
651+
}
652+
clangLocations, clangLocationLinks, clangErr, err := ls.Clangd.conn.TextDocumentImplementation(ctx, clangParams)
656653
if err != nil {
657654
logger.Logf("clangd communication error: %v", err)
658655
ls.Close()
659656
return nil, nil, &jsonrpc.ResponseError{Code: jsonrpc.ErrorCodesInternalError, Message: err.Error()}
660657
}
661-
if cppErr != nil {
662-
logger.Logf("clangd response error: %v", cppErr.AsError())
663-
return nil, nil, &jsonrpc.ResponseError{Code: jsonrpc.ErrorCodesInternalError, Message: cppErr.AsError().Error()}
658+
if clangErr != nil {
659+
logger.Logf("clangd response error: %v", clangErr.AsError())
660+
return nil, nil, &jsonrpc.ResponseError{Code: jsonrpc.ErrorCodesInternalError, Message: clangErr.AsError().Error()}
664661
}
665662

666-
var inoLocations []lsp.Location
667-
if cppLocations != nil {
668-
inoLocations, err = ls.clang2IdeLocationsArray(logger, cppLocations)
663+
var ideLocations []lsp.Location
664+
if clangLocations != nil {
665+
ideLocations, err = ls.clang2IdeLocationsArray(logger, clangLocations)
669666
if err != nil {
667+
logger.Logf("Error: %v", err)
670668
ls.Close()
671669
return nil, nil, &jsonrpc.ResponseError{Code: jsonrpc.ErrorCodesInternalError, Message: err.Error()}
672670
}
673671
}
674672

675673
var inoLocationLinks []lsp.LocationLink
676-
if cppLocationLinks != nil {
674+
if clangLocationLinks != nil {
677675
panic("unimplemented")
678676
}
679677

680-
return inoLocations, inoLocationLinks, nil
678+
return ideLocations, inoLocationLinks, nil
681679
}
682680

683681
func (ls *INOLanguageServer) TextDocumentDocumentHighlightReqFromIDE(ctx context.Context, logger jsonrpc.FunctionLogger, ideParams *lsp.DocumentHighlightParams) ([]lsp.DocumentHighlight, *jsonrpc.ResponseError) {
@@ -691,9 +689,12 @@ func (ls *INOLanguageServer) TextDocumentDocumentHighlightReqFromIDE(ctx context
691689
}
692690
clangURI := clangTextDocumentPosition.TextDocument.URI
693691

694-
clangParams := *ideParams
695-
clangParams.TextDocumentPositionParams = clangTextDocumentPosition
696-
clangHighlights, clangErr, err := ls.Clangd.conn.TextDocumentDocumentHighlight(ctx, &clangParams)
692+
clangParams := &lsp.DocumentHighlightParams{
693+
TextDocumentPositionParams: clangTextDocumentPosition,
694+
WorkDoneProgressParams: ideParams.WorkDoneProgressParams,
695+
PartialResultParams: ideParams.PartialResultParams,
696+
}
697+
clangHighlights, clangErr, err := ls.Clangd.conn.TextDocumentDocumentHighlight(ctx, clangParams)
697698
if err != nil {
698699
logger.Logf("clangd communication ERROR: %v", err)
699700
ls.Close()
@@ -730,16 +731,19 @@ func (ls *INOLanguageServer) TextDocumentDocumentSymbolReqFromIDE(ctx context.Co
730731
ideTextDocument := ideParams.TextDocument
731732

732733
// Convert request for clang
733-
cppTextDocument, err := ls.ide2ClangTextDocumentIdentifier(logger, ideTextDocument)
734+
clangTextDocument, err := ls.ide2ClangTextDocumentIdentifier(logger, ideTextDocument)
734735
if err != nil {
735736
logger.Logf("Error: %s", err)
736737
return nil, nil, &jsonrpc.ResponseError{Code: jsonrpc.ErrorCodesInternalError, Message: err.Error()}
737738
}
738-
clangParams := *ideParams
739-
clangParams.TextDocument = cppTextDocument
740739

741740
// Send request to clang
742-
clangDocSymbols, clangSymbolsInformation, clangErr, err := ls.Clangd.conn.TextDocumentDocumentSymbol(ctx, &clangParams)
741+
clangParams := &lsp.DocumentSymbolParams{
742+
TextDocument: clangTextDocument,
743+
WorkDoneProgressParams: ideParams.WorkDoneProgressParams,
744+
PartialResultParams: ideParams.PartialResultParams,
745+
}
746+
clangDocSymbols, clangSymbolsInformation, clangErr, err := ls.Clangd.conn.TextDocumentDocumentSymbol(ctx, clangParams)
743747
if err != nil {
744748
logger.Logf("clangd communication error: %v", err)
745749
ls.Close()

0 commit comments

Comments
 (0)