Skip to content

Commit

Permalink
Merge pull request #978 from krassowski/hover-ci
Browse files Browse the repository at this point in the history
Prepare extension and CI for release candidate
  • Loading branch information
krassowski authored Sep 17, 2023
2 parents 86df891 + 382cad3 commit 3fb68db
Show file tree
Hide file tree
Showing 50 changed files with 1,316 additions and 694 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/job.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ jobs:
matrix:
os: [ubuntu]
nodejs: ['>=16,<17.0.0a0']
lab: ['>=4.0.5,<5.0.0a0']
lab: ['>=4.0.6,<5.0.0a0']
r: ['>=4']
steps:
- uses: actions/checkout@v3
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
## Changelog

### `@jupyter-lsp/jupyterlab-lsp 5.0.0-rc.0`

- fixes diagnostics not showing up in text editor in certain circumstances
- fixes signature hover box not being clickable
- improves performance by not creating a temporary editor to setup linter underline style
- JSON overrides work again
- fixes issue with syntax highlighting breaking when pasting multiple cells

Requires JupyterLab `>=4.0.6,<5.0.0a0`

### `@jupyter-lsp/jupyterlab-lsp 5.0.0-beta.1`

- fix highlights conflict with selection
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Development requires, at a minimum:

- `nodejs >=16,!=17,<19`
- `python >=3.8,<3.11.0a0`
- `jupyterlab >=4.0.5,<5.0.0a0`
- `jupyterlab >=4.0.6,<5.0.0a0`

It is recommended to use a virtual environment (e.g. `virtualenv` or `conda env`)
for development.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ Use context menu on rows in the panel to filter out diagnostics or copy their me

You will need to have both of the following installed:

- JupyterLab >=4.0.5,<5.0.0a0
- JupyterLab >=4.0.6,<5.0.0a0
- Python 3.8+

In addition, if you wish to use javascript, html, markdown or any other NodeJS-based language server you will need to have appropriate NodeJS version installed.
Expand Down
37 changes: 16 additions & 21 deletions atest/01_Editor.robot
Original file line number Diff line number Diff line change
Expand Up @@ -9,56 +9,55 @@ Test Tags ui:editor aspect:ls:features

