Skip to content

Commit 082435b

Browse files
committed
On_DidChange_Notification and Server.Look_Ahead_Message
Refs #1141
1 parent 41aa7a5 commit 082435b

File tree

6 files changed

+0
-245
lines changed

6 files changed

+0
-245
lines changed

source/ada/lsp-ada_handlers.adb

Lines changed: 0 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,6 @@ with LSP.Generic_Cancel_Check;
9696
with LSP.GNATCOLL_Tracers.Handle;
9797
with LSP.Predefined_Completion;
9898
with LSP.Search;
99-
with LSP.Server_Notifications.DidChange;
10099
with LSP.Servers;
101100
with LSP.Servers.FS_Watch;
102101
with LSP.Structures.LSPAny_Vectors;
@@ -2031,101 +2030,6 @@ package body LSP.Ada_Handlers is
20312030
Self.Sender.On_Definition_Response (Id, Response);
20322031
end On_Definition_Request;
20332032

2034-
-------------------------------
2035-
-- On_DidChange_Notification --
2036-
-------------------------------
2037-
2038-
overriding procedure On_DidChange_Notification
2039-
(Self : in out Message_Handler;
2040-
Value : LSP.Structures.DidChangeTextDocumentParams)
2041-
is
2042-
use type LSP.Ada_Documents.Document_Access;
2043-
2044-
function Skip_Did_Change return Boolean;
2045-
-- Check if the following message in the queue is didChange for
2046-
-- the same document
2047-
2048-
URI : LSP.Structures.DocumentUri renames Value.textDocument.uri;
2049-
Document : constant LSP.Ada_Documents.Document_Access :=
2050-
Get_Open_Document (Self, URI);
2051-
2052-
---------------------
2053-
-- Skip_Did_Change --
2054-
---------------------
2055-
2056-
function Skip_Did_Change return Boolean is
2057-
use type LSP.Servers.Server_Message_Access;
2058-
2059-
subtype DidChange_Notification is
2060-
LSP.Server_Notifications.DidChange.Notification;
2061-
2062-
Next : constant LSP.Servers.Server_Message_Access :=
2063-
LSP.Servers.Server'Class (Self.Sender.all).Look_Ahead_Message;
2064-
begin
2065-
2066-
if Next = null
2067-
or else Next.all not in DidChange_Notification'Class
2068-
then
2069-
return False;
2070-
end if;
2071-
2072-
declare
2073-
use GNATCOLL.VFS;
2074-
Object : DidChange_Notification'Class renames
2075-
DidChange_Notification'Class (Next.all);
2076-
Object_File : constant Virtual_File := Self.To_File
2077-
(Object.Params.textDocument.uri);
2078-
Value_File : constant Virtual_File := Self.To_File (URI);
2079-
begin
2080-
if Object_File /= Value_File then
2081-
return False;
2082-
end if;
2083-
end;
2084-
2085-
return True;
2086-
end Skip_Did_Change;
2087-
2088-
begin
2089-
if Document = null then
2090-
Self.Tracer.Trace
2091-
("Unexpected null document in On_DidChange_Notification");
2092-
return;
2093-
end if;
2094-
2095-
if Self.Incremental_Text_Changes then
2096-
-- If we are applying incremental changes, we can't skip the
2097-
-- call to Apply_Changes, since this would break synchronization.
2098-
Document.Apply_Changes
2099-
(Value.textDocument.version,
2100-
Value.contentChanges);
2101-
2102-
-- However, we should skip the Indexing part if the next change in
2103-
-- the queue will re-change the text document.
2104-
if Skip_Did_Change then
2105-
return;
2106-
end if;
2107-
else
2108-
-- If we are not applying incremental changes, we can skip
2109-
-- Apply_Changes: the next change will contain the full text.
2110-
if Skip_Did_Change then
2111-
return;
2112-
end if;
2113-
2114-
Document.Apply_Changes
2115-
(Value.textDocument.version,
2116-
Value.contentChanges);
2117-
end if;
2118-
2119-
-- Reindex the document in each of the contexts where it is relevant
2120-
2121-
for Context of Self.Contexts_For_URI (URI) loop
2122-
Context.Index_Document (Document.all);
2123-
end loop;
2124-
2125-
-- Emit diagnostics
2126-
Self.Publish_Diagnostics (Document);
2127-
end On_DidChange_Notification;
2128-
21292033
-------------------------------------------
21302034
-- On_DidChangeWatchedFiles_Notification --
21312035
-------------------------------------------

