diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-08-26 10:21:50 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-08-26 10:21:50 +0000 |
commit | 61fd100acb820f1490acea2dd694ee680e1ffa91 (patch) | |
tree | 30633f81b6f68157a79316c9589f84decb9c6936 /tests/lint_tests/lint_tutil.py | |
parent | Adding upstream version 0.1.41. (diff) | |
download | debputy-61fd100acb820f1490acea2dd694ee680e1ffa91.tar.xz debputy-61fd100acb820f1490acea2dd694ee680e1ffa91.zip |
Adding upstream version 0.1.42.upstream/0.1.42
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/lint_tests/lint_tutil.py')
-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) |