Skip to content

Commit c49bf40

Browse files
committed
feat(langserver)!: remove Robotidy support
Use robotframework-robocop>=6.0 for formatting.
1 parent 7c825de commit c49bf40

File tree

17 files changed

+16
-220
lines changed

17 files changed

+16
-220
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@ Add any other context about the problem here.
4545
- OS: [e.g. Windows, Linux]
4646
- Python Version [e.g. 3.9.7]
4747
- RobotFramework Version [e.g. 4.0.0]
48-
- Additional tools like robocop, robotidy
48+
- Additional tools like robocop

.github/ISSUE_TEMPLATE/question.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ A clear and concise description of the problem and the question at hand.
1717
- OS: [e.g. Windows, Linux]
1818
- Python Version [e.g. 3.9.7]
1919
- RobotFramework Version [e.g. 4.0.0]
20-
- Additional tools like robocop, robotidy
20+
- Additional tools like robocop

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ With RobotCode, you can focus on building and testing your automation workflows
4646
- **Debugging**: Debug your Robot Framework tests with ease.
4747
- **Command Line Tools**: A wide array of tools to assist in setting up and managing Robot Framework environments.
4848
- **Code Analysis with Robocop**: Install [Robocop](https://robocop.readthedocs.io/) for additional code analysis.
49-
- **Code Formatting**: Format your code using Robot Framework’s built-in tools like `robot.tidy` or [Robotidy](https://robotidy.readthedocs.io/).
49+
- **Code Formatting**: Use [Robocop's formatter](https://robocop.readthedocs.io/) for consistent code formatting.
5050
- **Multi-root Workspace Support**: Manage multiple Robot Framework projects with different Python environments simultaneously.
5151
- **Customizable Settings**: Configure the extension to fit your needs.
5252
- **RobotCode Repl and Notebooks**: Play with Robot Framework in a Jupyter Notebook-like environment.

docs/01_about/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ RobotCode extends the Robot Framework CLI with enhanced tools for test execution
4040

4141
### Code Formatting and Tidying
4242

43-
- **Automatic Code Formatting:** Keep your code clean and consistent with RobotCode’s formatting tools. You can choose to use the built-in `robot.tidy` tool (now deprecated) or the more powerful [Robotidy](https://robotidy.readthedocs.io/). With just a few clicks, your code is neatly organized and ready for review.
43+
- **Automatic Code Formatting:** Keep your code clean and consistent with RobotCode’s formatting tools. Use [Robocop's formatter](https://robocop.readthedocs.io/) for modern, consistent formatting directly in RobotCode.
4444
- **Customizable Formatting Options:** Tailor the formatting rules to suit your project’s needs, ensuring that your codebase remains consistent and easy to read.
4545

4646
### Running and Debugging

docs/03_reference/cli.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ To install all packages, including optional dependencies, use:
5858
pip install robotcode[all]
5959
```
6060

61-
This includes additional tools, such as [`robocop`](https://robocop.readthedocs.io) for linting and [`robotidy`](https://robotidy.readthedocs.io) for code formatting, which further enhance the development experience with Robot Framework.
61+
This includes additional tools, such as [`robocop`](https://robocop.readthedocs.io) for linting and formatting, which further enhance the development experience with Robot Framework.
6262

6363

6464
## Commands
@@ -298,7 +298,7 @@ robotcode analyze code [OPTIONS] [PATHS]...
298298

299299
- `-f, --filter PATTERN *`
300300

301-
Glob pattern to filter files to analyze. Can be specified multiple times.
301+
Glob pattern to filter files to analyze. Can be specified multiple times.
302302

303303

304304
- `-v, --variable name:value *`

intellij-client/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ With RobotCode, you can focus on building and testing your automation workflows
4949
- **Rich Test Reports**: View detailed test results and logs directly in the IDE.
5050
- **Code Analysis**: Leverage tools like [Robocop](https://robocop.readthedocs.io/) for linting and static code
5151
analysis.
52-
- **Formatting Made Easy**: Use [Robotidy](https://robotidy.readthedocs.io/) for consistent code formatting.
52+
- **Formatting Made Easy**: Use Robocop's built-in formatter for consistent code formatting.
5353
- **Support for `robot.toml`**: Manage your Robot Framework projects with ease.
5454
- **More Features Coming Soon!**
5555

package.json

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,33 +1186,7 @@
11861186
}
11871187
}
11881188
},
1189-
{
1190-
"title": "Formatting - Tidy",
1191-
"type": "object",
1192-
"properties": {
1193-
"robotcode.robotidy.enabled": {
1194-
"type": "boolean",
1195-
"default": true,
1196-
"markdownDescription": "Enables 'robotidy' code formatting, if installed. See [robotidy](https://github.com/MarketSquare/robotframework-tidy)",
1197-
"scope": "resource",
1198-
"markdownDeprecationMessage": "Using of `robotframework-tidy` is deprecated, because it is no longer maintained. Please use `robotframework-robocop>=6.0` instead."
1199-
},
1200-
"robotcode.robotidy.ignoreGitDir": {
1201-
"type": "boolean",
1202-
"default": true,
1203-
"markdownDescription": "Ignore .git directories when searching for the default configuration file. Corresponds to the `--ignore-git-dir` of _robotidy_ See [robotidy](https://github.com/MarketSquare/robotframework-tidy)",
1204-
"scope": "resource",
1205-
"markdownDeprecationMessage": "Using of `robotframework-tidy` is deprecated, because it is no longer maintained. Please use `robotframework-robocop>=6.0` instead."
1206-
},
1207-
"robotcode.robotidy.config": {
1208-
"type": "string",
1209-
"default": "",
1210-
"markdownDescription": "Read configuration from FILE path. Corresponds to the `--config` of _robotidy_ See [robotidy](https://github.com/MarketSquare/robotframework-tidy)",
1211-
"scope": "resource",
1212-
"markdownDeprecationMessage": "Using of `robotframework-tidy` is deprecated, because it is no longer maintained. Please use `robotframework-robocop>=6.0` instead."
1213-
}
1214-
}
1215-
},
1189+
12161190
{
12171191
"title": "Workspace",
12181192
"type": "object",
@@ -2058,7 +2032,7 @@
20582032
"name": "robot-get_environment_details",
20592033
"displayName": "Get Robot Framework Environment Informations",
20602034
"toolReferenceName": "robotGetEnvironmentInfo",
2061-
"modelDescription": "Retrieves detailed environment information for Robot Framework workspaces or files. Returns comprehensive details about the Python interpreter (version, executable path), installed Robot Framework version, RobotCode extension version, and optional tool versions (robocop, robotidy) if available. Use this tool when you need to diagnose environment issues, verify installations, check version compatibility, or troubleshoot Robot Framework setup problems. Limitations: Only provides information about the currently configured Python environment for the workspace, may not detect tools installed in different Python environments, requires proper workspace configuration to access environment details, and information accuracy depends on the current RobotCode language server connection.",
2035+
"modelDescription": "Retrieves detailed environment information for Robot Framework workspaces or files. Returns comprehensive details about the Python interpreter (version, executable path), installed Robot Framework version, RobotCode extension version, and optional tool versions (e.g., robocop) if available. Use this tool when you need to diagnose environment issues, verify installations, check version compatibility, or troubleshoot Robot Framework setup problems. Limitations: Only provides information about the currently configured Python environment for the workspace, may not detect tools installed in different Python environments, requires proper workspace configuration to access environment details, and information accuracy depends on the current RobotCode language server connection.",
20622036
"userDescription": "Gets informations about the Robot Framework Environment .",
20632037
"canBeReferencedInPrompt": true,
20642038
"tags": [

packages/core/pyproject.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ module = [
9191
"robot.*",
9292
"robotremoteserver.*",
9393
"debugpy.*",
94-
"robotidy.*",
9594
"robocop.*",
9695
"pluggy",
9796
]

packages/language_server/src/robotcode/language_server/robotframework/configuration.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,6 @@ class RoboCopConfig(ConfigBase):
3939
configurations: List[str] = field(default_factory=list)
4040

4141

42-
@config_section("robotcode.robotidy")
43-
@dataclass
44-
class RoboTidyConfig(ConfigBase):
45-
enabled: bool = True
46-
ignore_git_dir: bool = False
47-
config: Optional[str] = None
48-
49-
5042
@config_section("robotcode.documentationServer")
5143
@dataclass
5244
class DocumentationServerConfig(ConfigBase):
Lines changed: 4 additions & 130 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import io
22
import os
3-
from concurrent.futures import CancelledError
43
from typing import TYPE_CHECKING, Any, List, Optional, cast
54

65
from robotcode.core.language import language_id
@@ -15,7 +14,7 @@
1514
from robotcode.core.utils.logging import LoggingDescriptor
1615
from robotcode.robot.utils import get_robot_version
1716

18-
from ..configuration import RoboCopConfig, RoboTidyConfig
17+
from ..configuration import RoboCopConfig
1918
from .protocol_part import RobotLanguageServerProtocolPart
2019

2120
if TYPE_CHECKING:
@@ -30,9 +29,7 @@ def __init__(self, parent: "RobotLanguageServerProtocol") -> None:
3029

3130
parent.formatting.format.add(self.format)
3231

33-
if self.parent.robocop_helper.robotidy_installed or (
34-
self.parent.robocop_helper.robocop_installed and self.parent.robocop_helper.robocop_version >= (6, 0)
35-
):
32+
if self.parent.robocop_helper.robocop_installed and self.parent.robocop_helper.robocop_version >= (6, 0):
3633
parent.formatting.format_range.add(self.format_range)
3734

3835
self.space_count = 4
@@ -42,13 +39,6 @@ def __init__(self, parent: "RobotLanguageServerProtocol") -> None:
4239
self.setting_and_variable_name_length = 14
4340
self.is_robocop_notification_shown = False
4441

45-
def get_tidy_config(self, document: TextDocument) -> RoboTidyConfig:
46-
folder = self.parent.workspace.get_workspace_folder(document.uri)
47-
if folder is None:
48-
return RoboTidyConfig()
49-
50-
return self.parent.workspace.get_configuration(RoboTidyConfig, folder.uri)
51-
5242
def get_robocop_config(self, document: TextDocument) -> RoboCopConfig:
5343
folder = self.parent.workspace.get_workspace_folder(document.uri)
5444
if folder is None:
@@ -66,22 +56,8 @@ def format(
6656
**further_options: Any,
6757
) -> Optional[List[TextEdit]]:
6858
if self.parent.robocop_helper.robocop_installed and self.parent.robocop_helper.robocop_version >= (6, 0):
69-
if not self.is_robocop_notification_shown and self.parent.robocop_helper.robotidy_installed:
70-
self.parent.window.show_message(
71-
"`robotframework-robocop >= 6.0` is installed and will be used for formatting.\n\n"
72-
"`robotframework-tidy` is also detected in the workspace, but its use is redundant.\n"
73-
"Robocop fully supports all formatting tasks and provides a more comprehensive solution.\n\n"
74-
"Note: The use of `robotframework-tidy` is deprecated and should be avoided in favor of Robocop.",
75-
MessageType.INFO,
76-
)
77-
self.is_robocop_notification_shown = True
78-
7959
return self.format_robocop(document, options, **further_options)
8060

81-
tidy_config = self.get_tidy_config(document)
82-
if (tidy_config.enabled or get_robot_version() >= (5, 0)) and self.parent.robocop_helper.robotidy_installed:
83-
return self.format_robot_tidy(document, options, config=tidy_config, **further_options)
84-
8561
if get_robot_version() < (5, 0):
8662
return self.format_internal(document, options, **further_options)
8763

@@ -92,105 +68,6 @@ def format(
9268

9369
return None
9470

95-
def format_robot_tidy(
96-
self,
97-
document: TextDocument,
98-
options: FormattingOptions,
99-
range: Optional[Range] = None,
100-
config: Optional[RoboTidyConfig] = None,
101-
**further_options: Any,
102-
) -> Optional[List[TextEdit]]:
103-
try:
104-
if config is None:
105-
config = self.get_tidy_config(document)
106-
107-
model = self.parent.documents_cache.get_model(document, False)
108-
109-
if self.parent.robocop_helper.robotidy_version >= (3, 0):
110-
from robotidy.api import get_robotidy
111-
from robotidy.disablers import RegisterDisablers
112-
113-
if self.parent.robocop_helper.robotidy_version >= (4, 2):
114-
robot_tidy = get_robotidy(
115-
document.uri.to_path(),
116-
None,
117-
ignore_git_dir=config.ignore_git_dir,
118-
config=config.config,
119-
)
120-
elif self.parent.robocop_helper.robotidy_version >= (4, 1):
121-
robot_tidy = get_robotidy(
122-
document.uri.to_path(),
123-
None,
124-
ignore_git_dir=config.ignore_git_dir,
125-
)
126-
else:
127-
robot_tidy = get_robotidy(document.uri.to_path(), None)
128-
129-
if range is not None:
130-
robot_tidy.config.formatting.start_line = range.start.line + 1
131-
robot_tidy.config.formatting.end_line = range.end.line + 1
132-
133-
disabler_finder = RegisterDisablers(
134-
robot_tidy.config.formatting.start_line,
135-
robot_tidy.config.formatting.end_line,
136-
)
137-
disabler_finder.visit(model)
138-
139-
if self.parent.robocop_helper.robotidy_version >= (4, 11):
140-
if disabler_finder.is_disabled_in_file():
141-
return None
142-
else:
143-
if disabler_finder.file_disabled:
144-
return None
145-
146-
if self.parent.robocop_helper.robotidy_version >= (4, 0):
147-
_, _, new, _ = robot_tidy.transform_until_stable(model, disabler_finder)
148-
else:
149-
_, _, new = robot_tidy.transform(model, disabler_finder.disablers)
150-
151-
else:
152-
from robotidy.api import RobotidyAPI
153-
154-
robot_tidy = RobotidyAPI(document.uri.to_path(), None)
155-
156-
if range is not None:
157-
robot_tidy.formatting_config.start_line = range.start.line + 1
158-
robot_tidy.formatting_config.end_line = range.end.line + 1
159-
160-
if self.parent.robocop_helper.robotidy_version >= (2, 2):
161-
from robotidy.disablers import RegisterDisablers
162-
163-
disabler_finder = RegisterDisablers(
164-
robot_tidy.formatting_config.start_line,
165-
robot_tidy.formatting_config.end_line,
166-
)
167-
disabler_finder.visit(model)
168-
if disabler_finder.file_disabled:
169-
return None
170-
_, _, new = robot_tidy.transform(model, disabler_finder.disablers)
171-
else:
172-
_, _, new = robot_tidy.transform(model)
173-
174-
if new.text == document.text():
175-
return None
176-
177-
return [
178-
TextEdit(
179-
range=Range(
180-
start=Position(line=0, character=0),
181-
end=Position(line=len(document.get_lines()), character=0),
182-
),
183-
new_text=new.text,
184-
)
185-
]
186-
187-
except (SystemExit, KeyboardInterrupt, CancelledError):
188-
raise
189-
except BaseException as e:
190-
self._logger.exception(e)
191-
self.parent.window.show_message(f"Executing `robotidy` failed: {e}", MessageType.ERROR)
192-
return None
193-
19471
def format_robocop(
19572
self,
19673
document: TextDocument,
@@ -278,10 +155,7 @@ def format_range(
278155
options: FormattingOptions,
279156
**further_options: Any,
280157
) -> Optional[List[TextEdit]]:
281-
config = self.get_tidy_config(document)
282-
if (config.enabled and self.parent.robocop_helper.robotidy_installed) or (
283-
self.parent.robocop_helper.robocop_installed and self.parent.robocop_helper.robocop_version >= (6, 0)
284-
):
285-
return self.format_robot_tidy(document, options, range=range, config=config, **further_options)
158+
if self.parent.robocop_helper.robocop_installed and self.parent.robocop_helper.robocop_version >= (6, 0):
159+
return self.format_robocop(document, options, range=range, **further_options)
286160

287161
return None

0 commit comments

Comments
 (0)