@@ -248,6 +248,8 @@ func (s *zkcServer) Initialize(
248248 HoverProvider : true ,
249249 DocumentSymbolProvider : true ,
250250 DefinitionProvider : true ,
251+ ReferencesProvider : true ,
252+ RenameProvider : & protocol.RenameOptions {PrepareProvider : true },
251253 DocumentFormattingProvider : true ,
252254 SignatureHelpProvider : & protocol.SignatureHelpOptions {
253255 TriggerCharacters : []string {"(" , "," },
@@ -756,11 +758,20 @@ func (s *zkcServer) OnTypeFormatting(
756758// rename is valid at the given position and, if so, what range should be
757759// pre-selected in the rename input box. The server may reject the request if
758760// the symbol cannot be renamed (e.g. it is a built-in).
759- // Not yet implemented.
760761func (s * zkcServer ) PrepareRename (
761- _ context.Context , _ * protocol.PrepareRenameParams ,
762+ _ context.Context , params * protocol.PrepareRenameParams ,
762763) (* protocol.Range , error ) {
763- return nil , errNotImplemented
764+ s .mu .RLock ()
765+ text , ok := s .compiler .Source (params .TextDocument .URI .Filename ())
766+ program := s .compiler .Program ()
767+ srcmaps := s .compiler .SourceMaps ()
768+ s .mu .RUnlock ()
769+
770+ if ! ok {
771+ return nil , nil
772+ }
773+
774+ return lsp .PrepareRenameFor (params .TextDocument .URI , text , params .Position , program , srcmaps )
764775}
765776
766777// RangeFormatting handles a textDocument/rangeFormatting request. The client
@@ -778,22 +789,46 @@ func (s *zkcServer) RangeFormatting(
778789// when the user invokes "find all references" on a symbol. The server returns
779790// every location in the workspace where that symbol is used, optionally
780791// including the declaration site itself.
781- // Not yet implemented.
782792func (s * zkcServer ) References (
783- _ context.Context , _ * protocol.ReferenceParams ,
793+ _ context.Context , params * protocol.ReferenceParams ,
784794) ([]protocol.Location , error ) {
785- return nil , errNotImplemented
795+ s .mu .RLock ()
796+ text , ok := s .compiler .Source (params .TextDocument .URI .Filename ())
797+ program := s .compiler .Program ()
798+ srcmaps := s .compiler .SourceMaps ()
799+ s .mu .RUnlock ()
800+
801+ if ! ok {
802+ return nil , nil
803+ }
804+
805+ return lsp .ReferencesFor (
806+ params .TextDocument .URI , text , params .Position ,
807+ params .Context .IncludeDeclaration , program , srcmaps ,
808+ )
786809}
787810
788811// Rename handles a textDocument/rename request. The client sends this when
789812// the user confirms a rename operation (following an optional PrepareRename).
790813// The server returns a workspace edit — a set of text changes across all
791814// affected files — that renames every occurrence of the symbol.
792- // Not yet implemented.
793815func (s * zkcServer ) Rename (
794- _ context.Context , _ * protocol.RenameParams ,
816+ _ context.Context , params * protocol.RenameParams ,
795817) (* protocol.WorkspaceEdit , error ) {
796- return nil , errNotImplemented
818+ s .mu .RLock ()
819+ text , ok := s .compiler .Source (params .TextDocument .URI .Filename ())
820+ program := s .compiler .Program ()
821+ srcmaps := s .compiler .SourceMaps ()
822+ s .mu .RUnlock ()
823+
824+ if ! ok {
825+ return nil , nil
826+ }
827+
828+ return lsp .RenameFor (
829+ params .TextDocument .URI , text , params .Position , params .NewName ,
830+ program , srcmaps ,
831+ )
797832}
798833
799834// SignatureHelp handles a textDocument/signatureHelp request. The client
0 commit comments