@@ -18,9 +18,9 @@ use lsp_server::ErrorCode;
1818use lsp_types:: {
1919 CallHierarchyIncomingCall , CallHierarchyIncomingCallsParams , CallHierarchyItem ,
2020 CallHierarchyOutgoingCall , CallHierarchyOutgoingCallsParams , CallHierarchyPrepareParams ,
21- CodeLens , CompletionItem , Contents , FoldingRange , FoldingRangeParams , InlayHint ,
22- InlayHintParams , Location , LocationLink , Position , PrepareRenameResult , Range , RenameParams ,
23- ResourceOperationKind , SemanticTokens , SemanticTokensDeltaParams ,
21+ CodeLens , CompletionItem , Contents , DocumentChange , FoldingRange , FoldingRangeParams ,
22+ InlayHint , InlayHintParams , Location , LocationLink , Position , PrepareRenameResult , Range ,
23+ RenameParams , ResourceOperationKind , SemanticTokens , SemanticTokensDeltaParams ,
2424 SemanticTokensDeltaRequestResponse , SemanticTokensParams , SemanticTokensRangeParams ,
2525 SymbolInformation , SymbolTag , TextDocumentIdentifier , Uri , WorkspaceEdit ,
2626} ;
@@ -252,7 +252,7 @@ pub(crate) fn handle_run_test(
252252 params : lsp_ext:: RunTestParams ,
253253) -> anyhow:: Result < ( ) > {
254254 if let Some ( _session) = state. test_run_session . take ( ) {
255- state. send_notification :: < lsp_ext:: EndRunTest > ( ( ) ) ;
255+ state. send_notification :: < lsp_ext:: EndRunTestNotification > ( ( ) ) ;
256256 }
257257
258258 let mut handles = vec ! [ ] ;
@@ -1416,7 +1416,7 @@ pub(crate) fn handle_rename(
14161416
14171417 if let Some ( changes) = workspace_edit. document_changes . as_ref ( ) {
14181418 for change in changes {
1419- resource_ops_supported ( & snap. config , resolve_resource_op ( change) ) ?;
1419+ resource_ops_supported ( & snap. config , change) ?;
14201420 }
14211421 }
14221422
@@ -1542,8 +1542,8 @@ pub(crate) fn handle_code_action(
15421542 let changes = code_action. edit . as_ref ( ) . and_then ( |it| it. document_changes . as_ref ( ) ) ;
15431543 if let Some ( changes) = changes {
15441544 for change in changes {
1545- if let lsp_ext:: SnippetDocumentChangeOperation :: Change ( res_op ) = change {
1546- resource_ops_supported ( & snap. config , resolve_resource_op ( res_op ) ) ?
1545+ if let lsp_ext:: SnippetDocumentChangeOperation :: Change ( change ) = change {
1546+ resource_ops_supported ( & snap. config , change ) ?
15471547 }
15481548 }
15491549 }
@@ -1645,8 +1645,8 @@ pub(crate) fn handle_code_action_resolve(
16451645 && let Some ( changes) = edit. document_changes . as_ref ( )
16461646 {
16471647 for change in changes {
1648- if let lsp_ext:: SnippetDocumentChangeOperation :: Change ( res_op ) = change {
1649- resource_ops_supported ( & snap. config , resolve_resource_op ( res_op ) ) ?
1648+ if let lsp_ext:: SnippetDocumentChangeOperation :: Change ( change ) = change {
1649+ resource_ops_supported ( & snap. config , change ) ?
16501650 }
16511651 }
16521652 }
@@ -2669,14 +2669,20 @@ fn crate_path(root_file_path: &VfsPath) -> Option<VfsPath> {
26692669 None
26702670}
26712671
2672- fn resource_ops_supported ( config : & Config , kind : ResourceOperationKind ) -> anyhow:: Result < ( ) > {
2673- if !matches ! ( config. workspace_edit_resource_operations( ) , Some ( resops) if resops. contains( & kind) )
2672+ fn resource_ops_supported ( config : & Config , kind : & DocumentChange ) -> anyhow:: Result < ( ) > {
2673+ let op = match kind {
2674+ lsp_types:: DocumentChange :: CreateFile ( _) => ResourceOperationKind :: Create ,
2675+ lsp_types:: DocumentChange :: RenameFile ( _) => ResourceOperationKind :: Rename ,
2676+ lsp_types:: DocumentChange :: DeleteFile ( _) => ResourceOperationKind :: Delete ,
2677+ lsp_types:: DocumentChange :: TextDocumentEdit ( _) => return Ok ( ( ) ) ,
2678+ } ;
2679+ if !matches ! ( config. workspace_edit_resource_operations( ) , Some ( resops) if resops. contains( & op) )
26742680 {
26752681 return Err ( LspError :: new (
26762682 ErrorCode :: RequestFailed as i32 ,
26772683 format ! (
26782684 "Client does not support {} capability." ,
2679- match kind {
2685+ match op {
26802686 ResourceOperationKind :: Create => "create" ,
26812687 ResourceOperationKind :: Rename => "rename" ,
26822688 ResourceOperationKind :: Delete => "delete" ,
@@ -2689,15 +2695,6 @@ fn resource_ops_supported(config: &Config, kind: ResourceOperationKind) -> anyho
26892695 Ok ( ( ) )
26902696}
26912697
2692- fn resolve_resource_op ( op : & lsp_types:: DocumentChange ) -> ResourceOperationKind {
2693- match op {
2694- lsp_types:: DocumentChange :: CreateFile ( _) => ResourceOperationKind :: Create ,
2695- lsp_types:: DocumentChange :: RenameFile ( _) => ResourceOperationKind :: Rename ,
2696- lsp_types:: DocumentChange :: DeleteFile ( _) => ResourceOperationKind :: Delete ,
2697- lsp_types:: DocumentChange :: TextDocumentEdit ( _) => todo ! ( ) ,
2698- }
2699- }
2700-
27012698pub ( crate ) fn diff ( left : & str , right : & str ) -> TextEdit {
27022699 use dissimilar:: Chunk ;
27032700
0 commit comments