From 8564bff96deeaffbde391cbc5cf42daf1d31aba1 Mon Sep 17 00:00:00 2001 From: Pierre-Marie de Rodat Date: Wed, 3 Feb 2021 17:08:43 +0100 Subject: [PATCH] $.Introspection: add prefixes to member names ("f_", "p_") TN: U203-015 --- .../pkg_introspection_impl_spec_ada.mako | 4 +- .../ada_api/field_introspection/test.out | 26 +-- .../ada_api/properties_introspection/main.adb | 6 +- .../ada_api/properties_introspection/test.out | 174 +++++++++--------- testsuite/tests/misc/rewriting/test.out | 172 ++++++++--------- 5 files changed, 191 insertions(+), 191 deletions(-) diff --git a/langkit/templates/pkg_introspection_impl_spec_ada.mako b/langkit/templates/pkg_introspection_impl_spec_ada.mako index 36556d482..33ad056d2 100644 --- a/langkit/templates/pkg_introspection_impl_spec_ada.mako +++ b/langkit/templates/pkg_introspection_impl_spec_ada.mako @@ -134,7 +134,7 @@ private package ${ada_lib_name}.Introspection_Implementation is -- Descriptors for syntax fields % for f in ctx.sorted_parse_fields: - <% name = f.original_name.lower %> + <% name = f.api_name.lower %> Desc_For_${f.introspection_enum_literal} : aliased constant Syntax_Field_Descriptor := ( Name_Length => ${len(name)}, @@ -201,7 +201,7 @@ private package ${ada_lib_name}.Introspection_Implementation is % endfor % for p in ctx.sorted_properties: - <% name = p.original_name.lower %> + <% name = p.api_name.lower %> Desc_For_${p.introspection_enum_literal} : aliased constant Property_Descriptor := ( Name_Length => ${len(name)}, diff --git a/testsuite/tests/ada_api/field_introspection/test.out b/testsuite/tests/ada_api/field_introspection/test.out index 6e3794f7d..d39d6b6f9 100644 --- a/testsuite/tests/ada_api/field_introspection/test.out +++ b/testsuite/tests/ada_api/field_introspection/test.out @@ -3,27 +3,27 @@ FooNode (FOO_NODE_TYPE_ID) Decl (DECL_TYPE_ID) Fields (with abstract ones): - field name (Name) - field value (Expr) + field f_name (Name) + field f_value (Expr) FunDecl (FUN_DECL_TYPE_ID) Fields (with abstract ones): - field name (Name) - field value (Expr) + field f_name (Name) + field f_value (Expr) Fields (only concrete ones): - name: 1 + f_name: 1 VarDecl (VAR_DECL_TYPE_ID) Fields (with abstract ones): - field var_kw (VarKeyword) - field name (Name) - field value (Expr) + field f_var_kw (VarKeyword) + field f_name (Name) + field f_value (Expr) Fields (only concrete ones): - var_kw: 1 - name: 2 - value: 3 + f_var_kw: 1 + f_name: 2 + f_value: 3 Expr (EXPR_TYPE_ID) Fields (with abstract ones): @@ -35,10 +35,10 @@ Number (NUMBER_TYPE_ID) Ref (REF_TYPE_ID) Fields (with abstract ones): - field name (Name) + field f_name (Name) Fields (only concrete ones): - name: 1 + f_name: 1 FooNodeBaseList (FOO_NODE_BASE_LIST_TYPE_ID) Fields (with abstract ones): diff --git a/testsuite/tests/ada_api/properties_introspection/main.adb b/testsuite/tests/ada_api/properties_introspection/main.adb index 4dc1e0ac8..1e9c9661e 100644 --- a/testsuite/tests/ada_api/properties_introspection/main.adb +++ b/testsuite/tests/ada_api/properties_introspection/main.adb @@ -303,12 +303,12 @@ begin & Lookup_Member (Id, Name)'Image); end Test; begin - Test (Foo_Node_Type_Id, "name"); + Test (Foo_Node_Type_Id, "p_name"); Test (Foo_Node_Type_Id, "parent"); Test (Var_Decl_Type_Id, "parent"); - Test (Var_Decl_Type_Id, "name"); - Test (Var_Decl_Type_Id, "eval"); + Test (Var_Decl_Type_Id, "p_name"); + Test (Var_Decl_Type_Id, "p_eval"); New_Line; end; diff --git a/testsuite/tests/ada_api/properties_introspection/test.out b/testsuite/tests/ada_api/properties_introspection/test.out index 7603903e3..cae0d2682 100644 --- a/testsuite/tests/ada_api/properties_introspection/test.out +++ b/testsuite/tests/ada_api/properties_introspection/test.out @@ -1,71 +1,71 @@ Properties for FOO_ADDITION: - id_bool + p_id_bool return type: Bool arguments: id: Bool - id_int + p_id_int return type: Int arguments: id: Int - id_bigint + p_id_bigint return type: BigInt arguments: id: BigInt - id_char + p_id_char return type: Character arguments: id: Character - id_token + p_id_token return type: Token arguments: id: Token - id_sym + p_id_sym return type: Symbol arguments: id: Symbol - id_unit + p_id_unit return type: AnalysisUnit arguments: id: AnalysisUnit - id_root_node + p_id_root_node return type: FooNode arguments: id: FooNode - id_name + p_id_name return type: Name arguments: id: Name - id_unit_kind + p_id_unit_kind return type: AnalysisUnitKind arguments: id: AnalysisUnitKind - id_node_array + p_id_node_array return type: FooNode.entity.array arguments: id: FooNode.entity.array - id_bigint_array + p_id_bigint_array return type: BigInt.array arguments: id: BigInt.array @@ -126,12 +126,12 @@ Properties for FOO_ADDITION: arguments: - eval + p_eval return type: Int arguments: - eval_plus + p_eval_plus return type: Int arguments: addend: Expr @@ -139,73 +139,73 @@ Properties for FOO_ADDITION: Properties for FOO_NUMBER: - id_bool + p_id_bool return type: Bool arguments: id: Bool - id_int + p_id_int return type: Int arguments: id: Int - id_bigint + p_id_bigint return type: BigInt arguments: id: BigInt - id_char + p_id_char return type: Character arguments: id: Character - id_token + p_id_token return type: Token arguments: id: Token - id_sym + p_id_sym return type: Symbol arguments: id: Symbol - id_unit + p_id_unit return type: AnalysisUnit arguments: id: AnalysisUnit - id_root_node + p_id_root_node return type: FooNode arguments: id: FooNode - id_name + p_id_name return type: Name arguments: id: Name - id_unit_kind + p_id_unit_kind return type: AnalysisUnitKind arguments: id: AnalysisUnitKind - id_node_array + p_id_node_array return type: FooNode.entity.array arguments: id: FooNode.entity.array - id_bigint_array + p_id_bigint_array return type: BigInt.array arguments: id: BigInt.array @@ -266,36 +266,36 @@ Properties for FOO_NUMBER: arguments: - eval + p_eval return type: Int arguments: - eval_plus + p_eval_plus return type: Int arguments: addend: Expr - id_dflt_bool + p_id_dflt_bool return type: Bool arguments: id: Bool := TRUE - id_dflt_int + p_id_dflt_int return type: Int arguments: id: Int := 42 - id_dflt_char + p_id_dflt_char return type: Character arguments: id: Character := [" 0"] - id_dflt_root_node + p_id_dflt_root_node return type: FooNode arguments: id: FooNode := None @@ -303,73 +303,73 @@ Properties for FOO_NUMBER: Properties for FOO_REF: - id_bool + p_id_bool return type: Bool arguments: id: Bool - id_int + p_id_int return type: Int arguments: id: Int - id_bigint + p_id_bigint return type: BigInt arguments: id: BigInt - id_char + p_id_char return type: Character arguments: id: Character - id_token + p_id_token return type: Token arguments: id: Token - id_sym + p_id_sym return type: Symbol arguments: id: Symbol - id_unit + p_id_unit return type: AnalysisUnit arguments: id: AnalysisUnit - id_root_node + p_id_root_node return type: FooNode arguments: id: FooNode - id_name + p_id_name return type: Name arguments: id: Name - id_unit_kind + p_id_unit_kind return type: AnalysisUnitKind arguments: id: AnalysisUnitKind - id_node_array + p_id_node_array return type: FooNode.entity.array arguments: id: FooNode.entity.array - id_bigint_array + p_id_bigint_array return type: BigInt.array arguments: id: BigInt.array @@ -430,91 +430,91 @@ Properties for FOO_REF: arguments: - eval + p_eval return type: Int arguments: - eval_plus + p_eval_plus return type: Int arguments: addend: Expr - referenced_var_decl + p_referenced_var_decl return type: VarDecl arguments: Properties for FOO_VAR_DECL_LIST: - id_bool + p_id_bool return type: Bool arguments: id: Bool - id_int + p_id_int return type: Int arguments: id: Int - id_bigint + p_id_bigint return type: BigInt arguments: id: BigInt - id_char + p_id_char return type: Character arguments: id: Character - id_token + p_id_token return type: Token arguments: id: Token - id_sym + p_id_sym return type: Symbol arguments: id: Symbol - id_unit + p_id_unit return type: AnalysisUnit arguments: id: AnalysisUnit - id_root_node + p_id_root_node return type: FooNode arguments: id: FooNode - id_name + p_id_name return type: Name arguments: id: Name - id_unit_kind + p_id_unit_kind return type: AnalysisUnitKind arguments: id: AnalysisUnitKind - id_node_array + p_id_node_array return type: FooNode.entity.array arguments: id: FooNode.entity.array - id_bigint_array + p_id_bigint_array return type: BigInt.array arguments: id: BigInt.array @@ -577,73 +577,73 @@ Properties for FOO_VAR_DECL_LIST: Properties for FOO_NAME: - id_bool + p_id_bool return type: Bool arguments: id: Bool - id_int + p_id_int return type: Int arguments: id: Int - id_bigint + p_id_bigint return type: BigInt arguments: id: BigInt - id_char + p_id_char return type: Character arguments: id: Character - id_token + p_id_token return type: Token arguments: id: Token - id_sym + p_id_sym return type: Symbol arguments: id: Symbol - id_unit + p_id_unit return type: AnalysisUnit arguments: id: AnalysisUnit - id_root_node + p_id_root_node return type: FooNode arguments: id: FooNode - id_name + p_id_name return type: Name arguments: id: Name - id_unit_kind + p_id_unit_kind return type: AnalysisUnitKind arguments: id: AnalysisUnitKind - id_node_array + p_id_node_array return type: FooNode.entity.array arguments: id: FooNode.entity.array - id_bigint_array + p_id_bigint_array return type: BigInt.array arguments: id: BigInt.array @@ -706,73 +706,73 @@ Properties for FOO_NAME: Properties for FOO_VAR_DECL: - id_bool + p_id_bool return type: Bool arguments: id: Bool - id_int + p_id_int return type: Int arguments: id: Int - id_bigint + p_id_bigint return type: BigInt arguments: id: BigInt - id_char + p_id_char return type: Character arguments: id: Character - id_token + p_id_token return type: Token arguments: id: Token - id_sym + p_id_sym return type: Symbol arguments: id: Symbol - id_unit + p_id_unit return type: AnalysisUnit arguments: id: AnalysisUnit - id_root_node + p_id_root_node return type: FooNode arguments: id: FooNode - id_name + p_id_name return type: Name arguments: id: Name - id_unit_kind + p_id_unit_kind return type: AnalysisUnitKind arguments: id: AnalysisUnitKind - id_node_array + p_id_node_array return type: FooNode.entity.array arguments: id: FooNode.entity.array - id_bigint_array + p_id_bigint_array return type: BigInt.array arguments: id: BigInt.array @@ -833,7 +833,7 @@ Properties for FOO_VAR_DECL: arguments: - eval + p_eval return type: Int arguments: @@ -872,11 +872,11 @@ P_Id_Node_Array: P_Eval: -Lookup_Member (FOO_NODE_TYPE_ID, name) = NONE +Lookup_Member (FOO_NODE_TYPE_ID, p_name) = NONE Lookup_Member (FOO_NODE_TYPE_ID, parent) = FOO_NODE_PARENT Lookup_Member (VAR_DECL_TYPE_ID, parent) = FOO_NODE_PARENT -Lookup_Member (VAR_DECL_TYPE_ID, name) = VAR_DECL_F_NAME -Lookup_Member (VAR_DECL_TYPE_ID, eval) = VAR_DECL_P_EVAL +Lookup_Member (VAR_DECL_TYPE_ID, p_name) = NONE +Lookup_Member (VAR_DECL_TYPE_ID, p_eval) = VAR_DECL_P_EVAL Done. Done diff --git a/testsuite/tests/misc/rewriting/test.out b/testsuite/tests/misc/rewriting/test.out index 3cc616bf5..e747f886a 100644 --- a/testsuite/tests/misc/rewriting/test.out +++ b/testsuite/tests/misc/rewriting/test.out @@ -23,59 +23,59 @@ main.adb: Done. == revert.adb == DefList[1:1-5:10] | Def[1:1-1:10] -| |name: +| |f_name: | | Name[1:5-1:6]: a -| |args: +| |f_args: | | NameList[1:4-1:4]: -| |expr: +| |f_expr: | | Literal[1:9-1:10]: 1 | Def[2:1-2:20] -| |name: +| |f_name: | | Name[2:5-2:6]: b -| |args: +| |f_args: | | NameList[2:4-2:4]: -| |expr: +| |f_expr: | | Plus[2:9-2:20] -| | |lhs: +| | |f_lhs: | | | ParenExpr[2:9-2:16] -| | | |expr: +| | | |f_expr: | | | | Plus[2:10-2:15] -| | | | |lhs: +| | | | |f_lhs: | | | | | Literal[2:10-2:11]: 2 -| | | | |rhs: +| | | | |f_rhs: | | | | | Ref[2:14-2:15] -| | | | | |name: +| | | | | |f_name: | | | | | | Name[2:14-2:15]: a -| | |rhs: +| | |f_rhs: | | | Literal[2:19-2:20]: 3 | Def[3:1-3:14] -| |name: +| |f_name: | | Name[3:5-3:6]: c -| |args: +| |f_args: | | NameList[3:4-3:4]: -| |expr: +| |f_expr: | | Plus[3:9-3:14] -| | |lhs: +| | |f_lhs: | | | Ref[3:9-3:10] -| | | |name: +| | | |f_name: | | | | Name[3:9-3:10]: a -| | |rhs: +| | |f_rhs: | | | Ref[3:13-3:14] -| | | |name: +| | | |f_name: | | | | Name[3:13-3:14]: b | Def[4:1-4:10] -| |name: +| |f_name: | | Name[4:5-4:6]: d -| |args: +| |f_args: | | NameList[4:4-4:4]: -| |expr: +| |f_expr: | | Literal[4:9-4:10]: 4 | Def[5:1-5:10] -| |name: +| |f_name: | | Name[5:5-5:6]: e -| |args: +| |f_args: | | NameList[5:4-5:4]: -| |expr: +| |f_expr: | | Literal[5:9-5:10]: 5 revert.adb: Done. @@ -100,88 +100,88 @@ Applying the diff... u1.txt: DefList | Def -| |name: +| |f_name: | | Name: d -| |args: +| |f_args: | | NameList: -| |expr: +| |f_expr: | | Literal: 4 | Def -| |name: +| |f_name: | | Name: c -| |args: +| |f_args: | | NameList: -| |expr: +| |f_expr: | | Plus -| | |lhs: +| | |f_lhs: | | | Ref -| | | |name: +| | | |f_name: | | | | Name: a -| | |rhs: +| | |f_rhs: | | | Ref -| | | |name: +| | | |f_name: | | | | Name: b | Def -| |name: +| |f_name: | | Name: c -| |args: +| |f_args: | | NameList: -| |expr: +| |f_expr: | | Plus -| | |lhs: +| | |f_lhs: | | | Ref -| | | |name: +| | | |f_name: | | | | Name: a -| | |rhs: +| | |f_rhs: | | | Ref -| | | |name: +| | | |f_name: | | | | Name: b | Def -| |name: +| |f_name: | | Name: a -| |args: +| |f_args: | | NameList: -| |expr: +| |f_expr: | | Literal: 1 | Def -| |name: +| |f_name: | | Name: e -| |args: +| |f_args: | | NameList: -| |expr: +| |f_expr: | | ParenExpr -| | |expr: +| | |f_expr: | | | Plus -| | | |lhs: +| | | |f_lhs: | | | | Ref -| | | | |name: +| | | | |f_name: | | | | | Name: d -| | | |rhs: +| | | |f_rhs: | | | | ParenExpr -| | | | |expr: +| | | | |f_expr: | | | | | Plus -| | | | | |lhs: +| | | | | |f_lhs: | | | | | | Literal: 5 -| | | | | |rhs: +| | | | | |f_rhs: | | | | | | Ref -| | | | | | |name: +| | | | | | |f_name: | | | | | | | Name: c u2.txt: DefList | Def -| |name: +| |f_name: | | Name: zz -| |args: +| |f_args: | | NameList: -| |expr: +| |f_expr: | | Literal: 111 | Def -| |name: +| |f_name: | | Name: yy -| |args: +| |f_args: | | NameList: -| |expr: +| |f_expr: | | Literal: 333 rewrite.adb: Done. @@ -189,18 +189,18 @@ rewrite.adb: Done. Applying the diff... DefList | Def -| |name: +| |f_name: | | Name: a -| |args: +| |f_args: | | NameList: -| |expr: +| |f_expr: | | Literal: 1 | Def -| |name: +| |f_name: | | Name: c -| |args: +| |f_args: | | NameList: -| |expr: +| |f_expr: | | Literal: 3 rewrite_lists.adb: Done. @@ -248,34 +248,34 @@ Use templates to create trees of node rewriting handles... Applying the diff... DefList | Def -| |name: +| |f_name: | | Name: a -| |args: +| |f_args: | | NameList: -| |expr: +| |f_expr: | | Literal: 1 | Def -| |name: +| |f_name: | | Name: b -| |args: +| |f_args: | | NameList: -| |expr: +| |f_expr: | | ParenExpr -| | |expr: +| | |f_expr: | | | Plus -| | | |lhs: +| | | |f_lhs: | | | | Ref -| | | | |name: +| | | | |f_name: | | | | | Name: b -| | | |rhs: +| | | |f_rhs: | | | | ParenExpr -| | | | |expr: +| | | | |f_expr: | | | | | Plus -| | | | | |lhs: +| | | | | |f_lhs: | | | | | | Ref -| | | | | | |name: +| | | | | | |f_name: | | | | | | | Name: a -| | | | | |rhs: +| | | | | |f_rhs: | | | | | | Literal: 3 templates.adb: Done. @@ -339,13 +339,13 @@ Applying the diff... u.txt: DefList | Def -| |name: +| |f_name: | | Name: B -| |args: +| |f_args: | | NameList: -| |expr: +| |f_expr: | | Ref -| | |name: +| | |f_name: | | | Name: A clone_synthetic.adb: Done. Done