-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor: Move onCodeLens to its own file
- Loading branch information
1 parent
ae7fc93
commit 2644a34
Showing
2 changed files
with
43 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/* -------------------------------------------------------------------------------------------- | ||
* Copyright (c) 2023 Savoir-faire Linux. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
* ------------------------------------------------------------------------------------------ */ | ||
|
||
import * as LSP from 'vscode-languageserver/node' | ||
import { analyzer } from '../tree-sitter/analyzer' | ||
|
||
export async function onCodeLensHandler (params: LSP.CodeLensParams, enableCodeLensReferencesOnFunctions: boolean): Promise<LSP.CodeLens[]> { | ||
const codeLenses: LSP.CodeLens[] = [] | ||
const uri = params.textDocument.uri | ||
|
||
if (!enableCodeLensReferencesOnFunctions) { | ||
return [] | ||
} | ||
|
||
const allSymbols = analyzer.getGlobalDeclarationSymbolsForUri(uri) | ||
allSymbols.forEach((symbol) => { | ||
if (symbol.kind === LSP.SymbolKind.Function) { | ||
const codeLens = LSP.CodeLens.create(symbol.location.range) | ||
|
||
codeLens.command = { | ||
title: 'Show References', | ||
command: 'bitbake.codeLens.showReferences', | ||
arguments: [uri, symbol.location.range.start] | ||
} | ||
|
||
codeLens.data = { uri, position: symbol.location.range.start } | ||
|
||
codeLenses.push(codeLens) | ||
} | ||
}) | ||
return codeLenses | ||
} | ||
|
||
export function onCodeLensResolveHandler (codeLens: LSP.CodeLens): LSP.CodeLens { | ||
return codeLens | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters