Skip to content

Commit 2e51429

Browse files
Merge branch 'topic/def_code' into 'master'
Add defensive code in LSP completion See merge request eng/ide/ada_language_server!1435
2 parents 59833d1 + 266a9b9 commit 2e51429

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

source/ada/lsp-ada_completions-names.adb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ package body LSP.Ada_Completions.Names is
3939
use all type Libadalang.Analysis.Base_Id;
4040
use all type Libadalang.Common.Ada_Node_Kind_Type;
4141
use type Libadalang.Common.Token_Kind;
42+
use type Libadalang.Common.Token_Reference;
4243

4344
Parent : Libadalang.Analysis.Ada_Node;
4445
-- The parent of the node to complete.
@@ -55,16 +56,17 @@ package body LSP.Ada_Completions.Names is
5556
-- - CallStmt
5657
-- - Dotted_Name
5758
-- - ErrorStmt/LoopStmt/etc.
59+
Previous_Token : constant Libadalang.Common.Token_Reference :=
60+
Libadalang.Common.Previous
61+
(Token, Exclude_Trivia => True);
5862
Error_Dotted_Recovery : constant Boolean :=
5963
Libadalang.Analysis.Is_Keyword
6064
(Token => Token,
6165
Version => Libadalang.Common.Ada_2012)
6266
and then
63-
Libadalang.Common.Kind
64-
(Libadalang.Common.Data
65-
(Libadalang.Common.Previous
66-
(Token, Exclude_Trivia => True)))
67-
= Libadalang.Common.Ada_Dot;
67+
(Previous_Token /= Libadalang.Common.No_Token and then
68+
Libadalang.Common.Kind (Libadalang.Common.Data (Previous_Token))
69+
= Libadalang.Common.Ada_Dot);
6870
begin
6971

7072
-- Get the outermost dotted name of which node is a prefix, so that when

0 commit comments

Comments
 (0)