Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Freed-Wu committed Mar 18, 2024
1 parent d91361c commit 5eee06e
Show file tree
Hide file tree
Showing 44 changed files with 1,562 additions and 2,027 deletions.
Binary file added client/.yarn/install-state.gz
Binary file not shown.
2 changes: 2 additions & 0 deletions client/.yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
nodeLinker: node-modules
20 changes: 7 additions & 13 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,11 @@
"type": "git",
"url": "https://github.com/yoctoproject/vscode-bitbake.git"
},
"keywords": [
"coc.nvim"
],
"engines": {
"vscode": "^1.75.0"
"coc": "^0.0.82"
},
"categories": [
"Programming Languages"
Expand Down Expand Up @@ -762,55 +765,46 @@
"command": "bitbake.devtool-build",
"group": "0@devtool_build@0",
"when": "viewItem == devtoolWorskpaceCtx"

},
{
"command": "bitbake.devtool-clean",
"group": "0@devtool_build@1",
"when": "viewItem == devtoolWorskpaceCtx"

},
{
"command": "bitbake.devtool-deploy",
"group": "0@devtool_build@2",
"when": "viewItem == devtoolWorskpaceCtx"

},
{
"command": "bitbake.devtool-open-workspace",
"group": "1@devtool_dev@0",
"when": "viewItem == devtoolWorskpaceCtx"

},
{
"command": "bitbake.devtool-ide-sdk",
"group": "1@devtool_dev@1",
"when": "viewItem == devtoolWorskpaceCtx"

},
{
"command": "bitbake.devtool-sdk-fallback",
"group": "1@devtool_dev@2",
"when": "viewItem == devtoolWorskpaceCtx"

},
{
"command": "bitbake.terminal-profile",
"group": "1@devtool_dev@3",
"when": "viewItem == devtoolWorskpaceCtx"

},
{
"command": "bitbake.devtool-update",
"group": "1@devtool_finalize@0",
"when": "viewItem == devtoolWorskpaceCtx"

},
{
"command": "bitbake.devtool-reset",
"group": "1@devtool_finalize@1",
"when": "viewItem == devtoolWorskpaceCtx"

}
]
},
Expand All @@ -832,13 +826,13 @@
},
"dependencies": {
"find": "^0.2.7",
"node-pty": "^1.0.0",
"vscode-languageclient": "^8.1.0"
"node-pty": "^1.0.0"
},
"devDependencies": {
"@types/find": "^0.2.2",
"@types/node": "^20.6.2",
"@types/vscode": "^1.75.1"
"coc.nvim": "^0.0.83-next.18",
"typescript": "^5.3.3"
},
"workspaces": [
"src/lib"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */

import * as vscode from 'vscode'
import * as vscode from 'coc.nvim'
import { BitbakeWorkspace } from '../../../ui/BitbakeWorkspace'
import { BitBakeProjectScanner } from '../../../driver/BitBakeProjectScanner'
import { BitbakeDriver } from '../../../driver/BitbakeDriver'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */

import * as vscode from 'vscode'
import * as vscode from 'coc.nvim'
import { type BitbakeRecipeTreeItem, BitbakeRecipesView } from '../../../ui/BitbakeRecipesView'
import { BitbakeWorkspace } from '../../../ui/BitbakeWorkspace'
import { BitBakeProjectScanner } from '../../../driver/BitBakeProjectScanner'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */

import * as vscode from 'vscode'
import * as vscode from 'coc.nvim'
import { BitbakeTerminalLinkProvider } from '../../../ui/BitbakeTerminalLinkProvider'
import { type BitBakeProjectScanner } from '../../../driver/BitBakeProjectScanner'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */

import * as vscode from 'vscode'
import * as vscode from 'coc.nvim'
import { type DevtoolWorkspaceTreeItem, DevtoolWorkspacesView } from '../../../ui/DevtoolWorkspacesView'
import { BitBakeProjectScanner } from '../../../driver/BitBakeProjectScanner'
import { type BitbakeScanResult } from '../../../lib/src/types/BitbakeScanResult'
Expand Down
2 changes: 1 addition & 1 deletion client/src/__tests__/utils/vscodeMock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */

import * as vscode from 'vscode'
import * as vscode from 'coc.nvim'

// This sets up a mock that will simulate the firing of vscode events
// The events are fired automatically when the event is created
Expand Down
10 changes: 5 additions & 5 deletions client/src/documentLinkProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */

import vscode from 'vscode'
import { type LanguageClient } from 'vscode-languageclient/node'
import vscode from 'coc.nvim'
import { type LanguageClient, Uri } from 'coc.nvim'
import { RequestMethod, type RequestResult } from './lib/src/types/requests'
import { logger } from './lib/src/utils/OutputLogger'
import path from 'path'
Expand Down Expand Up @@ -77,7 +77,7 @@ export class BitbakeDocumentLinkProvider implements vscode.DocumentLinkProvider
// Handle files: provide a direct link to the file
const fileUri = foundFiles.find(file => this.basenameIsEqual(file.fsPath, link.value))
if (fileUri !== undefined) {
documentLinks.push({ ...new vscode.DocumentLink(link.range, fileUri), tooltip: 'Bitbake: Go to file' })
documentLinks.push({ ...vscode.DocumentLink.create(link.range, fileUri.toString()), tooltip: 'Bitbake: Go to file' })
continue
}

Expand All @@ -90,7 +90,7 @@ export class BitbakeDocumentLinkProvider implements vscode.DocumentLinkProvider
*/
const targetUri = vscode.Uri.parse(`command:revealInExplorer?${encodeURIComponent(JSON.stringify(vscode.Uri.parse(foundDir)))}`)
// targetUri = vscode.Uri.parse('file://' + foundDir)
documentLinks.push({ ...new vscode.DocumentLink(link.range, targetUri), tooltip: 'Bitbake: Reveal in explorer' })
documentLinks.push({ ...vscode.DocumentLink.create(link.range, targetUri.toString()), tooltip: 'Bitbake: Reveal in explorer' })
}
}

