|
1 | 1 | # Copyright 2017-2020 Palantir Technologies, Inc.
|
2 | 2 | # Copyright 2021- Python Language Server Contributors.
|
3 | 3 |
|
4 |
| -"""Some Language Server Protocol constants |
| 4 | +"""Some Language Server Protocol constants. |
5 | 5 |
|
6 | 6 | https://github.com/Microsoft/language-server-protocol/blob/master/protocol.md
|
7 | 7 | """
|
8 | 8 |
|
| 9 | +from enum import Enum |
| 10 | +from typing import Optional, TypedDict |
| 11 | + |
9 | 12 |
|
10 | 13 | class CompletionItemKind:
|
11 | 14 | Text = 1
|
@@ -41,14 +44,14 @@ class DocumentHighlightKind:
|
41 | 44 | Write = 3
|
42 | 45 |
|
43 | 46 |
|
44 |
| -class DiagnosticSeverity: |
| 47 | +class DiagnosticSeverity(int, Enum): |
45 | 48 | Error = 1
|
46 | 49 | Warning = 2
|
47 | 50 | Information = 3
|
48 | 51 | Hint = 4
|
49 | 52 |
|
50 | 53 |
|
51 |
| -class DiagnosticTag: |
| 54 | +class DiagnosticTag(int, Enum): |
52 | 55 | Unnecessary = 1
|
53 | 56 | Deprecated = 2
|
54 | 57 |
|
@@ -113,3 +116,31 @@ class ErrorCodes:
|
113 | 116 | ContentModified = -32801
|
114 | 117 | RequestCancelled = -32800
|
115 | 118 | lspReservedErrorRangeEnd = -32800
|
| 119 | + |
| 120 | + |
| 121 | +class Position(TypedDict): |
| 122 | + """Position in a text document expressed as zero-based line and character offset. |
| 123 | +
|
| 124 | + A position is between two characters like an 'insert' cursor in a editor. |
| 125 | + Special values like for example (-1,-1) which indicates that the position |
| 126 | + is invalid. |
| 127 | + """ |
| 128 | + |
| 129 | + line: int |
| 130 | + character: int |
| 131 | + |
| 132 | +class Range(TypedDict): |
| 133 | + """The range type represents a span of text in the document.""" |
| 134 | + |
| 135 | + start: Position |
| 136 | + end: Position |
| 137 | + |
| 138 | +class Diagnostic(TypedDict): |
| 139 | + """The type of a diagnostic the lsp should publish.""" |
| 140 | + |
| 141 | + source: str |
| 142 | + range: Range |
| 143 | + message: str |
| 144 | + severity: DiagnosticSeverity |
| 145 | + code: str |
| 146 | + tags: list[DiagnosticTag] |
0 commit comments