Skip to content

Commit

Permalink
Add syntax colorization for GROUP marker. Improve Gherking recognitio…
Browse files Browse the repository at this point in the history
…n for multiple words.
  • Loading branch information
HelioGuilherme66 committed Feb 14, 2025
1 parent 85192a4 commit a4de481
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 14 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ and this project adheres to http://semver.org/spec/v2.0.0.html[Semantic Versioni

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

=== Added
- Added syntax colorization for the ``GROUP`` marker. Improved colorization for multiple Gherkin words, for example in the French language.

=== Fixed

- Fixed multiple scroll bars in Grid Editor when editing Test Cases or Keywords. This caused bad navigation on cells.
Expand Down
2 changes: 1 addition & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ Likewise, the current version of wxPython, is 4.2.2, but RIDE is known to work w

`pip install -U robotframework-ride`

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

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

Expand Down
9 changes: 8 additions & 1 deletion src/robotide/application/CHANGELOG.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<!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>
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; ">
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="_added1"></a>1.1. Added</h3></div></div></div><div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; ">
<li class="listitem">Added syntax colorization for the <em>GROUP</em> marker. Improved colorization for multiple Gherkin words, for
example in the French language.
</li>
</ul></div>

<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; ">
<li class="listitem">
Fixed multiple scroll bars in Grid Editor when editing Test Cases or Keywords. This caused bad navigation on cells.
</li>
Expand Down
4 changes: 3 additions & 1 deletion src/robotide/application/releasenotes.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,8 @@ def set_content(self, html_win, content):
</ul>
<p><strong>New Features and Fixes Highlights</strong></p>
<ul class="simple">
<li>Added syntax colorization for the <em>GROUP</em> marker. Improved colorization for multiple Gherkin words, for
example in the French language.</li>
<li>Fixed multiple scroll bars in Grid Editor when editing Test Cases or Keywords. This caused bad navigation on cells.</li>
<li>Regression fix from v2.1b1 - Fix wrong item selection, like Test Suite, when doing right-click actions in
Project Explorer.</li>
Expand Down Expand Up @@ -225,7 +227,7 @@ def set_content(self, html_win, content):
<pre class="literal-block">python -m robotide.postinstall -install</pre>
<p>or</p>
<pre class="literal-block">ride_postinstall.py -install</pre>
<p>RIDE {VERSION} was released on 13/February/2025.</p>
<p>RIDE {VERSION} was released on 14/February/2025.</p>
<!-- <br/>
<h3>May The Fourth Be With You!</h3>
<h3>Celebrate the bank holiday, 10th June, Day of Portugal, Portuguese Communities and Camões!!</h3>
Expand Down
3 changes: 2 additions & 1 deletion src/robotide/controller/ctrlcommands.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ class NullObserver(object):


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

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


INDENTED_INNER = ['ELSE', 'ELSE IF', 'EXCEPT', 'FINALLY']
INDENTED_START = ['FOR', 'IF', 'WHILE', 'TRY'] + INDENTED_INNER
INDENTED_START = ['FOR', 'GROUP', 'IF', 'WHILE', 'TRY'] + INDENTED_INNER


def is_indent_start(cell):
Expand Down
16 changes: 9 additions & 7 deletions src/robotide/lib/compat/parsing/languages.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,10 @@ def __init__(self, languages: 'Iterable[LanguageLike]|LanguageLike|None' = (), a
@property
def bdd_prefix_regexp(self):
if not self._bdd_prefix_regexp:
prefixes = '|'.join(self.bdd_prefixes).replace(' ', r'\s').lower()
self._bdd_prefix_regexp = re.compile(rf'({prefixes})\s', re.IGNORECASE)
# Sort prefixes by descending length so that the longest ones are matched first
prefixes = sorted(self.bdd_prefixes, key=len, reverse=True)
pattern = '|'.join(prefix.replace(' ', r'\s') for prefix in prefixes).lower()
self._bdd_prefix_regexp = re.compile(rf'({pattern})\s', re.IGNORECASE)
return self._bdd_prefix_regexp

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

Expand Down
4 changes: 3 additions & 1 deletion src/robotide/lib/compat/pygments/robotframework.py
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,9 @@ def __init__(self, new_lang=None):
self.new_lang = new_lang
if self.new_lang is None:
self.new_lang = Language.from_name('En')
self.normalized_bdd_prefixes = normalize_pipe_list(list(self.new_lang.bdd_prefixes), spaces=False)
# Sort prefixes by descending length so that the longest ones are matched first
prefixes = sorted(self.new_lang.bdd_prefixes, key=len, reverse=True)
self.normalized_bdd_prefixes = normalize_pipe_list(list(prefixes), spaces=False)
# print(f"DEBUG: robotframework.py GherkinTokenizer _tokenize DEFINITION GHERKIN"
# f" BDDPREFIXES={self.new_lang.bdd_prefixes}\n"
# f"PATTERN='^({self.normalized_bdd_prefixes}) '"
Expand Down
14 changes: 13 additions & 1 deletion src/robotide/namespace/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ def _build_default_kws(self):
'ROBOT', 'BuiltIn', 'loop_variables', 'selector', ARG_VALUES)
kws.append(obj1)
obj2 = BlockKeywordInfo('END',
'Ends `FOR` loops, `IF/ELSE`, `WHILE` and `TRY/EXCEPT` blocks. See `BuiltIn.FOR` docs'
'Ends `FOR` loops, `GROUP`, `IF/ELSE`, `WHILE` and `TRY/EXCEPT` blocks. See `BuiltIn.FOR` docs'
' at\n https://robotframework.org/robotframework/latest/'
'RobotFrameworkUserGuide.html#for-loops.')
kws.append(obj2)
Expand Down Expand Up @@ -205,6 +205,18 @@ def _build_default_kws(self):
obj18 = BlockKeywordInfo('VAR', var_doc, 'ROBOT', 'BuiltIn',
'name_of_variable', ARG_VALUES)
kws.append(obj18)
group_note = "*NOTE:* This marker exists since version 7.2" + (f" and is an error to use because your "
f"version of Robot Framework is"
f" {str(robot_version, encoding='UTF-8')}"
if rbt_version < 720 else ".")
group_doc = ('The GROUP syntax allows grouping related keywords and control structures together. Must be closed'
' with `END`.\n\nArguments: (optional) name of the group.\n\n'
f'\n\n{group_note}\n\n See `BuiltIn.GROUP` docs at\n https://robotframework.org/robotframework/latest/'
f'RobotFrameworkUserGuide.html#group-syntax')

obj19 = BlockKeywordInfo('GROUP', group_doc, 'ROBOT', 'BuiltIn',
'*name_of_group')
kws.append(obj19)
return kws

def _get_default_libraries(self):
Expand Down
2 changes: 1 addition & 1 deletion src/robotide/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
#
# Automatically generated by `tasks.py`.

VERSION = 'v2.2dev5'
VERSION = 'v2.2dev6'

0 comments on commit a4de481

Please sign in to comment.