Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: use native types and f-string #2459

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
158 changes: 79 additions & 79 deletions boot.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,92 +4,92 @@
import sublime_plugin

# Please keep this list sorted (Edit -> Sort Lines)
from .plugin.code_actions import LspCodeActionsCommand
from .plugin.code_actions import LspRefactorCommand
from .plugin.code_actions import LspSourceActionCommand
from .plugin.code_lens import LspCodeLensCommand
from .plugin.code_lens import LspToggleCodeLensesCommand
from .plugin.color import LspColorPresentationCommand
from .plugin.completion import LspCommitCompletionWithOppositeInsertMode
from .plugin.completion import LspResolveDocsCommand
from .plugin.completion import LspSelectCompletionCommand
from .plugin.configuration import LspDisableLanguageServerGloballyCommand
from .plugin.configuration import LspDisableLanguageServerInProjectCommand
from .plugin.configuration import LspEnableLanguageServerGloballyCommand
from .plugin.configuration import LspEnableLanguageServerInProjectCommand
from .plugin.core.collections import DottedDict
from .plugin.code_actions import LspCodeActionsCommand # noqa: F401
jfcherng marked this conversation as resolved.
Show resolved Hide resolved
from .plugin.code_actions import LspRefactorCommand # noqa: F401
from .plugin.code_actions import LspSourceActionCommand # noqa: F401
from .plugin.code_lens import LspCodeLensCommand # noqa: F401
from .plugin.code_lens import LspToggleCodeLensesCommand # noqa: F401
from .plugin.color import LspColorPresentationCommand # noqa: F401
from .plugin.completion import LspCommitCompletionWithOppositeInsertMode # noqa: F401
from .plugin.completion import LspResolveDocsCommand # noqa: F401
from .plugin.completion import LspSelectCompletionCommand # noqa: F401
from .plugin.configuration import LspDisableLanguageServerGloballyCommand # noqa: F401
from .plugin.configuration import LspDisableLanguageServerInProjectCommand # noqa: F401
from .plugin.configuration import LspEnableLanguageServerGloballyCommand # noqa: F401
from .plugin.configuration import LspEnableLanguageServerInProjectCommand # noqa: F401
from .plugin.core.collections import DottedDict # noqa: F401
from .plugin.core.css import load as load_css
from .plugin.core.open import opening_files
from .plugin.core.panels import PanelName
from .plugin.core.protocol import Error
from .plugin.core.registry import LspNextDiagnosticCommand
from .plugin.core.registry import LspOpenLocationCommand
from .plugin.core.registry import LspPrevDiagnosticCommand
from .plugin.core.registry import LspRestartServerCommand
from .plugin.core.protocol import Error # noqa: F401
jfcherng marked this conversation as resolved.
Show resolved Hide resolved
from .plugin.core.registry import LspNextDiagnosticCommand # noqa: F401
from .plugin.core.registry import LspOpenLocationCommand # noqa: F401
from .plugin.core.registry import LspPrevDiagnosticCommand # noqa: F401
from .plugin.core.registry import LspRestartServerCommand # noqa: F401
from .plugin.core.registry import windows
from .plugin.core.sessions import AbstractPlugin
from .plugin.core.sessions import register_plugin
from .plugin.core.settings import client_configs
from .plugin.core.settings import load_settings
from .plugin.core.settings import unload_settings
from .plugin.core.signature_help import LspSignatureHelpNavigateCommand
from .plugin.core.signature_help import LspSignatureHelpShowCommand
from .plugin.core.signature_help import LspSignatureHelpNavigateCommand # noqa: F401
from .plugin.core.signature_help import LspSignatureHelpShowCommand # noqa: F401
from .plugin.core.transports import kill_all_subprocesses
from .plugin.core.tree_view import LspCollapseTreeItemCommand
from .plugin.core.tree_view import LspExpandTreeItemCommand
from .plugin.core.views import LspRunTextCommandHelperCommand
from .plugin.document_link import LspOpenLinkCommand
from .plugin.documents import DocumentSyncListener
from .plugin.documents import TextChangeListener
from .plugin.edit import LspApplyDocumentEditCommand
from .plugin.edit import LspApplyWorkspaceEditCommand
from .plugin.execute_command import LspExecuteCommand
from .plugin.folding_range import LspFoldAllCommand
from .plugin.folding_range import LspFoldCommand
from .plugin.formatting import LspFormatCommand
from .plugin.formatting import LspFormatDocumentCommand
from .plugin.formatting import LspFormatDocumentRangeCommand
from .plugin.goto import LspSymbolDeclarationCommand
from .plugin.goto import LspSymbolDefinitionCommand
from .plugin.goto import LspSymbolImplementationCommand
from .plugin.goto import LspSymbolTypeDefinitionCommand
from .plugin.goto_diagnostic import LspGotoDiagnosticCommand
from .plugin.hierarchy import LspCallHierarchyCommand
from .plugin.hierarchy import LspHierarchyToggleCommand
from .plugin.hierarchy import LspTypeHierarchyCommand
from .plugin.hover import LspHoverCommand
from .plugin.hover import LspToggleHoverPopupsCommand
from .plugin.inlay_hint import LspInlayHintClickCommand
from .plugin.inlay_hint import LspToggleInlayHintsCommand
from .plugin.panels import LspClearLogPanelCommand
from .plugin.panels import LspClearPanelCommand
from .plugin.panels import LspShowDiagnosticsPanelCommand
from .plugin.panels import LspToggleLogPanelLinesLimitCommand
from .plugin.panels import LspToggleServerPanelCommand
from .plugin.panels import LspUpdateLogPanelCommand
from .plugin.panels import LspUpdatePanelCommand
from .plugin.references import LspSymbolReferencesCommand
from .plugin.rename import LspHideRenameButtonsCommand
from .plugin.rename import LspSymbolRenameCommand
from .plugin.save_command import LspSaveAllCommand
from .plugin.save_command import LspSaveCommand
from .plugin.selection_range import LspExpandSelectionCommand
from .plugin.semantic_highlighting import LspShowScopeNameCommand
from .plugin.symbols import LspDocumentSymbolsCommand
from .plugin.symbols import LspSelectionAddCommand
from .plugin.symbols import LspSelectionClearCommand
from .plugin.symbols import LspSelectionSetCommand
from .plugin.symbols import LspWorkspaceSymbolsCommand
from .plugin.tooling import LspCopyToClipboardFromBase64Command
from .plugin.tooling import LspDumpBufferCapabilities
from .plugin.tooling import LspDumpWindowConfigs
from .plugin.tooling import LspOnDoubleClickCommand
from .plugin.tooling import LspParseVscodePackageJson
from .plugin.tooling import LspTroubleshootServerCommand
from typing import Any, Dict, List, Optional, Type


