Skip to content

Commit

Permalink
Merge branch 'mr/pmderodat/reparse-same-buffer' into 'master'
Browse files Browse the repository at this point in the history
Update after a recent internal API change in Langkit

Closes langkit#674

See merge request eng/libadalang/libadalang!1870
  • Loading branch information
pmderodat committed Dec 16, 2024
2 parents 06c13fe + 092ae40 commit 2ad6868
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
15 changes: 10 additions & 5 deletions extensions/src/libadalang-pp_impl.adb
Original file line number Diff line number Diff line change
Expand Up @@ -1147,6 +1147,8 @@ package body Libadalang.PP_Impl is

Syms : Symbol_Table;
-- Symbol table for ``TDH``

Same_Contents : Boolean;
begin
-- If preprocessing is disabled for this file, just copy the input to
-- the output.
Expand Down Expand Up @@ -1176,11 +1178,14 @@ package body Libadalang.PP_Impl is
Syms := Create_Symbol_Table;
Initialize (TDH, Syms, System.Null_Address);
Extract_Tokens
(Input => (Text_Buffer, Buffer.all'Address, Buffer'Length),
With_Trivia => True,
File_Reader => null,
TDH => TDH,
Diagnostics => Diagnostics);
(Input => (Text_Buffer, Buffer.all'Address, Buffer'Length),
With_Trivia => True,
File_Reader => null,
TDH => TDH,
Diagnostics => Diagnostics,
Old_TDH => null,
Same_Contents => Same_Contents);
pragma Assert (not Same_Contents);

-- Go through TDH's tokens and create a list of tokens to emit in the
-- returned source buffer.
Expand Down
6 changes: 6 additions & 0 deletions testsuite/tests/ada_api/prep_parsing/main.adb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ procedure Main is
begin
Put_Line ("== " & Label & " ==");
New_Line;

-- Reparse once with an empty buffer and again using the on-disk source
-- file to make sure reparsing really happens.

U.Reparse (Buffer => "");
U.Reparse;

if U.Has_Diagnostics then
Put_Line ("Diagnostics:");
for D of U.Diagnostics loop
Expand Down

0 comments on commit 2ad6868

Please sign in to comment.