@@ -64,37 +64,50 @@ export function registerToolchainCommands(
6464 ] ;
6565}
6666
67+ export enum COMMANDS {
68+ ResolveDependencies = "swift.resolveDependencies" ,
69+ UpdateDependencies = "swift.updateDependencies" ,
70+ RunTestsMultipleTimes = "swift.runTestsMultipleTimes" ,
71+ ResetPackage = "swift.resetPackage" ,
72+ UseLocalDependency = "swift.useLocalDependency" ,
73+ UneditDependency = "swift.uneditDependency" ,
74+ runTestsMultipleTimes = "runTestsMultipleTimes" ,
75+ }
76+
6777/**
6878 * Registers this extension's commands in the given {@link vscode.ExtensionContext context}.
6979 */
7080export function register ( ctx : WorkspaceContext ) : vscode . Disposable [ ] {
7181 return [
7282 vscode . commands . registerCommand ( "swift.newFile" , uri => newSwiftFile ( uri ) ) ,
73- vscode . commands . registerCommand ( "swift.resolveDependencies" , ( ) =>
83+ vscode . commands . registerCommand ( COMMANDS . ResolveDependencies , ( ) =>
7484 resolveDependencies ( ctx )
7585 ) ,
76- vscode . commands . registerCommand ( "swift.updateDependencies" , ( ) => updateDependencies ( ctx ) ) ,
86+ vscode . commands . registerCommand ( COMMANDS . UpdateDependencies , ( ) => updateDependencies ( ctx ) ) ,
7787 vscode . commands . registerCommand ( "swift.run" , ( ) => runBuild ( ctx ) ) ,
7888 vscode . commands . registerCommand ( "swift.debug" , ( ) => debugBuild ( ctx ) ) ,
7989 vscode . commands . registerCommand ( "swift.cleanBuild" , ( ) => cleanBuild ( ctx ) ) ,
80- vscode . commands . registerCommand ( "swift.runTestsMultipleTimes" , item => {
90+ vscode . commands . registerCommand ( COMMANDS . RunTestsMultipleTimes , item => {
8191 if ( ctx . currentFolder ) {
8292 return runTestMultipleTimes ( ctx . currentFolder , item , false ) ;
8393 }
94+ return false ;
8495 } ) ,
8596 vscode . commands . registerCommand ( "swift.runTestsUntilFailure" , item => {
8697 if ( ctx . currentFolder ) {
8798 return runTestMultipleTimes ( ctx . currentFolder , item , true ) ;
8899 }
100+ return false ;
89101 } ) ,
90102 // Note: This is only available on macOS (gated in `package.json`) because its the only OS that has the iOS SDK available.
91103 vscode . commands . registerCommand ( "swift.switchPlatform" , ( ) => switchPlatform ( ) ) ,
92- vscode . commands . registerCommand ( "swift.resetPackage" , ( ) => resetPackage ( ctx ) ) ,
104+ vscode . commands . registerCommand ( COMMANDS . ResetPackage , ( ) => resetPackage ( ctx ) ) ,
93105 vscode . commands . registerCommand ( "swift.runScript" , ( ) => runSwiftScript ( ctx ) ) ,
94106 vscode . commands . registerCommand ( "swift.openPackage" , ( ) => {
95107 if ( ctx . currentFolder ) {
96108 return openPackage ( ctx . toolchain . swiftVersion , ctx . currentFolder . folder ) ;
97109 }
110+ return false ;
98111 } ) ,
99112 vscode . commands . registerCommand ( "swift.runSnippet" , ( ) => runSnippet ( ctx ) ) ,
100113 vscode . commands . registerCommand ( "swift.debugSnippet" , ( ) => debugSnippet ( ctx ) ) ,
@@ -106,30 +119,35 @@ export function register(ctx: WorkspaceContext): vscode.Disposable[] {
106119 vscode . commands . registerCommand ( "swift.insertFunctionComment" , ( ) =>
107120 insertFunctionComment ( ctx )
108121 ) ,
109- vscode . commands . registerCommand ( "swift.useLocalDependency" , item => {
122+ vscode . commands . registerCommand ( COMMANDS . UseLocalDependency , item => {
110123 if ( item instanceof PackageNode ) {
111124 return useLocalDependency ( item . name , ctx ) ;
112125 }
126+ return false ;
113127 } ) ,
114128 vscode . commands . registerCommand ( "swift.editDependency" , item => {
115129 if ( item instanceof PackageNode ) {
116130 return editDependency ( item . name , ctx ) ;
117131 }
132+ return false ;
118133 } ) ,
119- vscode . commands . registerCommand ( "swift.uneditDependency" , item => {
134+ vscode . commands . registerCommand ( COMMANDS . UneditDependency , item => {
120135 if ( item instanceof PackageNode ) {
121136 return uneditDependency ( item . name , ctx ) ;
122137 }
138+ return false ;
123139 } ) ,
124140 vscode . commands . registerCommand ( "swift.openInWorkspace" , item => {
125141 if ( item instanceof PackageNode ) {
126142 return openInWorkspace ( item ) ;
127143 }
144+ return false ;
128145 } ) ,
129146 vscode . commands . registerCommand ( "swift.openExternal" , item => {
130147 if ( item instanceof PackageNode ) {
131148 return openInExternalEditor ( item ) ;
132149 }
150+ return false ;
133151 } ) ,
134152 vscode . commands . registerCommand ( "swift.attachDebugger" , ( ) => attachDebugger ( ctx ) ) ,
135153 vscode . commands . registerCommand ( "swift.clearDiagnosticsCollection" , ( ) =>
@@ -142,3 +160,5 @@ export function register(ctx: WorkspaceContext): vscode.Disposable[] {
142160 ) ,
143161 ] ;
144162}
163+
164+ // Note: This is only available on macOS (gated in `package.json`) because its the only OS that has the iOS SDK available.
0 commit comments