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