Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 3dbfd72

Browse filesBrowse files
author
Akos Kitta
committed
Notify running LS about build complete.
Ref: arduino/arduino-ide#714 Signed-off-by: Akos Kitta <a.kitta@arduino.cc>
1 parent 8cd0916 commit 3dbfd72
Copy full SHA for 3dbfd72

File tree

3 files changed

+35
-8
lines changed
Filter options

3 files changed

+35
-8
lines changed

‎package.json

Copy file name to clipboardExpand all lines: package.json
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,11 @@
122122
"title": "Restart Language Server",
123123
"category": "Arduino"
124124
},
125+
{
126+
"command": "arduino.languageserver.notifyBuildDidComplete",
127+
"title": "Notify Build Did Complete",
128+
"category": "Arduino"
129+
},
125130
{
126131
"command": "arduino.debug.start",
127132
"title": "Start Debug",

‎src/extension.ts

Copy file name to clipboardExpand all lines: src/extension.ts
+22-8Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import deepmerge from 'deepmerge';
77
import { Mutex } from 'async-mutex';
88
import vscode, { ExtensionContext } from 'vscode';
99
import { LanguageClient, CloseAction, ErrorAction, InitializeError, Message, RevealOutputChannelOn } from 'vscode-languageclient';
10+
import { DidCompleteBuildNotification, DidCompleteBuildParams } from './protocol';
1011

1112
interface LanguageServerConfig {
1213
readonly lsPath: string;
@@ -72,10 +73,10 @@ export function activate(context: ExtensionContext) {
7273
const started = await startLanguageServer(context, config);
7374
languageServerIsRunning = started;
7475
return languageServerIsRunning ? config.board.fqbn : undefined;
75-
} catch (e) {
76-
console.log(e);
76+
} catch (err) {
77+
console.error('Failed to start the language server.', err);
7778
languageServerIsRunning = false;
78-
throw e;
79+
throw err;
7980
} finally {
8081
unlock();
8182
}
@@ -94,7 +95,14 @@ export function activate(context: ExtensionContext) {
9495
return vscode.commands.executeCommand('arduino.languageserver.start', latestConfig);
9596
}
9697
}),
97-
vscode.commands.registerCommand('arduino.debug.start', (config: DebugConfig) => startDebug(context, config))
98+
vscode.commands.registerCommand('arduino.debug.start', (config: DebugConfig) => startDebug(context, config)),
99+
vscode.commands.registerCommand('arduino.languageserver.notifyBuildDidComplete', (params: DidCompleteBuildParams) => {
100+
if (languageClient) {
101+
languageClient.sendNotification(DidCompleteBuildNotification.TYPE, params);
102+
} else {
103+
vscode.window.showWarningMessage('Language server is not running.');
104+
}
105+
})
98106
);
99107
}
100108

@@ -108,8 +116,7 @@ async function startDebug(_: ExtensionContext, config: DebugConfig): Promise<boo
108116
rawStdout = stdout.trim();
109117
rawStdErr = stderr.trim();
110118
} catch (err) {
111-
const message = err instanceof Error ? err.stack || err.message : 'Unknown error';
112-
vscode.window.showErrorMessage(message);
119+
showError(err);
113120
return false;
114121
}
115122
if (!rawStdout) {
@@ -125,7 +132,8 @@ async function startDebug(_: ExtensionContext, config: DebugConfig): Promise<boo
125132
try {
126133
info = JSON.parse(rawStdout);
127134
} catch (err) {
128-
vscode.window.showErrorMessage(err);
135+
console.error(`Could not parse JSON: <${rawStdout}>`);
136+
showError(err);
129137
}
130138
if (!info) {
131139
return false;
@@ -190,7 +198,7 @@ async function startLanguageServer(context: ExtensionContext, config: LanguageSe
190198

191199
async function buildLanguageClient(config: LanguageServerConfig): Promise<LanguageClient> {
192200
const { lsPath: command, clangdPath, cliDaemonAddr, cliDaemonInstance, board, flags, env, log } = config;
193-
const args = ['-clangd', clangdPath, '-cli-daemon-addr', cliDaemonAddr, '-cli-daemon-instance', cliDaemonInstance, '-fqbn', board.fqbn];
201+
const args = ['-clangd', clangdPath, '-cli-daemon-addr', cliDaemonAddr, '-cli-daemon-instance', cliDaemonInstance, '-fqbn', board.fqbn, '-skip-libraries-discovery-on-rebuild'];
194202
if (board.name) {
195203
args.push('-board-name', board.name);
196204
}
@@ -252,6 +260,12 @@ async function buildLanguageClient(config: LanguageServerConfig): Promise<Langua
252260
);
253261
}
254262

263+
function showError(err: unknown): void {
264+
console.error(err);
265+
const message = err instanceof Error ? err.message : typeof err === 'string' ? err : String(err);
266+
vscode.window.showErrorMessage(message);
267+
}
268+
255269
/**
256270
* Instead of writing the `launch.json` to the workspace, the file is written to the temporary binary output location.
257271
*/

‎src/protocol.ts

Copy file name to clipboard
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { NotificationType, DocumentUri } from 'vscode-languageclient';
2+
3+
export interface DidCompleteBuildParams {
4+
readonly buildOutputUri: DocumentUri;
5+
}
6+
export namespace DidCompleteBuildNotification {
7+
export const TYPE = new NotificationType<DidCompleteBuildParams, void>('ino/didCompleteBuild');
8+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.