Skip to content

Commit

Permalink
Drop pygls.lsp.types, use lsprotocol.types directly
Browse files Browse the repository at this point in the history
  • Loading branch information
alcarney committed Aug 20, 2022
1 parent 595995f commit 4ee8edb
Show file tree
Hide file tree
Showing 49 changed files with 98 additions and 117 deletions.
4 changes: 2 additions & 2 deletions examples/fountain-extension/src/server.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import re
from pygls.server import LanguageServer
from pygls.lsp.types import TEXT_DOCUMENT_COMPLETION
from pygls.lsp.types import (CompletionItem, CompletionParams, CompletionList, CompletionOptions)
from lsprotocol.types import TEXT_DOCUMENT_COMPLETION
from lsprotocol.types import (CompletionItem, CompletionParams, CompletionList, CompletionOptions)

# The following imports are required for the glue code in 'server.ts'
import json
Expand Down
4 changes: 2 additions & 2 deletions examples/json-extension/server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
from json import JSONDecodeError
from typing import Optional

from pygls.lsp.types import (TEXT_DOCUMENT_COMPLETION, TEXT_DOCUMENT_DID_CHANGE,
from lsprotocol.types import (TEXT_DOCUMENT_COMPLETION, TEXT_DOCUMENT_DID_CHANGE,
TEXT_DOCUMENT_DID_CLOSE, TEXT_DOCUMENT_DID_OPEN,
TEXT_DOCUMENT_SEMANTIC_TOKENS_FULL)
from pygls.lsp.types import (CompletionItem, CompletionList, CompletionOptions,
from lsprotocol.types import (CompletionItem, CompletionList, CompletionOptions,
CompletionParams, ConfigurationItem,
ConfigurationParams, Diagnostic,
DidChangeTextDocumentParams,
Expand Down
2 changes: 1 addition & 1 deletion examples/json-extension/server/tests/unit/test_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

import pytest
from mock import Mock
from pygls.lsp.types import (DidCloseTextDocumentParams,
from lsprotocol.types import (DidCloseTextDocumentParams,
DidOpenTextDocumentParams, TextDocumentIdentifier,
TextDocumentItem)
from pygls.workspace import Document, Workspace
Expand Down
4 changes: 2 additions & 2 deletions pygls/capabilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from functools import reduce
from typing import Any

from pygls.lsp.types import (
from lsprotocol.types import (
TEXT_DOCUMENT_CODE_ACTION, TEXT_DOCUMENT_CODE_LENS,
TEXT_DOCUMENT_COMPLETION, TEXT_DOCUMENT_DECLARATION,
TEXT_DOCUMENT_DEFINITION, TEXT_DOCUMENT_DOCUMENT_COLOR,
Expand All @@ -38,7 +38,7 @@
WORKSPACE_SYMBOL, WORKSPACE_WILL_CREATE_FILES,
WORKSPACE_WILL_DELETE_FILES, WORKSPACE_WILL_RENAME_FILES
)
from pygls.lsp.types import (ClientCapabilities, CodeLensOptions, CompletionOptions,
from lsprotocol.types import (ClientCapabilities, CodeLensOptions, CompletionOptions,
DocumentLinkOptions, ExecuteCommandOptions, ImplementationOptions,
SaveOptions, SemanticTokensOptions, SemanticTokensRegistrationOptions,
SemanticTokensOptionsFullType1, ServerCapabilities,
Expand Down
8 changes: 6 additions & 2 deletions pygls/lsp/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and #
# limitations under the License. #
############################################################################
from typing import Any, Optional, Union
from typing import Any, Callable, List, Optional, Union

import attrs
from lsprotocol.types import (
Expand All @@ -24,12 +24,16 @@
TEXT_DOCUMENT_SEMANTIC_TOKENS_FULL_DELTA,
TEXT_DOCUMENT_SEMANTIC_TOKENS_RANGE,
SemanticTokensLegend,
SemanticTokensRegistrationOptions
SemanticTokensRegistrationOptions,
ShowDocumentResult
)
from typeguard import check_type

from pygls.exceptions import MethodTypeNotRegisteredError

ConfigCallbackType = Callable[[List[Any]], None]
ShowDocumentCallbackType = Callable[[ShowDocumentResult], None]

METHOD_TO_OPTIONS = {
TEXT_DOCUMENT_SEMANTIC_TOKENS_FULL: Union[SemanticTokensLegend, SemanticTokensRegistrationOptions],
TEXT_DOCUMENT_SEMANTIC_TOKENS_FULL_DELTA: Union[SemanticTokensLegend, SemanticTokensRegistrationOptions],
Expand Down
24 changes: 0 additions & 24 deletions pygls/lsp/types.py

This file was deleted.

4 changes: 2 additions & 2 deletions pygls/progress.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
from concurrent.futures import Future
from typing import Dict

from pygls.lsp.types import (PROGRESS, WINDOW_WORK_DONE_PROGRESS_CANCEL,
from lsprotocol.types import (PROGRESS, WINDOW_WORK_DONE_PROGRESS_CANCEL,
WINDOW_WORK_DONE_PROGRESS_CREATE)
from pygls.lsp.types import (ProgressParams, ProgressToken, WorkDoneProgressBegin,
from lsprotocol.types import (ProgressParams, ProgressToken, WorkDoneProgressBegin,
WorkDoneProgressEnd, WorkDoneProgressReport,
WorkDoneProgressCancelParams, WorkDoneProgressCreateParams)
from pygls.protocol import LanguageServerProtocol
Expand Down
11 changes: 6 additions & 5 deletions pygls/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@
MethodTypeNotRegisteredError)
from pygls.feature_manager import (FeatureManager, assign_help_attrs, get_help_attrs,
is_thread_function)
from pygls.lsp import (JsonRPCNotification, JsonRPCRequestMessage, JsonRPCResponseMessage,
from pygls.lsp import (ConfigCallbackType, ShowDocumentCallbackType,
JsonRPCNotification, JsonRPCRequestMessage, JsonRPCResponseMessage,
get_method_params_type, get_method_return_type)
from pygls.lsp.types import (CANCEL_REQUEST, CLIENT_REGISTER_CAPABILITY,
from lsprotocol.types import (CANCEL_REQUEST, CLIENT_REGISTER_CAPABILITY,
CLIENT_UNREGISTER_CAPABILITY, EXIT, INITIALIZE, INITIALIZED,
LOG_TRACE, SET_TRACE, SHUTDOWN,
TEXT_DOCUMENT_DID_CHANGE, TEXT_DOCUMENT_DID_CLOSE,
Expand All @@ -49,14 +50,14 @@
WORKSPACE_APPLY_EDIT, WORKSPACE_CONFIGURATION,
WORKSPACE_DID_CHANGE_WORKSPACE_FOLDERS, WORKSPACE_EXECUTE_COMMAND,
WORKSPACE_SEMANTIC_TOKENS_REFRESH)
from pygls.lsp.types import (ApplyWorkspaceEditParams,
ConfigurationParams, ConfigCallbackType, Diagnostic,
from lsprotocol.types import (ApplyWorkspaceEditParams,
ConfigurationParams, Diagnostic,
DidChangeTextDocumentParams, DidChangeWorkspaceFoldersParams,
DidCloseTextDocumentParams, DidOpenTextDocumentParams,
ExecuteCommandParams, InitializeParams, InitializeResult,
LogMessageParams, LogTraceParams, MessageType, PublishDiagnosticsParams,
RegistrationParams, ResponseErrorMessage, SetTraceParams,
ShowDocumentParams, ShowMessageParams, ShowDocumentCallbackType,
ShowDocumentParams, ShowMessageParams,
TraceValues, UnregistrationParams, WorkspaceApplyEditResponse,
WorkspaceEdit)
from pygls.uris import from_fs_path
Expand Down
5 changes: 3 additions & 2 deletions pygls/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@
from typing import Any, Callable, List, Optional, TypeVar

from pygls import IS_WIN, IS_PYODIDE
from pygls.lsp.types import (WorkspaceApplyEditResponse, ClientCapabilities, ConfigCallbackType,
from pygls.lsp import ConfigCallbackType, ShowDocumentCallbackType
from lsprotocol.types import (WorkspaceApplyEditResponse, ClientCapabilities,
ConfigurationParams, Diagnostic, MessageType, RegistrationParams,
ServerCapabilities, ShowDocumentCallbackType, ShowDocumentParams,
ServerCapabilities, ShowDocumentParams,
TextDocumentSyncKind, UnregistrationParams,
WorkspaceEdit)
from pygls.progress import Progress
Expand Down
2 changes: 1 addition & 1 deletion pygls/workspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import re
from typing import List, Optional, Pattern

from pygls.lsp.types import (Position, Range, TextDocumentContentChangeEvent,
from lsprotocol.types import (Position, Range, TextDocumentContentChangeEvent,
TextDocumentItem, TextDocumentSyncKind,
VersionedTextDocumentIdentifier, WorkspaceFolder)
from pygls.uris import to_fs_path, uri_scheme
Expand Down
2 changes: 1 addition & 1 deletion tests/ls_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import threading

import pytest
from pygls.lsp.types import (
from lsprotocol.types import (
EXIT,
INITIALIZE,
SHUTDOWN,
Expand Down
4 changes: 2 additions & 2 deletions tests/lsp/semantic_tokens/test_delta_missing_legend.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
############################################################################
from typing import Optional, Union

from pygls.lsp.types import (
from lsprotocol.types import (
TEXT_DOCUMENT_SEMANTIC_TOKENS_FULL_DELTA,
)
from pygls.lsp.types import (
from lsprotocol.types import (
SemanticTokens,
SemanticTokensDeltaParams,
SemanticTokensLegend,
Expand Down
4 changes: 2 additions & 2 deletions tests/lsp/semantic_tokens/test_delta_missing_legend_none.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
############################################################################
from typing import Optional, Union

from pygls.lsp.types import (
from lsprotocol.types import (
SemanticTokens,
SemanticTokensDeltaParams,
SemanticTokensPartialResult,
)
from pygls.lsp.types import (
from lsprotocol.types import (
TEXT_DOCUMENT_SEMANTIC_TOKENS_FULL_DELTA,
)

Expand Down
4 changes: 2 additions & 2 deletions tests/lsp/semantic_tokens/test_full_missing_legend.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
############################################################################
from typing import Optional, Union

from pygls.lsp.types import (
from lsprotocol.types import (
TEXT_DOCUMENT_SEMANTIC_TOKENS_FULL,
)
from pygls.lsp.types import (
from lsprotocol.types import (
SemanticTokens,
SemanticTokensPartialResult,
SemanticTokensParams
Expand Down
4 changes: 2 additions & 2 deletions tests/lsp/semantic_tokens/test_range.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
############################################################################
from typing import Optional, Union

from pygls.lsp.types import (
from lsprotocol.types import (
TEXT_DOCUMENT_SEMANTIC_TOKENS_RANGE,
)
from pygls.lsp.types import (
from lsprotocol.types import (
Position,
Range,
SemanticTokens,
Expand Down
4 changes: 2 additions & 2 deletions tests/lsp/semantic_tokens/test_range_missing_legends.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
############################################################################
from typing import Optional, Union

from pygls.lsp.types import (
from lsprotocol.types import (
TEXT_DOCUMENT_SEMANTIC_TOKENS_RANGE,
)
from pygls.lsp.types import (
from lsprotocol.types import (
SemanticTokens,
SemanticTokensParams,
SemanticTokensPartialResult,
Expand Down
4 changes: 2 additions & 2 deletions tests/lsp/semantic_tokens/test_semantic_tokens_full.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@
############################################################################
from typing import Optional, Union

from pygls.lsp.types import (
from lsprotocol.types import (
TEXT_DOCUMENT_SEMANTIC_TOKENS_FULL,
)
from pygls.lsp.types import (
from lsprotocol.types import (
SemanticTokens,
SemanticTokensLegend,
SemanticTokensParams,
Expand Down
4 changes: 2 additions & 2 deletions tests/lsp/test_call_hierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
############################################################################
from typing import List, Optional

from pygls.lsp.types import (
from lsprotocol.types import (
CALL_HIERARCHY_INCOMING_CALLS,
CALL_HIERARCHY_OUTGOING_CALLS,
TEXT_DOCUMENT_PREPARE_CALL_HIERARCHY
)
from pygls.lsp.types import (
from lsprotocol.types import (
CallHierarchyIncomingCall, CallHierarchyIncomingCallsParams,
CallHierarchyItem, CallHierarchyOptions, CallHierarchyOutgoingCall,
CallHierarchyOutgoingCallsParams, CallHierarchyPrepareParams,
Expand Down
4 changes: 2 additions & 2 deletions tests/lsp/test_code_action.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
############################################################################
from typing import List, Optional, Union

from pygls.lsp.types import TEXT_DOCUMENT_CODE_ACTION
from pygls.lsp.types import (
from lsprotocol.types import TEXT_DOCUMENT_CODE_ACTION
from lsprotocol.types import (
CodeAction,
CodeActionContext,
CodeActionKind,
Expand Down
4 changes: 2 additions & 2 deletions tests/lsp/test_code_lens.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
############################################################################
from typing import List, Optional

from pygls.lsp.types import TEXT_DOCUMENT_CODE_LENS
from pygls.lsp.types import (
from lsprotocol.types import TEXT_DOCUMENT_CODE_LENS
from lsprotocol.types import (
CodeLens,
CodeLensOptions,
CodeLensParams,
Expand Down
4 changes: 2 additions & 2 deletions tests/lsp/test_color_presentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

from typing import List

from pygls.lsp.types import TEXT_DOCUMENT_COLOR_PRESENTATION
from pygls.lsp.types import (
from lsprotocol.types import TEXT_DOCUMENT_COLOR_PRESENTATION
from lsprotocol.types import (
Color,
ColorPresentation,
ColorPresentationParams,
Expand Down
4 changes: 2 additions & 2 deletions tests/lsp/test_completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
# See the License for the specific language governing permissions and #
# limitations under the License. #
############################################################################
from pygls.lsp.types import TEXT_DOCUMENT_COMPLETION
from pygls.lsp.types import (
from lsprotocol.types import TEXT_DOCUMENT_COMPLETION
from lsprotocol.types import (
CompletionItem,
CompletionItemKind,
CompletionList,
Expand Down
4 changes: 2 additions & 2 deletions tests/lsp/test_declaration.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

from typing import List, Optional, Union

from pygls.lsp.types import TEXT_DOCUMENT_DECLARATION
from pygls.lsp.types import (
from lsprotocol.types import TEXT_DOCUMENT_DECLARATION
from lsprotocol.types import (
DeclarationOptions,
DeclarationParams,
Location,
Expand Down
4 changes: 2 additions & 2 deletions tests/lsp/test_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

from typing import List, Optional, Union

from pygls.lsp.types import TEXT_DOCUMENT_DEFINITION
from pygls.lsp.types import (
from lsprotocol.types import TEXT_DOCUMENT_DEFINITION
from lsprotocol.types import (
DefinitionOptions,
DefinitionParams,
Location,
Expand Down
4 changes: 2 additions & 2 deletions tests/lsp/test_document_color.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

from typing import List

from pygls.lsp.types import TEXT_DOCUMENT_DOCUMENT_COLOR
from pygls.lsp.types import (
from lsprotocol.types import TEXT_DOCUMENT_DOCUMENT_COLOR
from lsprotocol.types import (
Color,
ColorInformation,
DocumentColorOptions,
Expand Down
4 changes: 2 additions & 2 deletions tests/lsp/test_document_highlight.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

from typing import List, Optional

from pygls.lsp.types import TEXT_DOCUMENT_DOCUMENT_HIGHLIGHT
from pygls.lsp.types import (
from lsprotocol.types import TEXT_DOCUMENT_DOCUMENT_HIGHLIGHT
from lsprotocol.types import (
DocumentHighlight,
DocumentHighlightKind,
DocumentHighlightOptions,
Expand Down
4 changes: 2 additions & 2 deletions tests/lsp/test_document_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

from typing import List, Optional

from pygls.lsp.types import TEXT_DOCUMENT_DOCUMENT_LINK
from pygls.lsp.types import (
from lsprotocol.types import TEXT_DOCUMENT_DOCUMENT_LINK
from lsprotocol.types import (
DocumentLink,
DocumentLinkOptions,
DocumentLinkParams,
Expand Down
4 changes: 2 additions & 2 deletions tests/lsp/test_document_symbol.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

from typing import List, Union

from pygls.lsp.types import TEXT_DOCUMENT_DOCUMENT_SYMBOL
from pygls.lsp.types import (
from lsprotocol.types import TEXT_DOCUMENT_DOCUMENT_SYMBOL
from lsprotocol.types import (
DocumentSymbol,
DocumentSymbolOptions,
DocumentSymbolParams,
Expand Down
4 changes: 2 additions & 2 deletions tests/lsp/test_folding_range.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

from typing import List, Optional

from pygls.lsp.types import TEXT_DOCUMENT_FOLDING_RANGE
from pygls.lsp.types import (
from lsprotocol.types import TEXT_DOCUMENT_FOLDING_RANGE
from lsprotocol.types import (
FoldingRange,
FoldingRangeKind,
FoldingRangeOptions,
Expand Down
Loading

0 comments on commit 4ee8edb

Please sign in to comment.