From cf807431fd29508ed35e82b71522f1be23fc090c Mon Sep 17 00:00:00 2001 From: snehara99 Date: Mon, 9 Dec 2024 13:05:41 -0800 Subject: [PATCH] created issue specific solution before full compilerFragments enhancement --- assets/parseCompilerArgs.sh | 0 src/parser.ts | 24 +++++++++++++++--------- 2 files changed, 15 insertions(+), 9 deletions(-) mode change 100644 => 100755 assets/parseCompilerArgs.sh diff --git a/assets/parseCompilerArgs.sh b/assets/parseCompilerArgs.sh old mode 100644 new mode 100755 diff --git a/src/parser.ts b/src/parser.ts index 14bd4575..36d12dde 100644 --- a/src/parser.ts +++ b/src/parser.ts @@ -1213,18 +1213,24 @@ export async function parseCustomConfigProvider( // and switches that don't affect IntelliSense but are causing errors. let compilerArgs: string[] = []; let compilerFragments: string[] = []; + if (useCompilerFragments) { - compilerFragments = await parseAnySwitchFromToolArguments( - compilerTool.arguments, - ["I", "FI", "include", "D", "std", "MF"] - ); - } else { - compilerArgs = await parseAnySwitchFromToolArguments( - compilerTool.arguments, - ["I", "FI", "include", "D", "std", "MF"] - ); + // This is a temporary solution where we are only using compiler fragments here to pass the + // -D defines to the compiler (to fix intellisense issues). We still separately parse defines. + // There is still an issue tracking using compilerFragments fully instead of compilerArgs: + // https://github.com/microsoft/vscode-makefile-tools/issues/352. + let tempFragments: string[] = compilerTool.arguments.trim().split(" -D"); + if (tempFragments.length > 1) { + for (let i: number = 1; i < tempFragments.length; i++) { + compilerFragments.push("-D" + tempFragments[i].trim().split("/\s+/")[0]); + } + } } + compilerArgs = await parseAnySwitchFromToolArguments( + compilerTool.arguments, + ["I", "FI", "include", "D", "std", "MF"] + ); // Parse and log the includes, forced includes and the defines let includes: string[] = parseMultipleSwitchFromToolArguments(