API reference¶
The importable Python surface: the pure diagnostic engine, which any
tool can call in-process, and the server glue that maps its results to
lsprotocol and publishes them. Generated from the docstrings by
mkdocstrings.
bankstatementparser_lsp.diagnostics
¶
Pure diagnostic engine for MT940 bank statement documents.
No LSP or editor dependencies, so it is unit-testable in isolation.
Given the raw text of an MT940 (.mt940/.sta) file it returns a
list of :class:Diagnostic objects locating missing mandatory tags and
malformed balance / statement lines, using the same tag patterns the
bankstatementparser MT940 parser relies on.
Severity
¶
Bases: IntEnum
Diagnostic severity, matching the LSP numeric scale.
Source code in bankstatementparser_lsp/diagnostics.py
34 35 36 37 38 39 40 | |
Diagnostic
dataclass
¶
A single editor diagnostic over a 0-based line/character range.
Attributes:
| Name | Type | Description |
|---|---|---|
line |
int
|
Zero-based line index of the affected text. |
col_start |
int
|
Zero-based start character on the line. |
col_end |
int
|
Zero-based end character (exclusive) on the line. |
severity |
Severity
|
Diagnostic severity. |
message |
str
|
Human-readable description of the problem. |
code |
str
|
Stable machine-readable rule identifier. |
Source code in bankstatementparser_lsp/diagnostics.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 | |
diagnostics_for_mt940(text)
¶
Lint an MT940 statement document and return diagnostics.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The full text of the MT940 document. |
required |
Returns:
| Type | Description |
|---|---|
list[Diagnostic]
|
A list of :class: |
list[Diagnostic]
|
is clean or has no content). |
Source code in bankstatementparser_lsp/diagnostics.py
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 | |
bankstatementparser_lsp.server
¶
Language Server (stdio) for MT940 bank statement files.
Wraps the pure :mod:bankstatementparser_lsp.diagnostics engine in a
pygls server so editors get live missing-tag and malformed-line
diagnostics as they type. Run it with bankstatementparser-lsp.
main()
¶
Start the language server over stdio.
Source code in bankstatementparser_lsp/server.py
102 103 104 | |
did_open(ls, params)
¶
Lint a document when it is opened.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ls
|
LanguageServer
|
The active language server. |
required |
params
|
DidOpenTextDocumentParams
|
The open-document notification parameters. |
required |
Source code in bankstatementparser_lsp/server.py
76 77 78 79 80 81 82 83 84 85 86 | |
did_change(ls, params)
¶
Re-lint a document when it changes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ls
|
LanguageServer
|
The active language server. |
required |
params
|
DidChangeTextDocumentParams
|
The change-document notification parameters. |
required |
Source code in bankstatementparser_lsp/server.py
89 90 91 92 93 94 95 96 97 98 99 | |
_to_lsp_diagnostic(diagnostic)
¶
Convert an internal diagnostic to an LSP diagnostic.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
diagnostic
|
Diagnostic
|
The engine-produced diagnostic. |
required |
Returns:
| Type | Description |
|---|---|
Diagnostic
|
The equivalent |
Source code in bankstatementparser_lsp/server.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | |
_publish(ls, uri)
¶
Lint a document and publish its diagnostics to the client.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
ls
|
LanguageServer
|
The active language server. |
required |
uri
|
str
|
URI of the document to lint. |
required |
Source code in bankstatementparser_lsp/server.py
60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |