@@ -548,8 +548,7 @@ func (ls *INOLanguageServer) TextDocumentDefinitionReqFromIDE(ctx context.Contex
548
548
ls .readLock (logger , true )
549
549
defer ls .readUnlock (logger )
550
550
551
- ideTextDocPosition := ideParams .TextDocumentPositionParams
552
- clangTextDocPosition , err := ls .ide2ClangTextDocumentPositionParams (logger , ideTextDocPosition )
551
+ clangTextDocPosition , err := ls .ide2ClangTextDocumentPositionParams (logger , ideParams .TextDocumentPositionParams )
553
552
if err != nil {
554
553
logger .Logf ("Error: %s" , err )
555
554
return nil , nil , & jsonrpc.ResponseError {Code : jsonrpc .ErrorCodesInternalError , Message : err .Error ()}
@@ -589,95 +588,94 @@ func (ls *INOLanguageServer) TextDocumentDefinitionReqFromIDE(ctx context.Contex
589
588
return ideLocations , ideLocationLinks , nil
590
589
}
591
590
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)
593
594
ls .readLock (logger , true )
594
595
defer ls .readUnlock (logger )
595
596
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 )
601
598
if err != nil {
602
599
logger .Logf ("Error: %s" , err )
603
600
return nil , nil , & jsonrpc.ResponseError {Code : jsonrpc .ErrorCodesInternalError , Message : err .Error ()}
604
601
}
605
602
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 )
612
609
if err != nil {
613
610
logger .Logf ("clangd communication error: %v" , err )
614
611
ls .Close ()
615
612
return nil , nil , & jsonrpc.ResponseError {Code : jsonrpc .ErrorCodesInternalError , Message : err .Error ()}
616
613
}
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 ()}
620
617
}
621
618
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 )
625
622
if err != nil {
623
+ logger .Logf ("Error: %v" , err )
626
624
ls .Close ()
627
625
return nil , nil , & jsonrpc.ResponseError {Code : jsonrpc .ErrorCodesInternalError , Message : err .Error ()}
628
626
}
629
627
}
630
628
631
- var inoLocationLinks []lsp.LocationLink
632
- if cppLocationLinks != nil {
629
+ var ideLocationLinks []lsp.LocationLink
630
+ if clangLocationLinks != nil {
633
631
panic ("unimplemented" )
634
632
}
635
633
636
- return inoLocations , inoLocationLinks , nil
634
+ return ideLocations , ideLocationLinks , nil
637
635
}
638
636
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 ) {
640
638
ls .readLock (logger , true )
641
639
defer ls .readUnlock (logger )
642
640
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 )
647
642
if err != nil {
648
643
logger .Logf ("Error: %s" , err )
649
644
return nil , nil , & jsonrpc.ResponseError {Code : jsonrpc .ErrorCodesInternalError , Message : err .Error ()}
650
645
}
651
646
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 )
656
653
if err != nil {
657
654
logger .Logf ("clangd communication error: %v" , err )
658
655
ls .Close ()
659
656
return nil , nil , & jsonrpc.ResponseError {Code : jsonrpc .ErrorCodesInternalError , Message : err .Error ()}
660
657
}
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 ()}
664
661
}
665
662
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 )
669
666
if err != nil {
667
+ logger .Logf ("Error: %v" , err )
670
668
ls .Close ()
671
669
return nil , nil , & jsonrpc.ResponseError {Code : jsonrpc .ErrorCodesInternalError , Message : err .Error ()}
672
670
}
673
671
}
674
672
675
673
var inoLocationLinks []lsp.LocationLink
676
- if cppLocationLinks != nil {
674
+ if clangLocationLinks != nil {
677
675
panic ("unimplemented" )
678
676
}
679
677
680
- return inoLocations , inoLocationLinks , nil
678
+ return ideLocations , inoLocationLinks , nil
681
679
}
682
680
683
681
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
691
689
}
692
690
clangURI := clangTextDocumentPosition .TextDocument .URI
693
691
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 )
697
698
if err != nil {
698
699
logger .Logf ("clangd communication ERROR: %v" , err )
699
700
ls .Close ()
@@ -730,16 +731,19 @@ func (ls *INOLanguageServer) TextDocumentDocumentSymbolReqFromIDE(ctx context.Co
730
731
ideTextDocument := ideParams .TextDocument
731
732
732
733
// Convert request for clang
733
- cppTextDocument , err := ls .ide2ClangTextDocumentIdentifier (logger , ideTextDocument )
734
+ clangTextDocument , err := ls .ide2ClangTextDocumentIdentifier (logger , ideTextDocument )
734
735
if err != nil {
735
736
logger .Logf ("Error: %s" , err )
736
737
return nil , nil , & jsonrpc.ResponseError {Code : jsonrpc .ErrorCodesInternalError , Message : err .Error ()}
737
738
}
738
- clangParams := * ideParams
739
- clangParams .TextDocument = cppTextDocument
740
739
741
740
// 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 )
743
747
if err != nil {
744
748
logger .Logf ("clangd communication error: %v" , err )
745
749
ls .Close ()
0 commit comments