@@ -40,7 +40,7 @@ use crate::{
4040 self , InlayHint , InlayHintsParams , PositionOrRange , ViewCrateGraphParams ,
4141 WorkspaceSymbolParams ,
4242 } ,
43- lsp_utils:: all_edits_are_disjoint,
43+ lsp_utils:: { all_edits_are_disjoint, invalid_params_error } ,
4444 to_proto, LspError , Result ,
4545} ;
4646
@@ -767,9 +767,8 @@ pub(crate) fn handle_completion_resolve(
767767 let _p = profile:: span ( "handle_completion_resolve" ) ;
768768
769769 if !all_edits_are_disjoint ( & original_completion, & [ ] ) {
770- return Err ( LspError :: new (
771- ErrorCode :: InvalidParams as i32 ,
772- "Received a completion with overlapping edits, this is not LSP-compliant" . into ( ) ,
770+ return Err ( invalid_params_error (
771+ "Received a completion with overlapping edits, this is not LSP-compliant" . to_string ( ) ,
773772 )
774773 . into ( ) ) ;
775774 }
@@ -1038,10 +1037,7 @@ pub(crate) fn handle_code_action_resolve(
10381037 let _p = profile:: span ( "handle_code_action_resolve" ) ;
10391038 let params = match code_action. data . take ( ) {
10401039 Some ( it) => it,
1041- None => Err ( LspError {
1042- code : lsp_server:: ErrorCode :: InvalidParams as i32 ,
1043- message : format ! ( "code action without data" ) ,
1044- } ) ?,
1040+ None => return Err ( invalid_params_error ( format ! ( "code action without data" ) ) . into ( ) ) ,
10451041 } ;
10461042
10471043 let file_id = from_proto:: file_id ( & snap, & params. code_action_params . text_document . uri ) ?;
@@ -1059,10 +1055,10 @@ pub(crate) fn handle_code_action_resolve(
10591055 let ( assist_index, assist_resolve) = match parse_action_id ( & params. id ) {
10601056 Ok ( parsed_data) => parsed_data,
10611057 Err ( e) => {
1062- return Err ( LspError :: new (
1063- ErrorCode :: InvalidParams as i32 ,
1064- format ! ( "Failed to parse action id string '{}': {}" , params. id, e) ,
1065- )
1058+ return Err ( invalid_params_error ( format ! (
1059+ "Failed to parse action id string '{}': {}" ,
1060+ params. id, e
1061+ ) )
10661062 . into ( ) )
10671063 }
10681064 } ;
@@ -1079,23 +1075,17 @@ pub(crate) fn handle_code_action_resolve(
10791075
10801076 let assist = match assists. get ( assist_index) {
10811077 Some ( assist) => assist,
1082- None => return Err ( LspError :: new (
1083- ErrorCode :: InvalidParams as i32 ,
1084- format ! (
1085- "Failed to find the assist for index {} provided by the resolve request. Resolve request assist id: {}" ,
1086- assist_index, params. id,
1087- ) ,
1088- )
1078+ None => return Err ( invalid_params_error ( format ! (
1079+ "Failed to find the assist for index {} provided by the resolve request. Resolve request assist id: {}" ,
1080+ assist_index, params. id,
1081+ ) )
10891082 . into ( ) )
10901083 } ;
10911084 if assist. id . 0 != expected_assist_id || assist. id . 1 != expected_kind {
1092- return Err ( LspError :: new (
1093- ErrorCode :: InvalidParams as i32 ,
1094- format ! (
1095- "Mismatching assist at index {} for the resolve parameters given. Resolve request assist id: {}, actual id: {:?}." ,
1096- assist_index, params. id, assist. id
1097- ) ,
1098- )
1085+ return Err ( invalid_params_error ( format ! (
1086+ "Mismatching assist at index {} for the resolve parameters given. Resolve request assist id: {}, actual id: {:?}." ,
1087+ assist_index, params. id, assist. id
1088+ ) )
10991089 . into ( ) ) ;
11001090 }
11011091 let edit = to_proto:: code_action ( & snap, assist. clone ( ) , None ) ?. edit ;
0 commit comments