def _get_final_subclasses(derived: List[Type], results: List[Type]) -> None:
from .plugin.core.tree_view import LspCollapseTreeItemCommand # noqa: F401
from .plugin.core.tree_view import LspExpandTreeItemCommand # noqa: F401
from .plugin.core.views import LspRunTextCommandHelperCommand # noqa: F401
from .plugin.document_link import LspOpenLinkCommand # noqa: F401
from .plugin.documents import DocumentSyncListener # noqa: F401
from .plugin.documents import TextChangeListener # noqa: F401
from .plugin.edit import LspApplyDocumentEditCommand # noqa: F401
from .plugin.edit import LspApplyWorkspaceEditCommand # noqa: F401
from .plugin.execute_command import LspExecuteCommand # noqa: F401
from .plugin.folding_range import LspFoldAllCommand # noqa: F401
from .plugin.folding_range import LspFoldCommand # noqa: F401
from .plugin.formatting import LspFormatCommand # noqa: F401
from .plugin.formatting import LspFormatDocumentCommand # noqa: F401
from .plugin.formatting import LspFormatDocumentRangeCommand # noqa: F401
from .plugin.goto import LspSymbolDeclarationCommand # noqa: F401
from .plugin.goto import LspSymbolDefinitionCommand # noqa: F401
from .plugin.goto import LspSymbolImplementationCommand # noqa: F401
from .plugin.goto import LspSymbolTypeDefinitionCommand # noqa: F401
from .plugin.goto_diagnostic import LspGotoDiagnosticCommand # noqa: F401
from .plugin.hierarchy import LspCallHierarchyCommand # noqa: F401
from .plugin.hierarchy import LspHierarchyToggleCommand # noqa: F401
from .plugin.hierarchy import LspTypeHierarchyCommand # noqa: F401
from .plugin.hover import LspHoverCommand # noqa: F401
from .plugin.hover import LspToggleHoverPopupsCommand # noqa: F401
from .plugin.inlay_hint import LspInlayHintClickCommand # noqa: F401
from .plugin.inlay_hint import LspToggleInlayHintsCommand # noqa: F401
from .plugin.panels import LspClearLogPanelCommand # noqa: F401
from .plugin.panels import LspClearPanelCommand # noqa: F401
from .plugin.panels import LspShowDiagnosticsPanelCommand # noqa: F401
from .plugin.panels import LspToggleLogPanelLinesLimitCommand # noqa: F401
from .plugin.panels import LspToggleServerPanelCommand # noqa: F401
from .plugin.panels import LspUpdateLogPanelCommand # noqa: F401
from .plugin.panels import LspUpdatePanelCommand # noqa: F401
from .plugin.references import LspSymbolReferencesCommand # noqa: F401
from .plugin.rename import LspHideRenameButtonsCommand # noqa: F401
from .plugin.rename import LspSymbolRenameCommand # noqa: F401
from .plugin.save_command import LspSaveAllCommand # noqa: F401
from .plugin.save_command import LspSaveCommand # noqa: F401
from .plugin.selection_range import LspExpandSelectionCommand # noqa: F401
from .plugin.semantic_highlighting import LspShowScopeNameCommand # noqa: F401
from .plugin.symbols import LspDocumentSymbolsCommand # noqa: F401
from .plugin.symbols import LspSelectionAddCommand # noqa: F401
from .plugin.symbols import LspSelectionClearCommand # noqa: F401
from .plugin.symbols import LspSelectionSetCommand # noqa: F401
from .plugin.symbols import LspWorkspaceSymbolsCommand # noqa: F401
from .plugin.tooling import LspCopyToClipboardFromBase64Command # noqa: F401
from .plugin.tooling import LspDumpBufferCapabilities # noqa: F401
from .plugin.tooling import LspDumpWindowConfigs # noqa: F401
from .plugin.tooling import LspOnDoubleClickCommand # noqa: F401
from .plugin.tooling import LspParseVscodePackageJson # noqa: F401
from .plugin.tooling import LspTroubleshootServerCommand # noqa: F401
from typing import Any


