Skip to content

Commit

Permalink
feat(langserver): added support for GROUP block in RF 7.2
Browse files Browse the repository at this point in the history
  • Loading branch information
d-biehl committed Dec 19, 2024
1 parent 98c96f9 commit 6495d59
Show file tree
Hide file tree
Showing 1,507 changed files with 181,729 additions and 8 deletions.
14 changes: 10 additions & 4 deletions hatch.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ create-json-schema = "python ./scripts/create_robot_toml_json_schema.py"
generate-rf-options = "python ./scripts/generate_rf_options.py"
install-packages = "python ./scripts/install_packages.py"

[envs.rflatest313]
[envs.rfbeta]
python = "3.13"
extra-dependencies = ["robotframework==7.1"]
extra-dependencies = ["robotframework==7.2b1"]

[envs.rfmaster313]
python = "3.13"
Expand Down Expand Up @@ -76,7 +76,7 @@ python = "3.8"

[[envs.devel.matrix]]
python = ["3.8", "3.9", "3.10", "3.11", "3.12", "3.13"]
rf = ["rf41", "rf50", "rf60", "rf61", "rf70", "rf71"]
rf = ["rf41", "rf50", "rf60", "rf61", "rf70", "rf71", "rf72"]

[envs.devel.overrides]
matrix.rf.dependencies = [
Expand All @@ -98,14 +98,17 @@ matrix.rf.dependencies = [
{ value = "robotframework>=7.1, <7.2", if = [
"rf71",
] },
{ value = "robotframework>=7.2, <7.3", if = [
"rf72b1",
] },
]

[envs.hatch-test]
dependencies = ["pytest", "pytest-html", "pytest_asyncio>=0.23", "pyyaml"]
pre-install-commands = ["python ./scripts/install_packages.py"]

[[envs.test.matrix]]
rf = ["rf41", "rf50", "rf60", "rf61", "rf70", "rf71"]
rf = ["rf41", "rf50", "rf60", "rf61", "rf70", "rf71", "rf72"]

[envs.test.overrides]
matrix.rf.dependencies = [
Expand All @@ -127,6 +130,9 @@ matrix.rf.dependencies = [
{ value = "robotframework>=7.1, <7.2", if = [
"rf71",
] },
{ value = "robotframework>=7.2, <7.3", if = [
"rf72b1",
] },
]

[envs.lint]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,18 @@ def get_snippets() -> Dict[str, List[str]]:
"VAR &{}": [r"VAR &{${1}} ${0}"],
}
)

if get_robot_version() >= (7, 2):
__snippets.update(
{
"GROUP": [
"GROUP ${1}",
" $0",
"END",
"",
]
}
)
return __snippets


Expand All @@ -283,10 +295,12 @@ def get_reserved_keywords() -> List[str]:
"CONTINUE",
"RETURN",
]

if get_robot_version() >= (7, 0):
__reserved_keywords += ["VAR"]
else:
__reserved_keywords += ["ELIF"]

if get_robot_version() >= (7, 2):
__reserved_keywords += ["GROUP"]

__reserved_keywords = sorted(__reserved_keywords)
return __reserved_keywords
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ def visit_ForLoop(self, node: ast.AST) -> None: # noqa: N802
self.__append(node, kind="for_loop")
self.generic_visit(node)

def visit_Group(self, node: ast.AST) -> None: # noqa: N802
self.__append(node, kind="group")
self.generic_visit(node)

def visit_For(self, node: ast.AST) -> None: # noqa: N802
self.__append(node, kind="for")
self.generic_visit(node)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,12 @@ def generate_mapping(cls) -> Dict[str, Tuple[Enum, Optional[Set[Enum]]]]:
}
)

