forked from yoctoproject/vscode-bitbake
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Chore: Add notification on BitBake not found
- Notify the user that their BitBake location could not be found - Provide a button to fix the BitBake location in the settings
- Loading branch information
1 parent
b94417d
commit 82b8cac
Showing
5 changed files
with
91 additions
and
4 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,50 @@ | ||
import { type Memento, commands, window } from 'vscode' | ||
import { type LanguageClient, type Disposable } from 'vscode-languageclient/node' | ||
|
||
export class ClientNotificationManager { | ||
private readonly _client: LanguageClient | ||
private readonly _memento: Memento | ||
|
||
constructor (client: LanguageClient, memento: Memento) { | ||
this._client = client | ||
this._memento = memento | ||
} | ||
|
||
buildHandlers (): Disposable[] { | ||
const handlers = [ | ||
this.buildBitBakeNotFoundHandler() | ||
] | ||
|
||
return handlers | ||
} | ||
|
||
private buildBitBakeNotFoundHandler (): Disposable { | ||
const isNeverShowAgain = this.checkIsNeverShowAgain('custom/bitBakeNotFound') | ||
if (isNeverShowAgain) { | ||
return { dispose: () => {} } | ||
} | ||
return this._client.onNotification('custom/bitBakeNotFound', () => { | ||
void window.showErrorMessage( | ||
'BitBake folder could not be found. Please set its path in the settings. Optionally, also set an environment script.', | ||
'Open Settings', | ||
'Close', | ||
'Never Show Again' | ||
) | ||
.then((item) => { | ||
if (item === 'Open Settings') { | ||
void commands.executeCommand('workbench.action.openSettings', 'bitbake') | ||
} else if (item === 'Never Show Again') { | ||
void this.neverShowAgain('custom/bitBakeNotFound') | ||
} | ||
}) | ||
}) | ||
} | ||
|
||
private neverShowAgain (method: string): Thenable<void> { | ||
return this._memento.update(`neverShowAgain/${method}`, true) | ||
} | ||
|
||
private checkIsNeverShowAgain (method: string): boolean { | ||
return this._memento.get(`neverShowAgain/${method}`, false) | ||
} | ||
} |
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,20 @@ | ||
import { type Connection } from 'vscode-languageserver' | ||
|
||
export type NotificationType = | ||
'custom/bitBakeNotFound' | ||
|
||
export class ServerNotificationManager { | ||
private readonly _connection: Connection | ||
|
||
constructor (connection: Connection) { | ||
this._connection = connection | ||
} | ||
|
||
send (type: NotificationType, message?: string): void { | ||
void this._connection.sendNotification(type, message) | ||
} | ||
|
||
sendBitBakeNotFound (): void { | ||
this.send('custom/bitBakeNotFound') | ||
} | ||
} |