-
Couldn't load subscription status.
- Fork 44
overview documentation of the extension #857
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
Open
vezwork
wants to merge
6
commits into
main
Choose a base branch
from
documentation/passing-info
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1cd9e7d
WIP documentation of how VE communicates with HOST and LSP
vezwork c76d035
Move Quarto interface next to where it is init'd
vezwork d41f17e
Move command registrations in to `activate`
vezwork fc4c6b5
Make Providers in hooks uniform
vezwork 7385d0a
document `defaultExtensionHost` and move `createPreviewPanel`
vezwork c1c29a9
Add documentation to help with understanding and navigating
vezwork File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,167 @@ | ||
| ## Terminology | ||
|
|
||
| - Source Editor | ||
| - controlled by VSCode/Positron | ||
| - we add some functionality to the source editor by registering commands and | ||
| providing our LSP | ||
|
|
||
| - Visual Editor | ||
| - controlled by this repo! See CLIENT below. | ||
|
|
||
| - EXTENSION HOST | ||
| - a.k.a. HOST | ||
| - code lives in [./vscode](./vscode/) and various packages | ||
| - entry point in [main.ts](./vscode/src/main.ts), this is the entry point to | ||
| the entire extension. The `activate` function is called by VSCODE/Positron | ||
| to start the extension. | ||
| - CLIENT | ||
| - a.k.a. Visual Editor | ||
| - code lives in [./vscode-editor](./vscode-editor/) and various packages | ||
| - initialized in the HOST by `VisualEditorProvider` in | ||
| [editor.ts](./vscode/src/providers/editor/editor.ts) | ||
| - more specifically, the actual html with css and scripts for the Visual | ||
| Editor is created in `getHtmlForWebview` | ||
| - this is loaded into a webview, a separate process from the HOST, | ||
| containing the Visual Editor | ||
| - there may be multiple CLIENTs running at the same time (one for every file | ||
| open in the Visual Editor). There is code in here to manage and coordinate | ||
| from the HOST to multiple CLIENTs. | ||
| - entry point in `runEditor` in [index.tsx](./vscode-editor/src/index.tsx) | ||
| - LSP | ||
| - code lives in [./vscode](./vscode/src/lsp/) | ||
| - initialized in the HOST by `activateLSP` in | ||
| [client.ts](./vscode/src/lsp/client.ts) | ||
| - entry point in [index.ts](./lsp/src/index.ts) | ||
| - this runs in a separate process from the HOST | ||
|
|
||
| ## Handling User Input | ||
|
|
||
| - VSCODE/POSITRON --commands-> EXTENSION HOST | ||
| - see [package.json](./vscode/package.json) for declaration of commands | ||
| - see [main.ts](./vscode/src/main.ts) for registration of command | ||
|
|
||
| - Look for "behaviors" in ProseMirror, CodeMirror | ||
| - arrow keys, ctrl+z, mouse click, etc. | ||
|
|
||
| - [commands in Ace](packages/editor/src/optional/ace/ace.ts) | ||
| - used instead of CodeMirror for code cells in the Visual Editor in RStudio | ||
|
|
||
| ## Communication boundaries | ||
|
|
||
| - EXTENSION HOST <-req-> CLIENT | ||
| - Set up on the EXTENSION HOST side: | ||
| [connection.ts](./vscode/src/providers/editor/connection.ts) | ||
| `visualEditorServer` and `visualEditorClient` | ||
| - Set up on the CLIENT side: [sync.ts](./vscode-editor/src/sync.ts) | ||
| `visualEditorHostServer` and `visualEditorHostClient` | ||
| - Communication is sent by using `request: JsonRpcRequestTransport` e.g. | ||
| `request(kCodeViewGetDiagnostics, [context])` | ||
|
|
||
| - EXTENSION HOST --req-> LSP | ||
| - received by [custom.ts](./lsp/src/custom.ts) | ||
| - sent by `lspRequest: JsonRpcRequestTransport` | ||
| - EXTENSION HOST <-req-- LSP | ||
| - I don't think this happens? | ||
|
|
||
| - EXTENSION HOST / LSP --command-> VSCODE/POSITRON | ||
| - sent by `vscode.commands.executeCommand(..)` | ||
|
|
||
| - LSP <-provider-- VSCODE/POSITRON | ||
| - How does this work? | ||
|
|
||
| - LSP --req-> Quarto CLI | ||
| - [quarto.ts](./lsp/src/quarto.ts) defines the methods that the LSP uses to | ||
| call the Quarto CLI. | ||
|
|
||
| ## Logging | ||
|
|
||
| You can use `console.log`. When running an extension development host to test | ||
| out the extension there are a couple of places where your logs can end up: | ||
|
|
||
| - browser console or `window` output console for [[CLIENT]] and [[EXTENSION | ||
| HOST]] code | ||
| - logs from these two places will look different. Logs from [[CLIENT]] will | ||
| look like normal logs; logs from [[EXTENSION HOST]] will have a blue prefix | ||
| that says EXTENSION HOST. | ||
| - `Quarto` output console for [[LSP]] code | ||
|
|
||
| ## Examples of Controlling the Visual Editor from the server-side of the extension | ||
|
|
||
| ### Example: Setting cursor position | ||
|
|
||
| for example in [commands.ts](./vscode/src/providers/cell/commands.ts): | ||
|
|
||
| ```ts | ||
| const visualEditor = VisualEditorProvider.activeEditor(); | ||
| visualEditor.setBlockSelection(blockContext, "nextblock"); | ||
| ``` | ||
|
|
||
| which passes through `VisualEditorPovider`, `visualEditorClient`, | ||
| `visualEditorHostServer`, `Editor`. See the "Communication Boundaries" section. | ||
|
|
||
| ## Examples of Getting server-side info from the Visual Editor | ||
|
|
||
| ### Example: Getting diagnostics | ||
|
|
||
| For example in | ||
| [diagnostics.ts](../packages/editor-codemirror/src/behaviors/diagnostics.ts) | ||
|
|
||
| ```ts | ||
| const diagnostics = await getDiagnostics(cellContext, behaviorContext); | ||
| if (!diagnostics) return; | ||
|
|
||
| for (const error of diagnostics) { | ||
| underline( | ||
| cmView, | ||
| rowColumnToIndex(code, [error[kStartColumn], error[kStartRow]]), | ||
| rowColumnToIndex(code, [error[kEndColumn], error[kEndRow]]), | ||
| error.text, | ||
| ); | ||
| } | ||
| ``` | ||
|
|
||
| which passes through | ||
|
|
||
| - [[CLIENT]] [services.ts](../packages/editor-core/src/services.ts) function | ||
| `editorCodeViewJsonRpcServer` registers `codeViewDiagnostics` calls | ||
| `request(kCodeViewGetDiagnostics` | ||
| - request seems to communicate from the CLIENT to the EXTENSION HOST? | ||
| - [[EXTENSION HOST]] | ||
| [codeview.ts](../packages/editor-server/src/services/codeview.ts) function | ||
| `codeViewServerMethods` registers `kCodeViewGetDiagnostics` calls | ||
| `server.codeViewDiagnostics` | ||
| - [[EXTENSION HOST]] | ||
| [other codeview.ts](./vscode/src/providers/editor/codeview.ts) function | ||
| `vscodeCodeViewServer` return object with prop `codeViewDiagnostics` calls | ||
| `lspRequest(kCodeViewGetDiagnostics, [context])` | ||
| - [[LSP]] [custom.ts](./lsp/src/custom.ts) `codeViewDiagnostics` | ||
| `getYamlDiagnostics` | ||
| - `initializeQuartoYamlModule` | ||
|
|
||
| #### Examples providing information to the Source Editor | ||
|
|
||
| ### Example: Completions | ||
|
|
||
| - [vdoc-completion.ts](./vscode/src/vdoc/vdoc-completion.ts) | ||
|
|
||
| ```ts | ||
| await withVirtualDocUri(vdoc, parentUri, "completion", async (uri: Uri) => { | ||
| return await commands.executeCommand<CompletionList>( | ||
| "vscode.executeCompletionItemProvider" | ||
| ... | ||
| ``` | ||
|
|
||
| In the Visual Editor, completions are obtained via | ||
| [codeview.ts](./vscode/src/providers/editor/codeview.ts) | ||
|
|
||
| In the Source Editor, completions are obtained `embeddedCodeCompletionProvider` | ||
| in [client.ts](./vscode/src/lsp/client.ts) | ||
|
|
||
| ### Example: Positron Specific - Help Topic & Statement Range | ||
|
|
||
| `EmbeddedStatementRangeProvider` or `EmbeddedHelpTopicProvider` in | ||
| [hooks.ts](./vscode/src/host/hooks.ts) | ||
|
|
||
| - simply executes the command "vscode.executeStatementRangeProvider" or | ||
| "positron.executeHelpTopicProvider" respectively inside a virtual doc for a | ||
| cell |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This set of changes in this file breaks the statement range provider in source mode. We need to use the code as it was before the change, to propagate the statement range through the virtual doc. We can't call
vscode.executeStatementRangeProvideron the.qmdbut instead must call it on the vdoc.