diff --git a/CLAUDE.md b/CLAUDE.md index bcb7b2222..b1026b7d2 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -98,7 +98,7 @@ cd intellij-client hatch run test # Test specific environment -hatch run devel.py312-rf73:test +hatch run devel.py3.12-rf73:test # Coverage reporting hatch run cov diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 58b8c0182..8f059b013 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -243,7 +243,7 @@ You can also check available environments with: `hatch env show` 1. **Create a branch:** `git checkout -b feature/your-feature-name` 2. **Make your changes** following the project's coding standards -3. **Run tests:** `hatch run devel.py312-rf73:test` (single combination for faster development) +3. **Run tests:** `hatch run devel.py3.12-rf73:test` (single combination for faster development) 4. **Run linting:** `hatch run lint:all` (or use the VS Code task) 5. **Fix linting issues:** `hatch run lint:style` for formatting 6. **Commit your changes** with a descriptive commit message @@ -297,20 +297,23 @@ hatch run test.rf41:test # Robot Framework 4.1.x # Run tests in specific development environments (single combination) hatch run devel:test # ⚠️ Runs ALL matrix combinations (Python 3.10-3.14 × RF 4.1-7.3) -hatch run devel.py311-rf70:test # Python 3.11 with Robot Framework 7.0.x (single combination) -hatch run devel.py312-rf73:test # Python 3.12 with Robot Framework 7.3.x (single combination) -hatch run devel.py313-rf73:test # Python 3.13 with Robot Framework 7.3.x (single combination) +hatch run devel.py3.11-rf70:test # Python 3.11 with Robot Framework 7.0.x (single combination) +hatch run devel.py3.12-rf73:test # Python 3.12 with Robot Framework 7.3.x (single combination) +hatch run devel.py3.13-rf73:test # Python 3.13 with Robot Framework 7.3.x (single combination) # Test against development versions of Robot Framework hatch run rfbeta:test # Robot Framework beta/RC versions hatch run rfmaster:test # Robot Framework master branch hatch run rfdevel:test # Local Robot Framework development version + +# Test with Robocop development version +hatch run robocopmain:test # Robocop main branch ``` **⚠️ Important Matrix Behavior:** - `hatch run test` executes tests for **all combinations** in the matrix (48 combinations: 6 Python versions × 8 RF versions) - `hatch run devel:test` also runs **all matrix combinations** -- For faster development, use specific combinations like `hatch run devel.py312-rf73:test` +- For faster development, use specific combinations like `hatch run devel.py3.12-rf73:test` - For CI/full testing, use the matrix commands **Available Environment Matrix:** diff --git a/hatch.toml b/hatch.toml index 223027951..39793f083 100644 --- a/hatch.toml +++ b/hatch.toml @@ -49,7 +49,13 @@ extra-dependencies = ["robotframework==7.2rc1"] [envs.rfmaster] python = "3.12" extra-dependencies = [ - "robotframework @ git+https://github.com/robotframework/robotframework.git", + "robotframework @ git+https://github.com/robotframework/robotframework.git" +] + +[envs.robocopmain] +python = "3.12" +extra-dependencies = [ + "robotframework-robocop @ git+https://github.com/MarketSquare/robotframework-robocop.git" ] [envs.rfdevel] diff --git a/packages/language_server/src/robotcode/language_server/robotframework/parts/formatting.py b/packages/language_server/src/robotcode/language_server/robotframework/parts/formatting.py index 418ce8ec7..3121e7c07 100644 --- a/packages/language_server/src/robotcode/language_server/robotframework/parts/formatting.py +++ b/packages/language_server/src/robotcode/language_server/robotframework/parts/formatting.py @@ -83,17 +83,26 @@ def format_robocop( config_manager = self.parent.robocop_helper.get_config_manager(workspace_folder) + source = document.uri.to_path() config = config_manager.get_config_for_source_file(document.uri.to_path()) if range is not None: config.formatter.start_line = range.start.line + 1 config.formatter.end_line = range.end.line + 1 + # TODO: not cached, we load all formatters everytime - but it's small cost runner = RobocopFormatter(config_manager) runner.config = config model = self.parent.documents_cache.get_model(document, False) - _, _, new, _ = runner.format_until_stable(model) + if get_robot_version() >= (8, 0): + from robocop.source_file import SourceFile + + # overwrite _model to stop Robocop from loading it + source_file = SourceFile(path=source, config=config, _model=model) + _, _, new, _ = runner.format_until_stable(source_file) + else: + _, _, new, _ = runner.format_until_stable(model) if new.text == document.text(): return None diff --git a/packages/language_server/src/robotcode/language_server/robotframework/parts/robocop_diagnostics.py b/packages/language_server/src/robotcode/language_server/robotframework/parts/robocop_diagnostics.py index 2278e7b77..2c2c06a93 100644 --- a/packages/language_server/src/robotcode/language_server/robotframework/parts/robocop_diagnostics.py +++ b/packages/language_server/src/robotcode/language_server/robotframework/parts/robocop_diagnostics.py @@ -44,6 +44,15 @@ def get_config(self, document: TextDocument) -> Optional[RoboCopConfig]: return self.parent.workspace.get_configuration(RoboCopConfig, folder.uri) + def get_linter(self, workspace_folder: WorkspaceFolder) -> "RobocopLinter": + linter = self._robocop_linters.get(workspace_folder, None) + + if linter is None: + config_manager = self.parent.robocop_helper.get_config_manager(workspace_folder) + linter = RobocopLinter(config_manager) + self._robocop_linters[workspace_folder] = linter + return linter + @language_id("robotframework") @_logger.call def collect_diagnostics( @@ -69,23 +78,21 @@ def collect_diagnostics( @_logger.call def collect(self, document: TextDocument, workspace_folder: WorkspaceFolder) -> List[Diagnostic]: from robocop.linter.rules import RuleSeverity - from robocop.linter.runner import RobocopLinter - linter = self._robocop_linters.get(workspace_folder, None) - - if linter is None: - config_manager = self.parent.robocop_helper.get_config_manager(workspace_folder) - - config = config_manager.get_config_for_source_file(document.uri.to_path()) - - linter = RobocopLinter(config_manager) - self._robocop_linters[workspace_folder] = linter + linter = self.get_linter(workspace_folder) source = document.uri.to_path() - config = linter.config_manager.get_config_for_source_file(source) model = self.parent.documents_cache.get_model(document, False) - diagnostics = linter.run_check(model, source, config) + + if self.parent.robocop_helper.robocop_version >= (8, 0): + from robocop.source_file import SourceFile + + # overwrite _model to stop Robocop from loading it + source_file = SourceFile(path=source, config=config, _model=model) + diagnostics = linter.run_check(source_file) + else: + diagnostics = linter.run_check(model, source, config) return [ Diagnostic(