Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing Value of SLOC #492

Closed
pjljvandelaar opened this issue Apr 14, 2021 · 4 comments
Closed

Missing Value of SLOC #492

pjljvandelaar opened this issue Apr 14, 2021 · 4 comments

Comments

@pjljvandelaar
Copy link

pjljvandelaar commented Apr 14, 2021

Dear adaCore,

I am missing some basic functionality.
The Value function (the inverse of image )
is not present.

A simple solution might be to add functions like

   function Source_Location_Value (Source_Location_String : String) return Source_Location
   is
      Index_Colon : constant Natural := Index (Source_Location_String, ":");
      Line : constant Line_Number := 
        Line_Number'Value (Head (Source_Location_String, Index_Colon - Source_Location_String'First));
      Column : constant Column_Number := 
        Column_Number'Value (Tail (Source_Location_String, Source_Location_String'Last - Index_Colon));
   begin
      return (Line => Line,
              Column => Column);
   end Source_Location_Value;

   function Source_Location_Range_Value (Source_Location_Range_String : String) 
                                         return Source_Location_Range
   is
      Index_Dash : constant Natural := Index (Source_Location_Range_String, "-");
      Start_Location_String : constant String := 
        Head (Source_Location_Range_String, Index_Dash - Source_Location_Range_String'First);
      Start_Location : constant Source_Location := Source_Location_Value (Start_Location_String);
      End_Location_String : constant String := 
        Tail (Source_Location_Range_String, Source_Location_Range_String'Last - Index_Dash);
      End_Location : constant Source_Location := Source_Location_Value (End_Location_String);
   begin
      return (Start_Line   => Start_Location.Line,
              End_Line     => End_Location.Line,
              Start_Column => Start_Location.Column, 
              End_Column   => End_Location.Column);
   end Source_Location_Range_Value;
pmderodat added a commit to pmderodat/langkit that referenced this issue Apr 14, 2021
pmderodat added a commit that referenced this issue Apr 15, 2021
@pmderodat
Copy link
Member

Hello,

This is now implemented (two new Value functions in Langkit_Support.Slocs, thank you for the suggestion!

Roldak pushed a commit to Roldak/langkit that referenced this issue Apr 28, 2021
@pjljvandelaar
Copy link
Author

Thanks!

I reported a minor issue on the commit.

pmderodat added a commit to pmderodat/langkit that referenced this issue Apr 29, 2021
pmderodat added a commit that referenced this issue May 3, 2021
Roldak pushed a commit to Roldak/langkit that referenced this issue May 7, 2021
@pjljvandelaar
Copy link
Author

Found a typo: Roldak@5adc777#r50932637

pmderodat added a commit to pmderodat/langkit that referenced this issue Jun 15, 2021
pmderodat added a commit to pmderodat/langkit that referenced this issue Jun 17, 2021
pmderodat added a commit that referenced this issue Jun 21, 2021
@pmderodat
Copy link
Member

Typo fix is now merged, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants