Exemplo n.º 1
0
    def test_hover_info(self):

        yield 100  # wait for file to be open
        self.view.run_command('insert', {"characters": ORIGINAL_CONTENT})

        wm = windows.lookup(self.view.window())

        text_config = ClientConfig("test", [], None, ["text.plain"], ["Plain text"], "test")
        register_client_config(text_config)
        wm._configs._configs.append(text_config)

        session = Session(text_config, dirname(__file__), TestClient())
        session.state = ClientStates.READY
        wm._sessions[text_config.name] = session

        # session = session_for_view(self.view)
        # self.assertIsNotNone(session)
        # self.assertTrue(session.has_capability('hoverProvider'))

        self.view.run_command('lsp_hover', {'point': 3})

        # popup should be visible eventually
        yield self.view.is_popup_visible()

        last_content = _test_contents[-1]
        self.assertTrue("greeting" in last_content)
Exemplo n.º 2
0
def handle_status(session: Session, params: Any) -> None:
    """Handle the metals/status notification."""

    if not isinstance(params, dict):
        return
    hide = params.get("hide") if isinstance(params.get("hide"),
                                            bool) else False
    if not hide:
        session.set_window_status_async(status_key, params.get('text', ''))
    else:
        session.erase_window_status_async(status_key)
Exemplo n.º 3
0
def inject_session(wm, config, client):

    session = Session(config, "", client)
    # session.state = ClientStates.READY
    wm.update_configs(client_configs.all)
    wm._sessions[config.name] = session
    wm._handle_session_started(session, "", config)
Exemplo n.º 4
0
Arquivo: setup.py Projeto: Narretz/LSP
def inject_session(wm, config, client):

    session = Session(config, "", client)
    # session.state = ClientStates.READY
    wm.update_configs()
    wm._sessions[config.name] = session
    wm._handle_post_initialize(session)
Exemplo n.º 5
0
def handle_decorations(session: Session, params: Union[Dict[str, Any], str]) -> None:
    phantom_key = "metals_decoraction"
    field_name = "_lsp_metals_decorations"
    clear_phantoms = False
    uri = None
    if isinstance(params, str):
        uri = session.config.map_client_path_to_server_uri(params)
        clear_phantoms = True
    elif isinstance(params, dict):
        uri = params.get('uri')

    if not uri:
        return

    session_buffer = session.get_session_buffer_for_uri_async(uri)
    if not session_buffer:
        return
    session_view = next(iter(session_buffer.session_views), None)
    if session_view:
        phantoms = []
        try:
            phantom_set = getattr(session_buffer, field_name)
        except AttributeError:
            phantom_set = sublime.PhantomSet(session_view.view, phantom_key)
            setattr(session_buffer, field_name, phantom_set)

        if not clear_phantoms:
            phantoms = decorations_to_phantom(params.get('options', []), session_view.view)

        phantom_set.update(phantoms)
def handle_execute_client(session: Session, params: Any) -> None:
    """Handle the metals/executeClientCommand notification."""

    if not isinstance(params, dict):
        return
    command_name = params.get('command')
    args = params.get('arguments')

    if command_name == "metals-goto-location":
        goto_location(session, args)
    elif command_name == 'metals-show-stacktrace':
        show_stacktrace(session, args)
    elif command_name in {'metals-doctor-run', 'metals-doctor-reload'}:
        run_doctor(session, args)
    else:
        msg = "Unknown command {}".format(command_name)
        session.set_window_status_async(status_key, msg)