protobuflab / protobuf-langserver

MIT License
0 stars 1 forks source link

Create a workspace manager #7

Closed NTaylorMullen closed 5 years ago

NTaylorMullen commented 5 years ago

This is the type that all workspace state changes will flow through. For simplicity it should ever be accessed from a single threaded thread. Dependent on https://github.com/protobuflab/protobuf-langserver/issues/6 This will enable us to work in LSP scenarios and not truly have to worry about race condition issues.

The basic structure looks like:

// This is triggered whenever the Workspace property changes. Since it's immutable this can happen whenever a document changes, is added, removed (not opened or closed). Will probably need to create the event args type
event EventHandler<WorkspaceSnapshotChangeEventArgsType> Changed;

// Document open state is not tracked at the DocumentSnapshot layer, opening or closing a document doesn't result in a new Workspace (it doesn't impact how a document parses)
bool IsDocumentOpen(string documentFilePath);

// Dependent on https://github.com/protobuflab/protobuf-langserver/issues/5
WorkspaceSnapshotType Workspace { get; }

// Below here are the methods that impact the above, if you feel inspired you can break this
// into a form such as DefaultWorkspaceManager -> WorkspaceManagerBase -> WorkspaceManager 
// where the above would be WorkspaceManager, the below would be WorkspaceManagerBase // and then the implementation you write would be DefaultWorkspaceManager

// SourceText and TextLoader are both Roslyn types.

void DocumentAdded(string documentFilePath, TextLoader textLoader);

void DocumentChanged(string documentFilePath, SourceText sourceText);

void DocumentRemoved(string documentFilePath);

void DocumentOpened(string documentFilePath, SourceText sourceText);

void DocumentClosed(string projectFilePath, string documentFilePath, TextLoader textLoader);
ryanbrandenburg commented 5 years ago

https://github.com/protobuflab/protobuf-langserver/commit/b9b78c2aed146f957bbf4ce3003c273dc8c5e2de