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

Load a document #14

Open
6 tasks
retailcoder opened this issue Feb 12, 2023 · 0 comments
Open
6 tasks

Load a document #14

retailcoder opened this issue Feb 12, 2023 · 0 comments
Labels
component: Rubberduck.Client Issue involves RPC client/platform component: Rubberduck.Core Issue involves the Core library feature: editor shell Issues that relate to the editor shell feature: workspace explorer Issues that relate to the workspace explorer / sync panel skill:xaml Issues that involve XAML markup and WPF

Comments

@retailcoder
Copy link
Member

retailcoder commented Feb 12, 2023

The document open notification is sent from the client to the server to signal newly opened text documents. The document’s content is now managed by the client and the server must not try to read the document’s content using the document’s Uri. Open in this sense means it is managed by the client. It doesn’t necessarily mean that its content is presented in an editor. An open notification must not be sent more than once without a corresponding close notification send before. This means open and close notification must be balanced and the max open count for a particular textDocument is one. Note that a server’s ability to fulfill requests is independent of whether a text document is open or closed.

The server receives a TextDocumentItem with the notification:

interface TextDocumentItem {
	/**
	 * The text document's URI.
	 */
	uri: DocumentUri;

	/**
	 * The text document's language identifier.
	 */
	languageId: string;

	/**
	 * The version number of this document (it will increase after each
	 * change, including undo/redo).
	 */
	version: integer;

	/**
	 * The content of the opened text document.
	 */
	text: string;
}

So this is where the server receives the text of the document at a given version. The languageId should be vba, to avoid clashing with "VB.NET" vb. The uri points to a path relative to the workspace root.

The string contains the complete file contents, including headings and attributes that are hidden in the VBIDE, so that's what we want to parse, and we'll want to quickly get a parse tree for it, cache it with the document uri and version as a key... and then sit on it for now - eventually the LSP server is going to send various notifications to the client, and we'll want to launch a semantic pass over all the parse trees and declarations, so having a parse tree associated to a specific version of a document URI is a very good starting point.

This supposes something is holding this state in some (thread-safe) dictionary: we'll need to inject a service that's responsible for just that.

  • Have an abstraction that provides an API to map TextDocumentItem to a parse tree, and to retrieve a parse tree for a given document URI and version
  • Have an abstraction that provides a parse tree given the text content of a TextDocumentItem.
  • Implement a DidOpenHandler class
    • InheritOmniSharp.Extensions.LanguageServer.Protocol.Document.DidOpenTextDocumentHandlerBase; constructor-inject state service
    • Implement the Handle override; access the document from the request parameter (DidOpenTextDocumentParams).
    • Implement the CreateRegistrationOptions override (specify DocumentSelector filters)

Log successful execution of the handler at INFO level; exceptions can be caught, but must be rethrown to return an error result at the JSON-RPC level.

@retailcoder retailcoder added skill:xaml Issues that involve XAML markup and WPF feature: editor shell Issues that relate to the editor shell feature: workspace explorer Issues that relate to the workspace explorer / sync panel component: Rubberduck.Core Issue involves the Core library component: Rubberduck.Client Issue involves RPC client/platform labels Feb 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: Rubberduck.Client Issue involves RPC client/platform component: Rubberduck.Core Issue involves the Core library feature: editor shell Issues that relate to the editor shell feature: workspace explorer Issues that relate to the workspace explorer / sync panel skill:xaml Issues that involve XAML markup and WPF
Projects
None yet
Development

No branches or pull requests

1 participant