Skip to content

Commit

Permalink
Move public function to the top of the class
Browse files Browse the repository at this point in the history
  • Loading branch information
mostafa-mohammed-sonarsource committed Dec 17, 2024
1 parent 377bb2e commit ff181a9
Showing 1 changed file with 46 additions and 46 deletions.
92 changes: 46 additions & 46 deletions src/Integration.Vsix/CFamily/VcxProject/FileConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,52 @@ namespace SonarLint.VisualStudio.Integration.Vsix.CFamily.VcxProject
{
internal class FileConfig : IFileConfig
{
[ExcludeFromCodeCoverage]
public static FileConfig TryGet(ILogger logger, ProjectItem dteProjectItem, string absoluteFilePath, IFileSystem fileSystem)
{
if (!(dteProjectItem.ContainingProject.Object is VCProject vcProject) ||
!(dteProjectItem.Object is VCFile vcFile))
{
return null;
}

var vcConfig = vcProject.ActiveConfiguration;

var vcFileSettings = GetVcFileSettings(logger, absoluteFilePath, vcConfig, vcFile);
if (vcFileSettings == null)
{
// Not supported
return null;
}

bool isHeaderFile = vcFile.ItemType == "ClInclude";
CmdBuilder cmdBuilder = new CmdBuilder(isHeaderFile);

if (!GetCompilerPath(logger, vcConfig, fileSystem, out var compilerPath))
{
return null;
}
logger.WriteLine(compilerPath);
// command: add compiler
cmdBuilder.AddCompiler(compilerPath);

// command: add options from VCRulePropertyStorage
cmdBuilder.AddOptFromProperties(vcFileSettings);

// cmd add File
cmdBuilder.AddFile(absoluteFilePath);
var envINCLUDE = vcConfig.GetEvaluatedPropertyValue("IncludePath");

return new FileConfig
{
CDDirectory = Path.GetDirectoryName(vcProject.ProjectFile),
CDCommand = cmdBuilder.GetFullCmd(),
CDFile = absoluteFilePath,
EnvInclude = envINCLUDE,
IsHeaderFile = isHeaderFile,
};
}

private static bool TryGetCompilerPathFromClCompilerPath(ILogger logger, VCConfiguration vcConfig, IFileSystem fileSystem, out string compilerPath)
{
compilerPath = vcConfig.GetEvaluatedPropertyValue("ClCompilerPath");
Expand Down Expand Up @@ -120,52 +166,6 @@ private static bool GetCompilerPath(ILogger logger, VCConfiguration vcConfig, IF
return false;
}

[ExcludeFromCodeCoverage]
public static FileConfig TryGet(ILogger logger, ProjectItem dteProjectItem, string absoluteFilePath, IFileSystem fileSystem)
{
if (!(dteProjectItem.ContainingProject.Object is VCProject vcProject) ||
!(dteProjectItem.Object is VCFile vcFile))
{
return null;
}

var vcConfig = vcProject.ActiveConfiguration;

var vcFileSettings = GetVcFileSettings(logger, absoluteFilePath, vcConfig, vcFile);
if (vcFileSettings == null)
{
// Not supported
return null;
}

bool isHeaderFile = vcFile.ItemType == "ClInclude";
CmdBuilder cmdBuilder = new CmdBuilder(isHeaderFile);

if (!GetCompilerPath(logger, vcConfig, fileSystem, out var compilerPath))
{
return null;
}
logger.WriteLine(compilerPath);
// command: add compiler
cmdBuilder.AddCompiler(compilerPath);

// command: add options from VCRulePropertyStorage
cmdBuilder.AddOptFromProperties(vcFileSettings);

// cmd add File
cmdBuilder.AddFile(absoluteFilePath);
var envINCLUDE = vcConfig.GetEvaluatedPropertyValue("IncludePath");

return new FileConfig
{
CDDirectory = Path.GetDirectoryName(vcProject.ProjectFile),
CDCommand = cmdBuilder.GetFullCmd(),
CDFile = absoluteFilePath,
EnvInclude = envINCLUDE,
IsHeaderFile = isHeaderFile,
};
}

private static IVCRulePropertyStorage GetVcFileSettings(ILogger logger, string absoluteFilePath, VCConfiguration vcConfig, VCFile vcFile)
{
var projectKind = vcConfig.ConfigurationType;
Expand Down

0 comments on commit ff181a9

Please sign in to comment.