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

Various refactorings #2366

Merged
merged 6 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
42 changes: 21 additions & 21 deletions Main.sublime-menu
Original file line number Diff line number Diff line change
Expand Up @@ -25,50 +25,50 @@
},
{
"command": "lsp_source_action",
"args": {"id": -1}
"args": {"index": -1}
},
{
"caption": "LSP: Source Action",
"children": [
{
"command": "lsp_source_action",
"args": {"id": 0}
"args": {"index": 0}
},
{
"command": "lsp_source_action",
"args": {"id": 1}
"args": {"index": 1}
},
{
"command": "lsp_source_action",
"args": {"id": 2}
"args": {"index": 2}
},
{
"command": "lsp_source_action",
"args": {"id": 3}
"args": {"index": 3}
},
{
"command": "lsp_source_action",
"args": {"id": 4}
"args": {"index": 4}
},
{
"command": "lsp_source_action",
"args": {"id": 5}
"args": {"index": 5}
},
{
"command": "lsp_source_action",
"args": {"id": 6}
"args": {"index": 6}
},
{
"command": "lsp_source_action",
"args": {"id": 7}
"args": {"index": 7}
},
{
"command": "lsp_source_action",
"args": {"id": 8}
"args": {"index": 8}
},
{
"command": "lsp_source_action",
"args": {"id": 9}
"args": {"index": 9}
}
]
},
Expand All @@ -81,43 +81,43 @@
},
{
"command": "lsp_refactor",
"args": {"id": 0}
"args": {"index": 0}
},
{
"command": "lsp_refactor",
"args": {"id": 1}
"args": {"index": 1}
},
{
"command": "lsp_refactor",
"args": {"id": 2}
"args": {"index": 2}
},
{
"command": "lsp_refactor",
"args": {"id": 3}
"args": {"index": 3}
},
{
"command": "lsp_refactor",
"args": {"id": 4}
"args": {"index": 4}
},
{
"command": "lsp_refactor",
"args": {"id": 5}
"args": {"index": 5}
},
{
"command": "lsp_refactor",
"args": {"id": 6}
"args": {"index": 6}
},
{
"command": "lsp_refactor",
"args": {"id": 7}
"args": {"index": 7}
},
{
"command": "lsp_refactor",
"args": {"id": 8}
"args": {"index": 8}
},
{
"command": "lsp_refactor",
"args": {"id": 9}
"args": {"index": 9}
}
]
},
Expand Down
4 changes: 2 additions & 2 deletions boot.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
from .plugin.core.open import opening_files
from .plugin.core.panels import PanelName
from .plugin.core.protocol import Error
from .plugin.core.registry import LspCollapseTreeItemCommand
from .plugin.core.registry import LspExpandTreeItemCommand
from .plugin.core.registry import LspNextDiagnosticCommand
from .plugin.core.registry import LspOpenLocationCommand
from .plugin.core.registry import LspPrevDiagnosticCommand
Expand All @@ -36,6 +34,8 @@
from .plugin.core.signature_help import LspSignatureHelpNavigateCommand
from .plugin.core.signature_help import LspSignatureHelpShowCommand
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.typing import Any, Optional, List, Type, Dict
from .plugin.core.views import LspRunTextCommandHelperCommand
from .plugin.document_link import LspOpenLinkCommand
Expand Down
24 changes: 12 additions & 12 deletions plugin/code_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -365,17 +365,17 @@ def actions_cache(self) -> List[Tuple[str, CodeAction]]:
def view(self) -> Optional[sublime.View]:
return self.window.active_view()

def is_enabled(self, id: int, event: Optional[dict] = None) -> bool:
if not -1 < id < len(self.actions_cache):
def is_enabled(self, index: int, event: Optional[dict] = None) -> bool:
if not -1 < index < len(self.actions_cache):
return False
return self._has_session(event)

def is_visible(self, id: int, event: Optional[dict] = None) -> bool:
if id == -1:
def is_visible(self, index: int, event: Optional[dict] = None) -> bool:
if index == -1:
if self._has_session(event):
sublime.set_timeout_async(partial(self._request_menu_actions_async, event))
return False
return id < len(self.actions_cache) and self._is_cache_valid(event)
return index < len(self.actions_cache) and self._is_cache_valid(event)

def _has_session(self, event: Optional[dict] = None) -> bool:
view = self.view
Expand All @@ -389,19 +389,19 @@ def _has_session(self, event: Optional[dict] = None) -> bool:
return False
return bool(listener.session_async(self.capability, region.b))

def description(self, id: int, event: Optional[dict] = None) -> Optional[str]:
if -1 < id < len(self.actions_cache):
return self.actions_cache[id][1]['title']
def description(self, index: int, event: Optional[dict] = None) -> Optional[str]:
if -1 < index < len(self.actions_cache):
return self.actions_cache[index][1]['title']

def want_event(self) -> bool:
return True

def run(self, id: int, event: Optional[dict] = None) -> None:
sublime.set_timeout_async(partial(self.run_async, id, event))
def run(self, index: int, event: Optional[dict] = None) -> None:
sublime.set_timeout_async(partial(self.run_async, index, event))

def run_async(self, id: int, event: Optional[dict]) -> None:
def run_async(self, index: int, event: Optional[dict]) -> None:
if self._is_cache_valid(event):
config_name, action = self.actions_cache[id]
config_name, action = self.actions_cache[index]
session = self.session_by_name(config_name)
if session:
session.run_code_action_async(action, progress=True, view=self.view) \
Expand Down
2 changes: 1 addition & 1 deletion plugin/completion.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from .core.constants import COMPLETION_KINDS
from .core.edit import parse_text_edit
from .core.logging import debug
from .core.promise import Promise
Expand All @@ -19,7 +20,6 @@
from .core.sessions import Session
from .core.settings import userprefs
from .core.typing import Callable, List, Dict, Optional, Generator, Tuple, Union, cast, Any, TypeGuard
from .core.views import COMPLETION_KINDS
from .core.views import FORMAT_STRING, FORMAT_MARKUP_CONTENT
from .core.views import MarkdownLangMap
from .core.views import minihtml
Expand Down
Loading