@@ -609,7 +609,7 @@ package body LSP.Ada_Documents is
609
609
(Self : Document;
610
610
Span : LSP.Messages.Span;
611
611
New_Text : VSS.Strings.Virtual_String;
612
- Edit : out LSP.Messages.TextEdit_Vector)
612
+ Edit : in out LSP.Messages.TextEdit_Vector)
613
613
is
614
614
use LSP.Types;
615
615
use LSP.Messages;
@@ -1115,68 +1115,50 @@ package body LSP.Ada_Documents is
1115
1115
end loop ;
1116
1116
end Append_PP_Messages ;
1117
1117
1118
- Output : Char_Vector;
1119
-
1120
- PP_Messages : Pp.Scanner.Source_Message_Vector;
1121
-
1122
- Input_Selection_Range : constant Source_Location_Range :=
1123
- (if Span = LSP.Messages.Empty_Span then
1124
- No_Source_Location_Range
1125
- else
1126
- Make_Range
1127
- (Self.Get_Source_Location (Span.first),
1128
- Self.Get_Source_Location (Span.last)));
1129
-
1130
- Output_Selection_Range : Source_Location_Range;
1131
-
1132
- Unit : constant Analysis_Unit :=
1133
- Self.Unit (Context);
1134
- Enclosing_Node : Ada_Node;
1135
-
1136
1118
begin
1137
1119
Context.Trace.Trace (" On Range_Formatting" );
1120
+
1138
1121
Context.Trace.Trace (" Format_Selection" );
1139
- begin
1140
- Format_Selection
1141
- (Main_Unit => Unit,
1142
- Input_Selection_Range => Input_Selection_Range,
1143
- Output => Output,
1144
- Output_Selection_Range => Output_Selection_Range,
1145
- PP_Messages => PP_Messages,
1146
- Formatted_Node => Enclosing_Node,
1147
- PP_Options => PP_Options,
1148
- Force_Source_Line_Breaks => False);
1122
+ declare
1123
+ Unit : constant Analysis_Unit :=
1124
+ Self.Unit (Context);
1125
+ Input_Selection_Range : constant Source_Location_Range :=
1126
+ (if Span = LSP.Messages.Empty_Span then No_Source_Location_Range
1127
+ else Make_Range
1128
+ (Self.Get_Source_Location (Span.first),
1129
+ Self.Get_Source_Location (Span.last)));
1130
+ Partial_Formatting_Edit :
1131
+ constant Laltools.Partial_GNATPP.Partial_Formatting_Edit :=
1132
+ Format_Selection (Unit, Input_Selection_Range, PP_Options);
1149
1133
1150
- exception
1151
- when others =>
1152
- Append_PP_Messages (PP_Messages);
1134
+ begin
1135
+ if not Partial_Formatting_Edit.Diagnostics.Is_Empty then
1136
+ Append_PP_Messages (Partial_Formatting_Edit.Diagnostics);
1137
+ Context.Trace.Trace
1138
+ (" Non empty diagnostics from GNATPP - "
1139
+ & " not continuing with Range_Formatting" );
1153
1140
return False;
1154
- end ;
1141
+ end if ;
1155
1142
1156
- if not PP_Messages.Is_Empty then
1157
- Context.Trace.Trace
1158
- (" Non empty PP_Messages - appending them to Messages" );
1159
- Append_PP_Messages (PP_Messages);
1160
- return False;
1161
- end if ;
1143
+ Context.Trace.Trace (" Computing Range_Formatting Text_Edits" );
1144
+ Edit.Clear;
1145
+ declare
1146
+ Edit_Span : constant LSP.Messages.Span :=
1147
+ Self.To_LSP_Range (Partial_Formatting_Edit.Edit.Location);
1148
+ Edit_Text : constant VSS.Strings.Virtual_String :=
1149
+ VSS.Strings.Conversions.To_Virtual_String
1150
+ (Partial_Formatting_Edit.Edit.Text);
1162
1151
1163
- Context.Trace.Trace (" Computing Range_Formatting Text_Edits" );
1164
- declare
1165
- Edit_Span : constant LSP.Messages.Span :=
1166
- Self.To_LSP_Range (Output_Selection_Range);
1167
- Output_Str : constant String :=
1168
- Char_Vectors.Elems (Output) (1 .. Char_Vectors.Last_Index (Output));
1169
- Edit_Text : constant VSS.Strings.Virtual_String :=
1170
- VSS.Strings.Conversions.To_Virtual_String (Output_Str);
1152
+ begin
1153
+ Edit.Append (TextEdit'(Edit_Span, Edit_Text));
1154
+ end ;
1171
1155
1172
- begin
1173
- Self.Diff_Symbols (Edit_Span, Edit_Text, Edit);
1156
+ return True;
1174
1157
end ;
1175
1158
1176
- return True;
1177
-
1178
1159
exception
1179
- when others =>
1160
+ when E : others =>
1161
+ Log (Self.Trace, E, " in Range_Formatting" );
1180
1162
return False;
1181
1163
end Range_Formatting ;
1182
1164
0 commit comments