Source code for lsp

# lsp.py - Language Server Protocol data structures and support functions
#
# Copyright 20w0  by Eckhart Arnold (arnold@badw.de)
#                 Bavarian Academy of Sciences an Humanities (badw.de)
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied.  See the License for the specific language governing
# permissions and limitations under the License.

"""Module lsp.py defines (some of) the constants and data structures from
the Language Server Protocol. See:
<https://microsoft.github.io/language-server-protocol/specifications/specification-current/>

EXPERIMENTAL!!!
"""

from __future__ import annotations

import bisect
from enum import Enum, IntEnum

from typing import Union, List, Tuple, Optional, Dict, Any, \
    Iterator, Iterable, Callable
try:
    from typing_extensions import Generic, TypeVar, Literal, TypeAlias
except ImportError:
    from DHParser.externallibs.typing_extensions import Generic, TypeVar, Literal, TypeAlias

from DHParser.json_validation import TypedDict, GenericTypedDict, \
    validate_type, type_check


#######################################################################
#
# Language-Server-Protocol functions
#
#######################################################################


# general #############################################################

# def get_lsp_methods(cls: Any, prefix: str= 'lsp_') -> List[str]:
#     """Returns the language-server-protocol-method-names from class ``cls``.
#     Methods are selected based on the prefix and their name converted in
#     accordance with the LSP-specification."""
#     return [gen_lsp_name(fn, prefix) for fn in lsp_candidates(cls, prefix)]


