Skip to content

Commit ca0db90

Browse files
committed
Fix circular dependencies
Signed-off-by: paulober <[email protected]>
1 parent 0162825 commit ca0db90

35 files changed

+601
-789
lines changed

src/commands/clearGithubApiCache.mts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@ import { Command } from "./command.mjs";
22
import Logger from "../logger.mjs";
33
import GithubApiCache from "../utils/githubApiCache.mjs";
44
import { window } from "vscode";
5+
import { CLEAR_GITHUB_API_CACHE } from "./cmdIds.mjs";
56

67
export default class ClearGithubApiCacheCommand extends Command {
78
private _logger: Logger = new Logger("ClearGithubApiCacheCommand");
89

9-
public static readonly id = "clearGithubApiCache";
10-
1110
constructor() {
12-
super(ClearGithubApiCacheCommand.id);
11+
super(CLEAR_GITHUB_API_CACHE);
1312
}
1413

1514
async execute(): Promise<void> {

src/commands/cmdIds.mts

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
// Command IDs
2+
export const CLEAR_GITHUB_API_CACHE = "clearGithubApiCache";
3+
export const COMPILE_PROJECT = "compileProject";
4+
export const CONDITIONAL_DEBUGGING = "conditionalDebugging";
5+
export const CONFIGURE_CMAKE = "configureCmake";
6+
export const CLEAN_CMAKE = "cleanCmake";
7+
export const SWITCH_BUILD_TYPE = "switchBuildType";
8+
export const DEBUG_LAYOUT = "debugLayout";
9+
export const FLASH_PROJECT_SWD = "flashProject";
10+
export const GET_PYTHON_PATH = "getPythonPath";
11+
export const GET_ENV_PATH = "getEnvPath";
12+
export const GET_GDB_PATH = "getGDBPath";
13+
export const GET_COMPILER_PATH = "getCompilerPath";
14+
export const GET_CXX_COMPILER_PATH = "getCxxCompilerPath";
15+
export const GET_CHIP = "getChip";
16+
export const GET_CHIP_UPPERCASE = "getChipUppercase";
17+
export const GET_TARGET = "getTarget";
18+
export const GET_PICOTOOL_PATH = "getPicotoolPath";
19+
export const GET_OPENOCD_ROOT = "getOpenOCDRoot";
20+
export const GET_SVD_PATH = "getSVDPath";
21+
export const GET_WEST_PATH = "getWestPath";
22+
export const GET_ZEPHYR_WORKSPACE_PATH = "getZephyrWorkspacePath";
23+
24+
export const IMPORT_PROJECT = "importProject";
25+
26+
export const LAUNCH_TARGET_PATH = "launchTargetPath";
27+
export const LAUNCH_TARGET_PATH_RELEASE = "launchTargetPathRelease";
28+
export const SBOM_TARGET_PATH_DEBUG = "sbomTargetPathDebug";
29+
export const SBOM_TARGET_PATH_RELEASE = "sbomTargetPathRelease";
30+
31+
export const NEW_EXAMPLE_PROJECT = "newExampleProject";
32+
33+
export const NEW_PROJECT = "newProject";
34+
35+
export const OPEN_SDK_DOCUMENTATION = "openSdkDocumentation";
36+
37+
export const RUN_PROJECT = "runProject";
38+
39+
export const SWITCH_BOARD = "switchBoard";
40+
41+
export const SWITCH_SDK = "switchSDK";
42+
43+
export const UNINSTALL_PICO_SDK = "uninstallPicoSDK";
44+
45+
export const UPDATE_OPENOCD = "updateOpenOCD";

src/commands/compileProject.mts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@ import Logger from "../logger.mjs";
55
import Settings, { SettingsKey } from "../settings.mjs";
66
import State from "../state.mjs";
77
import { cmakeToolsForcePicoKit } from "../utils/cmakeToolsUtil.mjs";
8+
import { COMPILE_PROJECT } from "./cmdIds.mjs";
89

910
export default class CompileProjectCommand extends CommandWithResult<boolean> {
1011
private _logger: Logger = new Logger("CompileProjectCommand");
1112

12-
public static readonly id = "compileProject";
13-
1413
constructor() {
15-
super(CompileProjectCommand.id);
14+
super(COMPILE_PROJECT);
1615
}
1716

1817
async execute(): Promise<boolean> {

src/commands/conditionalDebugging.mts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Command, extensionName } from "./command.mjs";
22
import Logger from "../logger.mjs";
33
import { commands, window, workspace, debug } from "vscode";
44
import State from "../state.mjs";
5-
import DebugLayoutCommand from "./debugLayout.mjs";
5+
import { CONDITIONAL_DEBUGGING, DEBUG_LAYOUT } from "./cmdIds.mjs";
66

77
/**
88
* Relay command for the default buildin debug select and start command.
@@ -11,10 +11,8 @@ import DebugLayoutCommand from "./debugLayout.mjs";
1111
export default class ConditionalDebuggingCommand extends Command {
1212
private _logger: Logger = new Logger("ConditionalDebuggingCommand");
1313

14-
public static readonly id = "conditionalDebugging";
15-
1614
constructor() {
17-
super(ConditionalDebuggingCommand.id);
15+
super(CONDITIONAL_DEBUGGING);
1816
}
1917

2018
async execute(): Promise<void> {
@@ -29,7 +27,7 @@ export default class ConditionalDebuggingCommand extends Command {
2927
return;
3028
}
3129

32-
void commands.executeCommand(`${extensionName}.${DebugLayoutCommand.id}`);
30+
void commands.executeCommand(`${extensionName}.${DEBUG_LAYOUT}`);
3331
void debug.startDebugging(wsFolder, "Pico Debug (probe-rs)");
3432

3533
return;

src/commands/configureCmake.mts

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@ import { join } from "path";
77
import { rimraf } from "rimraf";
88
import { unknownErrorToString } from "../utils/errorHelper.mjs";
99
import type UI from "../ui.mjs";
10+
import { CLEAN_CMAKE, CONFIGURE_CMAKE, SWITCH_BUILD_TYPE } from "./cmdIds.mjs";
1011

1112
export default class ConfigureCmakeCommand extends Command {
1213
private _logger: Logger = new Logger("ConfigureCmakeCommand");
1314

14-
public static readonly id = "configureCmake";
15-
1615
constructor() {
17-
super(ConfigureCmakeCommand.id);
16+
super(CONFIGURE_CMAKE);
1817
}
1918

2019
async execute(): Promise<void> {
@@ -59,10 +58,8 @@ export default class ConfigureCmakeCommand extends Command {
5958
export class CleanCMakeCommand extends Command {
6059
private _logger: Logger = new Logger("CleanCMakeCommand");
6160

62-
public static readonly id = "cleanCmake";
63-
6461
constructor(private readonly _ui: UI) {
65-
super(CleanCMakeCommand.id);
62+
super(CLEAN_CMAKE);
6663
}
6764

6865
async execute(): Promise<void> {
@@ -127,10 +124,8 @@ export class CleanCMakeCommand extends Command {
127124
export class SwitchBuildTypeCommand extends Command {
128125
private _logger: Logger = new Logger("SwitchBuildTypeCommand");
129126

130-
public static readonly id = "switchBuildType";
131-
132127
constructor(private readonly _ui: UI) {
133-
super(SwitchBuildTypeCommand.id);
128+
super(SWITCH_BUILD_TYPE);
134129
}
135130

136131
async execute(): Promise<void> {

src/commands/debugLayout.mts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
11
import { Command } from "./command.mjs";
22
import Logger from "../logger.mjs";
33
import { commands, workspace } from "vscode";
4+
import { DEBUG_LAYOUT } from "./cmdIds.mjs";
45

56
/**
67
* Relay command for toggling the debug layout (debug activity bar and debug repl).
78
*/
89
export default class DebugLayoutCommand extends Command {
910
private _logger: Logger = new Logger("DebugLayoutCommand");
1011

11-
public static readonly id = "debugLayout";
12-
1312
constructor() {
14-
super(DebugLayoutCommand.id);
13+
super(DEBUG_LAYOUT);
1514
}
1615

1716
async execute(): Promise<void> {

src/commands/flashProjectSwd.mts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@ import { CommandWithResult } from "./command.mjs";
22
import Logger from "../logger.mjs";
33
import { tasks, window } from "vscode";
44
import { EventEmitter } from "stream";
5+
import { FLASH_PROJECT_SWD } from "./cmdIds.mjs";
56

67
export default class FlashProjectSWDCommand extends CommandWithResult<boolean> {
78
private _logger: Logger = new Logger("FlashProjectSWDCommand");
89

9-
public static readonly id = "flashProject";
10-
1110
constructor() {
12-
super(FlashProjectSWDCommand.id);
11+
super(FLASH_PROJECT_SWD);
1312
}
1413

1514
async execute(): Promise<boolean> {

src/commands/getPaths.mts

Lines changed: 31 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,31 @@ import Logger from "../logger.mjs";
2929
import { rustProjectGetSelectedChip } from "../utils/rustUtil.mjs";
3030
import { OPENOCD_VERSION } from "../utils/sharedConstants.mjs";
3131
import {
32-
getBoardFromZephyrProject,
32+
GET_CHIP,
33+
GET_CHIP_UPPERCASE,
34+
GET_COMPILER_PATH,
35+
GET_CXX_COMPILER_PATH,
36+
GET_ENV_PATH,
37+
GET_GDB_PATH,
38+
GET_OPENOCD_ROOT,
39+
GET_PICOTOOL_PATH,
40+
GET_PYTHON_PATH,
41+
GET_SVD_PATH,
42+
GET_TARGET,
43+
GET_WEST_PATH,
44+
GET_ZEPHYR_WORKSPACE_PATH,
45+
} from "./cmdIds.mjs";
46+
import { getBoardFromZephyrProject } from "../utils/setupZephyr.mjs";
47+
import {
3348
ZEPHYR_PICO,
3449
ZEPHYR_PICO2,
3550
ZEPHYR_PICO2_W,
3651
ZEPHYR_PICO_W,
37-
} from "./switchBoard.mjs";
52+
} from "../models/zephyrBoards.mjs";
3853

3954
export class GetPythonPathCommand extends CommandWithResult<string> {
40-
public static readonly id = "getPythonPath";
41-
4255
constructor() {
43-
super(GetPythonPathCommand.id);
56+
super(GET_PYTHON_PATH);
4457
}
4558

4659
async execute(): Promise<string> {
@@ -58,10 +71,8 @@ export class GetPythonPathCommand extends CommandWithResult<string> {
5871
}
5972

6073
export class GetEnvPathCommand extends CommandWithResult<string> {
61-
public static readonly id = "getEnvPath";
62-
6374
constructor() {
64-
super(GetEnvPathCommand.id);
75+
super(GET_ENV_PATH);
6576
}
6677

6778
async execute(): Promise<string> {
@@ -79,10 +90,8 @@ export class GetEnvPathCommand extends CommandWithResult<string> {
7990
}
8091

8192
export class GetGDBPathCommand extends CommandWithResult<string> {
82-
public static readonly id = "getGDBPath";
83-
8493
constructor(private readonly _extensionUri: Uri) {
85-
super(GetGDBPathCommand.id);
94+
super(GET_GDB_PATH);
8695
}
8796

8897
async execute(): Promise<string> {
@@ -172,10 +181,8 @@ export class GetGDBPathCommand extends CommandWithResult<string> {
172181
}
173182

174183
export class GetCompilerPathCommand extends CommandWithResult<string> {
175-
public static readonly id = "getCompilerPath";
176-
177184
constructor() {
178-
super(GetCompilerPathCommand.id);
185+
super(GET_COMPILER_PATH);
179186
}
180187

181188
async execute(): Promise<string> {
@@ -213,10 +220,8 @@ export class GetCompilerPathCommand extends CommandWithResult<string> {
213220
}
214221

215222
export class GetCxxCompilerPathCommand extends CommandWithResult<string> {
216-
public static readonly id = "getCxxCompilerPath";
217-
218223
constructor() {
219-
super(GetCxxCompilerPathCommand.id);
224+
super(GET_CXX_COMPILER_PATH);
220225
}
221226

222227
async execute(): Promise<string> {
@@ -256,10 +261,8 @@ export class GetCxxCompilerPathCommand extends CommandWithResult<string> {
256261
export class GetChipCommand extends CommandWithResult<string> {
257262
private readonly _logger = new Logger("GetChipCommand");
258263

259-
public static readonly id = "getChip";
260-
261264
constructor() {
262-
super(GetChipCommand.id);
265+
super(GET_CHIP);
263266
}
264267

265268
async execute(): Promise<string> {
@@ -357,10 +360,8 @@ export class GetChipCommand extends CommandWithResult<string> {
357360
}
358361

359362
export class GetChipUppercaseCommand extends CommandWithResult<string> {
360-
public static readonly id = "getChipUppercase";
361-
362363
constructor() {
363-
super(GetChipUppercaseCommand.id);
364+
super(GET_CHIP_UPPERCASE);
364365
}
365366

366367
async execute(): Promise<string> {
@@ -372,10 +373,8 @@ export class GetChipUppercaseCommand extends CommandWithResult<string> {
372373
}
373374

374375
export class GetTargetCommand extends CommandWithResult<string> {
375-
public static readonly id = "getTarget";
376-
377376
constructor() {
378-
super(GetTargetCommand.id);
377+
super(GET_TARGET);
379378
}
380379

381380
async execute(): Promise<string> {
@@ -455,12 +454,11 @@ export class GetPicotoolPathCommand extends CommandWithResult<
455454
> {
456455
private running: boolean = false;
457456

458-
public static readonly id = "getPicotoolPath";
459-
460457
constructor() {
461-
super(GetPicotoolPathCommand.id);
458+
super(GET_PICOTOOL_PATH);
462459
}
463460

461+
// TODO: add rate limiting and caching
464462
async execute(): Promise<string | undefined> {
465463
if (this.running) {
466464
return undefined;
@@ -505,10 +503,8 @@ export class GetOpenOCDRootCommand extends CommandWithResult<
505503
> {
506504
private running: boolean = false;
507505

508-
public static readonly id = "getOpenOCDRoot";
509-
510506
constructor() {
511-
super(GetOpenOCDRootCommand.id);
507+
super(GET_OPENOCD_ROOT);
512508
}
513509

514510
async execute(): Promise<string | undefined> {
@@ -536,10 +532,8 @@ export class GetOpenOCDRootCommand extends CommandWithResult<
536532
* Currently rust only!
537533
*/
538534
export class GetSVDPathCommand extends CommandWithResult<string | undefined> {
539-
public static readonly id = "getSVDPath";
540-
541535
constructor(private readonly _extensionUri: Uri) {
542-
super(GetSVDPathCommand.id);
536+
super(GET_SVD_PATH);
543537
}
544538

545539
async execute(): Promise<string | undefined> {
@@ -582,10 +576,8 @@ export class GetSVDPathCommand extends CommandWithResult<string | undefined> {
582576
}
583577

584578
export class GetWestPathCommand extends CommandWithResult<string | undefined> {
585-
public static readonly id = "getWestPath";
586-
587579
constructor() {
588-
super(GetWestPathCommand.id);
580+
super(GET_WEST_PATH);
589581
}
590582

591583
execute(): string | undefined {
@@ -602,10 +594,8 @@ export class GetWestPathCommand extends CommandWithResult<string | undefined> {
602594
export class GetZephyrWorkspacePathCommand extends CommandWithResult<
603595
string | undefined
604596
> {
605-
public static readonly id = "getZephyrWorkspacePath";
606-
607597
constructor() {
608-
super(GetZephyrWorkspacePathCommand.id);
598+
super(GET_ZEPHYR_WORKSPACE_PATH);
609599
}
610600

611601
execute(): string | undefined {

src/commands/importProject.mts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
import { CommandWithArgs } from "./command.mjs";
2-
import Logger from "../logger.mjs";
32
import { type Uri } from "vscode";
43
import { NewProjectPanel } from "../webview/newProjectPanel.mjs";
4+
import { IMPORT_PROJECT } from "./cmdIds.mjs";
55

66
export default class ImportProjectCommand extends CommandWithArgs {
7-
private _logger: Logger = new Logger("ImportProjectCommand");
8-
9-
public static readonly id = "importProject";
10-
117
constructor(private readonly _extensionUri: Uri) {
12-
super(ImportProjectCommand.id);
8+
super(IMPORT_PROJECT);
139
}
1410

1511
execute(projectUri?: Uri): void {

0 commit comments

Comments
 (0)