Feat: implement webview to the api docs as go to definition #496
Feat: implement webview to the api docs as go to definition #496uxkjaer wants to merge 17 commits intoSAP:masterfrom
Conversation
uxkjaer
commented
Sep 12, 2022

|
This pull request introduces 3 alerts when merging aaf056e into 9d0c89c - view on LGTM.com new alerts:
|
|
Hi @uxkjaer I am a bit conflicted about this feature: Pros:
Cons:
@petermuessig WDYT? I think I should also consult with the product person responsible for this. |
|
My take on it.
I know we aren't navigating source code, but we don't have any other useful use case for these options. We could simply add our own as well and a different short cut. My idea was that you were already used to the f12 shortcut to go and read a definition. |
|
Good points I will setup a meeting with you and the relevant product person 👍 |
|
Hi Jacob, But you are right, I didn't know the function of "more information". I think the use case of Jakob is a good one and can help nicely, even if I probably won't use it. |
|
just also wanted to bring up @wozjac's extension.
|
|
We could also consider just using a custom menu option and command instead, if that makes more sense? |
Perhaps:
I am generally in favor of this (or similar) feature, But it a major feature and I'd like to demonstrate it to the |
|
We have types for openui5 and Sapui5 so maybe navigate to those instead? Happy to just add this as another menu option instead. Mainly I'm just keen to get a possibility not to leave vscode when needing to search the api. Happy to discuss this with relevant people. |
|
I've changed the shortcut and context menu to UI5-Language-Assistant: View API Reference. The go to definition no longer shows the api reference. I've also added a setting with options to either show API reference inside vscode or in browser. |
|
This pull request introduces 1 alert when merging 37f9155 into 90807cd - view on LGTM.com new alerts:
|
|
closes #495 |
| logLevel?: LogLevel; | ||
| }; | ||
|
|
||
| export function getNodeName( |
There was a problem hiding this comment.
why does the language server exposes a logical utility function?
It generally runs in a different process and communicates via JSON_RPC
There was a problem hiding this comment.
Generally the language server should use logical utilities from other packages.
Maybe getNodeName should be extracted out of the language server sub-package.
| }; | ||
|
|
||
| export function getNodeName( | ||
| text: string, |
There was a problem hiding this comment.
with so many arguments, some of which are optional you should probably use a config object in this case.
| framework, | ||
| ui5Version | ||
| ); | ||
| return ui5Node |
There was a problem hiding this comment.
I think too much is done here in a single expression.
Can you split this up into multiple statements for readability?
| } | ||
| } | ||
|
|
||
| export async function getUI5NodeName( |
There was a problem hiding this comment.
I am not sure this function belongs in this sub-package
| cachePath?: string, | ||
| framework?: string, | ||
| ui5Version?: string | ||
| ): Promise<BaseUI5Node | undefined> { |
There was a problem hiding this comment.
with so many params and optional params a config object may be warranted
| } | ||
|
|
||
| async function fetchModel(cachePath, framework, ui5Version) { | ||
| const ui5Model = await getSemanticModel(cachePath, framework, ui5Version); |
There was a problem hiding this comment.
I do not recall:
Does every functional flow invoke getSemanticModel ?
Or does it happen once on language server startup?
Is this different or the same as other functional flows?
| ui5Version?: string | ||
| ): Promise<BaseUI5Node | undefined> { | ||
| const documentText = text; | ||
| const { cst, tokenVector } = parse(documentText); |
There was a problem hiding this comment.
Again I do not recall.
Does every flow functional flow re-parses the text each time?
Or is there a cache of documents / CST?
| import { track } from "./swa"; | ||
|
|
||
| export function getHoverResponse( | ||
| export async function getHoverResponse( |
There was a problem hiding this comment.
could changing this to async break anything?
| minUI5Version | ||
| ); | ||
| connection.sendNotification("UI5LanguageAssistant/ui5Model", { | ||
| cachePath: initializationOptions?.modelCachePath, |
There was a problem hiding this comment.
why does this feature require adding the cache path to the notifications?
Perhaps I am rusty in regards to this code base, but why was it not needed for other features, but needed here?
| @@ -8841,11 +8841,6 @@ tr46@^1.0.1: | |||
| dependencies: | |||
There was a problem hiding this comment.
why did the lock file change if no changes were made to the package.json?
| export type Settings = CodeAssistSettings & | ||
| TraceSettings & | ||
| LoggingSettings & | ||
| API_Reference; |
There was a problem hiding this comment.
The naming of API_Reference type does not seem consistent
with the existing pattern in this code base / file
| browser: true; | ||
| } | ||
|
|
||
| export const validViewApiReferenceValues: IValidApiReferenceValues; |
There was a problem hiding this comment.
remove view from the name to have consistent type and const names?
|
|
||
| ### Quick navigation to API Reference | ||
|
|
||
| Right click a tag in the XML file and use the View API reference shortcut to navigate directly to the API reference. Use the setting |
There was a problem hiding this comment.
Creating a demo GIF for this feature may be a good idea to "publicize" it.
| "UI5LanguageAssistant.view.API_Reference": "browser" | "editor" | ||
| ``` | ||
|
|
||
| The default setting is editor which opens the API reference in a new editor to the side. |
There was a problem hiding this comment.
clearer explanation needed.
editorsettings is described by the same word "editor"- "browser" flow is not described.
|
|
||
| ### Quick navigation to API Reference | ||
|
|
||
| Right click a tag in the XML file and use the View API reference shortcut to navigate directly to the API reference. Use the setting |
There was a problem hiding this comment.
View API reference --> View API Reference
| "contributes": { | ||
| "commands": [ | ||
| { | ||
| "command": "UI5LanguageAssistant.command.webView", |
There was a problem hiding this comment.
is webView the correct term for the command?
Or is this an implementation detail of one of the two possible implementation?
|
Does the ui5 logo belong in this PR? |
| }); | ||
| }); | ||
|
|
||
| function getXmlSnippet( |
There was a problem hiding this comment.
are these two utility test functions copy / pasted from another sub-package?
| "SAPUI5", | ||
| ui5Model.version | ||
| ); | ||
| if (result) expect(getNodeDetail(result)).to.equal("sap.m.Input"); |
There was a problem hiding this comment.
why is the test none deterministic ?
why is an if / else needed?
| document.getText(), | ||
| ui5SemanticModel | ||
| ); | ||
| if (result) { |
There was a problem hiding this comment.
why is the test none deterministic ?
why is an if / else needed?
| }); | ||
|
|
||
| it("get the UI5 node name without a model", async () => { | ||
| const xmlSnippet = `<mvc:View displayBlock="true" |
There was a problem hiding this comment.
these snippets normally need a "⇶" symbol to mark the cursor position.
Why is this not needed here?
| } | ||
| } | ||
|
|
||
| async function showWebView() { |
There was a problem hiding this comment.
this logic should be in a separate file.
The "extension.ts" responsibility is for initializing the language server.
new concerns should be in a separate file.
| } | ||
| } | ||
|
|
||
| function getWebviewContent(ui5Url: string) { |
| return undefined; | ||
| }); | ||
| } | ||
| const ui5Url = `${new URL(apiRefUrl).href}${name ? "#/api/" + name : ""}`; |
There was a problem hiding this comment.
should not there be re-use in build the API ref link?
This is also done in the "more details" in hover feature...
| } | ||
| } | ||
|
|
||
| async function showWebView() { |
There was a problem hiding this comment.
try to refactor this 70 lines function by extracting logical sub-parts
so the high level logical flow would be easily visible
|
I think we need to review this in a "pair programing" session. |
|
|
2 similar comments
|
|
|
|