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

Implement missing API for vscode.typescript-language-features@1.62.3 #11083

Merged

Conversation

colin-grant-work
Copy link
Contributor

@colin-grant-work colin-grant-work commented Apr 27, 2022

What it does

Fixes #11129 by updating the MarkdownString implementation available to plugins.
Fixes #10819, fixes #10979, fixes #11036

This PR implements missing API required by recent versions of the TypeScript plugin. In particular:

This required a significant reworking of the StatusBar, and much of this is copied or adapted from VSCode.

  • Support for affinity between two items
  • Support for MarkdownStrings and HTML elements in hovers
  • Improvement in MarkdownString types and implementations
  • TextDocumentChangeReason

How to test

TS Plugin Activation, Language Server
  1. Download the TS plugin and TS language features plugin and replace the corresponding entries in your theia/plugins folder.
  2. Start the application with Theia as workspace and open a TypeScript file.
  3. Observe that you do not see any toasts about the plugin failing to activate.
  4. Use some new features, e.g. find an override modifier and ctrl+click to go to the super method. Observe that override is not treated as a syntax error.
Language Status Item (and HTML-element tooltips in StatusBar)
  1. With a TS file open, observe that you get a language status item ({}) next to the language indicator.
  2. Hover over that, and observe that two items are available.
  3. Clicking the links should execute the associated commands to select TS version or open the tsconfig file for the current editor.
  4. Clicking the pins should add / remove that command to / from the status bar as an independent item, and clicking that item should execute the command.
  5. The pinned items should appear and disappear according to the language of the current editor.
Markdown Rendering (MarkdownString in tooltips in StatusBar)
  1. Put markdown-renderer-test-0.0.1.zip in your plugins folder and start the application.
  2. Start the application.
  3. Run the command VSCode API: Show status item with Markdown tooltip
  4. A status item should appear on the left side with the text 'Check my tooltip'
  5. Hover over that item, and you should see
    image

The gear should spin, and if you have an editor open as the current widget, clicking the link should trigger the 'save-as' action for that editor.

Review checklist

Reminder for reviewers

@colin-grant-work colin-grant-work added typescript issues related to the typescript language vscode issues related to VSCode compatibility CQ Required (deprecated) issues requiring a CQ (contributor questionnaire) labels Apr 27, 2022
@planger
Copy link
Contributor

planger commented Apr 28, 2022

@colin-grant-work I saw that there's a playwright test that consistently fails with this PR.

[playwright]     > 43 |         expect(await notificationIndicator.isVisible()).toBe(true);
[playwright]          |                                                         ^
...
[playwright]   1 failed
[playwright]     ../../src/tests/theia-status-bar.test.ts:38:9 › Theia Status Bar › should contain status bar elements 
[playwright]   1 skipped
[playwright]   49 passed (2m)

Looks like the selector for the notification indicator doesn't work anymore.
Just wanted to offer to look into it, if you want. Feel free to skip this test and merge this PR, once it is ready, and create an issue for us to fix and re-enable the test.

@msujew
Copy link
Member

msujew commented Apr 28, 2022

I'll look into this once I'm back from vacation in mid May.

@msujew msujew self-requested a review April 28, 2022 09:44
@colin-grant-work
Copy link
Contributor Author

colin-grant-work commented Apr 28, 2022

@jfaltermeier, thanks for checking. I implemented a service that renders tooltips on status bar items as HTML elements rather than using the title property, but it looks like some of the Playwright machinery to determine whether a given status bar item is visible checks the title. At the moment, we don't put much other metadata on those elements, but we could for example add an id property that would make it easy to pick out one status bar item among the rest?

@planger
Copy link
Contributor

planger commented Apr 29, 2022

@colin-grant-work Thanks for the feedback!

I think we currently use either icons or titles as selectors for notifications or status bar items in general. Originally, because there wasn't other metadata and it's the closest to what the user would use to identify a status bar item.

But id or data-attributes would be fine too and it would be very low effort to change that in the page objects.
If you could add those additional attributes, that'd be great. Otherwise I'm happy to add them too, when I fix up the page objects. As you prefer.

Thanks!

@vince-fugnitto
Copy link
Member

The CQ opened for this pull-request has been approved 👍

Copy link
Member

@msujew msujew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Works as expected and the vscode API is correctly supported as far as I can tell.

I have a few minor issues and a suggestion regarding the hover API that you introduced.

@colin-grant-work
Copy link
Contributor Author

@planger, I have added an id to status bar elements and reworked the corresponding page objects. I ended up modifying them rather a lot because finding things by id is much easier than by icon or by title, but it may be desirable to retain some of the old icon-related functionality. Let me know what you think.

@planger
Copy link
Contributor

planger commented May 17, 2022

@planger, I have added an id to status bar elements and reworked the corresponding page objects. I ended up modifying them rather a lot because finding things by id is much easier than by icon or by title, but it may be desirable to retain some of the old icon-related functionality. Let me know what you think.

Very nice! Thank you!

You are certainly right, working with IDs makes the code much leaner. I think the use case for selecting by icons is rather uncommon for such rather static core elements, like status bar items. So I think only using the ID is completely fine for now.

Thanks again!

Copy link
Member

@vince-fugnitto vince-fugnitto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll continue with a functional review, I only have some minor comments.

examples/api-tests/src/preferences.spec.js Outdated Show resolved Hide resolved
examples/playwright/src/theia-notification-indicator.ts Outdated Show resolved Hide resolved
packages/callhierarchy/src/common/glob.ts Outdated Show resolved Hide resolved
packages/callhierarchy/src/common/paths.ts Outdated Show resolved Hide resolved
packages/core/src/browser/common-frontend-contribution.ts Outdated Show resolved Hide resolved
packages/core/src/browser/status-bar/status-bar.tsx Outdated Show resolved Hide resolved
}

.hover-language-status>.element>.left>.detail:not(:empty)::before {
/* endash */
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I might be wrong but isn't it spelled like so: ;)

Suggested change
/* endash */
/* en dash */

Copy link
Contributor Author

@colin-grant-work colin-grant-work May 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compromise on en-dash?

packages/editor/src/common/language-selector.ts Outdated Show resolved Hide resolved
Copy link
Member

@msujew msujew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, the changes look good to me!

  • The updated versions of the typescript extensions start as expected
  • Markdown rendered hovers behave as in vscode
  • Status bar elements continue to work as expected

Copy link
Member

@vince-fugnitto vince-fugnitto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The changes work well for me 👍

I confirmed that:

  • existing statusbar items contributed by the framework look and work as expected
  • the typescript-language-server builtin works without errors
    • the { } statusbar item looks good and works
    • the { } pin/unpin functionality works
    • the { } config file works
  • the contributed statusbar item works in markdown, icons are properly displayed

…feature/api-for-ts

Conflicts:
	packages/plugin-ext/src/common/plugin-api-rpc.ts
	packages/plugin-ext/src/main/browser/languages-main.ts
	packages/plugin-ext/src/plugin/languages.ts
	packages/plugin-ext/src/plugin/plugin-context.ts
	packages/plugin/src/theia.d.ts
@colin-grant-work colin-grant-work merged commit 70466bb into eclipse-theia:master May 18, 2022
@colin-grant-work colin-grant-work added this to the 1.26.0 milestone May 18, 2022
@colin-grant-work colin-grant-work deleted the feature/api-for-ts branch May 18, 2022 21:21
@msujew msujew mentioned this pull request Nov 15, 2022
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CQ Required (deprecated) issues requiring a CQ (contributor questionnaire) typescript issues related to the typescript language vscode issues related to VSCode compatibility
Projects
None yet
4 participants