*** Test Cases ***
Bash
${def} = Set Variable xpath:(//div[contains(@class, 'cm-line')]//text()[contains(., 'HelloWorld')])[last()]
${def} = Set Variable lastToken:fib
Editor Shows Features for Language
... Bash
... example.sh
... Diagnostics=Double quote to prevent globbing and word splitting.
... Jump to Definition=${def}

CSS
${def} = Set Variable
... xpath:(//div[contains(@class, 'cm-line')]//text()[contains(., '--some-var')])[last()]
${def} = Set Variable lastToken:--some-var
Editor Shows Features for Language CSS example.css Diagnostics=Do not use empty rulesets
... Jump to Definition=${def} Rename=${def}

Docker
${def} = Set Variable xpath://div[contains(@class, 'cm-line')]//text()[contains(., 'PLANET')]
${def} = Set Variable lastToken:PLANET
Wait Until Keyword Succeeds 3x 100ms Editor Shows Features for Language Docker Dockerfile
... Diagnostics=Instructions should be written in uppercase letters Jump to Definition=${def}
... Rename=${def}

JS
${def} = Set Variable xpath:(//div[contains(@class, 'cm-line')]//text()[contains(., 'fib')])[last()]
${def} = Set Variable lastToken:fib
Editor Shows Features for Language JS example.js Diagnostics=Expression expected
... Jump to Definition=${def} Rename=${def}

JSON
Editor Shows Features for Language JSON example.json Diagnostics=Duplicate object key

JSX
${def} = Set Variable xpath:(//div[contains(@class, 'cm-line')]//text()[contains(., 'hello')])[last()]
${def} = Set Variable lastToken:hello
Editor Shows Features for Language JSX example.jsx Diagnostics=Expression expected
... Jump to Definition=${def} Rename=${def}
# Julia
# ${def} = Set Variable xpath:(//div[contains(@class, 'cm-line')]//text()[contains(., 'add_together')])[last()]
# ${def} = Set Variable lastToken:add_together
# Editor Shows Features for Language Julia example.jl Jump to Definition=${def} Rename=${def}

LaTeX
[Tags] language:latex
${def} = Set Variable xpath:(//div[contains(@class, 'cm-line')]//span[contains(text(), 'foo')])[last()]
${def} = Set Variable lastToken:foo
Editor Shows Features for Language LaTeX example.tex Jump to Definition=${def} Rename=${def}

Less
${def} = Set Variable xpath:(//div[contains(@class, 'cm-line')]//text()[contains(., '@width')])[last()]
${def} = Set Variable lastToken:@width
Editor Shows Features for Language Less example.less Diagnostics=Do not use empty rulesets
... Jump to Definition=${def}

Markdown
Editor Shows Features for Language Markdown example.md Diagnostics=`Color` is misspelt

Python (pylsp)
${def} = Set Variable xpath:(//div[contains(@class, 'cm-line')]//text()[contains(., 'fib')])[last()]
${def} = Set Variable lastToken:fib
Editor Shows Features for Server
... pylsp
... Python
Expand All @@ -68,35 +67,33 @@ Python (pylsp)
... Rename=${def}

Python (pyright)
${def} = Set Variable xpath:(//div[contains(@class, 'cm-line')]//text()[contains(., 'fib')])[last()]
${def} = Set Variable lastToken:fib
Editor Shows Features for Server pyright Python example.py Diagnostics=is not defined (Pyright)
... Jump to Definition=${def}

R
${def} = Set Variable xpath:(//div[contains(@class, 'cm-line')]//text()[contains(., 'fib')])[last()]
${def} = Set Variable lastToken:fib
Editor Shows Features for Language R example.R Diagnostics=Put spaces around all infix operators
... Jump to Definition=${def}

Robot Framework
[Tags] gh:332
${def} = Set Variable
... xpath:(//div[contains(@class, 'cm-line')]//text()[contains(., 'Special Log')])[last()]
${def} = Set Variable lastToken:Special Log
Editor Shows Features for Language Robot Framework example.robot Diagnostics=Undefined keyword
... Jump to Definition=${def}

SCSS
${def} = Set Variable
... xpath:(//div[contains(@class, 'cm-line')]//text()[contains(., 'primary-color')])[last()]
${def} = Set Variable lastToken:primary-color
Editor Shows Features for Language SCSS example.scss Diagnostics=Do not use empty rulesets
... Jump to Definition=${def}

TSX
${def} = Set Variable xpath:(//div[contains(@class, 'cm-line')]//text()[contains(., 'HelloWorld')])[last()]
${def} = Set Variable lastToken:HelloWorld
Editor Shows Features for Language TSX example.tsx
... Diagnostics='hello' is declared but its value is never read. Jump to Definition=${def} Rename=${def}

TypeScript
${def} = Set Variable xpath:(//div[contains(@class, 'cm-line')]//text()[contains(., 'inc')])[last()]
${def} = Set Variable lastToken:inc
Editor Shows Features for Language TypeScript example.ts Diagnostics=The left-hand side of an arithmetic
... Jump to Definition=${def} Rename=${def}

Expand Down Expand Up @@ -155,9 +152,7 @@ Editor Content Changed
Editor Should Rename
[Arguments] ${symbol}
Set Tags feature:rename
${sel} = Set Variable If "${symbol}".startswith(("xpath", "css")) ${symbol}
... xpath:(//span[@role="presentation"][contains(., "${symbol}")])[last()]
Open Context Menu Over ${sel}
Open Context Menu Over Token ${symbol}
${old_content} = Get Editor Content
Capture Page Screenshot 03-rename-0.png
Mouse Over ${MENU RENAME}
Expand Down
30 changes: 19 additions & 11 deletions atest/04_Interface/DiagnosticsPanel.robot
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ ${DIAGNOSTIC MESSAGE} trailing whitespace
${DIAGNOSTIC} W291 trailing whitespace (pycodestyle)
${EXPECTED_COUNT} 4
${MENU COLUMNS} xpath://div[contains(@class, 'lm-Menu-itemLabel')][contains(text(), "columns")]
${R CELL} %%R\n{}


*** Test Cases ***
Expand Down Expand Up @@ -79,9 +78,8 @@ Diagnostics Can Be Ignored By Code
Open Context Menu Over W291
Expand Menu Entry Ignore diagnostics
Select Menu Entry code
Open in Advanced Settings ${DIAGNOSTICS PLUGIN ID}
Capture Page Screenshot 02-code-pressed.png
Wait Until Keyword Succeeds 10 x 1s Should Have Expected Rows Count ${EXPECTED_AFTER}
Configure JupyterLab Plugin {} plugin id=${DIAGNOSTICS PLUGIN ID}

Diagnostics Can Be Ignored By Message
Wait Until Keyword Succeeds 10 x 1s Should Have Expected Rows Count ${EXPECTED_COUNT}
Expand All @@ -91,38 +89,48 @@ Diagnostics Can Be Ignored By Message
Expand Menu Entry Ignore diagnostics
Capture Page Screenshot 02-menu-visible.png
Select Menu Entry Ignore diagnostics with "W291 trailing whitespace" message
Open in Advanced Settings ${DIAGNOSTICS PLUGIN ID}
Capture Page Screenshot 02-message-pressed.png
Wait Until Keyword Succeeds 10 x 1s Should Have Expected Rows Count ${EXPECTED_AFTER}
Configure JupyterLab Plugin {} plugin id=${DIAGNOSTICS PLUGIN ID}

Diagnostic Message Can Be Copied
Wait Until Keyword Succeeds 10 x 1s Element Should Contain ${DIAGNOSTICS PANEL}
... ${DIAGNOSTIC MESSAGE}
Open Context Menu Over css:.lsp-diagnostics-listing tbody tr
Select Menu Entry Copy diagnostic
Close Diagnostics Panel
Wait Until Element Contains css:.lsp-statusbar-item Successfully copied timeout=10s
Wait Until Element Contains css:.jp-toast-message Successfully copied timeout=10s

Diagnostics Panel Works After Removing Foreign Document
Enter Cell Editor 2
Lab Command Insert Cell Below
Enter Cell Editor 3
Press Keys None ${R CELL}
Press Keys None %%R\n
# these two steps ideally would not be needed (they show that for slow-starting server
# update may not be triggered until user manually makes another action).
Wait Until Fully Initialized
Press Keys None {}
Wait Until Keyword Succeeds 10 x 1s Element Should Contain ${DIAGNOSTICS PANEL}
... ${DIAGNOSTIC MESSAGE}
Wait Until Keyword Succeeds 10 x 1s Element Should Contain ${DIAGNOSTICS PANEL}
... ${DIAGNOSTIC MESSAGE R}
Lab Command Delete Cells
Lab Command Delete Cell
# regain focus by entering cell
Enter Cell Editor 2
# trigger 7 document updates to trigger the garbage collector that removes unused documents
# (search for VirtualDocument.remainining_lifetime for more)
# (search for VirtualDocument.remainingLifetime for more)
Press Keys None 1234567
Wait Until Keyword Succeeds 10 x 1s Element Should Contain ${DIAGNOSTICS PANEL}
... ${DIAGNOSTIC MESSAGE}
Wait Until Keyword Succeeds 10 x 1s Element Should Not Contain ${DIAGNOSTICS PANEL}
... ${DIAGNOSTIC MESSAGE R}

# it should be possible to get the diagnostic back after re-creatign the cell
Lab Command Insert Cell Below
Enter Cell Editor 3
Press Keys None %%R\n{}
Wait Until Keyword Succeeds 10 x 1s Element Should Contain ${DIAGNOSTICS PANEL}
... ${DIAGNOSTIC MESSAGE}
Wait Until Keyword Succeeds 10 x 1s Element Should Contain ${DIAGNOSTICS PANEL}
... ${DIAGNOSTIC MESSAGE R}

*** Keywords ***
Open Context Menu Over W291
Expand All @@ -134,7 +142,7 @@ Open Context Menu Over W291
Open Notebook And Panel
[Arguments] ${notebook}
Setup Notebook Python ${notebook}
Capture Page Screenshot 00-notebook-and-panel-openeing.png
Capture Page Screenshot 00-notebook-and-panel-opening.png
Wait Until Page Contains Diagnostic [title*="${DIAGNOSTIC}"] timeout=20s
Open Diagnostics Panel
Capture Page Screenshot 00-notebook-and-panel-opened.png
Expand Down
8 changes: 5 additions & 3 deletions atest/05_Features/Completion.robot
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Invalidates On Focus Loss
Completer Should Not Suggest test
Enter Cell Editor 1 line=2

Uses LSP Completions When Kernel Resoponse Times Out
Uses LSP Completions When Kernel Response Times Out
[Tags] requires:busy-indicator
Configure JupyterLab Plugin {"kernelResponseTimeout": 1, "waitForBusyKernel": true}
... plugin id=${COMPLETION PLUGIN ID}
Expand Down Expand Up @@ -150,7 +150,7 @@ Continuous Hinting Works
[Setup] Prepare File for Editing Python completion completion.py
Configure JupyterLab Plugin {"continuousHinting": true} plugin id=${COMPLETION PLUGIN ID}
# TODO: remove once we resolve https://github.com/jupyterlab/jupyterlab/issues/15022
Configure JupyterLab Plugin {"autoCompletion": true} plugin id=${MANAGER PLUGIN ID}
Configure JupyterLab Plugin {"autoCompletion": true, "providerTimeout": 2500} plugin id=${MANAGER PLUGIN ID}
Place Cursor In File Editor At 9 2
Wait For Ready State
Press Keys None d
Expand Down Expand Up @@ -373,6 +373,8 @@ Completes Paths In Strings
*** Keywords ***
Setup Completion Test
Setup Notebook Python Completion.ipynb
# TODO: this should be per-provider (upstream issue)
Configure JupyterLab Plugin {"providerTimeout": 2500} plugin id=${MANAGER PLUGIN ID}

Get Cell Editor Content
[Arguments] ${cell_nr}
Expand Down Expand Up @@ -470,4 +472,4 @@ Should Complete While Kernel Is Busy
Page Should Contain Element ${KERNEL_BUSY_INDICATOR}

Wait For Our Completer To Initialize
Wait Until Page Contains Element css:.body[data-lsp-completer-layout]
Wait Until Page Contains Element css:body[data-lsp-completer-layout]
42 changes: 14 additions & 28 deletions atest/05_Features/Hover.robot
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ ${HOVER_SIGNAL} css:.cm-lsp-hover-available
*** Test Cases ***
Hover Does Not Trigger Automatically
Enter Cell Editor 1
${sel} = Last Occurrence python_add
${sel} = Set Variable lastToken:python_add
Configure JupyterLab Plugin {"autoActivate": false}
... plugin id=${HOVER PLUGIN ID}
Trigger Automatically By Hover ${sel}
Expand All @@ -27,7 +27,7 @@ Hover Does Not Trigger Automatically

Hover Triggers Automatically
Enter Cell Editor 1
${sel} = Last Occurrence python_add
${sel} = Set Variable lastToken:python_add
Configure JupyterLab Plugin {"delay": 100, "autoActivate": true}
... plugin id=${HOVER PLUGIN ID}
Trigger Automatically By Hover ${sel}
Expand All @@ -48,7 +48,7 @@ Hover works in notebooks

Hover can be triggered via modifier key once cursor stopped moving
Enter Cell Editor 1
${element} = Last Occurrence python_add
${element} = Set Variable lastToken:python_add
Wait Until Keyword Succeeds 5x 0.1 s Trigger Via Modifier Key Press ${element}

Hover works in foreign code (javascript)
Expand All @@ -70,60 +70,46 @@ Update hover after character deletion
Enter Cell Editor 4
Trigger Tooltip atan2
Element Text Should Be ${HOVER_SIGNAL} atan2
Capture Page Screenshot 01-hover-before-delection.png
Capture Page Screenshot 01-hover-before-deletion.png
Element Should Contain ${HOVER_BOX} atan2(y: SupportsFloat, x: SupportsFloat, /)
Place Cursor In Cell Editor At 4 line=2 character=13
Press Keys None DELETE
Trigger Tooltip atan
Element Text Should Be ${HOVER_SIGNAL} atan
Capture Page Screenshot 02-hover-after-delection.png
Capture Page Screenshot 02-hover-after-deletion.png
Element Should Contain ${HOVER_BOX} atan(x: SupportsFloat, /)


*** Keywords ***
Last Occurrence
[Arguments] ${symbol}
${sel} = Set Variable If "${symbol}".startswith(("xpath", "css")) ${symbol}
... xpath:(//div[@class="cm-content"]//text()[contains(., "${symbol}")])[last()]
RETURN ${sel}

Trigger Automatically By Hover
[Arguments] ${sel}
# bring the cursor to the element
Wokraround Visibility Problem ${sel}
Mouse Over ${sel}
Mouse Over Token ${sel}
Wait Until Page Contains Element ${HOVER_SIGNAL} timeout=10s
Mouse Over And Wiggle ${sel} 5
Mouse Over Token And Wiggle ${sel} 5

Trigger Via Hover With Modifier
[Arguments] ${sel}
# bring the cursor to the element
Wokraround Visibility Problem ${sel}
Mouse Over ${sel}
# move it back and forth (wiggle) while hodling the ctrl modifier
Mouse Over With Control ${sel} x_wiggle=5
Mouse Over Token ${sel}
# move it back and forth (wiggle) while holding the ctrl modifier
Mouse Over Token With Control ${sel} x_wiggle=5
Wait Until Keyword Succeeds 4x 0.1s Page Should Contain Element ${HOVER_BOX}

Trigger Via Modifier Key Press
[Arguments] ${sel}
# bring the cursor to the element
Wokraround Visibility Problem ${sel}
Mouse Over ${sel}
Mouse Over Token ${sel}
Wait Until Page Contains Element ${HOVER_SIGNAL} timeout=10s
Mouse Over And Wiggle ${sel} 5
Press Keys ${sel} CTRL
Mouse Over Token And Wiggle ${sel} 5
Press Keys None CTRL
Wait Until Keyword Succeeds 4x 0.1s Page Should Contain Element ${HOVER_BOX}

Trigger Tooltip
[Documentation] The default way to trigger the hover tooltip
[Arguments] ${symbol}
${sel} = Last Occurrence ${symbol}
${sel} = Set Variable lastToken:${symbol}
Wait Until Keyword Succeeds 4x 0.1 s Trigger Via Hover With Modifier ${sel}

Setup Hover Test
Setup Notebook Python Hover.ipynb

Wokraround Visibility Problem
[Arguments] ${sel}
${width} ${height} = Get Element Size ${sel}
IF ${width} == 0 Cover Element ${sel}
3 changes: 1 addition & 2 deletions atest/05_Features/Jump.robot
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ Python Jumps Between Files
Copy Files to Folder With Spaces jump_a.py jump_b.py
Open ${FOLDER WITH SPACE}/jump_b.py in ${MENU EDITOR}
Wait Until Fully Initialized
${sel} = Select Token Occurrence a_function_definition
Jump To Definition ${sel}
Jump To Definition lastToken:a_function_definition
Wait Until Page Contains ANOTHER_CONSTANT
Capture Page Screenshot 10-jumped.png
[Teardown] Clean Up Folder With Spaces jump_a.py jump_b.py
Expand Down
Loading

0 comments on commit 3fb68db

Please sign in to comment.