@@ -20,9 +20,9 @@ use lsp_types::{
2020 CallHierarchyOutgoingCall , CallHierarchyOutgoingCallsParams , CallHierarchyPrepareParams ,
2121 CodeLens , CompletionItem , Contents , FoldingRange , FoldingRangeParams , InlayHint ,
2222 InlayHintParams , Location , LocationLink , Position , PrepareRenameResult , Range , RenameParams ,
23- ResourceOperationKind , SemanticTokens , SemanticTokensDeltaParams ,
24- SemanticTokensDeltaRequestResponse , SemanticTokensParams , SemanticTokensRangeParams ,
25- SymbolInformation , SymbolTag , TextDocumentIdentifier , Uri , WorkspaceEdit ,
23+ SemanticTokens , SemanticTokensDeltaParams , SemanticTokensDeltaRequestResponse ,
24+ SemanticTokensParams , SemanticTokensRangeParams , SymbolInformation , SymbolTag ,
25+ TextDocumentIdentifier , Uri , WorkspaceEdit ,
2626} ;
2727use paths:: Utf8PathBuf ;
2828use project_model:: { CargoWorkspace , ManifestPath , ProjectWorkspaceKind , TargetKind } ;
@@ -33,9 +33,7 @@ use triomphe::Arc;
3333use vfs:: { AbsPath , AbsPathBuf , FileId , VfsPath } ;
3434
3535use crate :: {
36- config:: {
37- ClientCommandsConfig , Config , HoverActionsConfig , RustfmtConfig , WorkspaceSymbolConfig ,
38- } ,
36+ config:: { ClientCommandsConfig , HoverActionsConfig , RustfmtConfig , WorkspaceSymbolConfig } ,
3937 diagnostics:: convert_diagnostic,
4038 global_state:: { FetchWorkspaceRequest , GlobalState , GlobalStateSnapshot } ,
4139 line_index:: LineEndings ,
@@ -1414,12 +1412,6 @@ pub(crate) fn handle_rename(
14141412
14151413 let workspace_edit = to_proto:: workspace_edit ( & snap, change) ?;
14161414
1417- if let Some ( changes) = workspace_edit. document_changes . as_ref ( ) {
1418- for change in changes {
1419- resource_ops_supported ( & snap. config , resolve_resource_op ( change) ) ?;
1420- }
1421- }
1422-
14231415 Ok ( Some ( workspace_edit) )
14241416}
14251417
@@ -1537,17 +1529,6 @@ pub(crate) fn handle_code_action(
15371529 None
15381530 } ;
15391531 let code_action = to_proto:: code_action ( & snap, & client_commands, assist, resolve_data) ?;
1540-
1541- // Check if the client supports the necessary `ResourceOperation`s.
1542- let changes = code_action. edit . as_ref ( ) . and_then ( |it| it. document_changes . as_ref ( ) ) ;
1543- if let Some ( changes) = changes {
1544- 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) ) ?
1547- }
1548- }
1549- }
1550-
15511532 res. push ( code_action)
15521533 }
15531534
@@ -1640,17 +1621,6 @@ pub(crate) fn handle_code_action_resolve(
16401621 let ca = to_proto:: code_action ( & snap, & snap. config . client_commands ( ) , assist. clone ( ) , None ) ?;
16411622 code_action. edit = ca. edit ;
16421623 code_action. command = ca. command ;
1643-
1644- if let Some ( edit) = code_action. edit . as_ref ( )
1645- && let Some ( changes) = edit. document_changes . as_ref ( )
1646- {
1647- 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) ) ?
1650- }
1651- }
1652- }
1653-
16541624 Ok ( code_action)
16551625}
16561626
@@ -2669,35 +2639,6 @@ fn crate_path(root_file_path: &VfsPath) -> Option<VfsPath> {
26692639 None
26702640}
26712641
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) )
2674- {
2675- return Err ( LspError :: new (
2676- ErrorCode :: RequestFailed as i32 ,
2677- format ! (
2678- "Client does not support {} capability." ,
2679- match kind {
2680- ResourceOperationKind :: Create => "create" ,
2681- ResourceOperationKind :: Rename => "rename" ,
2682- ResourceOperationKind :: Delete => "delete" ,
2683- }
2684- ) ,
2685- )
2686- . into ( ) ) ;
2687- }
2688-
2689- Ok ( ( ) )
2690- }
2691-
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-
27012642pub ( crate ) fn diff ( left : & str , right : & str ) -> TextEdit {
27022643 use dissimilar:: Chunk ;
27032644
0 commit comments