本文整理汇总了TypeScript中vscode-languageserver.IConnection.onCodeLens方法的典型用法代码示例。如果您正苦于以下问题:TypeScript IConnection.onCodeLens方法的具体用法?TypeScript IConnection.onCodeLens怎么用?TypeScript IConnection.onCodeLens使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vscode-languageserver.IConnection
的用法示例。
在下文中一共展示了IConnection.onCodeLens方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: constructor
constructor(
protected connection: IConnection,
private converter: AnalyzerLSPConverter,
private featureFinder: FeatureFinder, private analyzer: LsAnalyzer,
settings: Settings) {
super();
this.connection.onDefinition(async(textPosition) => {
return this.handleErrors(
this.getDefinition(textPosition), undefined) as Promise<Definition>;
});
this.connection.onReferences(async(params) => {
return this.handleErrors(this.getReferences(params), []);
});
this.connection.onWorkspaceSymbol(async(params) => {
const analysis =
await this.analyzer.analyzePackage('get workspace symbols');
const symbols = this.findSymbols(analysis);
return fuzzaldrin.filter(symbols, params.query, {key: 'name'});
});
this.connection.onDocumentSymbol(async(params) => {
const localPath = converter.getWorkspacePathToFile(params.textDocument);
const analysis =
await this.analyzer.analyze([localPath], 'get document symbols');
const maybeDocument = analysis.getDocument(localPath);
if (!(maybeDocument instanceof Document)) {
return [];
}
return this.findSymbols(maybeDocument);
});
this.connection.onCodeLens(async(params) => {
const lenses = [];
if (settings.referencesCodeLens) {
lenses.push(...await this.handleErrors(this.getCodeLenses(params), []));
}
return lenses;
});
}
示例2: constructor
constructor(
protected connection: IConnection,
private converter: AnalyzerLSPConverter,
private featureFinder: FeatureFinder, private analyzer: LsAnalyzer,
settings: Settings) {
super();
this.connection.onDefinition(async(textPosition) => {
return this.handleErrors(this.getDefinition(textPosition), null);
});
this.connection.onReferences(async(params) => {
return this.handleErrors(this.getReferences(params), []);
});
this.connection.onWorkspaceSymbol(async(params) => {
const analysis =
await this.analyzer.analyzePackage({reason: 'get workspace symbols'});
const symbols = this.findSymbols(analysis);
return fuzzaldrin.filter(symbols, params.query, {key: 'name'});
});
this.connection.onDocumentSymbol(async(params) => {
const url = params.textDocument.uri;
const analysis =
await this.analyzer.analyze([url], {reason: 'get document symbols'});
const result = analysis.getDocument(url);
if (!result.successful) {
return [];
}
return this.findSymbols(result.value);
});
this.connection.onCodeLens(async(params) => {
const lenses = [];
if (settings.referencesCodeLens) {
lenses.push(...await this.handleErrors(this.getCodeLenses(params), []));
}
return lenses;
});
}