diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-08-26 10:21:51 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-08-26 10:21:51 +0000 |
commit | 6be310341b51446a28dc27c35bd277b250756827 (patch) | |
tree | 17d41d8a5e09c8f0b6c26a3e26c5f82b84cbe42e /tests/lint_tests/lint_tutil.py | |
parent | Releasing progress-linux version 0.1.41-0.0~progress7.99u1. (diff) | |
download | debputy-6be310341b51446a28dc27c35bd277b250756827.tar.xz debputy-6be310341b51446a28dc27c35bd277b250756827.zip |
Merging upstream version 0.1.42.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | tests/lint_tests/lint_tutil.py | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/tests/lint_tests/lint_tutil.py b/tests/lint_tests/lint_tutil.py index 267f669..74e08db 100644 --- a/tests/lint_tests/lint_tutil.py +++ b/tests/lint_tests/lint_tutil.py @@ -1,5 +1,5 @@ import collections -from typing import List, Optional, Mapping, Any, Callable +from typing import List, Optional, Mapping, Any, Callable, Sequence import pytest @@ -13,7 +13,7 @@ from debputy.lsp.style_prefs import StylePreferenceTable, EffectivePreference from debputy.packages import DctrlParser from debputy.plugin.api.feature_set import PluginProvidedFeatureSet -from debputy.lsprotocol.types import Diagnostic, DiagnosticSeverity +from debputy.lsprotocol.types import Diagnostic, DiagnosticSeverity, Range try: @@ -108,3 +108,18 @@ def group_diagnostics_by_severity( by_severity[severity].append(diagnostic) return by_severity + + +def diag_range_to_text(lines: Sequence[str], range_: "Range") -> str: + parts = [] + for line_no in range(range_.start.line, range_.end.line + 1): + line = lines[line_no] + chunk = line + if line_no == range_.start.line and line_no == range_.end.line: + chunk = line[range_.start.character : range_.end.character] + elif line_no == range_.start.line: + chunk = line[range_.start.character :] + elif line_no == range_.end.line: + chunk = line[: range_.end.character] + parts.append(chunk) + return "".join(parts) |