From ca82b20be62ec46b877d8a8c5653279df0f75ab4 Mon Sep 17 00:00:00 2001 From: Andreea Isac Date: Thu, 5 Mar 2020 21:52:13 -0800 Subject: [PATCH] Linter fixes plus remove annoying popup when logging is enough --- src/configuration.ts | 10 +++++----- src/extension.ts | 2 +- src/parser.ts | 24 ++++++++++++------------ 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/configuration.ts b/src/configuration.ts index a0c0195..f534b95 100644 --- a/src/configuration.ts +++ b/src/configuration.ts @@ -284,7 +284,7 @@ export async function setNewLaunchConfiguration(): Promise { await util.spawnChildProcess(configurationCommandName, commandArgs, vscode.workspace.rootPath || "", stdout, stderr, closing); } catch (error) { - vscode.window.showErrorMessage('Failed to launch make command. Make sure it is on the path. ' + error); + logger.message(error); return; } } @@ -325,7 +325,7 @@ export async function setNewTarget(): Promise { await util.spawnChildProcess(configurationCommandName, commandArgs, vscode.workspace.rootPath || "", stdout, stderr, closing); } catch (error) { - vscode.window.showErrorMessage('Failed to launch make command. Make sure it is on the path. ' + error); + logger.message(error); return; } } @@ -358,9 +358,9 @@ export async function selectLaunchConfiguration(launchConfigurations: LaunchConf items.push(launchConfigurationToString(config)); }); - items = items.sort().filter(function(elem, index, selef) { - return index === selef.indexOf(elem); - }) + items = items.sort().filter(function(elem, index, self) : boolean { + return index === self.indexOf(elem); + }); // TODO: create a quick pick with description and details for items // to better view the long targets commands diff --git a/src/extension.ts b/src/extension.ts index 6da8b1b..ba82e3d 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -84,7 +84,7 @@ export class MakefileToolsExtension { this.cppConfigurationProvider.buildCustomConfigurationProvider(defines, includePath, forcedInclude, standard, intelliSenseMode, compilerPath, filesPaths, windowsSdkVersion); } - public getCompilerFullPath() { return this.compilerFullPath; } + public getCompilerFullPath() : string | undefined { return this.compilerFullPath; } } // A change of target or configuration triggered a new dry-run, diff --git a/src/parser.ts b/src/parser.ts index 1fffe63..3ff496f 100644 --- a/src/parser.ts +++ b/src/parser.ts @@ -75,10 +75,10 @@ function preprocessDryRunOutput(dryRunOutputStr: string): string { // TODO: figure out how to do this with string replace //preprocessedDryRunOutputStr = preprocessedDryRunOutputStr.replace(/\\s+\\$/mg, " "); preprocessedDryRunOutputStr = preprocessedDryRunOutputStr.replace("\r\n", "\n"); - let regexp = /\s+\\$/mg; - let match = regexp.exec(preprocessedDryRunOutputStr); + let regexp : RegExp = /\s+\\$/mg; + let match: RegExpExecArray | null = regexp.exec(preprocessedDryRunOutputStr); while (match) { - let result = match[0]; + let result: string = match[0]; result = result.concat("\n"); preprocessedDryRunOutputStr = preprocessedDryRunOutputStr.replace(result, " "); match = regexp.exec(preprocessedDryRunOutputStr); @@ -87,18 +87,18 @@ function preprocessDryRunOutput(dryRunOutputStr: string): string { // Process some more makefile output weirdness let preprocessedDryRunOutputLines : string[] = []; preprocessedDryRunOutputStr.split("\n").forEach(line => { - let strC = "--mode=compile"; - let idxC = line.indexOf(strC); + let strC: string = "--mode=compile"; + let idxC: number = line.indexOf(strC); if (idxC >= 0) { line = line.replace(line.substring(0, idxC), ""); - line = line.replace(strC, "") + line = line.replace(strC, ""); } - let strL = "--mode=link"; - let idxL = line.indexOf(strL); + let strL: string = "--mode=link"; + let idxL: number = line.indexOf(strL); if (idxL >= 0) { line = line.replace(line.substring(0, idxL), ""); - line = line.replace(strL, "") + line = line.replace(strL, ""); } preprocessedDryRunOutputLines.push(line); @@ -106,8 +106,8 @@ function preprocessDryRunOutput(dryRunOutputStr: string): string { if (idxL >= 0 && idxC >= 0) { logger.message("Not supporting --mode=compile and --mode=link on the same line"); } - }) - + }); + preprocessedDryRunOutputStr = preprocessedDryRunOutputLines.join("\n"); // Extract the link command @@ -708,7 +708,7 @@ export function parseForLaunchConfiguration(dryRunOutputStr: string): configurat }); // Target binary launch configuration duplicates may be generated in the following scenarios. - // They will be filtered later when dealing with the UI pick. + // They will be filtered later when dealing with the UI pick. // - a target binary invoked several times with the same arguments and from the same path // - a target binary invoked once with no parameters is still a duplicate // of the entry generated by the linker command which produced the binary