source/ada/lsp-ada_handlers.ads

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -370,10 +370,6 @@ private
370370
(Self : in out Message_Handler;
371371
Value : LSP.Structures.DidOpenTextDocumentParams);
372372

373-
overriding procedure On_DidChange_Notification
374-
(Self : in out Message_Handler;
375-
Value : LSP.Structures.DidChangeTextDocumentParams);
376-
377373
overriding procedure On_DidClose_Notification
378374
(Self : in out Message_Handler;
379375
Value : LSP.Structures.DidCloseTextDocumentParams);

source/gpr/lsp-gpr_handlers.adb

Lines changed: 0 additions & 123 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
with Ada.Exceptions;
1919
with Ada.Unchecked_Deallocation;
2020

21-
with GNATCOLL.Traces;
22-
2321
with GPR2.Log;
2422
with GPR2.Message;
2523
with GPR2.Path_Name.Set;
@@ -32,21 +30,9 @@ with LSP.Generic_Cancel_Check;
3230
with LSP.GPR_Documentation;
3331
with LSP.GPR_File_Readers;
3432
with LSP.GPR_Files.Symbols;
35-
with LSP.Servers;
36-
with LSP.Server_Notifications.DidChange;
3733

3834
package 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
------------------------------

source/gpr/lsp-gpr_handlers.ads

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,6 @@ private
139139
Id : LSP.Structures.Integer_Or_Virtual_String;
140140
Value : LSP.Structures.DocumentSymbolParams);
141141

142-
overriding procedure On_DidChange_Notification
143-
(Self : in out Message_Handler;
144-
Value : LSP.Structures.DidChangeTextDocumentParams);
145-
146142
overriding procedure On_DidClose_Notification
147143
(Self : in out Message_Handler;
148144
Value : LSP.Structures.DidCloseTextDocumentParams);

source/server/lsp-servers.adb

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
with Ada.Characters.Latin_1;
1919
with Ada.Exceptions;
2020
with Ada.IO_Exceptions;
21-
with Ada.Task_Identification;
2221
with Ada.Unchecked_Deallocation;
2322

2423
with VSS.JSON.Pull_Readers.Simple;
@@ -966,17 +965,4 @@ package body LSP.Servers is
966965
Server.Stop; -- Ask server to stop
967966
end Processing_Task_Type;
968967

969-
------------------------
970-
-- Look_Ahead_Message --
971-
------------------------
972-
973-
function Look_Ahead_Message (Self : Server) return Server_Message_Access is
974-
use type Ada.Task_Identification.Task_Id;
975-
begin
976-
pragma Assert
977-
(Ada.Task_Identification.Current_Task = Self.Processing_Task'Identity);
978-
979-
return Self.Look_Ahead;
980-
end Look_Ahead_Message;
981-
982968
end LSP.Servers;

source/server/lsp-servers.ads

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,6 @@ package LSP.Servers is
9696
subtype Server_Message_Access is LSP.Server_Messages.Server_Message_Access;
9797
-- Message send by a client to a server
9898

99-
function Look_Ahead_Message (Self : Server) return Server_Message_Access;
100-
-- Get next message in the queue if any. Only request/notification
101-
-- handlers are allowed to call this function.
102-
10399
function Input_Queue_Length (Self : Server) return Natural;
104100
-- Return number of messages pending in Input_Queue.
105101
-- For debug purposes only!

0 commit comments

Comments
 (0)