@@ -27,6 +27,7 @@ with GPR2.Containers;
2727with GPR2.Path_Name ;
2828with GPR2.Project.Attribute ;
2929with GPR2.Project.Attribute_Index ;
30+ with GPR2.Project.Registry.Attribute ;
3031with GPR2.Build.Source ;
3132with GPR2.Build.Source.Sets ;
3233
@@ -925,73 +926,105 @@ package body LSP.Ada_Contexts is
925926 return Ada.Strings.Unbounded.To_String (Self.Charset);
926927 end Charset ;
927928
929+ -- ----------------------------
930+ -- Project_Attribute_Values --
931+ -- ----------------------------
932+
933+ function Project_Attribute_Values
934+ (View : GPR2.Project.View.Object;
935+ Attribute : GPR2.Q_Attribute_Id;
936+ Index : String := " " ;
937+ Is_List_Attribute : out Boolean;
938+ Is_Known : out Boolean)
939+ return VSS.String_Vectors.Virtual_String_Vector
940+ is
941+ use GPR2.Project.Registry.Attribute;
942+
943+ Attribute_Index : constant GPR2.Project.Attribute_Index.Object :=
944+ (if Index = " " then GPR2.Project.Attribute_Index.Undefined
945+ else GPR2.Project.Attribute_Index.Create (Index));
946+
947+ Attribute_Value : GPR2.Project.Attribute.Object;
948+
949+ function Convert
950+ (Values : GPR2.Containers.Source_Value_List)
951+ return VSS.String_Vectors.Virtual_String_Vector;
952+
953+ -- -----------
954+ -- Convert --
955+ -- -----------
956+
957+ function Convert
958+ (Values : GPR2.Containers.Source_Value_List)
959+ return VSS.String_Vectors.Virtual_String_Vector
960+ is
961+ Result : VSS.String_Vectors.Virtual_String_Vector;
962+ begin
963+ for Value of Values loop
964+ Result.Append (VSS.Strings.Conversions.To_Virtual_String (Value.Text));
965+ end loop ;
966+
967+ return Result;
968+ end Convert ;
969+
970+ begin
971+ Is_Known := False;
972+
973+ if View.Check_Attribute
974+ (Name => Attribute,
975+ Index => Attribute_Index,
976+ Result => Attribute_Value)
977+ then
978+ Is_List_Attribute := (Attribute_Value.Kind = List);
979+ Is_Known := True;
980+ return Convert (Attribute_Value.Values);
981+ end if ;
982+
983+ return [];
984+ end Project_Attribute_Values ;
985+
928986 -- ---------------------------
929987 -- Project_Attribute_Value --
930988 -- ---------------------------
931989
932990 function Project_Attribute_Value
933- (Self : Context ;
991+ (View : GPR2.Project.View.Object ;
934992 Attribute : GPR2.Q_Attribute_Id;
935993 Index : String := " " ;
936- Default : String := " " ;
937- Use_Extended : Boolean := False) return String is
994+ Default : String := " " ) return String
995+ is
996+ Dummy : Boolean;
997+ Is_Known : Boolean;
998+ Values : constant VSS.String_Vectors.Virtual_String_Vector :=
999+ Project_Attribute_Values
1000+ (View => View,
1001+ Attribute => Attribute,
1002+ Index => Index,
1003+ Is_List_Attribute => Dummy,
1004+ Is_Known => Is_Known);
9381005 begin
939- return Project_Attribute_Value
940- (View => Self.Tree.Root_Project,
941- Attribute => Attribute,
942- Index => Index,
943- Default => Default,
944- Use_Extended => Use_Extended);
1006+ if Is_Known then
1007+ return VSS.Strings.Conversions.To_UTF_8_String (Values.First_Element);
1008+ else
1009+ return Default;
1010+ end if ;
9451011 end Project_Attribute_Value ;
9461012
9471013 -- ---------------------------
9481014 -- Project_Attribute_Value --
9491015 -- ---------------------------
9501016
9511017 function Project_Attribute_Value
952- (View : GPR2.Project.View.Object ;
1018+ (Self : Context ;
9531019 Attribute : GPR2.Q_Attribute_Id;
9541020 Index : String := " " ;
955- Default : String := " " ;
956- Use_Extended : Boolean := False) return String is
957- Attribute_Index : constant GPR2.Project.Attribute_Index.Object :=
958- (if Index = " "
959- then GPR2.Project.Attribute_Index.Undefined
960- else GPR2.Project.Attribute_Index.Create (Index));
961-
962- Attribute_Value : GPR2.Project.Attribute.Object;
963-
1021+ Default : String := " " ) return String is
9641022 begin
965- if View.Check_Attribute
966- (Name => Attribute,
967- Index => Attribute_Index,
968- Result => Attribute_Value)
969- then
970- return Attribute_Value.Value.Text;
971- elsif Use_Extended and then View.Is_Extending then
972- -- Look at Extended project list as attribute not found in
973- -- Root_Project and Use_Extended requested.
974-
975- declare
976- Extended_Root : GPR2.Project.View.Object :=
977- View.Extended_Root;
978- begin
979- while Extended_Root.Is_Defined loop
980- if Extended_Root.Check_Attribute
981- (Name => Attribute,
982- Index => Attribute_Index,
983- Result => Attribute_Value)
984- then
985- return Attribute_Value.Value.Text;
986- elsif Extended_Root.Is_Extending then
987- Extended_Root := Extended_Root.Extended_Root;
988- else
989- Extended_Root := GPR2.Project.View.Undefined;
990- end if ;
991- end loop ;
992- end ;
993- end if ;
994- return Default;
1023+ return Project_Attribute_Value
1024+ (View => Self.Tree.Root_Project,
1025+ Attribute => Attribute,
1026+ Index => Index,
1027+ Default => Default);
9951028 end Project_Attribute_Value ;
9961029
9971030end LSP.Ada_Contexts ;
0 commit comments