Skip to content

Commit

Permalink
👽 Fix incompatible APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
Freed-Wu committed Apr 18, 2024
1 parent e07211b commit f7b9a67
Show file tree
Hide file tree
Showing 39 changed files with 697 additions and 2,118 deletions.
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 @@ -249,12 +249,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 @@ -273,9 +273,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 @@ -464,13 +465,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 f7b9a67

Please sign in to comment.