From 73224ed9c0f2784651a5ca0c7d45a0e76a942479 Mon Sep 17 00:00:00 2001 From: Sneha Ramachandran Date: Wed, 11 Dec 2024 12:10:24 -0500 Subject: [PATCH] updated changelog --- CHANGELOG.md | 1 + src/parser.ts | 24 +++++++++++++++--------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ed901ff9..97714953 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ Bug Fixes: - Ensure that we append line endings, which fixes a recent regression. [#641](https://github.com/microsoft/vscode-makefile-tools/issues/641) - Ensure we handle parenthesis without their partner correctly. [#543](https://github.com/microsoft/vscode-makefile-tools/issues/543) +- Fix intellisense "unrecognized token" issue with define. [#526](https://github.com/microsoft/vscode-makefile-tools/issues/526) Improvements: 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(