2020-11-11 12:29:30 +00:00
|
|
|
/**
|
|
|
|
* providers/code_lens.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-11-11 12:29:30 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
import * as vscode from 'vscode';
|
2021-04-19 12:43:20 +00:00
|
|
|
import GlobalContext from '../global_context';
|
2020-11-11 12:29:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Provide code lenses for Texinfo document.
|
|
|
|
*/
|
2021-08-11 17:23:04 +00:00
|
|
|
export default class CodeLensProvider implements vscode.CodeLensProvider
|
|
|
|
{
|
2020-11-11 12:29:30 +00:00
|
|
|
provideCodeLenses(document: vscode.TextDocument) {
|
2021-08-11 17:23:04 +00:00
|
|
|
if (!this._globalContext.options.enableCodeLens) {
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
if (!this._globalContext.indicator.canDisplayPreview) {
|
|
|
|
return undefined;
|
|
|
|
}
|
|
|
|
return this._globalContext.contextMapping
|
|
|
|
.getDocumentContext(document).foldingRange.nodeValues;
|
2020-11-11 12:29:30 +00:00
|
|
|
}
|
2021-04-19 12:43:20 +00:00
|
|
|
|
2021-05-25 04:16:56 +00:00
|
|
|
constructor(private readonly _globalContext: GlobalContext) {}
|
2020-11-11 12:29:30 +00:00
|
|
|
}
|