| 796 | } |
| 797 | |
| 798 | class DidCloseTextDocumentFeature extends DocumentNotifiactions<DidCloseTextDocumentParams, TextDocument> { |
| 799 | |
| 800 | constructor(client: BaseLanguageClient, private _syncedDocuments: Map<string, TextDocument>) { |
| 801 | super( |
| 802 | client, Workspace.onDidCloseTextDocument, DidCloseTextDocumentNotification.type, |
| 803 | client.clientOptions.middleware!.didClose, |
| 804 | (textDocument) => client.code2ProtocolConverter.asCloseTextDocumentParams(textDocument), |
| 805 | DocumentNotifiactions.textDocumentFilter |
| 806 | ); |
| 807 | } |
| 808 | |
| 809 | public get messages(): typeof DidCloseTextDocumentNotification.type { |
| 810 | return DidCloseTextDocumentNotification.type; |
| 811 | } |
| 812 | |
| 813 | public fillClientCapabilities(capabilities: ClientCapabilities): void { |
| 814 | ensure(ensure(capabilities, 'textDocument')!, 'synchronization')!.dynamicRegistration = true; |
| 815 | } |
| 816 | |
| 817 | public initialize(capabilities: ServerCapabilities, documentSelector: DocumentSelector): void { |
| 818 | let textDocumentSyncOptions = (capabilities as ResolvedTextDocumentSyncCapabilities).resolvedTextDocumentSync; |
| 819 | if (documentSelector && textDocumentSyncOptions && textDocumentSyncOptions.openClose) { |
| 820 | this.register(this.messages, { id: UUID.generateUuid(), registerOptions: { documentSelector: documentSelector } }); |
| 821 | } |
| 822 | } |
| 823 | |
| 824 | protected notificationSent(textDocument: TextDocument): void { |
| 825 | super.notificationSent(textDocument); |
| 826 | this._syncedDocuments.delete(textDocument.uri.toString()); |
| 827 | } |
| 828 | |
| 829 | public unregister(id: string): void { |
| 830 | let selector = this._selectors.get(id)!; |
| 831 | // The super call removed the selector from the map |
| 832 | // of selectors. |
| 833 | super.unregister(id); |
| 834 | let selectors = this._selectors.values(); |
| 835 | this._syncedDocuments.forEach((textDocument) => { |
| 836 | if (Languages.match(selector, textDocument) && !this._selectorFilter!(selectors, textDocument)) { |
| 837 | let middleware = this._client.clientOptions.middleware!; |
| 838 | let didClose = (textDocument: TextDocument) => { |
| 839 | this._client.sendNotification(this._type, this._createParams(textDocument)); |
| 840 | }; |
| 841 | this._syncedDocuments.delete(textDocument.uri.toString()); |
| 842 | if (middleware.didClose) { |
| 843 | middleware.didClose(textDocument, didClose); |
| 844 | } else { |
| 845 | didClose(textDocument); |
| 846 | } |
| 847 | } |
| 848 | }); |
| 849 | } |
| 850 | } |
| 851 | |
| 852 | interface DidChangeTextDocumentData { |
| 853 | documentSelector: DocumentSelector; |
nothing calls this directly
no outgoing calls
no test coverage detected