Skip to content

Commit eaa6b66

Browse files
committed
Merge branch 'topic/instance_error' into 'master'
Enhance GNATcheck error messages about instantiation process Closes #364 See merge request eng/libadalang/langkit-query-language!314
2 parents adcbb23 + ca9bd7a commit eaa6b66

File tree

14 files changed

+38
-22
lines changed

14 files changed

+38
-22
lines changed

lkql_checker/src/gnatcheck-rules-rule_table.adb

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,8 +1062,8 @@ package body Gnatcheck.Rules.Rule_Table is
10621062
return;
10631063
elsif not Enable and then Instance = null then
10641064
Error
1065-
("rule instance doesn't exist, therefore, cannot be " &
1066-
"disabled: """ & To_String (Instance_Name) & """" &
1065+
("""" & To_String (Instance_Name) & """ is not enabled, " &
1066+
"therefore, cannot be disabled" &
10671067
Diag_Defined_At);
10681068
Bad_Rule_Detected := True;
10691069
return;
@@ -1162,8 +1162,11 @@ package body Gnatcheck.Rules.Rule_Table is
11621162
Expect (Instance_Object, "sourceMode");
11631163
Params_Object : JSON_Value := Instance_Object.Get ("arguments");
11641164

1165-
function Real_Instance_Name return String is
1166-
(if Instance_Name /= "" then Instance_Name else Rule_Name);
1165+
function Precise_Rule_Name return String is
1166+
("""" & Rule_Name & """" &
1167+
(if Instance_Name /= ""
1168+
then " (instance """ & Instance_Name & """)"
1169+
else ""));
11671170

11681171
procedure Error_In_Rule_File (Msg : String);
11691172
-- Emit a GNATcheck error when there is an error during the processing
@@ -1196,7 +1199,7 @@ package body Gnatcheck.Rules.Rule_Table is
11961199
pragma Unreferenced (Arg_Value);
11971200
begin
11981201
Error_In_Rule_File
1199-
("extra argument for instance " & Real_Instance_Name &
1202+
("extra argument for rule " & Precise_Rule_Name &
12001203
": '" & Arg_Name & "'");
12011204
end Report_Extra_Arg;
12021205

@@ -1270,15 +1273,15 @@ package body Gnatcheck.Rules.Rule_Table is
12701273
exception
12711274
when E : Field_Not_Found =>
12721275
Error_In_Rule_File
1273-
("missing parameter for instance " & Real_Instance_Name & ": '" &
1274-
Exception_Message (E) & "'");
1276+
("missing '" & Exception_Message (E) & "' parameter for rule " &
1277+
Precise_Rule_Name);
12751278
when E : Invalid_Type =>
12761279
Error_In_Rule_File
1277-
("invalid parameter for instance " & Real_Instance_Name & ": " &
1280+
("invalid parameter for rule " & Precise_Rule_Name & ": " &
12781281
Exception_Message (E));
12791282
when E : Invalid_Value =>
12801283
Error_In_Rule_File
1281-
("invalid parameter value for instance " & Real_Instance_Name &
1284+
("invalid parameter value for rule " & Precise_Rule_Name &
12821285
": " & Exception_Message (E));
12831286
end Process_Rule_Object;
12841287

testsuite/tests/gnatcheck/disabling_instance/test.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,6 @@ main.adb:8:07: goto statement [cond_goto|goto_statements]
1414
Disabling the wrong instance
1515
============================
1616

17-
gnatcheck: rule instance doesn't exist, therefore, cannot be disabled: "goto_statements"
17+
gnatcheck: "goto_statements" is not enabled, therefore, cannot be disabled
1818
main.adb:3:04: goto statement [cond_goto|goto_statements]
1919
>>>program returned status code 5

testsuite/tests/gnatcheck/lkql_rules_config/actual_parameters/test.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ main.adb:17:08: actual parameter mismatch
99
Invalid type
1010
============
1111

12-
gnatcheck: invalid parameter for instance actual_parameters: 'forbidden' should be a list of string tuples (invalid_type.lkql)
12+
gnatcheck: invalid parameter for rule "actual_parameters": 'forbidden' should be a list of string tuples (invalid_type.lkql)
1313
gnatcheck: No rule to check specified
1414
try "gnatcheck --help" for more information.
1515
>>>program returned status code 2

testsuite/tests/gnatcheck/lkql_rules_config/array_param/test.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ main.adb:9:15: direct (in)equality
77
Invalid type
88
============
99

10-
gnatcheck: invalid parameter for instance direct_equalities: 'actuals' value should be a list (invalid_type.lkql)
10+
gnatcheck: invalid parameter for rule "direct_equalities": 'actuals' value should be a list (invalid_type.lkql)
1111
gnatcheck: No rule to check specified
1212
try "gnatcheck --help" for more information.
1313
>>>program returned status code 2

testsuite/tests/gnatcheck/lkql_rules_config/bool_param/test.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ main.adb:3:24: use of predefined OR for boolean type
1212
Invalid type
1313
============
1414

15-
gnatcheck: invalid parameter for instance goto_statements: 'only_unconditional' value should be a boolean (invalid_type.lkql)
15+
gnatcheck: invalid parameter for rule "goto_statements": 'only_unconditional' value should be a boolean (invalid_type.lkql)
1616
gnatcheck: No rule to check specified
1717
try "gnatcheck --help" for more information.
1818
>>>program returned status code 2

testsuite/tests/gnatcheck/lkql_rules_config/exception_propagation_from_callbacks/test.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ main.adb:11:45: callback may propagate exceptions
77
Invalid type
88
============
99

10-
gnatcheck: invalid parameter for instance exception_propagation_from_callbacks: 'callbacks' should be a list of string tuples (invalid_type.lkql)
10+
gnatcheck: invalid parameter for rule "exception_propagation_from_callbacks": 'callbacks' should be a list of string tuples (invalid_type.lkql)
1111
gnatcheck: No rule to check specified
1212
try "gnatcheck --help" for more information.
1313
>>>program returned status code 2

testsuite/tests/gnatcheck/lkql_rules_config/headers/test.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ no_header.adb:1:01: compilation unit does not start with header
66
Missing parameter
77
=================
88

9-
gnatcheck: missing parameter for instance headers: 'header' (missing_param.lkql)
9+
gnatcheck: missing 'header' parameter for rule "headers" (missing_param.lkql)
1010
gnatcheck: No rule to check specified
1111
try "gnatcheck --help" for more information.
1212
>>>program returned status code 2

testsuite/tests/gnatcheck/lkql_rules_config/int_and_bool_params/test.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ main.adb:17:10: membership test
1616
Invalid type
1717
============
1818

19-
gnatcheck: invalid parameter for instance membership_tests: 'float_types_only' value should be a boolean (invalid_type.lkql)
19+
gnatcheck: invalid parameter for rule "membership_tests": 'float_types_only' value should be a boolean (invalid_type.lkql)
2020
gnatcheck: No rule to check specified
2121
try "gnatcheck --help" for more information.
2222
>>>program returned status code 2

testsuite/tests/gnatcheck/lkql_rules_config/int_param/test.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ main.ads:5:14: too many formal OUT parameters (3)
66
Missing parameter
77
=================
88

9-
gnatcheck: missing parameter for instance maximum_out_parameters: 'n' (missing_param.lkql)
9+
gnatcheck: missing 'n' parameter for rule "maximum_out_parameters" (missing_param.lkql)
1010
gnatcheck: No rule to check specified
1111
try "gnatcheck --help" for more information.
1212
>>>program returned status code 2
1313

1414
Invalid type
1515
============
1616

17-
gnatcheck: invalid parameter for instance maximum_out_parameters: 'n' value should be an integer (invalid_type.lkql)
17+
gnatcheck: invalid parameter for rule "maximum_out_parameters": 'n' value should be an integer (invalid_type.lkql)
1818
gnatcheck: No rule to check specified
1919
try "gnatcheck --help" for more information.
2020
>>>program returned status code 2

testsuite/tests/gnatcheck/lkql_rules_config/name_clashes/test.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ main.adb:3:04: use of forbidden identifier
66
Missing parameter
77
=================
88

9-
gnatcheck: missing parameter for instance name_clashes: 'dictionary_file' (missing_param.lkql)
9+
gnatcheck: missing 'dictionary_file' parameter for rule "name_clashes" (missing_param.lkql)
1010
gnatcheck: No rule to check specified
1111
try "gnatcheck --help" for more information.
1212
>>>program returned status code 2

0 commit comments

Comments
 (0)