Skip to content

Commit

Permalink
Move LSP constants to completion manager so provider depend on manage…
Browse files Browse the repository at this point in the history
…r and not languageserver
  • Loading branch information
goanpeca committed Jul 28, 2020
1 parent 2f02c11 commit b6206fd
Show file tree
Hide file tree
Showing 27 changed files with 807 additions and 795 deletions.
179 changes: 0 additions & 179 deletions spyder/api/completion.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,182 +12,3 @@
and workspace management functions.
"""

from qtpy.QtCore import QObject, Signal
from spyder.api.plugins import SpyderPlugin


class SpyderCompletionPlugin(QObject, SpyderPlugin):
"""
Spyder plugin API for completion clients.
All completion clients must implement this interface in order to interact
with Spyder CodeEditor and Projects manager.
"""

# Use this signal to send a response back to the completion manager
# str: Completion client name
# int: Request sequence identifier
# dict: Response dictionary
sig_response_ready = Signal(str, int, dict)

# Use this signal to indicate that the plugin is ready
sig_plugin_ready = Signal(str)

# ---------------------------- ATTRIBUTES ---------------------------------

# Name of the completion service
# Status: Required
COMPLETION_CLIENT_NAME = None

def __init__(self, parent):
QObject.__init__(self, parent)
SpyderPlugin.__init__(self, parent)
self.main = parent

def register_file(self, language, filename, codeeditor):
"""
Register file to perform completions.
If a language client is not available for a given file, then this
method should keep a queue, such that files can be initialized once
a server is available.
Parameters
----------
language: str
Programming language of the given file
filename: str
Filename to register
codeeditor: spyder.plugins.editor.widgets.codeeditor.CodeEditor
Codeeditor to send the client configurations
"""
pass

def send_request(self, language, req_type, req, req_id):
"""
Process completion/introspection request from Spyder.
Parameters
----------
language: str
Programming language for the incoming request
req_type: str
Type of request, one of
:class:`spyder.plugins.completion.CompletionTypes`
req: dict
Request body
{
'filename': str,
**kwargs: request-specific parameters
}
req_id: int
Request identifier for response
"""
pass

def send_notification(self, language, notification_type, notification):
"""
Send notification to completion server based on Spyder changes.
Parameters
----------
language: str
Programming language for the incoming request
notification_type: str
Type of request, one of
:class:`spyder.plugins.completion.CompletionTypes`
notification: dict
Request body
{
'filename': str,
**kwargs: request-specific parameters
}
"""
pass

def send_response(self, response, resp_id):
"""
Send response for server request.
Parameters
----------
response: dict
Response body for server
{
**kwargs: response-specific keys
}
resp_id: int
Request identifier for response
"""
pass

def broadcast_notification(self, notification_type, notification):
"""
Send a broadcast notification across all programming languages.
Parameters
----------
req_type: str
Type of request, one of
:class:`spyder.plugins.completion.CompletionTypes`
req: dict
Request body
{
**kwargs: notification-specific parameters
}
req_id: int
Request identifier for response, None if notification
"""
pass

def update_configuration(self):
"""Handle completion option configuration updates."""
pass

def project_path_update(self, project_path, update_kind):
"""
Handle project path updates on Spyder.
Parameters
----------
project_path: str
Path to the project folder modified
update_kind: str
Path update kind, one of
:class:`spyder.plugins.completion.WorkspaceUpdateKind`
"""
pass

def start_client(self, language):
"""
Start completions/introspection services for a given language.
Parameters
----------
language: str
Programming language to start analyzing
Returns
-------
bool
True if language client could be started, otherwise False.
"""
return False

def stop_client(self, language):
"""
Stop completions/introspection services for a given language.
Parameters
----------
language: str
Programming language to stop analyzing
"""
pass

def start(self):
"""Start completion plugin."""
self.sig_plugin_ready.emit(self.COMPLETION_CLIENT_NAME)

def shutdown(self):
"""Stop completion plugin."""
pass
4 changes: 2 additions & 2 deletions spyder/plugins/completion/fallback/actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
from diff_match_patch import diff_match_patch

# Local imports
from spyder.plugins.completion.languageserver import CompletionItemKind
from spyder.plugins.completion.languageserver import LSPRequestTypes
from spyder.plugins.completion.manager.api import CompletionItemKind
from spyder.plugins.completion.manager.api import LSPRequestTypes
from spyder.plugins.completion.fallback.utils import (
get_keywords, get_words, is_prefix_valid)

Expand Down
2 changes: 1 addition & 1 deletion spyder/plugins/completion/fallback/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import logging

# Local imports
from spyder.api.completion import SpyderCompletionPlugin
from spyder.plugins.completion.manager.api import SpyderCompletionPlugin
from spyder.plugins.completion.fallback.actor import FallbackActor


Expand Down
2 changes: 1 addition & 1 deletion spyder/plugins/completion/fallback/tests/test_fallback.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

import pytest
from diff_match_patch import diff_match_patch
from spyder.plugins.completion.languageserver import LSPRequestTypes
from spyder.plugins.completion.manager.api import LSPRequestTypes
from spyder.plugins.completion.fallback.utils import get_words


Expand Down
2 changes: 1 addition & 1 deletion spyder/plugins/completion/kite/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

"""Kite client requests and constants."""

from spyder.plugins.completion.languageserver import LSPRequestTypes
from spyder.plugins.completion.manager.api import LSPRequestTypes


LOCALHOST = '127.0.0.1'
Expand Down
2 changes: 1 addition & 1 deletion spyder/plugins/completion/kite/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from spyder.config.base import _, running_under_pytest
from spyder.config.manager import CONF
from spyder.utils.programs import run_program
from spyder.api.completion import SpyderCompletionPlugin
from spyder.plugins.completion.manager.api import SpyderCompletionPlugin
from spyder.plugins.completion.kite.client import KiteClient
from spyder.plugins.completion.kite.utils.status import (
check_if_kite_running, check_if_kite_installed)
Expand Down
2 changes: 1 addition & 1 deletion spyder/plugins/completion/kite/providers/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from qtpy.QtCore import QMutexLocker
from spyder.plugins.completion.kite.decorators import send_request, handles
from spyder.plugins.completion.languageserver import (
from spyder.plugins.completion.manager.api import (
LSPRequestTypes, CompletionItemKind)


Expand Down
Loading

0 comments on commit b6206fd

Please sign in to comment.