Expand All @@ -99,6 +99,6 @@ export class BitbakeDocumentLinkProvider implements vscode.DocumentLinkProvider

async provideDocumentLinks (document: vscode.TextDocument, token: vscode.CancellationToken): Promise<vscode.DocumentLink[]> {
const linksData = await this.client.sendRequest<RequestResult['getLinksInDocument']>(RequestMethod.getLinksInDocument, { documentUri: document.uri.toString() })
return await this.resolveUris(document.uri, linksData, token)
return await this.resolveUris(Uri.parse(document.uri), linksData, token)
}
}
34 changes: 18 additions & 16 deletions client/src/driver/BitBakeProjectScanner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import find from 'find'
import path from 'path'
import EventEmitter from 'events'
import * as vscode from 'vscode'
import * as vscode from 'coc.nvim'

import { logger } from '../lib/src/utils/OutputLogger'

Expand All @@ -19,11 +19,11 @@ import type {
} from '../lib/src/types/BitbakeScanResult'

import { type BitbakeDriver } from './BitbakeDriver'
import { type LanguageClient } from 'vscode-languageclient/node'
import { type LanguageClient } from 'coc.nvim'
import fs from 'fs'
import { runBitbakeTerminalCustomCommand } from '../ui/BitbakeTerminal'
// import { runBitbakeTerminalCustomCommand } from '../ui/BitbakeTerminal'
import { bitbakeESDKMode } from './BitbakeESDK'
import { finishProcessExecution } from '../utils/ProcessUtils'
// import { finishProcessExecution } from '../utils/ProcessUtils'
import { extractRecipeName, extractRecipeVersion } from '../lib/src/utils/files'

interface ScannStatus {
Expand Down Expand Up @@ -245,12 +245,12 @@ export class BitBakeProjectScanner {
// Showing a modal here because this can only happend through the command devtool-update-recipe which is not used often
if (!quiet) {
await vscode.window.showErrorMessage(
'Bitbake extension couldn\'t locate a file.', {
'Bitbake extension couldn\'t locate a file.', /* {
modal: true,
detail: `It looks like you are using the bitbake.commandWrapper setting to use a docker container.\n
Couldn't find ${inputPath} corresponding paths inside and outside of the container.\n
You should adjust your docker volumes to use the same URIs as those present on your host machine.`
})
} */)
}
return resolvedPath
}
Expand All @@ -269,9 +269,10 @@ You should adjust your docker volumes to use the same URIs as those present on y
}

private async existsInContainer (containerPath: string): Promise<boolean> {
const process = runBitbakeTerminalCustomCommand(this._bitbakeDriver, 'test -e ' + containerPath, 'BitBake: Test file', true)
const res = finishProcessExecution(process, async () => { await this.bitbakeDriver.killBitbake() })
return (await res).status === 0
// const process = runBitbakeTerminalCustomCommand(this._bitbakeDriver, 'test -e ' + containerPath, 'BitBake: Test file', true)
// const res = finishProcessExecution(process, async () => { await this.bitbakeDriver.killBitbake() })
// return (await res).status === 0
return true;
}

private searchFiles (pattern: string): ElementInfo[] {
Expand Down Expand Up @@ -460,13 +461,14 @@ You should adjust your docker volumes to use the same URIs as those present on y
if (this._bitbakeDriver === undefined) {
throw new Error('Bitbake driver is not set')
}
const result = await finishProcessExecution(runBitbakeTerminalCustomCommand(this._bitbakeDriver, command, 'BitBake: Scan Project', true),
async () => { await this.bitbakeDriver.killBitbake() })
if (result.status !== 0) {
logger.error(`Failed to execute bitbake command: ${command}`)
throw new Error(`Failed to execute bitbake command: ${command}\r\n${result.stderr.toString()}`)
}
return result.output.toString()
// const result = await finishProcessExecution(runBitbakeTerminalCustomCommand(this._bitbakeDriver, command, 'BitBake: Scan Project', true),
// async () => { await this.bitbakeDriver.killBitbake() })
// if (result.status !== 0) {
// logger.error(`Failed to execute bitbake command: ${command}`)
// throw new Error(`Failed to execute bitbake command: ${command}\r\n${result.stderr.toString()}`)
// }
// return result.output.toString()
return "";
}
}

Expand Down
Loading

0 comments on commit 5eee06e

Please sign in to comment.