Fix squiggles caused by -MF switch and of comma separated sub-switches (#75)

* Fix squiggles caused by -MF switch and of comma separated sub-switches

* Fix more cases of unnecessary quotes removals
This commit is contained in:
Andreea Isac 2020-11-20 08:37:02 -08:00 коммит произвёл GitHub
Родитель d04162fe9e
Коммит 58abe11ee3
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 8 добавлений и 16 удалений

Просмотреть файл

@ -118,7 +118,7 @@ export class CppConfigurationProvider implements cpp.CustomConfigurationProvider
logger.message(" Browse Path: " + this.workspaceBrowseConfiguration.browsePath.join(";"));
logger.message(" Standard: " + this.workspaceBrowseConfiguration.standard);
logger.message(" Compiler Path: " + this.workspaceBrowseConfiguration.compilerPath);
logger.message(" Compiler Arguments: " + this.workspaceBrowseConfiguration.compilerArgs);
logger.message(" Compiler Arguments: " + this.workspaceBrowseConfiguration.compilerArgs?.join(";"));
if (process.platform === "win32" && this.workspaceBrowseConfiguration.windowsSdkVersion) {
logger.message(" Windows SDK Version: " + this.workspaceBrowseConfiguration.windowsSdkVersion);
}
@ -135,7 +135,7 @@ export class CppConfigurationProvider implements cpp.CustomConfigurationProvider
logger.message(" Standard: " + filePath.configuration.standard, "Verbose");
logger.message(" IntelliSense Mode: " + filePath.configuration.intelliSenseMode, "Verbose");
logger.message(" Compiler Path: " + filePath.configuration.compilerPath, "Verbose");
logger.message(" Compiler Arguments: " + filePath.configuration.compilerArgs, "Verbose");
logger.message(" Compiler Arguments: " + filePath.configuration.compilerArgs?.join(";"), "Verbose");
if (process.platform === "win32" && filePath.configuration.windowsSdkVersion, "Verbose") {
logger.message(" Windows SDK Version: " + filePath.configuration.windowsSdkVersion, "Verbose");
}

Просмотреть файл

@ -338,7 +338,7 @@ function parseAnySwitchFromToolArguments(args: string, excludeArgs: string[]): s
// Identify the non value part of the switch: prefix, switch name
// and what may separate this from an eventual switch value
let switches: string[] = [];
let regExpStr: string = "(^|,|\\s+)(--|-" +
let regExpStr: string = "(^|\\s+)(--|-" +
// On Win32 allow '/' as switch prefix as well,
// otherwise it conflicts with path character
(process.platform === "win32" ? "|\\/" : "") +
@ -359,10 +359,6 @@ function parseAnySwitchFromToolArguments(args: string, excludeArgs: string[]): s
// and also CppTools expects the compiler arguments to be prefixed
// when received from the custom providers.
index1 = regexp.lastIndex - match1[0].length;
// skip over the switches separator if it happens to be comma
if (match1[0][0] === ",") {
index1++;
}
// Marks the beginning of the next switch
match2 = regexp.exec(args);
@ -451,8 +447,7 @@ function parseMultipleSwitchFromToolArguments(args: string, sw: string): string[
'(' +
// the left side (or whole value if no '=' is following)
'(' +
'[^\\s=,]+' + // not quoted switch value component
// comma is excluded because it can be a switch separator sometimes
'[^\\s=]+' + // not quoted switch value component
')' +
'(' +
'=' + // separator between switch value left side and right side
@ -460,8 +455,7 @@ function parseMultipleSwitchFromToolArguments(args: string, sw: string): string[
'\\`[^\\`]*?\\`|' + // anything between `
'\\\'[^\\\']*?\\\'|' + // anything between '
'\\"[^\\"]*?\\"|' + // anything between "
'[^\\s,]+' + // not quoted right side of switch value
// comma is excluded because it can be a switch separator sometimes
'[^\\s]+' + // not quoted right side of switch value
// equal is actually allowed (example gcc switch: -fmacro-prefix-map=./= )
')' +
')?' +
@ -476,7 +470,6 @@ function parseMultipleSwitchFromToolArguments(args: string, sw: string): string[
let result: string = match[6];
if (result) {
result = result.trim();
result = result.replace(/"/g, "");
results.push(result);
}
match = regexp.exec(args);
@ -528,7 +521,6 @@ function parseMultipleSwitchesFromToolArguments(args: string, simpleSwitches: st
let result: string = match[12] || match[15];
if (result) {
result = result.trim();
result = result.replace(/"/g, "");
results.push(result);
}
match = regexp.exec(args);
@ -566,7 +558,6 @@ function parseSingleSwitchFromToolArguments(args: string, sw: string[]): string
let result: string = match[5];
if (result) {
result = result.trim();
result = result.replace(/"/g, "");
results.push(result);
}
match = regexp.exec(args);
@ -628,7 +619,6 @@ function parseFilesFromToolArguments(args: string, exts: string[]): string[] {
let result: string = match[1];
if (result) {
result = result.trim();
result = result.replace(/"/g, "");
files.push(result);
}
match = regexp.exec(args);
@ -761,8 +751,10 @@ export async function parseCustomConfigProvider(cancel: vscode.CancellationToken
compilerFullPath = path.join(util.toolPathInEnv(toolBaseName) || "", toolBaseName);
}
// Exclude switches that are being processed separately (I, FI, include, D, std)
// and switches that don't affect IntelliSense but are causing errors.
let compilerArgs: string[] = [];
compilerArgs = parseAnySwitchFromToolArguments(compilerTool.arguments, ["I", "FI", "include", "D", "std"]);
compilerArgs = parseAnySwitchFromToolArguments(compilerTool.arguments, ["I", "FI", "include", "D", "std", "MF"]);
// Parse and log the includes, forced includes and the defines
let includes: string[] = parseMultipleSwitchFromToolArguments(compilerTool.arguments, 'I');