From 15e56072405de48736710d329fbd8881bc932eed Mon Sep 17 00:00:00 2001 From: Markus <5188411+Noordsestern@users.noreply.github.com> Date: Sat, 31 Aug 2024 11:26:08 +0200 Subject: [PATCH] Add `.resource` extension to Robot Framework (#6500) * add .resource extension to robot * add resource file example * docs * add heuristics for RF resource files * fix typo * add robotframework keywords heuristic --------- Co-authored-by: Colin Seymour --- lib/linguist/generic.yml | 1 + lib/linguist/heuristics.yml | 5 +++++ lib/linguist/languages.yml | 1 + samples/RobotFramework/keywords.resource | 21 +++++++++++++++++++++ test/test_heuristics.rb | 6 ++++++ 5 files changed, 34 insertions(+) create mode 100644 samples/RobotFramework/keywords.resource diff --git a/lib/linguist/generic.yml b/lib/linguist/generic.yml index ab92e50ad0..9c911f4959 100644 --- a/lib/linguist/generic.yml +++ b/lib/linguist/generic.yml @@ -16,6 +16,7 @@ extensions: - ".9" - ".app" - ".cmp" +- ".resource" - ".sol" - ".stl" - ".tag" diff --git a/lib/linguist/heuristics.yml b/lib/linguist/heuristics.yml index a03e483f35..67891bd2ab 100644 --- a/lib/linguist/heuristics.yml +++ b/lib/linguist/heuristics.yml @@ -656,6 +656,11 @@ disambiguations: pattern: - '^\s*(let|module|type)\s+\w*\s+=\s+' - '^\s*(?:include|open)\s+\w+\s*$' +- extensions: ['.resource'] + rules: + - language: RobotFramework + pattern: + - '^\*{3} (Settings|Variables|Keywords) \*{3}$' - extensions: ['.rno'] rules: - language: RUNOFF diff --git a/lib/linguist/languages.yml b/lib/linguist/languages.yml index 7b96e2ceb6..9bde77235a 100644 --- a/lib/linguist/languages.yml +++ b/lib/linguist/languages.yml @@ -6207,6 +6207,7 @@ RobotFramework: color: "#00c0b5" extensions: - ".robot" + - ".resource" tm_scope: text.robot ace_mode: text language_id: 324 diff --git a/samples/RobotFramework/keywords.resource b/samples/RobotFramework/keywords.resource new file mode 100644 index 0000000000..622cd9f819 --- /dev/null +++ b/samples/RobotFramework/keywords.resource @@ -0,0 +1,21 @@ +*** Settings *** +Documentation Example keywords file. +... It is recommended to use another ending than `.robot` for resource files. +... By convention, the file ending for resource files is `.resource`. +... Another resource than `.robot` makes maintaining large projects easier. It also prevents +... the parser to search for tasks or test cases in resource files, which saves some startup performance. + +Library Collections + + +*** Variables *** +${variable} ${EMPTY} +${some_list} @{EMPTY} +${some_dict} &{EMPTY} + + +*** Keywords *** +Dictionary Should Contain ${key}=${value} + [Arguments] ${dict} + Dictionary Should Contain Key ${dict} ${key} + Should Be Equal ${dict}[key] ${value} msg=Dictionary does not hold expected item. diff --git a/test/test_heuristics.rb b/test/test_heuristics.rb index c085179df1..8277ceba53 100755 --- a/test/test_heuristics.rb +++ b/test/test_heuristics.rb @@ -885,6 +885,12 @@ def test_res_by_heuristics }) end + def test_resource_by_heuristics + assert_heuristics({ + "RobotFramework" => all_fixtures("RobotFramework", "*.resource") + }) + end + def test_rno_by_heuristics assert_heuristics({ "RUNOFF" => all_fixtures("RUNOFF", "*.rno"),