Skip to content

Commit 12933ba

Browse files
committed
Implemented textDocument/didClose method
1 parent 9d7cee6 commit 12933ba

File tree

4 files changed

+93
-61
lines changed

4 files changed

+93
-61
lines changed

source/ada/lsp-ada_contexts.adb

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ package body LSP.Ada_Contexts is
119119
-------------------
120120

121121
not overriding procedure Load_Document
122-
(Self : in out Context;
123-
Item : LSP.Messages.TextDocumentItem)
122+
(Self : in out Context;
123+
Item : LSP.Messages.TextDocumentItem)
124124
is
125125
Object : constant LSP.Ada_Documents.Document_Access :=
126126
new LSP.Ada_Documents.Document;
@@ -129,6 +129,18 @@ package body LSP.Ada_Contexts is
129129
Self.Documents.Insert (Item.uri, Object);
130130
end Load_Document;
131131

132+
---------------------
133+
-- Unload_Document --
134+
---------------------
135+
136+
not overriding procedure Unload_Document
137+
(Self : in out Context;
138+
Item : LSP.Messages.TextDocumentIdentifier)
139+
is
140+
begin
141+
Self.Documents.Delete (Item.uri);
142+
end Unload_Document;
143+
132144
----------------------
133145
-- Get_Source_Files --
134146
----------------------

source/ada/lsp-ada_contexts.ads

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,12 @@ package LSP.Ada_Contexts is
3636
Root : LSP.Types.LSP_String);
3737

3838
not overriding procedure Load_Document
39-
(Self : in out Context;
40-
Item : LSP.Messages.TextDocumentItem);
39+
(Self : in out Context;
40+
Item : LSP.Messages.TextDocumentItem);
41+
42+
not overriding procedure Unload_Document
43+
(Self : in out Context;
44+
Item : LSP.Messages.TextDocumentIdentifier);
4145

