vscode-texinfo/src/contexts/document.ts

56 lines
1.6 KiB
TypeScript
Raw Normal View History

2020-10-24 21:45:32 +00:00
/**
2020-10-25 18:14:13 +00:00
* contexts/document.ts
2021-03-16 12:01:13 +00:00
*
* Copyright (C) 2020,2021 CismonX <admin@cismon.net>
*
* This file is part of vscode-texinfo.
*
* vscode-texinfo is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option)
* any later version.
*
* vscode-texinfo is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License along with
* vscode-texinfo. If not, see <https://www.gnu.org/licenses/>.
2020-10-24 21:45:32 +00:00
*/
import * as vscode from 'vscode';
2021-04-19 12:43:20 +00:00
import GlobalContext from '../global_context';
2020-10-24 21:45:32 +00:00
import DocumentSymbolContext from './document_symbol';
import FoldingRangeContext from './folding_range';
import PreviewContext from './preview';
2020-10-25 17:52:13 +00:00
/**
* Holds all contexts for a Texinfo document.
*/
2020-10-24 21:45:32 +00:00
export default class DocumentContext {
2021-04-19 12:43:20 +00:00
readonly foldingRange = new FoldingRangeContext(this);
2020-10-24 21:45:32 +00:00
readonly documentSymbol = new DocumentSymbolContext(this);
initPreview() {
2021-05-25 04:16:56 +00:00
return this._preview ??= new PreviewContext(this);
2020-10-24 21:45:32 +00:00
}
getPreview() {
2021-05-25 04:16:56 +00:00
return this._preview;
2020-10-24 21:45:32 +00:00
}
closePreview() {
2021-05-25 04:16:56 +00:00
this._preview = undefined;
2020-10-24 21:45:32 +00:00
}
constructor(
readonly globalContext: GlobalContext,
readonly document: vscode.TextDocument,
) {}
2021-04-19 12:43:20 +00:00
2021-05-25 04:16:56 +00:00
private _preview?: PreviewContext;
2020-10-24 21:45:32 +00:00
}