1818with Ada.Exceptions ;
1919with Ada.Unchecked_Deallocation ;
2020
21- with GNATCOLL.Traces ;
22-
2321with GPR2.Log ;
2422with GPR2.Message ;
2523with GPR2.Path_Name.Set ;
@@ -32,21 +30,9 @@ with LSP.Generic_Cancel_Check;
3230with LSP.GPR_Documentation ;
3331with LSP.GPR_File_Readers ;
3432with LSP.GPR_Files.Symbols ;
35- with LSP.Servers ;
36- with LSP.Server_Notifications.DidChange ;
3733
3834package body LSP.GPR_Handlers is
3935
40- Allow_Incremental_Text_Changes : constant GNATCOLL.Traces.Trace_Handle :=
41- GNATCOLL.Traces.Create (" ALS.ALLOW_INCREMENTAL_TEXT_CHANGES" ,
42- GNATCOLL.Traces.On);
43- -- Trace to activate the support for incremental text changes.
44-
45- procedure Log_Unexpected_Null_Document
46- (Self : access Message_Handler;
47- Where : String);
48- -- Log a message saying we unexpectedly couldn't find an open document
49-
5036 function To_Optional_DiagnosticSeverity
5137 (Level : GPR2.Message.Level_Value)
5238 return LSP.Structures.DiagnosticSeverity_Optional;
@@ -156,115 +142,6 @@ package body LSP.GPR_Handlers is
156142 end if ;
157143 end Get_Parsed_File ;
158144
159- -- --------------------------------
160- -- Log_Unexpected_Null_Document --
161- -- --------------------------------
162-
163- procedure Log_Unexpected_Null_Document
164- (Self : access Message_Handler;
165- Where : String) is
166- begin
167- Self.Tracer.Trace (" Unexpected null document in " & Where);
168- end Log_Unexpected_Null_Document ;
169-
170- -- -----------------------------
171- -- On_DidChange_Notification --
172- -- -----------------------------
173-
174- overriding procedure On_DidChange_Notification
175- (Self : in out Message_Handler;
176- Value : LSP.Structures.DidChangeTextDocumentParams)
177- is
178- use type GNATCOLL.VFS.Virtual_File;
179- use type LSP.GPR_Documents.Document_Access;
180-
181- function Skip_Did_Change return Boolean;
182- -- Check if the following message in the queue is didChange for
183- -- the same document
184-
185- -- -------------------
186- -- Skip_Did_Change --
187- -- -------------------
188-
189- function Skip_Did_Change return Boolean is
190- use type LSP.Servers.Server_Message_Access;
191-
192- subtype DidChange_Notification is
193- LSP.Server_Notifications.DidChange.Notification;
194-
195- Next : constant LSP.Servers.Server_Message_Access :=
196- LSP.Servers.Server'Class (Self.Sender.all ).Look_Ahead_Message;
197-
198- begin
199- if Next = null
200- or else Next.all not in DidChange_Notification'Class
201- then
202- return False;
203- end if ;
204-
205- declare
206- Object : DidChange_Notification'Class renames
207- DidChange_Notification'Class (Next.all );
208- Object_File : constant GNATCOLL.VFS.Virtual_File :=
209- Self.To_File (Object.Params.textDocument.uri);
210- Value_File : constant GNATCOLL.VFS.Virtual_File :=
211- Self.To_File (Value.textDocument.uri);
212-
213- begin
214- return Object_File = Value_File;
215- end ;
216- end Skip_Did_Change ;
217-
218- Document : constant LSP.GPR_Documents.Document_Access :=
219- Self.Get_Open_Document (Value.textDocument.uri);
220-
221- begin
222- if Document = null then
223- Self.Log_Unexpected_Null_Document
224- (" On_DidChangeTextDocument_Notification" );
225- end if ;
226-
227- if Allow_Incremental_Text_Changes.Active then
228- -- If we are applying incremental changes, we can't skip the
229- -- call to Apply_Changes, since this would break synchronization.
230-
231- Document.Apply_Changes
232- (Value.textDocument.version, Value.contentChanges);
233-
234- -- However, we should skip the Indexing part if the next change in
235- -- the queue will re-change the text document.
236-
237- if Skip_Did_Change then
238- return ;
239- end if ;
240-
241- else
242- -- If we are not applying incremental changes, we can skip
243- -- Apply_Changes: the next change will contain the full text.
244-
245- if Skip_Did_Change then
246- return ;
247- end if ;
248-
249- Document.Apply_Changes
250- (Value.textDocument.version, Value.contentChanges);
251- end if ;
252-
253- -- Load gpr tree & prepare diagnostics
254-
255- Document.Load;
256-
257- -- Build GPR file for LSP needs.
258-
259- LSP.GPR_Files.Parse_Modified_Document
260- (File_Provider => Self'Unchecked_Access,
261- Path => Self.To_File (Value.textDocument.uri));
262-
263- -- Emit diagnostics
264-
265- Self.Publish_Diagnostics (Document);
266- end On_DidChange_Notification ;
267-
268145 -- ----------------------------
269146 -- On_DidClose_Notification --
270147 -- ----------------------------
0 commit comments