Skip to content

Commit f9f4f60

Browse files
committed
Wire cbuild complete to solution ,anager
1 parent 4b5b1b0 commit f9f4f60

2 files changed

Lines changed: 27 additions & 2 deletions

File tree

src/solutions/solution-manager.test.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -321,4 +321,22 @@ describe('SolutionManager', () => {
321321
}),
322322
);
323323
});
324+
325+
it('fires updatedCompileCommands when cbuild completes', async () => {
326+
const updatedCompileCommandsListener = jest.fn();
327+
solutionManager.onUpdatedCompileCommands(updatedCompileCommandsListener);
328+
329+
mockActiveSolutionTracker.activeSolution = testSolutionPath;
330+
changeActiveSolutionEmitter.fire();
331+
await waitTimeout(200);
332+
333+
// Reset mock to count only cbuild event
334+
updatedCompileCommandsListener.mockClear();
335+
336+
// Fire cbuild completion event
337+
const cbuildData = { success: true, severity: 'success' as const, toolsOutputMessages: [] };
338+
eventHub.fireCbuildCompleted(cbuildData);
339+
340+
expect(updatedCompileCommandsListener).toHaveBeenCalledTimes(1);
341+
});
324342
});

src/solutions/solution-manager.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { ActiveSolutionTracker } from './active-solution-tracker';
2121
import { CSolution } from './csolution';
2222
import { UPDATE_DEBUG_TASKS_COMMAND_ID } from '../debug/debug-launch-provider';
2323
import { Severity } from './constants';
24-
import { SolutionEventHub, ConvertResultData } from './solution-event-hub';
24+
import { SolutionEventHub, ConvertResultData, CbuildResultData } from './solution-event-hub';
2525
import { ExtensionApiProvider } from '../vscode-api/extension-api-provider';
2626
import { EnvironmentManagerApiV1 } from '@arm-software/vscode-environment-manager';
2727
import { ETextFileResult } from '../generic/text-file';
@@ -103,6 +103,7 @@ export class SolutionManagerImpl implements SolutionManager {
103103
this.activeSolutionTracker.onDidChangeActiveSolution(this.handleChangeActiveSolution, this),
104104
this.activeSolutionTracker.onActiveSolutionFilesChanged(this.handleActiveSolutionFilesChanged, this),
105105
this.eventHub.onDidConvertCompleted(this.handleSolutionConvertCompleted, this),
106+
this.eventHub.onDidCbuildCompleted(this.handleCbuildCompleted, this),
106107
this.commandsProvider.registerCommand(SolutionManagerImpl.refreshCommandId, this.refresh, this),
107108
this.environmentManagerApiProvider.onActivate(environmentManagerApi => {
108109
environmentManagerApi.onDidActivate(() => {
@@ -250,7 +251,13 @@ export class SolutionManagerImpl implements SolutionManager {
250251
await this.commandsProvider.executeCommandIfRegistered(UPDATE_DEBUG_TASKS_COMMAND_ID);
251252
}
252253
this.loadBuildFilesEmitter.fire([data.severity, data.detection]);
253-
this.updatedCompileCommandsEmitter.fire();
254+
}
255+
256+
private handleCbuildCompleted(_data: CbuildResultData): void {
257+
if (this.csolution) {
258+
// Cbuild setup completed: signal compile-commands update for ClangdManager
259+
this.updatedCompileCommandsEmitter.fire();
260+
}
254261
}
255262

256263
public async loadSolutionBuildFiles() {

0 commit comments

Comments
 (0)