| 739 | } |
| 740 | |
| 741 | class DidOpenTextDocumentFeature extends DocumentNotifiactions<DidOpenTextDocumentParams, TextDocument> { |
| 742 | constructor(client: BaseLanguageClient, private _syncedDocuments: Map<string, TextDocument>) { |
| 743 | super( |
| 744 | client, Workspace.onDidOpenTextDocument, DidOpenTextDocumentNotification.type, |
| 745 | client.clientOptions.middleware!.didOpen, |
| 746 | (textDocument) => client.code2ProtocolConverter.asOpenTextDocumentParams(textDocument), |
| 747 | DocumentNotifiactions.textDocumentFilter |
| 748 | ); |
| 749 | } |
| 750 | |
| 751 | public get messages(): typeof DidOpenTextDocumentNotification.type { |
| 752 | return DidOpenTextDocumentNotification.type; |
| 753 | } |
| 754 | |
| 755 | public fillClientCapabilities(capabilities: ClientCapabilities): void { |
| 756 | ensure(ensure(capabilities, 'textDocument')!, 'synchronization')!.dynamicRegistration = true; |
| 757 | } |
| 758 | |
| 759 | public initialize(capabilities: ServerCapabilities, documentSelector: DocumentSelector): void { |
| 760 | let textDocumentSyncOptions = (capabilities as ResolvedTextDocumentSyncCapabilities).resolvedTextDocumentSync; |
| 761 | if (documentSelector && textDocumentSyncOptions && textDocumentSyncOptions.openClose) { |
| 762 | this.register(this.messages, { id: UUID.generateUuid(), registerOptions: { documentSelector: documentSelector } }); |
| 763 | } |
| 764 | } |
| 765 | |
| 766 | public register(message: RPCMessageType, data: RegistrationData<TextDocumentRegistrationOptions>): void { |
| 767 | super.register(message, data); |
| 768 | if (!data.registerOptions.documentSelector) { |
| 769 | return; |
| 770 | } |
| 771 | let documentSelector = data.registerOptions.documentSelector; |
| 772 | Workspace.textDocuments.forEach((textDocument) => { |
| 773 | let uri: string = textDocument.uri.toString(); |
| 774 | if (this._syncedDocuments.has(uri)) { |
| 775 | return; |
| 776 | } |
| 777 | if (Languages.match(documentSelector, textDocument)) { |
| 778 | let middleware = this._client.clientOptions.middleware!; |
| 779 | let didOpen = (textDocument: TextDocument) => { |
| 780 | this._client.sendNotification(this._type, this._createParams(textDocument)); |
| 781 | }; |
| 782 | if (middleware.didOpen) { |
| 783 | middleware.didOpen(textDocument, didOpen); |
| 784 | } else { |
| 785 | didOpen(textDocument); |
| 786 | } |
| 787 | this._syncedDocuments.set(uri, textDocument); |
| 788 | } |
| 789 | }); |
| 790 | } |
| 791 | |
| 792 | protected notificationSent(textDocument: TextDocument): void { |
| 793 | super.notificationSent(textDocument); |
| 794 | this._syncedDocuments.set(textDocument.uri.toString(), textDocument); |
| 795 | } |
| 796 | } |
| 797 | |
| 798 | class DidCloseTextDocumentFeature extends DocumentNotifiactions<DidCloseTextDocumentParams, TextDocument> { |
nothing calls this directly
no outgoing calls
no test coverage detected