def _get_final_subclasses(derived: list[type], results: list[type]) -> None:
for d in derived:
d_subclasses = d.__subclasses__()
if len(d_subclasses) > 0:
Expand All @@ -99,7 +99,7 @@ def _get_final_subclasses(derived: List[Type], results: List[Type]) -> None:


def _register_all_plugins() -> None:
plugin_classes: List[Type[AbstractPlugin]] = []
plugin_classes: list[type[AbstractPlugin]] = []
_get_final_subclasses(AbstractPlugin.__subclasses__(), plugin_classes)
for plugin_class in plugin_classes:
try:
Expand All @@ -112,6 +112,7 @@ def _register_all_plugins() -> None:

def _unregister_all_plugins() -> None:
from LSP.plugin.core.sessions import _plugins

_plugins.clear()
client_configs.external.clear()
client_configs.all.clear()
Expand All @@ -132,7 +133,6 @@ def plugin_unloaded() -> None:


class Listener(sublime_plugin.EventListener):

def on_exit(self) -> None:
kill_all_subprocesses()

Expand Down Expand Up @@ -187,7 +187,7 @@ def on_pre_close(self, view: sublime.View) -> None:
tup[1](None)
break

def on_post_window_command(self, window: sublime.Window, command_name: str, args: Optional[Dict[str, Any]]) -> None:
def on_post_window_command(self, window: sublime.Window, command_name: str, args: dict[str, Any] | None) -> None:
if command_name == "show_panel":
wm = windows.lookup(window)
if not wm:
Expand Down
Loading
Loading