[docs] def lsp_candidates(cls: Any, prefix: str = 'lsp_') -> Iterator[str]: """Returns an iterator over all method names from a class that either have a certain prefix or, if no prefix was given, all non-special and non-private-methods of the class.""" assert not prefix[:1] == '_' if prefix: # return [fn for fn in dir(cls) if fn.startswith(prefix) and callable(getattr(cls, fn))] for fn in dir(cls): if fn[:len(prefix)] == prefix and callable(getattr(cls, fn)): yield fn else: # return [fn for fn in dir(cls) if not fn.startswith('_') and callable(getattr(cls, fn))] for fn in dir(cls): if not fn[:1] == '_' and callable(getattr(cls, fn)): yield fn
[docs] def gen_lsp_name(func_name: str, prefix: str = 'lsp_') -> str: """Generates the name of an lsp-method from a function name, e.g. "lsp_S_cancelRequest" -> "$/cancelRequest" """ assert func_name[:len(prefix)] == prefix return func_name[len(prefix):].replace('_', '/').replace('S/', '$/')
[docs] def gen_lsp_table(lsp_funcs_or_instance: Union[Iterable[Callable], Any], prefix: str = 'lsp_') -> Dict[str, Callable]: """Creates an RPC from a list of functions or from the methods of a class that implement the language server protocol. The dictionary keys are derived from the function name by replacing an underscore _ with a slash / and a single capital S with a $-sign. if ``prefix`` is not the empty string only functions or methods that start with ``prefix`` will be added to the table. The prefix will be removed before converting the functions' name to a dictionary key. >>> class LSP: ... def lsp_initialize(self, **kw): ... pass # return InitializeResult ... def lsp_shutdown(self, **kw): ... pass >>> lsp = LSP() >>> gen_lsp_table(lsp, 'lsp_').keys() dict_keys(['initialize', 'shutdown']) """ if isinstance(lsp_funcs_or_instance, Iterable): assert all(callable(func) for func in lsp_funcs_or_instance) rpc_table = {gen_lsp_name(func.__name__, prefix): func for func in lsp_funcs_or_instance} else: # assume lsp_funcs_or_instance is the instance of a class cls = lsp_funcs_or_instance rpc_table = {gen_lsp_name(fn, prefix): getattr(cls, fn) for fn in lsp_candidates(cls, prefix)} return rpc_table
# textDocument/completion ############################################# def shortlist(long_list: List[str], typed: str, lo: int = 0, hi: int = -1) -> Tuple[int, int]: if not typed: return 0, 0 if hi < 0: hi = len(long_list) a = bisect.bisect_left(long_list, typed, lo, hi) b = bisect.bisect_left(long_list, typed[:-1] + chr(ord(typed[-1]) + 1), lo, hi) return a, b ####################################################################### # # Language-Server-Protocol data structures (AUTOGENERATED: Don't edit!) # ####################################################################### ##### BEGIN OF LSP SPECS integer = float uinteger = float decimal = float
[docs] class Message(TypedDict, total=True): jsonrpc: str
[docs] class RequestMessage(Message, TypedDict, total=False): id: Union[int, str] method: str params: Union[List, Dict, None]
[docs] class ResponseMessage(Message, TypedDict, total=False): id: Union[int, str, None] result: Union[str, float, bool, Dict, None] error: Optional['ResponseError']
[docs] class ResponseError(TypedDict, total=False): code: int message: str data: Union[str, float, bool, List, Dict, None]
[docs] class ErrorCodes(IntEnum): ParseError = -32700 InvalidRequest = -32600 MethodNotFound = -32601 InvalidParams = -32602 InternalError = -32603 jsonrpcReservedErrorRangeStart = -32099 serverErrorStart = jsonrpcReservedErrorRangeStart ServerNotInitialized = -32002 UnknownErrorCode = -32001 jsonrpcReservedErrorRangeEnd = -32000 serverErrorEnd = jsonrpcReservedErrorRangeEnd lspReservedErrorRangeStart = -32899 ContentModified = -32801 RequestCancelled = -32800 lspReservedErrorRangeEnd = -32800
[docs] class NotificationMessage(Message, TypedDict, total=False): method: str params: Union[List, Dict, None]
[docs] class CancelParams(TypedDict, total=True): id: Union[int, str]
ProgressToken = Union[int, str] T = TypeVar('T')
[docs] class ProgressParams(Generic[T], GenericTypedDict, total=True): token: ProgressToken value: 'T'
DocumentUri = str URI = str
[docs] class RegularExpressionsClientCapabilities(TypedDict, total=False): engine: str version: Optional[str]
EOL: List[str] = ['\n', '\r\n', '\r']
[docs] class Position(TypedDict, total=True): line: int character: int
[docs] class Range(TypedDict, total=True): start: Position end: Position
[docs] class Location(TypedDict, total=True): uri: DocumentUri range: Range
[docs] class Diagnostic(TypedDict, total=False): range: Range severity: Optional['DiagnosticSeverity'] code: Union[int, str, None] codeDescription: Optional['CodeDescription'] source: Optional[str] message: str tags: Optional[List['DiagnosticTag']] relatedInformation: Optional[List['DiagnosticRelatedInformation']] data: Optional[Any]
[docs] class DiagnosticSeverity(IntEnum): Error = 1 Warning = 2 Information = 3 Hint = 4
[docs] class DiagnosticTag(IntEnum): Unnecessary = 1 Deprecated = 2
[docs] class DiagnosticRelatedInformation(TypedDict, total=True): location: Location message: str
[docs] class CodeDescription(TypedDict, total=True): href: URI
[docs] class Command(TypedDict, total=False): title: str command: str arguments: Optional[List[Any]]
[docs] class TextEdit(TypedDict, total=True): range: Range newText: str
[docs] class ChangeAnnotation(TypedDict, total=False): label: str needsConfirmation: Optional[bool] description: Optional[str]
ChangeAnnotationIdentifier = str
[docs] class AnnotatedTextEdit(TextEdit, TypedDict, total=True): annotationId: ChangeAnnotationIdentifier
[docs] class TextDocumentEdit(TypedDict, total=True): textDocument: 'OptionalVersionedTextDocumentIdentifier' edits: List[Union[TextEdit, AnnotatedTextEdit]]
[docs] class CreateFileOptions(TypedDict, total=False): overwrite: Optional[bool] ignoreIfExists: Optional[bool]
[docs] class CreateFile(TypedDict, total=False): kind: 'create' uri: DocumentUri options: Optional[CreateFileOptions] annotationId: Optional[ChangeAnnotationIdentifier]
[docs] class RenameFileOptions(TypedDict, total=False): overwrite: Optional[bool] ignoreIfExists: Optional[bool]
[docs] class RenameFile(TypedDict, total=False): kind: 'rename' oldUri: DocumentUri newUri: DocumentUri options: Optional[RenameFileOptions] annotationId: Optional[ChangeAnnotationIdentifier]
[docs] class DeleteFileOptions(TypedDict, total=False): recursive: Optional[bool] ignoreIfNotExists: Optional[bool]
[docs] class DeleteFile(TypedDict, total=False): kind: 'delete' uri: DocumentUri options: Optional[DeleteFileOptions] annotationId: Optional[ChangeAnnotationIdentifier]
[docs] class WorkspaceEdit(TypedDict, total=False): changes: Optional[Dict[DocumentUri, List[TextEdit]]] documentChanges: Union[List[TextDocumentEdit], List[Union[TextDocumentEdit, CreateFile, RenameFile, DeleteFile]], None] changeAnnotations: Optional[Dict[str, ChangeAnnotation]]
[docs] class WorkspaceEditClientCapabilities(TypedDict, total=False):
[docs] class ChangeAnnotationSupport_(TypedDict, total=False): groupsOnLabel: Optional[bool]
documentChanges: Optional[bool] resourceOperations: Optional[List['ResourceOperationKind']] failureHandling: Optional['FailureHandlingKind'] normalizesLineEndings: Optional[bool] changeAnnotationSupport: Optional[ChangeAnnotationSupport_]
[docs] class ResourceOperationKind(Enum): Create = 'create' Rename = 'rename' Delete = 'delete'
[docs] class FailureHandlingKind(Enum): Abort = 'abort' Transactional = 'transactional' TextOnlyTransactional = 'textOnlyTransactional' Undo = 'undo'
[docs] class TextDocumentIdentifier(TypedDict, total=True): uri: DocumentUri
[docs] class TextDocumentItem(TypedDict, total=True): uri: DocumentUri languageId: str version: int text: str
[docs] class VersionedTextDocumentIdentifier(TextDocumentIdentifier, TypedDict, total=True): version: int
[docs] class OptionalVersionedTextDocumentIdentifier(TextDocumentIdentifier, TypedDict, total=True): version: Union[int, None]
[docs] class TextDocumentPositionParams(TypedDict, total=True): textDocument: TextDocumentIdentifier position: Position
[docs] class DocumentFilter(TypedDict, total=False): language: Optional[str] scheme: Optional[str] pattern: Optional[str]
DocumentSelector = List[DocumentFilter]
[docs] class StaticRegistrationOptions(TypedDict, total=False): id: Optional[str]
[docs] class TextDocumentRegistrationOptions(TypedDict, total=True): documentSelector: Union[DocumentSelector, None]
[docs] class MarkupKind(Enum): PlainText = 'plaintext' Markdown = 'markdown'
[docs] class MarkupContent(TypedDict, total=True): kind: MarkupKind value: str
[docs] class MarkdownClientCapabilities(TypedDict, total=False): parser: str version: Optional[str]
[docs] class WorkDoneProgressBegin(TypedDict, total=False): kind: 'begin' title: str cancellable: Optional[bool] message: Optional[str] percentage: Optional[int]
[docs] class WorkDoneProgressReport(TypedDict, total=False): kind: 'report' cancellable: Optional[bool] message: Optional[str] percentage: Optional[int]
[docs] class WorkDoneProgressEnd(TypedDict, total=False): kind: 'end' message: Optional[str]
[docs] class WorkDoneProgressParams(TypedDict, total=False): workDoneToken: Optional[ProgressToken]
[docs] class WorkDoneProgressOptions(TypedDict, total=False): workDoneProgress: Optional[bool]
[docs] class PartialResultParams(TypedDict, total=False): partialResultToken: Optional[ProgressToken]
TraceValue = Literal['off', 'messages', 'verbose']
[docs] class InitializeParams(WorkDoneProgressParams, TypedDict, total=False):
[docs] class ClientInfo_(TypedDict, total=False): name: str version: Optional[str]
processId: Union[int, None] clientInfo: Optional[ClientInfo_] locale: Optional[str] rootPath: Union[str, None] rootUri: Union[DocumentUri, None] initializationOptions: Optional[Any] capabilities: 'ClientCapabilities' trace: Optional[TraceValue] workspaceFolders: Union[List['WorkspaceFolder'], None]
[docs] class TextDocumentClientCapabilities(TypedDict, total=False): synchronization: Optional['TextDocumentSyncClientCapabilities'] completion: Optional['CompletionClientCapabilities'] hover: Optional['HoverClientCapabilities'] signatureHelp: Optional['SignatureHelpClientCapabilities'] declaration: Optional['DeclarationClientCapabilities'] definition: Optional['DefinitionClientCapabilities'] typeDefinition: Optional['TypeDefinitionClientCapabilities'] implementation: Optional['ImplementationClientCapabilities'] references: Optional['ReferenceClientCapabilities'] documentHighlight: Optional['DocumentHighlightClientCapabilities'] documentSymbol: Optional['DocumentSymbolClientCapabilities'] codeAction: Optional['CodeActionClientCapabilities'] codeLens: Optional['CodeLensClientCapabilities'] documentLink: Optional['DocumentLinkClientCapabilities'] colorProvider: Optional['DocumentColorClientCapabilities'] formatting: Optional['DocumentFormattingClientCapabilities'] rangeFormatting: Optional['DocumentRangeFormattingClientCapabilities'] onTypeFormatting: Optional['DocumentOnTypeFormattingClientCapabilities'] rename: Optional['RenameClientCapabilities'] publishDiagnostics: Optional['PublishDiagnosticsClientCapabilities'] foldingRange: Optional['FoldingRangeClientCapabilities'] selectionRange: Optional['SelectionRangeClientCapabilities'] linkedEditingRange: Optional['LinkedEditingRangeClientCapabilities'] callHierarchy: Optional['CallHierarchyClientCapabilities'] semanticTokens: Optional['SemanticTokensClientCapabilities'] moniker: Optional['MonikerClientCapabilities']
[docs] class ClientCapabilities(TypedDict, total=False):
[docs] class Workspace_(TypedDict, total=False):
[docs] class FileOperations_(TypedDict, total=False): dynamicRegistration: Optional[bool] didCreate: Optional[bool] willCreate: Optional[bool] didRename: Optional[bool] willRename: Optional[bool] didDelete: Optional[bool] willDelete: Optional[bool]
applyEdit: Optional[bool] workspaceEdit: Optional[WorkspaceEditClientCapabilities] didChangeConfiguration: Optional['DidChangeConfigurationClientCapabilities'] didChangeWatchedFiles: Optional['DidChangeWatchedFilesClientCapabilities'] symbol: Optional['WorkspaceSymbolClientCapabilities'] executeCommand: Optional['ExecuteCommandClientCapabilities'] workspaceFolders: Optional[bool] configuration: Optional[bool] semanticTokens: Optional['SemanticTokensWorkspaceClientCapabilities'] codeLens: Optional['CodeLensWorkspaceClientCapabilities'] fileOperations: Optional[FileOperations_]
[docs] class Window_(TypedDict, total=False): workDoneProgress: Optional[bool] showMessage: Optional['ShowMessageRequestClientCapabilities'] showDocument: Optional['ShowDocumentClientCapabilities']
[docs] class General_(TypedDict, total=False): regularExpressions: Optional[RegularExpressionsClientCapabilities] markdown: Optional[MarkdownClientCapabilities]
workspace: Optional[Workspace_] textDocument: Optional[TextDocumentClientCapabilities] window: Optional[Window_] general: Optional[General_] experimental: Optional[Any]
[docs] class InitializeResult(TypedDict, total=False):
[docs] class ServerInfo_(TypedDict, total=False): name: str version: Optional[str]
capabilities: 'ServerCapabilities' serverInfo: Optional[ServerInfo_]
class InitializeError(IntEnum): unknownProtocolVersion = 1
[docs] class InitializeError(TypedDict, total=True): retry: bool
[docs] class ServerCapabilities(TypedDict, total=False):
[docs] class Workspace_(TypedDict, total=False):
[docs] class FileOperations_(TypedDict, total=False): didCreate: Optional['FileOperationRegistrationOptions'] willCreate: Optional['FileOperationRegistrationOptions'] didRename: Optional['FileOperationRegistrationOptions'] willRename: Optional['FileOperationRegistrationOptions'] didDelete: Optional['FileOperationRegistrationOptions'] willDelete: Optional['FileOperationRegistrationOptions']
workspaceFolders: Optional['WorkspaceFoldersServerCapabilities'] fileOperations: Optional[FileOperations_]
textDocumentSync: Union['TextDocumentSyncOptions', 'TextDocumentSyncKind', None] completionProvider: Optional['CompletionOptions'] hoverProvider: Union[bool, 'HoverOptions', None] signatureHelpProvider: Optional['SignatureHelpOptions'] declarationProvider: Union[bool, 'DeclarationOptions', 'DeclarationRegistrationOptions', None] definitionProvider: Union[bool, 'DefinitionOptions', None] typeDefinitionProvider: Union[bool, 'TypeDefinitionOptions', 'TypeDefinitionRegistrationOptions', None] implementationProvider: Union[bool, 'ImplementationOptions', 'ImplementationRegistrationOptions', None] referencesProvider: Union[bool, 'ReferenceOptions', None] documentHighlightProvider: Union[bool, 'DocumentHighlightOptions', None] documentSymbolProvider: Union[bool, 'DocumentSymbolOptions', None] codeActionProvider: Union[bool, 'CodeActionOptions', None] codeLensProvider: Optional['CodeLensOptions'] documentLinkProvider: Optional['DocumentLinkOptions'] colorProvider: Union[bool, 'DocumentColorOptions', 'DocumentColorRegistrationOptions', None] documentFormattingProvider: Union[bool, 'DocumentFormattingOptions', None] documentRangeFormattingProvider: Union[bool, 'DocumentRangeFormattingOptions', None] documentOnTypeFormattingProvider: Optional['DocumentOnTypeFormattingOptions'] renameProvider: Union[bool, 'RenameOptions', None] foldingRangeProvider: Union[bool, 'FoldingRangeOptions', 'FoldingRangeRegistrationOptions', None] executeCommandProvider: Optional['ExecuteCommandOptions'] selectionRangeProvider: Union[bool, 'SelectionRangeOptions', 'SelectionRangeRegistrationOptions', None] linkedEditingRangeProvider: Union[bool, 'LinkedEditingRangeOptions', 'LinkedEditingRangeRegistrationOptions', None] callHierarchyProvider: Union[bool, 'CallHierarchyOptions', 'CallHierarchyRegistrationOptions', None] semanticTokensProvider: Union['SemanticTokensOptions', 'SemanticTokensRegistrationOptions', None] monikerProvider: Union[bool, 'MonikerOptions', 'MonikerRegistrationOptions', None] workspaceSymbolProvider: Union[bool, 'WorkspaceSymbolOptions', None] workspace: Optional[Workspace_] experimental: Optional[Any]
[docs] class InitializedParams(TypedDict, total=True): pass
[docs] class LogTraceParams(TypedDict, total=False): message: str verbose: Optional[str]
[docs] class SetTraceParams(TypedDict, total=True): value: TraceValue
[docs] class ShowMessageParams(TypedDict, total=True): type: 'MessageType' message: str
[docs] class MessageType(IntEnum): Error = 1 Warning = 2 Info = 3 Log = 4
[docs] class ShowMessageRequestClientCapabilities(TypedDict, total=False):
[docs] class MessageActionItem_(TypedDict, total=False): additionalPropertiesSupport: Optional[bool]
messageActionItem: Optional[MessageActionItem_]
[docs] class ShowMessageRequestParams(TypedDict, total=False): type: MessageType message: str actions: Optional[List['MessageActionItem']]
[docs] class MessageActionItem(TypedDict, total=True): title: str
[docs] class ShowDocumentClientCapabilities(TypedDict, total=True): support: bool
[docs] class ShowDocumentParams(TypedDict, total=False): uri: URI external: Optional[bool] takeFocus: Optional[bool] selection: Optional[Range]
[docs] class ShowDocumentResult(TypedDict, total=True): success: bool
[docs] class LogMessageParams(TypedDict, total=True): type: MessageType message: str
[docs] class WorkDoneProgressCreateParams(TypedDict, total=True): token: ProgressToken
[docs] class WorkDoneProgressCancelParams(TypedDict, total=True): token: ProgressToken
[docs] class Registration(TypedDict, total=False): id: str method: str registerOptions: Optional[Any]
[docs] class RegistrationParams(TypedDict, total=True): registrations: List[Registration]
[docs] class Unregistration(TypedDict, total=True): id: str method: str
[docs] class UnregistrationParams(TypedDict, total=True): unregisterations: List[Unregistration]
[docs] class WorkspaceFoldersServerCapabilities(TypedDict, total=False): supported: Optional[bool] changeNotifications: Union[str, bool, None]
[docs] class WorkspaceFolder(TypedDict, total=True): uri: DocumentUri name: str
[docs] class DidChangeWorkspaceFoldersParams(TypedDict, total=True): event: 'WorkspaceFoldersChangeEvent'
[docs] class WorkspaceFoldersChangeEvent(TypedDict, total=True): added: List[WorkspaceFolder] removed: List[WorkspaceFolder]
[docs] class DidChangeConfigurationClientCapabilities(TypedDict, total=False): dynamicRegistration: Optional[bool]
[docs] class DidChangeConfigurationParams(TypedDict, total=True): settings: Any
[docs] class ConfigurationParams(TypedDict, total=True): items: List['ConfigurationItem']
[docs] class ConfigurationItem(TypedDict, total=False): scopeUri: Optional[DocumentUri] section: Optional[str]
[docs] class DidChangeWatchedFilesClientCapabilities(TypedDict, total=False): dynamicRegistration: Optional[bool]
[docs] class DidChangeWatchedFilesRegistrationOptions(TypedDict, total=True): watchers: List['FileSystemWatcher']
[docs] class FileSystemWatcher(TypedDict, total=False): globPattern: str kind: Optional[int]
[docs] class WatchKind(IntEnum): Create = 1 Change = 2 Delete = 4
[docs] class DidChangeWatchedFilesParams(TypedDict, total=True): changes: List['FileEvent']
[docs] class FileEvent(TypedDict, total=True): uri: DocumentUri type: int
[docs] class FileChangeType(IntEnum): Created = 1 Changed = 2 Deleted = 3
[docs] class WorkspaceSymbolClientCapabilities(TypedDict, total=False):
[docs] class SymbolKind_(TypedDict, total=False): valueSet: Optional[List['SymbolKind']]
[docs] class TagSupport_(TypedDict, total=True): valueSet: List['SymbolTag']
dynamicRegistration: Optional[bool] symbolKind: Optional[SymbolKind_] tagSupport: Optional[TagSupport_]
[docs] class WorkspaceSymbolOptions(WorkDoneProgressOptions, TypedDict, total=True): pass
[docs] class WorkspaceSymbolRegistrationOptions(WorkspaceSymbolOptions, TypedDict, total=True): pass
[docs] class WorkspaceSymbolParams(WorkDoneProgressParams, PartialResultParams, TypedDict, total=True): query: str
[docs] class ExecuteCommandClientCapabilities(TypedDict, total=False): dynamicRegistration: Optional[bool]
[docs] class ExecuteCommandOptions(WorkDoneProgressOptions, TypedDict, total=True): commands: List[str]
[docs] class ExecuteCommandRegistrationOptions(ExecuteCommandOptions, TypedDict, total=True): pass
[docs] class ExecuteCommandParams(WorkDoneProgressParams, TypedDict, total=False): command: str arguments: Optional[List[Any]]
[docs] class ApplyWorkspaceEditParams(TypedDict, total=False): label: Optional[str] edit: WorkspaceEdit
[docs] class ApplyWorkspaceEditResponse(TypedDict, total=False): applied: bool failureReason: Optional[str] failedChange: Optional[int]
[docs] class FileOperationRegistrationOptions(TypedDict, total=True): filters: List['FileOperationFilter']
[docs] class FileOperationPatternKind(Enum): file = 'file' folder = 'folder'
[docs] class FileOperationPatternOptions(TypedDict, total=False): ignoreCase: Optional[bool]
[docs] class FileOperationPattern(TypedDict, total=False): glob: str matches: Optional[FileOperationPatternKind] options: Optional[FileOperationPatternOptions]
[docs] class FileOperationFilter(TypedDict, total=False): scheme: Optional[str] pattern: FileOperationPattern
[docs] class CreateFilesParams(TypedDict, total=True): files: List['FileCreate']
[docs] class FileCreate(TypedDict, total=True): uri: str
[docs] class RenameFilesParams(TypedDict, total=True): files: List['FileRename']
[docs] class FileRename(TypedDict, total=True): oldUri: str newUri: str
[docs] class DeleteFilesParams(TypedDict, total=True): files: List['FileDelete']
[docs] class FileDelete(TypedDict, total=True): uri: str
[docs] class TextDocumentSyncKind(IntEnum): None_ = 0 Full = 1 Incremental = 2
class TextDocumentSyncOptions(TypedDict, total=False): openClose: Optional[bool] change: Optional[TextDocumentSyncKind]
[docs] class DidOpenTextDocumentParams(TypedDict, total=True): textDocument: TextDocumentItem
[docs] class TextDocumentChangeRegistrationOptions(TextDocumentRegistrationOptions, TypedDict, total=True): syncKind: TextDocumentSyncKind
[docs] class DidChangeTextDocumentParams(TypedDict, total=True): textDocument: VersionedTextDocumentIdentifier contentChanges: List['TextDocumentContentChangeEvent']
[docs] class TextDocumentContentChangeEvent_0(TypedDict, total=False): range: Range rangeLength: Optional[int] text: str
[docs] class TextDocumentContentChangeEvent_1(TypedDict, total=True): text: str
TextDocumentContentChangeEvent = Union[TextDocumentContentChangeEvent_0, TextDocumentContentChangeEvent_1]
[docs] class WillSaveTextDocumentParams(TypedDict, total=True): textDocument: TextDocumentIdentifier reason: 'TextDocumentSaveReason'
[docs] class TextDocumentSaveReason(IntEnum): Manual = 1 AfterDelay = 2 FocusOut = 3
[docs] class SaveOptions(TypedDict, total=False): includeText: Optional[bool]
[docs] class TextDocumentSaveRegistrationOptions(TextDocumentRegistrationOptions, TypedDict, total=False): includeText: Optional[bool]
[docs] class DidSaveTextDocumentParams(TypedDict, total=False): textDocument: TextDocumentIdentifier text: Optional[str]
[docs] class DidCloseTextDocumentParams(TypedDict, total=True): textDocument: TextDocumentIdentifier
[docs] class TextDocumentSyncClientCapabilities(TypedDict, total=False): dynamicRegistration: Optional[bool] willSave: Optional[bool] willSaveWaitUntil: Optional[bool] didSave: Optional[bool]
[docs] class TextDocumentSyncOptions(TypedDict, total=False): openClose: Optional[bool] change: Optional[TextDocumentSyncKind] willSave: Optional[bool] willSaveWaitUntil: Optional[bool] save: Union[bool, SaveOptions, None]
[docs] class PublishDiagnosticsClientCapabilities(TypedDict, total=False):
[docs] class TagSupport_(TypedDict, total=True): valueSet: List[DiagnosticTag]
relatedInformation: Optional[bool] tagSupport: Optional[TagSupport_] versionSupport: Optional[bool] codeDescriptionSupport: Optional[bool] dataSupport: Optional[bool]
[docs] class PublishDiagnosticsParams(TypedDict, total=False): uri: DocumentUri version: Optional[int] diagnostics: List[Diagnostic]
[docs] class CompletionClientCapabilities(TypedDict, total=False):
[docs] class CompletionItem_(TypedDict, total=False):
[docs] class TagSupport_(TypedDict, total=True): valueSet: List['CompletionItemTag']
[docs] class ResolveSupport_(TypedDict, total=True): properties: List[str]
[docs] class InsertTextModeSupport_(TypedDict, total=True): valueSet: List['InsertTextMode']
snippetSupport: Optional[bool] commitCharactersSupport: Optional[bool] documentationFormat: Optional[List[MarkupKind]] deprecatedSupport: Optional[bool] preselectSupport: Optional[bool] tagSupport: Optional[TagSupport_] insertReplaceSupport: Optional[bool] resolveSupport: Optional[ResolveSupport_] insertTextModeSupport: Optional[InsertTextModeSupport_]
[docs] class CompletionItemKind_(TypedDict, total=False): valueSet: Optional[List['CompletionItemKind']]
dynamicRegistration: Optional[bool] completionItem: Optional[CompletionItem_] completionItemKind: Optional[CompletionItemKind_] contextSupport: Optional[bool]
[docs] class CompletionOptions(WorkDoneProgressOptions, TypedDict, total=False): triggerCharacters: Optional[List[str]] allCommitCharacters: Optional[List[str]] resolveProvider: Optional[bool]
[docs] class CompletionRegistrationOptions(TextDocumentRegistrationOptions, CompletionOptions, TypedDict, total=True): pass
[docs] class CompletionParams(TextDocumentPositionParams, WorkDoneProgressParams, PartialResultParams, TypedDict, total=False): context: Optional['CompletionContext']
[docs] class CompletionTriggerKind(IntEnum): Invoked = 1 TriggerCharacter = 2 TriggerForIncompleteCompletions = 3
[docs] class CompletionContext(TypedDict, total=False): triggerKind: CompletionTriggerKind triggerCharacter: Optional[str]
[docs] class CompletionList(TypedDict, total=True): isIncomplete: bool items: List['CompletionItem']
[docs] class InsertTextFormat(IntEnum): PlainText = 1 Snippet = 2
[docs] class CompletionItemTag(IntEnum): Deprecated = 1
[docs] class InsertReplaceEdit(TypedDict, total=True): newText: str insert: Range replace: Range
[docs] class InsertTextMode(IntEnum): asIs = 1 adjustIndentation = 2
[docs] class CompletionItem(TypedDict, total=False): label: str kind: Optional['CompletionItemKind'] tags: Optional[List[CompletionItemTag]] detail: Optional[str] documentation: Union[str, MarkupContent, None] deprecated: Optional[bool] preselect: Optional[bool] sortText: Optional[str] filterText: Optional[str] insertText: Optional[str] insertTextFormat: Optional[InsertTextFormat] insertTextMode: Optional[InsertTextMode] textEdit: Union[TextEdit, InsertReplaceEdit, None] additionalTextEdits: Optional[List[TextEdit]] commitCharacters: Optional[List[str]] command: Optional[Command] data: Optional[Any]
[docs] class CompletionItemKind(IntEnum): Text = 1 Method = 2 Function = 3 Constructor = 4 Field = 5 Variable = 6 Class = 7 Interface = 8 Module = 9 Property = 10 Unit = 11 Value = 12 Enum = 13 Keyword = 14 Snippet = 15 Color = 16 File = 17 Reference = 18 Folder = 19 EnumMember = 20 Constant = 21 Struct = 22 Event = 23 Operator = 24 TypeParameter = 25
[docs] class HoverClientCapabilities(TypedDict, total=False): dynamicRegistration: Optional[bool] contentFormat: Optional[List[MarkupKind]]
[docs] class HoverOptions(WorkDoneProgressOptions, TypedDict, total=True): pass
[docs] class HoverRegistrationOptions(TextDocumentRegistrationOptions, HoverOptions, TypedDict, total=True): pass
[docs] class HoverParams(TextDocumentPositionParams, WorkDoneProgressParams, TypedDict, total=True): pass
[docs] class Hover(TypedDict, total=False): contents: Union['MarkedString', List['MarkedString'], MarkupContent] range: Optional[Range]
[docs] class MarkedString_1(TypedDict, total=True): language: str value: str
MarkedString = Union[str, MarkedString_1]
[docs] class SignatureHelpClientCapabilities(TypedDict, total=False):
[docs] class SignatureInformation_(TypedDict, total=False):
[docs] class ParameterInformation_(TypedDict, total=False): labelOffsetSupport: Optional[bool]
documentationFormat: Optional[List[MarkupKind]] parameterInformation: Optional[ParameterInformation_] activeParameterSupport: Optional[bool]
dynamicRegistration: Optional[bool] signatureInformation: Optional[SignatureInformation_] contextSupport: Optional[bool]
[docs] class SignatureHelpOptions(WorkDoneProgressOptions, TypedDict, total=False): triggerCharacters: Optional[List[str]] retriggerCharacters: Optional[List[str]]
[docs] class SignatureHelpRegistrationOptions(TextDocumentRegistrationOptions, SignatureHelpOptions, TypedDict, total=True): pass
[docs] class SignatureHelpParams(TextDocumentPositionParams, WorkDoneProgressParams, TypedDict, total=False): context: Optional['SignatureHelpContext']
[docs] class SignatureHelpTriggerKind(IntEnum): Invoked = 1 TriggerCharacter = 2 ContentChange = 3
[docs] class SignatureHelpContext(TypedDict, total=False): triggerKind: SignatureHelpTriggerKind triggerCharacter: Optional[str] isRetrigger: bool activeSignatureHelp: Optional['SignatureHelp']
[docs] class SignatureHelp(TypedDict, total=False): signatures: List['SignatureInformation'] activeSignature: Optional[int] activeParameter: Optional[int]
[docs] class SignatureInformation(TypedDict, total=False): label: str documentation: Union[str, MarkupContent, None] parameters: Optional[List['ParameterInformation']] activeParameter: Optional[int]
[docs] class ParameterInformation(TypedDict, total=False): label: Union[str, Tuple[int, int]] documentation: Union[str, MarkupContent, None]
[docs] class DeclarationClientCapabilities(TypedDict, total=False): dynamicRegistration: Optional[bool] linkSupport: Optional[bool]
[docs] class DeclarationOptions(WorkDoneProgressOptions, TypedDict, total=True): pass
[docs] class DeclarationRegistrationOptions(DeclarationOptions, TextDocumentRegistrationOptions, StaticRegistrationOptions, TypedDict, total=True): pass
[docs] class DeclarationParams(TextDocumentPositionParams, WorkDoneProgressParams, PartialResultParams, TypedDict, total=True): pass
[docs] class DefinitionClientCapabilities(TypedDict, total=False): dynamicRegistration: Optional[bool] linkSupport: Optional[bool]
[docs] class DefinitionOptions(WorkDoneProgressOptions, TypedDict, total=True): pass
[docs] class DefinitionRegistrationOptions(TextDocumentRegistrationOptions, DefinitionOptions, TypedDict, total=True): pass
[docs] class DefinitionParams(TextDocumentPositionParams, WorkDoneProgressParams, PartialResultParams, TypedDict, total=True): pass
[docs] class TypeDefinitionClientCapabilities(TypedDict, total=False): dynamicRegistration: Optional[bool] linkSupport: Optional[bool]
[docs] class TypeDefinitionOptions(WorkDoneProgressOptions, TypedDict, total=True): pass
[docs] class TypeDefinitionRegistrationOptions(TextDocumentRegistrationOptions, TypeDefinitionOptions, StaticRegistrationOptions, TypedDict, total=True): pass
[docs] class TypeDefinitionParams(TextDocumentPositionParams, WorkDoneProgressParams, PartialResultParams, TypedDict, total=True): pass
[docs] class ImplementationClientCapabilities(TypedDict, total=False): dynamicRegistration: Optional[bool] linkSupport: Optional[bool]
[docs] class ImplementationOptions(WorkDoneProgressOptions, TypedDict, total=True): pass
[docs] class ImplementationRegistrationOptions(TextDocumentRegistrationOptions, ImplementationOptions, StaticRegistrationOptions, TypedDict, total=True): pass
[docs] class ImplementationParams(TextDocumentPositionParams, WorkDoneProgressParams, PartialResultParams, TypedDict, total=True): pass
[docs] class ReferenceClientCapabilities(TypedDict, total=False): dynamicRegistration: Optional[bool]
[docs] class ReferenceOptions(WorkDoneProgressOptions, TypedDict, total=True): pass
[docs] class ReferenceRegistrationOptions(TextDocumentRegistrationOptions, ReferenceOptions, TypedDict, total=True): pass
[docs] class ReferenceParams(TextDocumentPositionParams, WorkDoneProgressParams, PartialResultParams, TypedDict, total=True): context: 'ReferenceContext'
[docs] class ReferenceContext(TypedDict, total=True): includeDeclaration: bool
[docs] class DocumentHighlightClientCapabilities(TypedDict, total=False): dynamicRegistration: Optional[bool]
[docs] class DocumentHighlightOptions(WorkDoneProgressOptions, TypedDict, total=True): pass
[docs] class DocumentHighlightRegistrationOptions(TextDocumentRegistrationOptions, DocumentHighlightOptions, TypedDict, total=True): pass
[docs] class DocumentHighlightParams(TextDocumentPositionParams, WorkDoneProgressParams, PartialResultParams, TypedDict, total=True): pass
[docs] class DocumentHighlight(TypedDict, total=False): range: Range kind: Optional['DocumentHighlightKind']
[docs] class DocumentHighlightKind(IntEnum): Text = 1 Read = 2 Write = 3
[docs] class DocumentSymbolClientCapabilities(TypedDict, total=False):
[docs] class SymbolKind_(TypedDict, total=False): valueSet: Optional[List['SymbolKind']]
[docs] class TagSupport_(TypedDict, total=True): valueSet: List['SymbolTag']
dynamicRegistration: Optional[bool] symbolKind: Optional[SymbolKind_] hierarchicalDocumentSymbolSupport: Optional[bool] tagSupport: Optional[TagSupport_] labelSupport: Optional[bool]
[docs] class DocumentSymbolOptions(WorkDoneProgressOptions, TypedDict, total=False): label: Optional[str]
[docs] class DocumentSymbolRegistrationOptions(TextDocumentRegistrationOptions, DocumentSymbolOptions, TypedDict, total=True): pass
[docs] class DocumentSymbolParams(WorkDoneProgressParams, PartialResultParams, TypedDict, total=True): textDocument: TextDocumentIdentifier
[docs] class SymbolKind(IntEnum): File = 1 Module = 2 Namespace = 3 Package = 4 Class = 5 Method = 6 Property = 7 Field = 8 Constructor = 9 Enum = 10 Interface = 11 Function = 12 Variable = 13 Constant = 14 String = 15 Number = 16 Boolean = 17 Array = 18 Object = 19 Key = 20 Null = 21 EnumMember = 22 Struct = 23 Event = 24 Operator = 25 TypeParameter = 26
[docs] class SymbolTag(IntEnum): Deprecated = 1
[docs] class DocumentSymbol(TypedDict, total=False): name: str detail: Optional[str] kind: SymbolKind tags: Optional[List[SymbolTag]] deprecated: Optional[bool] range: Range selectionRange: Range children: Optional[List['DocumentSymbol']]
[docs] class SymbolInformation(TypedDict, total=False): name: str kind: SymbolKind tags: Optional[List[SymbolTag]] deprecated: Optional[bool] location: Location containerName: Optional[str]
[docs] class CodeActionClientCapabilities(TypedDict, total=False):
[docs] class CodeActionLiteralSupport_(TypedDict, total=True):
[docs] class CodeActionKind_(TypedDict, total=True): valueSet: List['CodeActionKind']
codeActionKind: CodeActionKind_
[docs] class ResolveSupport_(TypedDict, total=True): properties: List[str]
dynamicRegistration: Optional[bool] codeActionLiteralSupport: Optional[CodeActionLiteralSupport_] isPreferredSupport: Optional[bool] disabledSupport: Optional[bool] dataSupport: Optional[bool] resolveSupport: Optional[ResolveSupport_] honorsChangeAnnotations: Optional[bool]
[docs] class CodeActionOptions(WorkDoneProgressOptions, TypedDict, total=False): codeActionKinds: Optional[List['CodeActionKind']] resolveProvider: Optional[bool]
[docs] class CodeActionRegistrationOptions(TextDocumentRegistrationOptions, CodeActionOptions, TypedDict, total=True): pass
[docs] class CodeActionParams(WorkDoneProgressParams, PartialResultParams, TypedDict, total=True): textDocument: TextDocumentIdentifier range: Range context: 'CodeActionContext'
[docs] class CodeActionKind(Enum): Empty = '' QuickFix = 'quickfix' Refactor = 'refactor' RefactorExtract = 'refactor.extract' RefactorInline = 'refactor.inline' RefactorRewrite = 'refactor.rewrite' Source = 'source' SourceOrganizeImports = 'source.organizeImports'
[docs] class CodeActionContext(TypedDict, total=False): diagnostics: List[Diagnostic] only: Optional[List[CodeActionKind]]
[docs] class CodeAction(TypedDict, total=False):
[docs] class Disabled_(TypedDict, total=True): reason: str
title: str kind: Optional[CodeActionKind] diagnostics: Optional[List[Diagnostic]] isPreferred: Optional[bool] disabled: Optional[Disabled_] edit: Optional[WorkspaceEdit] command: Optional[Command] data: Optional[Any]
[docs] class CodeLensClientCapabilities(TypedDict, total=False): dynamicRegistration: Optional[bool]
[docs] class CodeLensOptions(WorkDoneProgressOptions, TypedDict, total=False): resolveProvider: Optional[bool]
[docs] class CodeLensRegistrationOptions(TextDocumentRegistrationOptions, CodeLensOptions, TypedDict, total=True): pass
[docs] class CodeLensParams(WorkDoneProgressParams, PartialResultParams, TypedDict, total=True): textDocument: TextDocumentIdentifier
[docs] class CodeLens(TypedDict, total=False): range: Range command: Optional[Command] data: Optional[Any]
[docs] class CodeLensWorkspaceClientCapabilities(TypedDict, total=False): refreshSupport: Optional[bool]
[docs] class DocumentLinkClientCapabilities(TypedDict, total=False): dynamicRegistration: Optional[bool] tooltipSupport: Optional[bool]
[docs] class DocumentLinkOptions(WorkDoneProgressOptions, TypedDict, total=False): resolveProvider: Optional[bool]
[docs] class DocumentLinkRegistrationOptions(TextDocumentRegistrationOptions, DocumentLinkOptions, TypedDict, total=True): pass
[docs] class DocumentLinkParams(WorkDoneProgressParams, PartialResultParams, TypedDict, total=True): textDocument: TextDocumentIdentifier
[docs] class DocumentColorClientCapabilities(TypedDict, total=False): dynamicRegistration: Optional[bool]
[docs] class DocumentColorOptions(WorkDoneProgressOptions, TypedDict, total=True): pass
[docs] class DocumentColorRegistrationOptions(TextDocumentRegistrationOptions, StaticRegistrationOptions, DocumentColorOptions, TypedDict, total=True): pass
[docs] class DocumentColorParams(WorkDoneProgressParams, PartialResultParams, TypedDict, total=True): textDocument: TextDocumentIdentifier
[docs] class ColorInformation(TypedDict, total=True): range: Range color: 'Color'
[docs] class Color(TypedDict, total=True): red: float green: float blue: float alpha: float
[docs] class ColorPresentationParams(WorkDoneProgressParams, PartialResultParams, TypedDict, total=True): textDocument: TextDocumentIdentifier color: Color range: Range
[docs] class ColorPresentation(TypedDict, total=False): label: str textEdit: Optional[TextEdit] additionalTextEdits: Optional[List[TextEdit]]
[docs] class DocumentFormattingClientCapabilities(TypedDict, total=False): dynamicRegistration: Optional[bool]
[docs] class DocumentFormattingOptions(WorkDoneProgressOptions, TypedDict, total=True): pass
[docs] class DocumentFormattingRegistrationOptions(TextDocumentRegistrationOptions, DocumentFormattingOptions, TypedDict, total=True): pass
[docs] class DocumentFormattingParams(WorkDoneProgressParams, TypedDict, total=True): textDocument: TextDocumentIdentifier options: 'FormattingOptions'
[docs] class FormattingOptions(TypedDict, total=False): tabSize: int insertSpaces: bool trimTrailingWhitespace: Optional[bool] insertFinalNewline: Optional[bool] trimFinalNewlines: Optional[bool]
[docs] class DocumentRangeFormattingClientCapabilities(TypedDict, total=False): dynamicRegistration: Optional[bool]
[docs] class DocumentRangeFormattingOptions(WorkDoneProgressOptions, TypedDict, total=True): pass
[docs] class DocumentRangeFormattingRegistrationOptions(TextDocumentRegistrationOptions, DocumentRangeFormattingOptions, TypedDict, total=True): pass
[docs] class DocumentRangeFormattingParams(WorkDoneProgressParams, TypedDict, total=True): textDocument: TextDocumentIdentifier range: Range options: FormattingOptions
[docs] class DocumentOnTypeFormattingClientCapabilities(TypedDict, total=False): dynamicRegistration: Optional[bool]
[docs] class DocumentOnTypeFormattingOptions(TypedDict, total=False): firstTriggerCharacter: str moreTriggerCharacter: Optional[List[str]]
[docs] class DocumentOnTypeFormattingRegistrationOptions(TextDocumentRegistrationOptions, DocumentOnTypeFormattingOptions, TypedDict, total=True): pass
[docs] class DocumentOnTypeFormattingParams(TextDocumentPositionParams, TypedDict, total=True): ch: str options: FormattingOptions
[docs] class PrepareSupportDefaultBehavior(IntEnum): Identifier = 1
[docs] class RenameClientCapabilities(TypedDict, total=False): dynamicRegistration: Optional[bool] prepareSupport: Optional[bool] prepareSupportDefaultBehavior: Optional[PrepareSupportDefaultBehavior] honorsChangeAnnotations: Optional[bool]
[docs] class RenameOptions(WorkDoneProgressOptions, TypedDict, total=False): prepareProvider: Optional[bool]
[docs] class RenameRegistrationOptions(TextDocumentRegistrationOptions, RenameOptions, TypedDict, total=True): pass
[docs] class RenameParams(TextDocumentPositionParams, WorkDoneProgressParams, TypedDict, total=True): newName: str
[docs] class PrepareRenameParams(TextDocumentPositionParams, TypedDict, total=True): pass
[docs] class FoldingRangeClientCapabilities(TypedDict, total=False): dynamicRegistration: Optional[bool] rangeLimit: Optional[int] lineFoldingOnly: Optional[bool]
[docs] class FoldingRangeOptions(WorkDoneProgressOptions, TypedDict, total=True): pass
[docs] class FoldingRangeRegistrationOptions(TextDocumentRegistrationOptions, FoldingRangeOptions, StaticRegistrationOptions, TypedDict, total=True): pass
[docs] class FoldingRangeParams(WorkDoneProgressParams, PartialResultParams, TypedDict, total=True): textDocument: TextDocumentIdentifier
[docs] class FoldingRangeKind(Enum): Comment = 'comment' Imports = 'imports' Region = 'region'
[docs] class FoldingRange(TypedDict, total=False): startLine: int startCharacter: Optional[int] endLine: int endCharacter: Optional[int] kind: Optional[str]
[docs] class SelectionRangeClientCapabilities(TypedDict, total=False): dynamicRegistration: Optional[bool]
[docs] class SelectionRangeOptions(WorkDoneProgressOptions, TypedDict, total=True): pass
[docs] class SelectionRangeRegistrationOptions(SelectionRangeOptions, TextDocumentRegistrationOptions, StaticRegistrationOptions, TypedDict, total=True): pass
[docs] class SelectionRangeParams(WorkDoneProgressParams, PartialResultParams, TypedDict, total=True): textDocument: TextDocumentIdentifier positions: List[Position]
[docs] class SelectionRange(TypedDict, total=False): range: Range parent: Optional['SelectionRange']
[docs] class CallHierarchyClientCapabilities(TypedDict, total=False): dynamicRegistration: Optional[bool]
[docs] class CallHierarchyOptions(WorkDoneProgressOptions, TypedDict, total=True): pass
[docs] class CallHierarchyRegistrationOptions(TextDocumentRegistrationOptions, CallHierarchyOptions, StaticRegistrationOptions, TypedDict, total=True): pass
[docs] class CallHierarchyPrepareParams(TextDocumentPositionParams, WorkDoneProgressParams, TypedDict, total=True): pass
[docs] class CallHierarchyItem(TypedDict, total=False): name: str kind: SymbolKind tags: Optional[List[SymbolTag]] detail: Optional[str] uri: DocumentUri range: Range selectionRange: Range data: Optional[Any]
[docs] class CallHierarchyIncomingCallsParams(WorkDoneProgressParams, PartialResultParams, TypedDict, total=True): item: CallHierarchyItem
[docs] class CallHierarchyIncomingCall(TypedDict, total=True): from_: CallHierarchyItem fromRanges: List[Range]
[docs] class CallHierarchyOutgoingCallsParams(WorkDoneProgressParams, PartialResultParams, TypedDict, total=True): item: CallHierarchyItem
[docs] class CallHierarchyOutgoingCall(TypedDict, total=True): to: CallHierarchyItem fromRanges: List[Range]
[docs] class SemanticTokenTypes(Enum): namespace = 'namespace' type = 'type' class_ = 'class' enum = 'enum' interface = 'interface' struct = 'struct' typeParameter = 'typeParameter' parameter = 'parameter' variable = 'variable' property = 'property' enumMember = 'enumMember' event = 'event' function = 'function' method = 'method' macro = 'macro' keyword = 'keyword' modifier = 'modifier' comment = 'comment' string = 'string' number = 'number' regexp = 'regexp' operator = 'operator'
[docs] class SemanticTokenModifiers(Enum): declaration = 'declaration' definition = 'definition' readonly = 'readonly' static = 'static' deprecated = 'deprecated' abstract = 'abstract' async_ = 'async' modification = 'modification' documentation = 'documentation' defaultLibrary = 'defaultLibrary'
[docs] class TokenFormat(Enum): Relative = 'relative'
[docs] class SemanticTokensLegend(TypedDict, total=True): tokenTypes: List[str] tokenModifiers: List[str]
[docs] class SemanticTokensClientCapabilities(TypedDict, total=False):
[docs] class Requests_(TypedDict, total=False):
[docs] class Range_1(TypedDict, total=True): pass
[docs] class Full_1(TypedDict, total=False): delta: Optional[bool]
range: Union[bool, Range_1, None] full: Union[bool, Full_1, None]
dynamicRegistration: Optional[bool] requests: Requests_ tokenTypes: List[str] tokenModifiers: List[str] formats: List[TokenFormat] overlappingTokenSupport: Optional[bool] multilineTokenSupport: Optional[bool]
[docs] class SemanticTokensOptions(WorkDoneProgressOptions, TypedDict, total=False):
[docs] class Range_1(TypedDict, total=True): pass
[docs] class Full_1(TypedDict, total=False): delta: Optional[bool]
legend: SemanticTokensLegend range: Union[bool, Range_1, None] full: Union[bool, Full_1, None]
[docs] class SemanticTokensRegistrationOptions(TextDocumentRegistrationOptions, SemanticTokensOptions, StaticRegistrationOptions, TypedDict, total=True): pass
[docs] class SemanticTokensParams(WorkDoneProgressParams, PartialResultParams, TypedDict, total=True): textDocument: TextDocumentIdentifier
[docs] class SemanticTokens(TypedDict, total=False): resultId: Optional[str] data: List[int]
[docs] class SemanticTokensPartialResult(TypedDict, total=True): data: List[int]
[docs] class SemanticTokensDeltaParams(WorkDoneProgressParams, PartialResultParams, TypedDict, total=True): textDocument: TextDocumentIdentifier previousResultId: str
[docs] class SemanticTokensDelta(TypedDict, total=False): resultId: Optional[str] edits: List['SemanticTokensEdit']
[docs] class SemanticTokensEdit(TypedDict, total=False): start: int deleteCount: int data: Optional[List[int]]
[docs] class SemanticTokensDeltaPartialResult(TypedDict, total=True): edits: List[SemanticTokensEdit]
[docs] class SemanticTokensRangeParams(WorkDoneProgressParams, PartialResultParams, TypedDict, total=True): textDocument: TextDocumentIdentifier range: Range
[docs] class SemanticTokensWorkspaceClientCapabilities(TypedDict, total=False): refreshSupport: Optional[bool]
[docs] class LinkedEditingRangeClientCapabilities(TypedDict, total=False): dynamicRegistration: Optional[bool]
[docs] class LinkedEditingRangeOptions(WorkDoneProgressOptions, TypedDict, total=True): pass
[docs] class LinkedEditingRangeRegistrationOptions(TextDocumentRegistrationOptions, LinkedEditingRangeOptions, StaticRegistrationOptions, TypedDict, total=True): pass
[docs] class LinkedEditingRangeParams(TextDocumentPositionParams, WorkDoneProgressParams, TypedDict, total=True): pass
[docs] class LinkedEditingRanges(TypedDict, total=False): ranges: List[Range] wordPattern: Optional[str]
[docs] class MonikerClientCapabilities(TypedDict, total=False): dynamicRegistration: Optional[bool]
[docs] class MonikerOptions(WorkDoneProgressOptions, TypedDict, total=True): pass
[docs] class MonikerRegistrationOptions(TextDocumentRegistrationOptions, MonikerOptions, TypedDict, total=True): pass
[docs] class MonikerParams(TextDocumentPositionParams, WorkDoneProgressParams, PartialResultParams, TypedDict, total=True): pass
[docs] class UniquenessLevel(Enum): document = 'document' project = 'project' group = 'group' scheme = 'scheme' global_ = 'global'
[docs] class MonikerKind(Enum): import_ = 'import' export = 'export' local = 'local'
[docs] class Moniker(TypedDict, total=False): scheme: str identifier: str unique: UniquenessLevel kind: Optional[MonikerKind]
##### END OF LSP SPECS ####################################################################### # # Language-Server-Protocol methods # ####################################################################### class LSPTasks: def __init__(self, lsp_data: dict): self.lsp_data = lsp_data self.lsp_table = gen_lsp_table([], prefix='lsp_') NO_TASKS = LSPTasks({}) class LSPBase: def __init__(self, cpu_bound: LSPTasks=NO_TASKS, blocking: LSPTasks=NO_TASKS): self.lsp_data = { 'processId': 0, 'rootUri': '', 'clientCapabilities': {}, 'serverInfo': {"name": self.__class__.__name__, "version": "0.1"}, 'serverCapabilities': { } } self.connection = None self.cpu_bound = cpu_bound self.blocking = blocking self.lsp_table = gen_lsp_table(self, prefix='lsp_') self.lsp_fulltable = self.lsp_table.copy() assert self.lsp_fulltable.keys().isdisjoint(self.cpu_bound.lsp_table.keys()) self.lsp_fulltable.update(self.cpu_bound.lsp_table) assert self.lsp_fulltable.keys().isdisjoint(self.blocking.lsp_table.keys()) self.lsp_fulltable.update(self.blocking.lsp_table) def connect(self, connection): self.connection = connection def lsp_initialize(self, **kwargs) -> Dict: # InitializeParams -> InitializeResult self.lsp_data['processId'] = kwargs['processId'] self.lsp_data['rootUri'] = kwargs['rootUri'] self.lsp_data['clientCapabilities'] = kwargs['capabilities'] return {'capabilities': self.lsp_data['serverCapabilities'], 'serverInfo': self.lsp_data['serverInfo']} def lsp_initialized(self, params: InitializedParams) -> None: pass def lsp_shutdown(self) -> Dict: self.lsp_data['processId'] = 0 self.lsp_data['rootUri'] = '' self.lsp_data['clientCapabilities'] = dict() return {}