@@ -697,18 +697,36 @@ func (handler *InoHandler) transformClangdResult(method string, uri lsp.Document
697697 handler .synchronizer .DataMux .RLock ()
698698 defer handler .synchronizer .DataMux .RUnlock ()
699699
700+ cppToIno := uri != "" && uri .AsPath ().EquivalentTo (handler .buildSketchCpp )
701+
700702 switch r := result .(type ) {
701703 case * lsp.Hover :
702704 // method "textDocument/hover"
703705 if len (r .Contents .Value ) == 0 {
704706 return nil
705707 }
706- if uri . AsPath (). EquivalentTo ( handler . buildSketchCpp ) {
708+ if cppToIno {
707709 _ , * r .Range = handler .sketchMapper .CppToInoRange (* r .Range )
708710 }
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
709729
710- case * lsp.CompletionList : // "textDocument/completion":
711- handler .cpp2inoCompletionList (r , uri )
712730 case * []* lsp.CommandOrCodeAction : // "textDocument/codeAction":
713731 for index := range * r {
714732 command := (* r )[index ].Command
@@ -774,22 +792,6 @@ func (handler *InoHandler) transformClangdResult(method string, uri lsp.Document
774792 return result
775793}
776794
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-
793795func (handler * InoHandler ) cpp2inoCodeAction (codeAction * lsp.CodeAction , uri lsp.DocumentURI ) {
794796 panic ("not implemented" )
795797 // codeAction.Edit = handler.cpp2inoWorkspaceEdit(codeAction.Edit)
0 commit comments