4246
not overriding function Get_Document
4347
(Self : Context;

source/ada/lsp-ada_handlers.adb

Lines changed: 55 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,6 @@ package body LSP.Ada_Handlers is
3535
return LSP.Types.LSP_String renames
3636
LSP.Types.To_LSP_String;
3737

38-
-----------------------
39-
-- Exit_Notification --
40-
-----------------------
41-
42-
overriding procedure Exit_Notification (Self : access Message_Handler) is
43-
begin
44-
Self.Server.Stop;
45-
end Exit_Notification;
46-
4738
------------------------
4839
-- Initialize_Request --
4940
------------------------
@@ -55,12 +46,12 @@ package body LSP.Ada_Handlers is
5546
is
5647
Root : LSP.Types.LSP_String;
5748
begin
49+
Response.result.capabilities.textDocumentSync :=
50+
(Is_Set => True, Is_Number => True, Value => LSP.Messages.Full);
5851
Response.result.capabilities.referencesProvider :=
5952
LSP.Types.Optional_True;
6053
Response.result.capabilities.documentSymbolProvider :=
6154
LSP.Types.Optional_True;
62-
Response.result.capabilities.textDocumentSync :=
63-
(Is_Set => True, Is_Number => True, Value => LSP.Messages.Full);
6455

6556
if not LSP.Types.Is_Empty (Value.rootUri) then
6657
Root := Delete (Value.rootUri, 1, 7);
@@ -71,38 +62,6 @@ package body LSP.Ada_Handlers is
7162
Self.Context.Initialize (Root);
7263
end Initialize_Request;
7364

74-
------------------------------
75-
-- Text_Document_Did_Change --
76-
------------------------------
77-
78-
overriding procedure Text_Document_Did_Change
79-
(Self : access Message_Handler;
80-
Value : LSP.Messages.DidChangeTextDocumentParams)
81-
is
82-
Document : constant LSP.Ada_Documents.Document_Access :=
83-
Self.Context.Get_Document (Value.textDocument.uri);
84-
Note : LSP.Messages.PublishDiagnostics_Notification;
85-
begin
86-
Document.Apply_Changes (Value.contentChanges);
87-
Document.Get_Errors (Note.params.diagnostics);
88-
89-
Note.method := +"textDocument/publishDiagnostics";
90-
Note.params.uri := Value.textDocument.uri;
91-
Self.Server.Send_Notification (Note);
92-
end Text_Document_Did_Change;
93-
94-
----------------------------
95-
-- Text_Document_Did_Open --
96-
----------------------------
97-
98-
overriding procedure Text_Document_Did_Open
99-
(Self : access Message_Handler;
100-
Value : LSP.Messages.DidOpenTextDocumentParams)
101-
is
102-
begin
103-
Self.Context.Load_Document (Value.textDocument);
104-
end Text_Document_Did_Open;
105-
10665
--------------------------------------
10766
-- Text_Document_References_Request --
10867
--------------------------------------
@@ -186,4 +145,57 @@ package body LSP.Ada_Handlers is
186145
Document.Get_Symbols (Response.result);
187146
end Text_Document_Symbol_Request;
188147

148+
----------------------------
149+
-- Text_Document_Did_Open --
150+
----------------------------
151+
152+
overriding procedure Text_Document_Did_Open
153+
(Self : access Message_Handler;
154+
Value : LSP.Messages.DidOpenTextDocumentParams)
155+
is
156+
begin
157+
Self.Context.Load_Document (Value.textDocument);
158+
end Text_Document_Did_Open;
159+
160+
------------------------------
161+
-- Text_Document_Did_Change --
162+
------------------------------
163+
164+
overriding procedure Text_Document_Did_Change
165+
(Self : access Message_Handler;
166+
Value : LSP.Messages.DidChangeTextDocumentParams)
167+
is
168+
Document : constant LSP.Ada_Documents.Document_Access :=
169+
Self.Context.Get_Document (Value.textDocument.uri);
170+
Note : LSP.Messages.PublishDiagnostics_Notification;
171+
begin
172+
Document.Apply_Changes (Value.contentChanges);
173+
Document.Get_Errors (Note.params.diagnostics);
174+
175+
Note.method := +"textDocument/publishDiagnostics";
176+
Note.params.uri := Value.textDocument.uri;
177+
Self.Server.Send_Notification (Note);
178+
end Text_Document_Did_Change;
179+
180+
-----------------------------
181+
-- Text_Document_Did_Close --
182+
-----------------------------
183+
184+
overriding procedure Text_Document_Did_Close
185+
(Self : access Message_Handler;
186+
Value : LSP.Messages.DidCloseTextDocumentParams)
187+
is
188+
begin
189+
Self.Context.Unload_Document (Value.textDocument);
190+
end Text_Document_Did_Close;
191+
192+
-----------------------
193+
-- Exit_Notification --
194+
-----------------------
195+
196+
overriding procedure Exit_Notification (Self : access Message_Handler) is
197+
begin
198+
Self.Server.Stop;
199+
end Exit_Notification;
200+
189201
end LSP.Ada_Handlers;

source/ada/lsp-ada_handlers.ads

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -39,30 +39,34 @@ private
3939
null;
4040
end record;
4141

42-
overriding procedure Exit_Notification
43-
(Self : access Message_Handler);
44-
4542
overriding procedure Initialize_Request
4643
(Self : access Message_Handler;
4744
Value : LSP.Messages.InitializeParams;
4845
Response : in out LSP.Messages.Initialize_Response);
4946

50-
overriding procedure Text_Document_Did_Change
51-
(Self : access Message_Handler;
52-
Value : LSP.Messages.DidChangeTextDocumentParams);
53-
54-
overriding procedure Text_Document_Did_Open
55-
(Self : access Message_Handler;
56-
Value : LSP.Messages.DidOpenTextDocumentParams);
57-
5847
overriding procedure Text_Document_References_Request
59-
(Self : access Message_Handler;
60-
Value : LSP.Messages.ReferenceParams;
61-
Response : in out LSP.Messages.Location_Response);
48+
(Self : access Message_Handler;
49+
Value : LSP.Messages.ReferenceParams;
50+
Response : in out LSP.Messages.Location_Response);
6251

6352
overriding procedure Text_Document_Symbol_Request
6453
(Self : access Message_Handler;
6554
Value : LSP.Messages.DocumentSymbolParams;
6655
Response : in out LSP.Messages.Symbol_Response);
6756

57+
overriding procedure Text_Document_Did_Open
58+
(Self : access Message_Handler;
59+
Value : LSP.Messages.DidOpenTextDocumentParams);
60+
61+
overriding procedure Text_Document_Did_Change
62+
(Self : access Message_Handler;
63+
Value : LSP.Messages.DidChangeTextDocumentParams);
64+
65+
overriding procedure Text_Document_Did_Close
66+
(Self : access Message_Handler;
67+
Value : LSP.Messages.DidCloseTextDocumentParams);
68+
69+
overriding procedure Exit_Notification
70+
(Self : access Message_Handler);
71+
6872
end LSP.Ada_Handlers;

0 commit comments

Comments
 (0)