Skip to content

Commit

Permalink
Fix: Hover for Python functions that are Yocto tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
idillon-sfl committed Nov 29, 2023
1 parent 25b9d43 commit 0a9f005
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
6 changes: 5 additions & 1 deletion client/src/language/middlewareHover.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,13 @@ import { getEmbeddedLanguageDocPosition } from './utils'
import { getFileContent } from '../lib/src/utils/files'

export const middlewareProvideHover: HoverMiddleware['provideHover'] = async (document, position, token, next) => {
const nextResult = await next(document, position, token)
if (nextResult !== undefined) {
return nextResult
}
const embeddedLanguageDocInfos = await requestsManager.getEmbeddedLanguageDocInfos(document.uri.toString(), position)
if (embeddedLanguageDocInfos === undefined || embeddedLanguageDocInfos === null) {
return await next(document, position, token)
return
}
const embeddedLanguageDocContent = await getFileContent(Uri.parse(embeddedLanguageDocInfos.uri).fsPath)
if (embeddedLanguageDocContent === undefined) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,9 @@ python do_foo(){
do_bar(){
echo '123'
}

python do_build() {
}

do_build() {
}
12 changes: 12 additions & 0 deletions integration-tests/src/tests/hover.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,16 @@ suite('Bitbake Hover Test Suite', () => {
const expected = 'echo'
await testHover(position, expected)
}).timeout(300000)

test('Hover shows task description on python function declaration', async () => {
const position = new vscode.Position(10, 9)
const expected = 'The default task for all recipes. This task depends on all other normal'
await testHover(position, expected)
}).timeout(300000)

test('Hover shows task description on bash function declaration', async () => {
const position = new vscode.Position(13, 1)
const expected = 'The default task for all recipes. This task depends on all other normal'
await testHover(position, expected)
}).timeout(300000)
})

0 comments on commit 0a9f005

Please sign in to comment.