@@ -697,18 +697,36 @@ func (handler *InoHandler) transformClangdResult(method string, uri lsp.Document
697
697
handler .synchronizer .DataMux .RLock ()
698
698
defer handler .synchronizer .DataMux .RUnlock ()
699
699
700
+ cppToIno := uri != "" && uri .AsPath ().EquivalentTo (handler .buildSketchCpp )
701
+
700
702
switch r := result .(type ) {
701
703
case * lsp.Hover :
702
704
// method "textDocument/hover"
703
705
if len (r .Contents .Value ) == 0 {
704
706
return nil
705
707
}
706
- if uri . AsPath (). EquivalentTo ( handler . buildSketchCpp ) {
708
+ if cppToIno {
707
709
_ , * r .Range = handler .sketchMapper .CppToInoRange (* r .Range )
708
710
}
711
+ log .Printf ("<-- hover(%s)" , strconv .Quote (r .Contents .Value ))
712
+ return r
713
+
714
+ case * lsp.CompletionList :
715
+ // method "textDocument/completion"
716
+ newItems := make ([]lsp.CompletionItem , 0 )
717
+
718
+ for _ , item := range r .Items {
719
+ if ! strings .HasPrefix (item .InsertText , "_" ) {
720
+ if cppToIno && item .TextEdit != nil {
721
+ _ , item .TextEdit .Range = handler .sketchMapper .CppToInoRange (item .TextEdit .Range )
722
+ }
723
+ newItems = append (newItems , item )
724
+ }
725
+ }
726
+ r .Items = newItems
727
+ log .Printf ("<-- completion(%d items)" , len (r .Items ))
728
+ return r
709
729
710
- case * lsp.CompletionList : // "textDocument/completion":
711
- handler .cpp2inoCompletionList (r , uri )
712
730
case * []* lsp.CommandOrCodeAction : // "textDocument/codeAction":
713
731
for index := range * r {
714
732
command := (* r )[index ].Command
@@ -774,22 +792,6 @@ func (handler *InoHandler) transformClangdResult(method string, uri lsp.Document
774
792
return result
775
793
}
776
794
777
- func (handler * InoHandler ) cpp2inoCompletionList (list * lsp.CompletionList , uri lsp.DocumentURI ) {
778
- panic ("not implemented" )
779
- // if data, ok := handler.data[uri]; ok {
780
- // newItems := make([]lsp.CompletionItem, 0, len(list.Items))
781
- // for _, item := range list.Items {
782
- // if !strings.HasPrefix(item.InsertText, "_") {
783
- // if item.TextEdit != nil {
784
- // _, item.TextEdit.Range = data.sourceMap.CppToInoRange(item.TextEdit.Range)
785
- // }
786
- // newItems = append(newItems, item)
787
- // }
788
- // }
789
- // list.Items = newItems
790
- // }
791
- }
792
-
793
795
func (handler * InoHandler ) cpp2inoCodeAction (codeAction * lsp.CodeAction , uri lsp.DocumentURI ) {
794
796
panic ("not implemented" )
795
797
// codeAction.Edit = handler.cpp2inoWorkspaceEdit(codeAction.Edit)
0 commit comments