Skip to content

Commit e10fe78

Browse files
U617-025: fix completionItem/resolve requests for runtime symbols
1 parent de05e4a commit e10fe78

File tree

6 files changed

+26
-21
lines changed

6 files changed

+26
-21
lines changed

source/ada/lsp-ada_contexts.adb

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -781,9 +781,10 @@ package body LSP.Ada_Contexts is
781781
-----------------
782782

783783
function Get_Node_At
784-
(Self : Context;
785-
Document : LSP.Ada_Documents.Document_Access;
786-
Position : LSP.Messages.TextDocumentPositionParams'Class)
784+
(Self : Context;
785+
Document : LSP.Ada_Documents.Document_Access;
786+
Position : LSP.Messages.TextDocumentPositionParams'Class;
787+
Project_Only : Boolean := True)
787788
return Libadalang.Analysis.Ada_Node
788789
is
789790
use type Libadalang.Analysis.Ada_Node;
@@ -801,12 +802,13 @@ package body LSP.Ada_Contexts is
801802
-- We're about to get a node from an analysis unit. Either the document
802803
-- is open for it, in which case we read the document, or the
803804
-- document is not open for it. In this case, resolve this only
804-
-- if the file belongs to the project: we don't want to pollute the
805-
-- LAL context with units that are not in the project.
805+
-- if the file belongs to the project (unless if Project_Only is False):
806+
-- we don't want to pollute the LAL context with units that are not in
807+
-- the project.
806808

807809
if Document /= null then
808810
return Document.Get_Node_At (Self, Position.position);
809-
elsif Self.Is_Part_Of_Project (File) then
811+
elsif not Project_Only or else Self.Is_Part_Of_Project (File) then
810812
Unit := Self.LAL_Context.Get_From_File
811813
(Name,
812814
Charset => Self.Get_Charset);

source/ada/lsp-ada_contexts.ads

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,15 @@ package LSP.Ada_Contexts is
8383
return Ada.Strings.UTF_Encoding.UTF_8_String;
8484

8585
function Get_Node_At
86-
(Self : Context;
87-
Document : LSP.Ada_Documents.Document_Access;
88-
Position : LSP.Messages.TextDocumentPositionParams'Class)
86+
(Self : Context;
87+
Document : LSP.Ada_Documents.Document_Access;
88+
Position : LSP.Messages.TextDocumentPositionParams'Class;
89+
Project_Only : Boolean := True)
8990
return Libadalang.Analysis.Ada_Node;
9091
-- Return the node at the given location.
9192
-- If Document is not null, get the location from the document, otherwise
92-
-- get it from the file.
93+
-- get it from the file if it belongs to the context's project when
94+
-- Project_Only is True.
9395

9496
procedure Format
9597
(Self : in out Context;

source/ada/lsp-ada_documents.ads

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ package LSP.Ada_Documents is
148148
Limit : Ada.Containers.Count_Type;
149149
Only_Public : Boolean;
150150
Canceled : access function return Boolean;
151-
Result : in out LSP.Ada_Completions.Completion_Maps.Map);
151+
Result : in out LSP.Ada_Completions.Completion_Maps.Map);
152152
-- See Contexts.Get_Any_Symbol
153153

154154
procedure Get_Folding_Blocks

source/ada/lsp-ada_handlers-invisibles.adb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,12 @@ package body LSP.Ada_Handlers.Invisibles is
138138

139139
for Doc of Self.Handler.Open_Documents loop
140140
Doc.Get_Any_Symbol
141-
(Self.Context.all,
142-
Pattern,
143-
Limit,
144-
True,
145-
Dummy_Canceled'Access,
146-
Names);
141+
(Context => Self.Context.all,
142+
Pattern => Pattern,
143+
Limit => Limit,
144+
Only_Public => True,
145+
Canceled => Dummy_Canceled'Access,
146+
Result => Names);
147147
end loop;
148148
end;
149149
end if;

source/ada/lsp-ada_handlers.adb

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3966,9 +3966,10 @@ package body LSP.Ada_Handlers is
39663966

39673967
C := Self.Contexts.Get_Best_Context (Item.data.Value.uri);
39683968
Node := Get_Node_At
3969-
(Self => C.all,
3970-
Document => null,
3971-
Position => LSP.Messages.TextDocumentPositionParams'
3969+
(Self => C.all,
3970+
Document => null,
3971+
Project_Only => False,
3972+
Position => LSP.Messages.TextDocumentPositionParams'
39723973
(textDocument => (uri => Item.data.Value.uri),
39733974
position => Item.data.Value.span.first));
39743975

testsuite/ada_lsp/completion.invisible.runtime/test.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@
162162
}
163163
}
164164
},
165-
"waitFactor": "40",
165+
"waitFactor": "10",
166166
"wait": [
167167
{
168168
"jsonrpc": "2.0",

0 commit comments

Comments
 (0)