if get_robot_version() >= (7, 2):
definition.update(
{
frozenset({Token.GROUP}): (RobotSemTokenTypes.CONTROL_FLOW, None),
}
)
result: Dict[str, Tuple[Enum, Optional[Set[Enum]]]] = {}
for k, v in definition.items():
for e in k:
Expand Down
2 changes: 1 addition & 1 deletion syntaxes/robotframework.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@
"control_flow_statements": {
"name": "meta.keyword-call.content.robotframework",
"contentName": "string.unquoted.argument.robotframework",
"begin": "^(?!(?: {2,}| ?\\t ?)+(?:(?=[$\\[@&%]|\\.)))(?: {2,}| ?\\t ?)+(FOR|END|ELSE|TRY|EXCEPT|FINALLY)(?= {2,}| ?\\t ?| ?$)",
"begin": "^(?!(?: {2,}| ?\\t ?)+(?:(?=[$\\[@&%]|\\.)))(?: {2,}| ?\\t ?)+(FOR|GROUP|END|ELSE|TRY|EXCEPT|FINALLY)(?= {2,}| ?\\t ?| ?$)",
"end": "^(?!(\\s*(\\.\\.\\.((( {2}| ?\\t)\\s*\\S.*)|(\\s*))?$))|(\\s*#.*$)|(\\s*$))",
"beginCaptures": { "1": { "name": "keyword.control.flow.robotframework" } },
"patterns": [
Expand Down
2 changes: 1 addition & 1 deletion syntaxes/robotframework.tmLanguage.template.json
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@
"control_flow_statements": {
"name": "meta.keyword-call.content.robotframework",
"contentName": "string.unquoted.argument.robotframework",
"begin": "^(?!(?: {2,}| ?\\t ?)+(?:(?=[$\\[@&%]|\\.)))(?: {2,}| ?\\t ?)+(FOR|END|ELSE|TRY|EXCEPT|FINALLY)(?= {2,}| ?\\t ?| ?$)",
"begin": "^(?!(?: {2,}| ?\\t ?)+(?:(?=[$\\[@&%]|\\.)))(?: {2,}| ?\\t ?)+(FOR|GROUP|END|ELSE|TRY|EXCEPT|FINALLY)(?= {2,}| ?\\t ?| ?$)",
"end": "^(?!(\\s*(\\.\\.\\.((( {2}| ?\\t)\\s*\\S.*)|(\\s*))?$))|(\\s*#.*$)|(\\s*$))",
"beginCaptures": { "1": { "name": "keyword.control.flow.robotframework" } },
"patterns": [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
result: !SemanticTokens
data:
- 0
- 0
- 18
- 29
- 0
- 1
- 0
- 5
- 33
- 1
- 1
- 4
- 5
- 39
- 0
- 0
- 9
- 9
- 36
- 0
- 1
- 8
- 5
- 39
- 0
- 1
- 4
- 3
- 39
- 0
- 2
- 4
- 5
- 39
- 0
- 0
- 9
- 11
- 36
- 0
- 1
- 8
- 6
- 39
- 0
- 1
- 8
- 5
- 39
- 0
- 0
- 9
- 5
- 36
- 0
- 1
- 12
- 6
- 39
- 0
- 2
- 8
- 3
- 39
- 0
- 2
- 4
- 3
- 39
- 0
result_id: null
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
result: !SemanticTokens
data:
- 0
- 0
- 18
- 29
- 0
- 1
- 0
- 5
- 33
- 1
- 1
- 4
- 5
- 39
- 0
- 0
- 9
- 9
- 36
- 0
- 1
- 8
- 5
- 39
- 0
- 1
- 4
- 3
- 39
- 0
- 2
- 4
- 5
- 39
- 0
- 0
- 9
- 11
- 36
- 0
- 1
- 8
- 6
- 39
- 0
- 1
- 8
- 5
- 39
- 0
- 0
- 9
- 5
- 36
- 0
- 1
- 12
- 6
- 39
- 0
- 2
- 8
- 3
- 39
- 0
- 2
- 4
- 3
- 39
- 0
result_id: null
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
result: !SemanticTokens
data:
- 0
- 0
- 18
- 29
- 0
- 1
- 0
- 5
- 33
- 1
- 1
- 4
- 5
- 39
- 0
- 0
- 9
- 9
- 36
- 0
- 1
- 8
- 5
- 39
- 0
- 1
- 4
- 3
- 39
- 0
- 2
- 4
- 5
- 39
- 0
- 0
- 9
- 11
- 36
- 0
- 1
- 8
- 6
- 39
- 0
- 1
- 8
- 5
- 39
- 0
- 0
- 9
- 5
- 36
- 0
- 1
- 12
- 6
- 39
- 0
- 2
- 8
- 3
- 39
- 0
- 2
- 4
- 3
- 39
- 0
result_id: null
Loading

0 comments on commit 6495d59

Please sign in to comment.