@@ -80,6 +80,11 @@ class TreeViewController implements Disposable {
80
80
private waitUserContest : boolean ;
81
81
82
82
// 获取当前文件的路径
83
+ /**
84
+ * It returns the path of the currently active file, or undefined if there is no active file
85
+ * @param [uri] - The file path to open.
86
+ * @returns A promise that resolves to a string or undefined.
87
+ */
83
88
public async getActiveFilePath ( uri ?: vscode . Uri ) : Promise < string | undefined > {
84
89
let textEditor : vscode . TextEditor | undefined ;
85
90
if ( uri ) {
@@ -103,6 +108,13 @@ class TreeViewController implements Disposable {
103
108
}
104
109
105
110
// 提交问题
111
+ /**
112
+ * It gets the active file path, then submits the solution to the server, and finally refreshes the
113
+ * tree view
114
+ * @param [uri] - The URI of the file to be submitted. If not provided, the currently active file will
115
+ * be submitted.
116
+ * @returns A promise that resolves to a string.
117
+ */
106
118
public async submitSolution ( uri ?: vscode . Uri ) : Promise < void > {
107
119
if ( ! statusBarService . getUser ( ) ) {
108
120
promptForSignIn ( ) ;
@@ -127,6 +139,11 @@ class TreeViewController implements Disposable {
127
139
}
128
140
129
141
// 提交测试用例
142
+ /**
143
+ * It takes the current file, and sends it to the server to be tested
144
+ * @param [uri] - The file path of the file to be submitted. If it is not passed, the currently active
145
+ * file is submitted.
146
+ */
130
147
public async testSolution ( uri ?: vscode . Uri ) : Promise < void > {
131
148
try {
132
149
if ( statusBarService . getStatus ( ) === UserStatus . SignedOut ) {
@@ -217,6 +234,13 @@ class TreeViewController implements Disposable {
217
234
await promptForOpenOutputChannel ( "提交测试出错了. 请查看控制台信息~" , DialogType . error ) ;
218
235
}
219
236
}
237
+ /**
238
+ * "Show a file selection dialog, and return the selected file's URI."
239
+ *
240
+ * The function is async, so it returns a promise
241
+ * @param {string } [fsPath] - The path of the file that is currently open in the editor.
242
+ * @returns An array of file URIs or undefined.
243
+ */
220
244
public async showFileSelectDialog ( fsPath ?: string ) : Promise < vscode . Uri [ ] | undefined > {
221
245
const defaultUri : vscode . Uri | undefined = this . getBelongingWorkspaceFolderUri ( fsPath ) ;
222
246
const options : vscode . OpenDialogOptions = {
@@ -229,6 +253,14 @@ class TreeViewController implements Disposable {
229
253
return await vscode . window . showOpenDialog ( options ) ;
230
254
}
231
255
256
+ /**
257
+ * It gets the active file path, and then calls the executeService.testSolution function to test the
258
+ * solution
259
+ * @param [uri] - The path of the file to be submitted. If it is not passed, the currently active file
260
+ * is submitted.
261
+ * @param {boolean } [allCase] - Whether to submit all cases.
262
+ * @returns a promise that resolves to void.
263
+ */
232
264
public async testSolutionDefault ( uri ?: vscode . Uri , allCase ?: boolean ) : Promise < void > {
233
265
try {
234
266
if ( statusBarService . getStatus ( ) === UserStatus . SignedOut ) {
@@ -251,6 +283,15 @@ class TreeViewController implements Disposable {
251
283
}
252
284
}
253
285
286
+ /**
287
+ * It gets the active file path, then calls the executeService.testSolution function to test the
288
+ * solution
289
+ * @param [uri] - The file path of the file to be submitted. If it is not passed in, the currently
290
+ * active file is submitted.
291
+ * @param {string } [testcase] - The test case to be tested. If it is not specified, the test case will
292
+ * be randomly selected.
293
+ * @returns a promise that resolves to void.
294
+ */
254
295
public async testSolutionArea ( uri ?: vscode . Uri , testcase ?: string ) : Promise < void > {
255
296
try {
256
297
if ( statusBarService . getStatus ( ) === UserStatus . SignedOut ) {
@@ -273,6 +314,13 @@ class TreeViewController implements Disposable {
273
314
}
274
315
}
275
316
317
+ /**
318
+ * "If the ComSpec environment variable is not set, or if it is set to cmd.exe, then return true."
319
+ *
320
+ * The ComSpec environment variable is set to the path of the command processor. On Windows, this is
321
+ * usually cmd.exe. On Linux, it is usually bash
322
+ * @returns A boolean value.
323
+ */
276
324
public usingCmd ( ) : boolean {
277
325
const comSpec : string | undefined = process . env . ComSpec ;
278
326
// 'cmd.exe' is used as a fallback if process.env.ComSpec is unavailable.
@@ -286,6 +334,12 @@ class TreeViewController implements Disposable {
286
334
return false ;
287
335
}
288
336
337
+ /**
338
+ * If you're on Windows, and you're using cmd.exe, then you need to escape double quotes with
339
+ * backslashes. Otherwise, you don't
340
+ * @param {string } test - The test string to be parsed.
341
+ * @returns a string.
342
+ */
289
343
public parseTestString ( test : string ) : string {
290
344
if ( systemUtils . useWsl ( ) || ! systemUtils . isWindows ( ) ) {
291
345
if ( systemUtils . useVscodeNode ( ) ) {
@@ -310,6 +364,10 @@ class TreeViewController implements Disposable {
310
364
}
311
365
}
312
366
367
+ /**
368
+ * It switches the endpoint of LeetCode, and then signs out and signs in again
369
+ * @returns a promise that resolves to a void.
370
+ */
313
371
public async switchEndpoint ( ) : Promise < void > {
314
372
const isCnEnabled : boolean = getLeetCodeEndpoint ( ) === Endpoint . LeetCodeCN ;
315
373
const picks : Array < IQuickItemEx < string > > = [ ] ;
@@ -350,6 +408,11 @@ class TreeViewController implements Disposable {
350
408
}
351
409
}
352
410
411
+ /**
412
+ * It shows a quick pick menu with the available sorting strategies, and if the user selects one, it
413
+ * updates the sorting strategy and refreshes the tree view
414
+ * @returns A promise that resolves to a void.
415
+ */
353
416
public async switchSortingStrategy ( ) : Promise < void > {
354
417
const currentStrategy : SortingStrategy = getSortingStrategy ( ) ;
355
418
const picks : Array < IQuickItemEx < string > > = [ ] ;
@@ -371,6 +434,10 @@ class TreeViewController implements Disposable {
371
434
await treeDataService . refresh ( ) ;
372
435
}
373
436
437
+ /**
438
+ * It adds a node to the user's favorites
439
+ * @param {NodeModel } node - NodeModel
440
+ */
374
441
public async addFavorite ( node : NodeModel ) : Promise < void > {
375
442
try {
376
443
await executeService . toggleFavorite ( node , true ) ;
@@ -383,6 +450,10 @@ class TreeViewController implements Disposable {
383
450
}
384
451
}
385
452
453
+ /**
454
+ * It removes a node from the user's favorites
455
+ * @param {NodeModel } node - The node that is currently selected in the tree.
456
+ */
386
457
public async removeFavorite ( node : NodeModel ) : Promise < void > {
387
458
try {
388
459
await executeService . toggleFavorite ( node , false ) ;
@@ -395,6 +466,10 @@ class TreeViewController implements Disposable {
395
466
}
396
467
}
397
468
469
+ /**
470
+ * It returns a list of problems
471
+ * @returns An array of problems.
472
+ */
398
473
public async listProblems ( ) : Promise < IProblem [ ] > {
399
474
try {
400
475
if ( statusBarService . getStatus ( ) === UserStatus . SignedOut ) {
0 commit comments