|
16 | 16 | DidOpenTextDocumentParams, |
17 | 17 | DocumentFormattingParams, |
18 | 18 | Position, |
| 19 | + PublishDiagnosticsParams, |
19 | 20 | Range, |
20 | 21 | TEXT_DOCUMENT_DID_CHANGE, |
21 | 22 | TEXT_DOCUMENT_DID_OPEN, |
22 | 23 | TEXT_DOCUMENT_FORMATTING, |
23 | 24 | TextEdit, |
24 | 25 | ) |
25 | | -from pygls.server import LanguageServer |
| 26 | +from pygls.lsp.server import LanguageServer |
26 | 27 | from pygls.workspace.text_document import TextDocument |
27 | 28 |
|
28 | 29 | from .__version__ import __version__ |
@@ -69,12 +70,12 @@ def diagnostic_generator( |
69 | 70 | """ |
70 | 71 | LSP wrapper (provides document state from `pygls`) for `fixit_bytes`. |
71 | 72 | """ |
72 | | - path = Uri.to_fs_path(uri) |
73 | | - if not path: |
| 73 | + path_uri = Uri.to_fs_path(uri) |
| 74 | + if not path_uri: |
74 | 75 | return None |
75 | | - path = Path(path) |
| 76 | + path = Path(path_uri) |
76 | 77 |
|
77 | | - doc: TextDocument = self.lsp.workspace.get_document(uri) # type: ignore[no-untyped-call] |
| 78 | + doc: TextDocument = self.lsp.workspace.get_text_document(uri) # type: ignore[no-untyped-call] |
78 | 79 | return fixit_bytes( |
79 | 80 | path, |
80 | 81 | doc.source.encode(), |
@@ -107,7 +108,9 @@ def _validate(self, uri: str, version: int) -> None: |
107 | 108 | source="fixit", |
108 | 109 | ) |
109 | 110 | diagnostics.append(diagnostic) |
110 | | - self.lsp.publish_diagnostics(uri, diagnostics, version=version) |
| 111 | + self.lsp.text_document_publish_diagnostics( |
| 112 | + PublishDiagnosticsParams(uri, diagnostics, version) |
| 113 | + ) |
111 | 114 |
|
112 | 115 | def validate(self, uri: str, version: int) -> None: |
113 | 116 | """ |
@@ -137,7 +140,9 @@ def format(self, params: DocumentFormattingParams) -> Optional[List[TextEdit]]: |
137 | 140 | if not formatted_content: |
138 | 141 | return None |
139 | 142 |
|
140 | | - doc: TextDocument = self.lsp.workspace.get_document(params.text_document.uri) # type: ignore[no-untyped-call] |
| 143 | + doc: TextDocument = self.lsp.workspace.get_text_document( |
| 144 | + params.text_document.uri |
| 145 | + ) |
141 | 146 | entire_range = Range( |
142 | 147 | start=Position(line=0, character=0), |
143 | 148 | end=Position(line=len(doc.lines) - 1, character=len(doc.lines[-1])), |
|
0 commit comments