Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
snehara99 committed Dec 9, 2024
1 parent 36a5174 commit a123cce
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
2 changes: 2 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ export class MakefileToolsExtension {
intelliSenseMode: customConfigProviderItem.intelliSenseMode,
compilerPath: customConfigProviderItem.compilerFullPath,
compilerArgs: customConfigProviderItem.compilerArgs,
compilerFragments: customConfigProviderItem.compilerFragments,
windowsSdkVersion: customConfigProviderItem.windowsSDKVersion,
};

Expand Down Expand Up @@ -243,6 +244,7 @@ export class MakefileToolsExtension {
standard: customConfigProviderItem.standard,
compilerPath: customConfigProviderItem.compilerFullPath,
compilerArgs: customConfigProviderItem.compilerArgs,
compilerFragments: customConfigProviderItem.compilerFragments,
windowsSdkVersion: customConfigProviderItem.windowsSDKVersion,
};

Expand Down
29 changes: 22 additions & 7 deletions src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1109,6 +1109,7 @@ export interface CustomConfigProviderItem {
intelliSenseMode?: util.IntelliSenseMode;
compilerFullPath: string;
compilerArgs: string[];
compilerFragments: string[];
files: string[];
windowsSDKVersion?: string;
currentPath: string;
Expand Down Expand Up @@ -1140,6 +1141,9 @@ export async function parseCustomConfigProvider(
"Normal"
);

let cppToolsVersion = ext.extension.getCppToolsVersion();
let useCompilerFragments: boolean = cppToolsVersion !== undefined && cppToolsVersion >= cpp.Version.v6;

// Current path starts with workspace root and can be modified
// with prompt commands like cd, cd-, pushd/popd or with -C make switch
let currentPath: string = util.getWorkspaceRoot();
Expand Down Expand Up @@ -1208,10 +1212,19 @@ export async function parseCustomConfigProvider(
// 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 = await parseAnySwitchFromToolArguments(
compilerTool.arguments,
["I", "FI", "include", "D", "std", "MF"]
);
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"]
);
}


// Parse and log the includes, forced includes and the defines
let includes: string[] = parseMultipleSwitchFromToolArguments(
Expand Down Expand Up @@ -1242,7 +1255,7 @@ export async function parseCustomConfigProvider(
compilerTool.arguments
);
let intelliSenseMode: util.IntelliSenseMode = getIntelliSenseMode(
ext.extension.getCppToolsVersion(),
cppToolsVersion,
compilerFullPath,
targetArchitecture
);
Expand Down Expand Up @@ -1287,7 +1300,7 @@ export async function parseCustomConfigProvider(
if (language) {
// More standard validation and defaults, in the context of the whole command.
let standard: util.StandardVersion | undefined = parseStandard(
ext.extension.getCppToolsVersion(),
cppToolsVersion,
standardStr,
language
);
Expand All @@ -1301,6 +1314,7 @@ export async function parseCustomConfigProvider(
intelliSenseMode,
compilerFullPath,
compilerArgs,
compilerFragments,
files,
windowsSDKVersion,
currentPath,
Expand All @@ -1319,7 +1333,7 @@ export async function parseCustomConfigProvider(

// More standard validation and defaults, in the context of each source file.
let standard: util.StandardVersion | undefined = parseStandard(
ext.extension.getCppToolsVersion(),
cppToolsVersion,
standardStr,
language
);
Expand All @@ -1333,6 +1347,7 @@ export async function parseCustomConfigProvider(
intelliSenseMode,
compilerFullPath,
compilerArgs,
compilerFragments,
files: [file],
windowsSDKVersion,
currentPath,
Expand Down

0 comments on commit a123cce

Please sign in to comment.