-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement codeLens #209
Draft
WilsonZiweiWang
wants to merge
4
commits into
yoctoproject:staging
Choose a base branch
from
savoirfairelinux:Feat-14622-code-lens
base: staging
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Implement codeLens #209
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
2d50f37
Refactor: Rename getGlobalDeclarationSymbols to getGlobalDeclarationS…
WilsonZiweiWang 00f0821
Feat: Add codeLens for bitbake function references
WilsonZiweiWang ae7fc93
Feat: Add a config to enable or disable codeLens on function references
WilsonZiweiWang 2805fa7
Refactor: Move onCodeLens to its own file
idillon-sfl File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
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
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
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
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
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not very familiar with CodeLens. So you're disabling it by default on purpose, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this surprised me also. However since currently we only have code lens for references, which have their dedicated button, I'm not sure the feature adds much value right now. Meanwhile it would bloat the interface.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This demo is cool however I think codelenses are justified when we have specific commands to run. There are few extensions doing so and the additional buttons could annoy users. A useful example for instance is the git extension which adds additional commands for comparing with other branches.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we would need different commands in order for this to be useful. I cannot think of one that isn't already seemlessly integrated into the interface yet (value hovers, rename, definitions, references...).