Skip to content

Commit a4de481

Browse files
Add syntax colorization for GROUP marker. Improve Gherking recognition for multiple words.
1 parent 85192a4 commit a4de481

File tree

9 files changed

+43
-14
lines changed

9 files changed

+43
-14
lines changed

CHANGELOG.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ and this project adheres to http://semver.org/spec/v2.0.0.html[Semantic Versioni
88

99
== https://github.com/robotframework/RIDE[Unreleased]
1010

11+
=== Added
12+
- Added syntax colorization for the ``GROUP`` marker. Improved colorization for multiple Gherkin words, for example in the French language.
13+
1114
=== Fixed
1215

1316
- Fixed multiple scroll bars in Grid Editor when editing Test Cases or Keywords. This caused bad navigation on cells.

README.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ Likewise, the current version of wxPython, is 4.2.2, but RIDE is known to work w
4040

4141
`pip install -U robotframework-ride`
4242

43-
(3.8 <= python <= 3.13) Install current development version (**2.2dev5**) with:
43+
(3.8 <= python <= 3.13) Install current development version (**2.2dev6**) with:
4444

4545
`pip install -U https://github.com/robotframework/RIDE/archive/develop.zip`
4646

src/robotide/application/CHANGELOG.html

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Changelog</title><link rel="stylesheet" type="text/css" href="docbook-xsl.css" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /></head><body><div xml:lang="en" class="article" lang="en"><div class="titlepage"><div><div><h2 class="title"><a id="id1337"></a>Changelog</h2></div></div><hr /></div><p>All notable changes to this project will be documented in this file.</p><p>The format is based on <a class="ulink" href="http://keepachangelog.com/en/1.0.0/" target="_top">Keep a Changelog</a>
3-
and this project adheres to <a class="ulink" href="http://semver.org/spec/v2.0.0.html" target="_top">Semantic Versioning</a>.</p><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_ulink_url_https_github_com_robotframework_ride_unreleased_ulink"></a>1. <a class="ulink" href="https://github.com/robotframework/RIDE" target="_top">Unreleased</a></h2></div></div></div><div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_fixed"></a>1.1. Fixed</h3></div></div></div><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
3+
and this project adheres to <a class="ulink" href="http://semver.org/spec/v2.0.0.html" target="_top">Semantic Versioning</a>.</p><div class="section"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a id="_ulink_url_https_github_com_robotframework_ride_unreleased_ulink"></a>1. <a class="ulink" href="https://github.com/robotframework/RIDE" target="_top">Unreleased</a></h2></div></div></div>
4+
<div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_added1"></a>1.1. Added</h3></div></div></div><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
5+
<li class="listitem">Added syntax colorization for the <em>GROUP</em> marker. Improved colorization for multiple Gherkin words, for
6+
example in the French language.
7+
</li>
8+
</ul></div>
9+
10+
<div class="section"><div class="titlepage"><div><div><h3 class="title"><a id="_fixed"></a>2.1. Fixed</h3></div></div></div><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
411
<li class="listitem">
512
Fixed multiple scroll bars in Grid Editor when editing Test Cases or Keywords. This caused bad navigation on cells.
613
</li>

src/robotide/application/releasenotes.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,8 @@ def set_content(self, html_win, content):
168168
</ul>
169169
<p><strong>New Features and Fixes Highlights</strong></p>
170170
<ul class="simple">
171+
<li>Added syntax colorization for the <em>GROUP</em> marker. Improved colorization for multiple Gherkin words, for
172+
example in the French language.</li>
171173
<li>Fixed multiple scroll bars in Grid Editor when editing Test Cases or Keywords. This caused bad navigation on cells.</li>
172174
<li>Regression fix from v2.1b1 - Fix wrong item selection, like Test Suite, when doing right-click actions in
173175
Project Explorer.</li>
@@ -225,7 +227,7 @@ def set_content(self, html_win, content):
225227
<pre class="literal-block">python -m robotide.postinstall -install</pre>
226228
<p>or</p>
227229
<pre class="literal-block">ride_postinstall.py -install</pre>
228-
<p>RIDE {VERSION} was released on 13/February/2025.</p>
230+
<p>RIDE {VERSION} was released on 14/February/2025.</p>
229231
<!-- <br/>
230232
<h3>May The Fourth Be With You!</h3>
231233
<h3>Celebrate the bank holiday, 10th June, Day of Portugal, Portuguese Communities and Camões!!</h3>

src/robotide/controller/ctrlcommands.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,6 +279,7 @@ class NullObserver(object):
279279

280280

281281
class RenameKeywordOccurrences(_ReversibleCommand):
282+
# TODO: Consider localization language Gherkin
282283
_gherkin_prefix = re.compile('^(Given|When|Then|And|But) ', re.IGNORECASE)
283284

284285
def __init__(self, original_name, new_name, observer, keyword_info=None):
@@ -1339,7 +1340,7 @@ def _get_undo_command(self):
13391340

13401341

13411342
INDENTED_INNER = ['ELSE', 'ELSE IF', 'EXCEPT', 'FINALLY']
1342-
INDENTED_START = ['FOR', 'IF', 'WHILE', 'TRY'] + INDENTED_INNER
1343+
INDENTED_START = ['FOR', 'GROUP', 'IF', 'WHILE', 'TRY'] + INDENTED_INNER
13431344

13441345

13451346
def is_indent_start(cell):

src/robotide/lib/compat/parsing/languages.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,10 @@ def __init__(self, languages: 'Iterable[LanguageLike]|LanguageLike|None' = (), a
6262
@property
6363
def bdd_prefix_regexp(self):
6464
if not self._bdd_prefix_regexp:
65-
prefixes = '|'.join(self.bdd_prefixes).replace(' ', r'\s').lower()
66-
self._bdd_prefix_regexp = re.compile(rf'({prefixes})\s', re.IGNORECASE)
65+
# Sort prefixes by descending length so that the longest ones are matched first
66+
prefixes = sorted(self.bdd_prefixes, key=len, reverse=True)
67+
pattern = '|'.join(prefix.replace(' ', r'\s') for prefix in prefixes).lower()
68+
self._bdd_prefix_regexp = re.compile(rf'({pattern})\s', re.IGNORECASE)
6769
return self._bdd_prefix_regexp
6870

6971
def reset(self, languages: Iterable[LanguageLike] = (), add_english: bool = True):
@@ -557,11 +559,11 @@ class Fr(Language):
557559
template_setting = 'Modèle'
558560
timeout_setting = "Délai d'attente"
559561
arguments_setting = 'Arguments'
560-
given_prefixes = ['Étant donné']
561-
when_prefixes = ['Lorsque']
562-
then_prefixes = ['Alors']
563-
and_prefixes = ['Et']
564-
but_prefixes = ['Mais']
562+
given_prefixes = ['Soit', 'Sachant', 'Sachant que', "Sachant qu'", 'Étant donné', 'Étant donné que', "Etant donné qu'"]
563+
when_prefixes = ['Quand', 'Lorsque', "Lorsqu'"]
564+
then_prefixes = ['Alors', 'Donc']
565+
and_prefixes = ['Et', 'Et que', "Et qu'"]
566+
but_prefixes = ['Mais', 'Mais que', "Mais qu'"]
565567
true_strings = ['Vrai', 'Oui', 'Actif']
566568
false_strings = ['Faux', 'Non', 'Désactivé', 'Aucun']
567569

src/robotide/lib/compat/pygments/robotframework.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,9 @@ def __init__(self, new_lang=None):
501501
self.new_lang = new_lang
502502
if self.new_lang is None:
503503
self.new_lang = Language.from_name('En')
504-
self.normalized_bdd_prefixes = normalize_pipe_list(list(self.new_lang.bdd_prefixes), spaces=False)
504+
# Sort prefixes by descending length so that the longest ones are matched first
505+
prefixes = sorted(self.new_lang.bdd_prefixes, key=len, reverse=True)
506+
self.normalized_bdd_prefixes = normalize_pipe_list(list(prefixes), spaces=False)
505507
# print(f"DEBUG: robotframework.py GherkinTokenizer _tokenize DEFINITION GHERKIN"
506508
# f" BDDPREFIXES={self.new_lang.bdd_prefixes}\n"
507509
# f"PATTERN='^({self.normalized_bdd_prefixes}) '"

src/robotide/namespace/cache.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def _build_default_kws(self):
112112
'ROBOT', 'BuiltIn', 'loop_variables', 'selector', ARG_VALUES)
113113
kws.append(obj1)
114114
obj2 = BlockKeywordInfo('END',
115-
'Ends `FOR` loops, `IF/ELSE`, `WHILE` and `TRY/EXCEPT` blocks. See `BuiltIn.FOR` docs'
115+
'Ends `FOR` loops, `GROUP`, `IF/ELSE`, `WHILE` and `TRY/EXCEPT` blocks. See `BuiltIn.FOR` docs'
116116
' at\n https://robotframework.org/robotframework/latest/'
117117
'RobotFrameworkUserGuide.html#for-loops.')
118118
kws.append(obj2)
@@ -205,6 +205,18 @@ def _build_default_kws(self):
205205
obj18 = BlockKeywordInfo('VAR', var_doc, 'ROBOT', 'BuiltIn',
206206
'name_of_variable', ARG_VALUES)
207207
kws.append(obj18)
208+
group_note = "*NOTE:* This marker exists since version 7.2" + (f" and is an error to use because your "
209+
f"version of Robot Framework is"
210+
f" {str(robot_version, encoding='UTF-8')}"
211+
if rbt_version < 720 else ".")
212+
group_doc = ('The GROUP syntax allows grouping related keywords and control structures together. Must be closed'
213+
' with `END`.\n\nArguments: (optional) name of the group.\n\n'
214+
f'\n\n{group_note}\n\n See `BuiltIn.GROUP` docs at\n https://robotframework.org/robotframework/latest/'
215+
f'RobotFrameworkUserGuide.html#group-syntax')
216+
217+
obj19 = BlockKeywordInfo('GROUP', group_doc, 'ROBOT', 'BuiltIn',
218+
'*name_of_group')
219+
kws.append(obj19)
208220
return kws
209221

210222
def _get_default_libraries(self):

src/robotide/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@
1515
#
1616
# Automatically generated by `tasks.py`.
1717

18-
VERSION = 'v2.2dev5'
18+
VERSION = 'v2.2dev6'

0 commit comments

Comments
 (0)