diff options
author | Karsten Heimrich <karsten.heimrich@qt.io> | 2021-11-30 14:36:16 +0100 |
---|---|---|
committer | Karsten Heimrich <karsten.heimrich@qt.io> | 2021-12-02 10:45:50 +0000 |
commit | f84e79c82218a0c6d9fff9db14a44a8baa75f670 (patch) | |
tree | b2fe05c7c21a7dbc83293b78697bc5e0675f78d0 /QtVsTools.Core | |
parent | ebb4a02670f2a1fab96a1bc888a59ab1502b4b41 (diff) |
Format switch-case according to the .editorconfig rule
Change-Id: I87cf1f2058fe53b940d00e82299ba414823e17c6
Reviewed-by: Miguel Costa <miguel.costa@qt.io>
Diffstat (limited to 'QtVsTools.Core')
-rw-r--r-- | QtVsTools.Core/CommandLineParser.cs | 140 | ||||
-rw-r--r-- | QtVsTools.Core/CxxStreamReader.cs | 9 | ||||
-rw-r--r-- | QtVsTools.Core/HelperFunctions.cs | 162 | ||||
-rw-r--r-- | QtVsTools.Core/QtMsBuild.cs | 16 | ||||
-rw-r--r-- | QtVsTools.Core/QtProject.cs | 116 |
5 files changed, 220 insertions, 223 deletions
diff --git a/QtVsTools.Core/CommandLineParser.cs b/QtVsTools.Core/CommandLineParser.cs index 94b1ef8d..36f62835 100644 --- a/QtVsTools.Core/CommandLineParser.cs +++ b/QtVsTools.Core/CommandLineParser.cs @@ -349,86 +349,86 @@ namespace QtVsTools.Core.CommandLine } string optionName = ""; switch (singleDashWordOptionMode) { - case SingleDashWordOptionMode.ParseAsCompactedShortOptions: - bool valueFound = false; - for (int pos = 1; pos < argument.Length; ++pos) { - optionName = argument.Substring(pos, 1); - if (!RegisterFoundOption(optionName)) { - error = true; - } else { - int optionOffset; - Trace.Assert(nameHash.TryGetValue( - optionName, - out optionOffset)); - bool withValue = !string.IsNullOrEmpty( - commandLineOptionList[optionOffset].ValueName); - if (withValue) { - if (pos + 1 < argument.Length) { - if (argument[pos + 1] == assignChar) - ++pos; - if (!optionValuesHash.ContainsKey(optionOffset)) { - optionValuesHash.Add( - optionOffset, - new List<string>()); - } - optionValuesHash[optionOffset].Add( - argument.Substring(pos + 1)); - valueFound = true; - } - break; - } - if (pos + 1 < argument.Length - && argument[pos + 1] == assignChar) { - break; - } - } - } - if (!valueFound - && !ParseOptionValue( - optionName, - argument, - argumentIterator, - ref atEnd)) { + case SingleDashWordOptionMode.ParseAsCompactedShortOptions: + bool valueFound = false; + for (int pos = 1; pos < argument.Length; ++pos) { + optionName = argument.Substring(pos, 1); + if (!RegisterFoundOption(optionName)) { error = true; - } - - break; - case SingleDashWordOptionMode.ParseAsLongOptions: - if (argument.Length > 2) { - string possibleShortOptionStyleName = argument.Substring(1, 1); - - int shortOptionIdx; - if (nameHash.TryGetValue( - possibleShortOptionStyleName, - out shortOptionIdx)) { - var arg = commandLineOptionList[shortOptionIdx]; - if ((arg.Flags & Option.Flag.ShortOptionStyle) != 0) { - RegisterFoundOption(possibleShortOptionStyleName); - if (!optionValuesHash.ContainsKey(shortOptionIdx)) { + } else { + int optionOffset; + Trace.Assert(nameHash.TryGetValue( + optionName, + out optionOffset)); + bool withValue = !string.IsNullOrEmpty( + commandLineOptionList[optionOffset].ValueName); + if (withValue) { + if (pos + 1 < argument.Length) { + if (argument[pos + 1] == assignChar) + ++pos; + if (!optionValuesHash.ContainsKey(optionOffset)) { optionValuesHash.Add( - shortOptionIdx, + optionOffset, new List<string>()); } - optionValuesHash[shortOptionIdx].Add( - argument.Substring(2)); - break; + optionValuesHash[optionOffset].Add( + argument.Substring(pos + 1)); + valueFound = true; } + break; } - } - optionName = argument.Substring(1).Split(new char[] { assignChar })[0]; - if (RegisterFoundOption(optionName)) { - if (!ParseOptionValue( - optionName, - argument, - argumentIterator, - ref atEnd)) { - error = true; + if (pos + 1 < argument.Length + && argument[pos + 1] == assignChar) { + break; } + } + } + if (!valueFound + && !ParseOptionValue( + optionName, + argument, + argumentIterator, + ref atEnd)) { + error = true; + } - } else { + break; + case SingleDashWordOptionMode.ParseAsLongOptions: + if (argument.Length > 2) { + string possibleShortOptionStyleName = argument.Substring(1, 1); + + int shortOptionIdx; + if (nameHash.TryGetValue( + possibleShortOptionStyleName, + out shortOptionIdx)) { + var arg = commandLineOptionList[shortOptionIdx]; + if ((arg.Flags & Option.Flag.ShortOptionStyle) != 0) { + RegisterFoundOption(possibleShortOptionStyleName); + if (!optionValuesHash.ContainsKey(shortOptionIdx)) { + optionValuesHash.Add( + shortOptionIdx, + new List<string>()); + } + optionValuesHash[shortOptionIdx].Add( + argument.Substring(2)); + break; + } + } + } + optionName = argument.Substring(1).Split(new char[] { assignChar })[0]; + if (RegisterFoundOption(optionName)) { + if (!ParseOptionValue( + optionName, + argument, + argumentIterator, + ref atEnd)) { error = true; } - break; + + } else { + error = true; + } + break; } } else { positionalArgumentList.Add(argument); diff --git a/QtVsTools.Core/CxxStreamReader.cs b/QtVsTools.Core/CxxStreamReader.cs index 6554df05..1e6721c7 100644 --- a/QtVsTools.Core/CxxStreamReader.cs +++ b/QtVsTools.Core/CxxStreamReader.cs @@ -114,8 +114,7 @@ namespace QtVsTools.Core private string ProcessString(string line, bool removeStrings) { switch (state) { - case State.Normal: - { + case State.Normal: { var lineCopy = line; line = string.Empty; for (int i = 0, j = 1; i < lineCopy.Length; ++i, ++j) { @@ -164,8 +163,7 @@ namespace QtVsTools.Core } } break; - case State.Comment: - { + case State.Comment: { var idx = line.IndexOf("*/", StringComparison.Ordinal); if (idx >= 0) { state = State.Normal; @@ -175,8 +173,7 @@ namespace QtVsTools.Core } } break; - case State.String: - { + case State.String: { var lineCopy = line; line = string.Empty; var endIdx = -1; diff --git a/QtVsTools.Core/HelperFunctions.cs b/QtVsTools.Core/HelperFunctions.cs index 762f7407..67c23c05 100644 --- a/QtVsTools.Core/HelperFunctions.cs +++ b/QtVsTools.Core/HelperFunctions.cs @@ -1537,20 +1537,20 @@ namespace QtVsTools.Core string propName = propNameMatch.Groups[1].Value; string propValue = ""; switch (propName) { - case "Configuration": - case "ConfigurationName": - if (string.IsNullOrEmpty(configName)) - return false; - propValue = configName; - break; - case "Platform": - case "PlatformName": - if (string.IsNullOrEmpty(platformName)) - return false; - propValue = platformName; - break; - default: + case "Configuration": + case "ConfigurationName": + if (string.IsNullOrEmpty(configName)) return false; + propValue = configName; + break; + case "Platform": + case "PlatformName": + if (string.IsNullOrEmpty(platformName)) + return false; + propValue = platformName; + break; + default: + return false; } expanded = expanded.Replace(string.Format("$({0})", propName), propValue); } @@ -1560,75 +1560,75 @@ namespace QtVsTools.Core string metaName = metaNameMatch.Groups[1].Value; string metaValue = ""; switch (metaName) { - case "FullPath": - if (vcFile == null) - return false; - metaValue = vcFile.FullPath; - break; - case "RootDir": - if (vcFile == null) - return false; - metaValue = Path.GetPathRoot(vcFile.FullPath); - break; - case "Filename": - if (vcFile == null) - return false; - metaValue = Path.GetFileNameWithoutExtension(vcFile.FullPath); - break; - case "Extension": - if (vcFile == null) - return false; - metaValue = Path.GetExtension(vcFile.FullPath); - break; - case "RelativeDir": - if (vcProj == null || vcFile == null) - return false; - metaValue = Path.GetDirectoryName(GetRelativePath( - Path.GetDirectoryName(vcProj.ProjectFile), - vcFile.FullPath)); - if (!metaValue.EndsWith("\\")) - metaValue += "\\"; - if (metaValue.StartsWith(".\\")) - metaValue = metaValue.Substring(2); - break; - case "Directory": - if (vcFile == null) - return false; - metaValue = Path.GetDirectoryName(GetRelativePath( - Path.GetPathRoot(vcFile.FullPath), - vcFile.FullPath)); - if (!metaValue.EndsWith("\\")) - metaValue += "\\"; - if (metaValue.StartsWith(".\\")) - metaValue = metaValue.Substring(2); - break; - case "Identity": - if (vcProj == null || vcFile == null) - return false; - metaValue = GetRelativePath( - Path.GetDirectoryName(vcProj.ProjectFile), - vcFile.FullPath); - if (metaValue.StartsWith(".\\")) - metaValue = metaValue.Substring(2); - break; - case "RecursiveDir": - case "ModifiedTime": - case "CreatedTime": - case "AccessedTime": + case "FullPath": + if (vcFile == null) return false; - default: - var vcFileConfig = config as VCFileConfiguration; - if (vcFileConfig == null) - return false; - var propStoreTool = vcFileConfig.Tool as IVCRulePropertyStorage; - if (propStoreTool == null) - return false; - try { - metaValue = propStoreTool.GetEvaluatedPropertyValue(metaName); - } catch { - return false; - } - break; + metaValue = vcFile.FullPath; + break; + case "RootDir": + if (vcFile == null) + return false; + metaValue = Path.GetPathRoot(vcFile.FullPath); + break; + case "Filename": + if (vcFile == null) + return false; + metaValue = Path.GetFileNameWithoutExtension(vcFile.FullPath); + break; + case "Extension": + if (vcFile == null) + return false; + metaValue = Path.GetExtension(vcFile.FullPath); + break; + case "RelativeDir": + if (vcProj == null || vcFile == null) + return false; + metaValue = Path.GetDirectoryName(GetRelativePath( + Path.GetDirectoryName(vcProj.ProjectFile), + vcFile.FullPath)); + if (!metaValue.EndsWith("\\")) + metaValue += "\\"; + if (metaValue.StartsWith(".\\")) + metaValue = metaValue.Substring(2); + break; + case "Directory": + if (vcFile == null) + return false; + metaValue = Path.GetDirectoryName(GetRelativePath( + Path.GetPathRoot(vcFile.FullPath), + vcFile.FullPath)); + if (!metaValue.EndsWith("\\")) + metaValue += "\\"; + if (metaValue.StartsWith(".\\")) + metaValue = metaValue.Substring(2); + break; + case "Identity": + if (vcProj == null || vcFile == null) + return false; + metaValue = GetRelativePath( + Path.GetDirectoryName(vcProj.ProjectFile), + vcFile.FullPath); + if (metaValue.StartsWith(".\\")) + metaValue = metaValue.Substring(2); + break; + case "RecursiveDir": + case "ModifiedTime": + case "CreatedTime": + case "AccessedTime": + return false; + default: + var vcFileConfig = config as VCFileConfiguration; + if (vcFileConfig == null) + return false; + var propStoreTool = vcFileConfig.Tool as IVCRulePropertyStorage; + if (propStoreTool == null) + return false; + try { + metaValue = propStoreTool.GetEvaluatedPropertyValue(metaName); + } catch { + return false; + } + break; } expanded = expanded.Replace(string.Format("%({0})", metaName), metaValue); } diff --git a/QtVsTools.Core/QtMsBuild.cs b/QtVsTools.Core/QtMsBuild.cs index 7ede2902..d8235f1a 100644 --- a/QtVsTools.Core/QtMsBuild.cs +++ b/QtVsTools.Core/QtMsBuild.cs @@ -446,14 +446,14 @@ namespace QtVsTools.Core.QtMsBuild IVSMacroExpander macros) { switch (itemType) { - case QtMoc.ItemTypeName: - return SetQtMocCommandLine(propertyStorage, commandLine, macros); - case QtRcc.ItemTypeName: - return SetQtRccCommandLine(propertyStorage, commandLine, macros); - case QtRepc.ItemTypeName: - return SetQtRepcCommandLine(propertyStorage, commandLine, macros); - case QtUic.ItemTypeName: - return SetQtUicCommandLine(propertyStorage, commandLine, macros); + case QtMoc.ItemTypeName: + return SetQtMocCommandLine(propertyStorage, commandLine, macros); + case QtRcc.ItemTypeName: + return SetQtRccCommandLine(propertyStorage, commandLine, macros); + case QtRepc.ItemTypeName: + return SetQtRepcCommandLine(propertyStorage, commandLine, macros); + case QtUic.ItemTypeName: + return SetQtUicCommandLine(propertyStorage, commandLine, macros); } return false; } diff --git a/QtVsTools.Core/QtProject.cs b/QtVsTools.Core/QtProject.cs index eb462b80..9a83c241 100644 --- a/QtVsTools.Core/QtProject.cs +++ b/QtVsTools.Core/QtProject.cs @@ -721,12 +721,12 @@ namespace QtVsTools.Core foreach (VCFileConfiguration config in (IVCCollection) file.FileConfigurations) { switch (toolSettings) { - case CustomTool.MSBuildTarget: - AddUic4BuildStepMsBuild(config, description, uiFileMacro); - break; - default: - AddUic4BuildStepCustomBuild(config, description, uiFileMacro); - break; + case CustomTool.MSBuildTarget: + AddUic4BuildStepMsBuild(config, description, uiFileMacro); + break; + default: + AddUic4BuildStepCustomBuild(config, description, uiFileMacro); + break; } var conf = config.ProjectConfiguration as VCConfiguration; @@ -1567,22 +1567,22 @@ namespace QtVsTools.Core try { foreach (VCFileConfiguration vfc in (IVCCollection) qrcFile.FileConfigurations) { switch (toolSettings) { - case CustomTool.MSBuildTarget: - UpdateRccStepMsBuild( - vfc, - rccOpts, - filesInQrcFile, - nameOnly, - qrcCppFile); - break; - default: - UpdateRccStepCustomBuild( - vfc, - rccOpts, - filesInQrcFile, - nameOnly, - qrcCppFile); - break; + case CustomTool.MSBuildTarget: + UpdateRccStepMsBuild( + vfc, + rccOpts, + filesInQrcFile, + nameOnly, + qrcCppFile); + break; + default: + UpdateRccStepCustomBuild( + vfc, + rccOpts, + filesInQrcFile, + nameOnly, + qrcCppFile); + break; } } if (toolSettings == CustomTool.CustomBuildStep) @@ -4061,38 +4061,38 @@ namespace QtVsTools.Core get { switch (itemType) { - case FileItemType.CustomBuild: - return (tool != null) ? tool.CommandLine : ""; - case FileItemType.QtMoc: - return qtMsBuild.GenerateQtMocCommandLine(vcConfig); - case FileItemType.QtRcc: - return qtMsBuild.GenerateQtRccCommandLine(vcConfig); - case FileItemType.QtRepc: - return qtMsBuild.GenerateQtRepcCommandLine(vcConfig); - case FileItemType.QtUic: - return qtMsBuild.GenerateQtUicCommandLine(vcConfig); + case FileItemType.CustomBuild: + return (tool != null) ? tool.CommandLine : ""; + case FileItemType.QtMoc: + return qtMsBuild.GenerateQtMocCommandLine(vcConfig); + case FileItemType.QtRcc: + return qtMsBuild.GenerateQtRccCommandLine(vcConfig); + case FileItemType.QtRepc: + return qtMsBuild.GenerateQtRepcCommandLine(vcConfig); + case FileItemType.QtUic: + return qtMsBuild.GenerateQtUicCommandLine(vcConfig); } return ""; } set { switch (itemType) { - case FileItemType.CustomBuild: - if (tool != null) - tool.CommandLine = value; - break; - case FileItemType.QtMoc: - qtMsBuild.SetQtMocCommandLine(vcConfig, value, macros); - break; - case FileItemType.QtRcc: - qtMsBuild.SetQtRccCommandLine(vcConfig, value, macros); - break; - case FileItemType.QtRepc: - qtMsBuild.SetQtRepcCommandLine(vcConfig, value, macros); - break; - case FileItemType.QtUic: - qtMsBuild.SetQtUicCommandLine(vcConfig, value, macros); - break; + case FileItemType.CustomBuild: + if (tool != null) + tool.CommandLine = value; + break; + case FileItemType.QtMoc: + qtMsBuild.SetQtMocCommandLine(vcConfig, value, macros); + break; + case FileItemType.QtRcc: + qtMsBuild.SetQtRccCommandLine(vcConfig, value, macros); + break; + case FileItemType.QtRepc: + qtMsBuild.SetQtRepcCommandLine(vcConfig, value, macros); + break; + case FileItemType.QtUic: + qtMsBuild.SetQtUicCommandLine(vcConfig, value, macros); + break; } } } @@ -4102,16 +4102,16 @@ namespace QtVsTools.Core get { switch (itemType) { - case FileItemType.CustomBuild: - return (tool != null) ? tool.Outputs : ""; - case FileItemType.QtMoc: - return qtMsBuild.GetPropertyValue(vcConfig, QtMoc.Property.OutputFile); - case FileItemType.QtRcc: - return qtMsBuild.GetPropertyValue(vcConfig, QtRcc.Property.OutputFile); - case FileItemType.QtRepc: - return qtMsBuild.GetPropertyValue(vcConfig, QtRepc.Property.OutputFile); - case FileItemType.QtUic: - return qtMsBuild.GetPropertyValue(vcConfig, QtUic.Property.OutputFile); + case FileItemType.CustomBuild: + return (tool != null) ? tool.Outputs : ""; + case FileItemType.QtMoc: + return qtMsBuild.GetPropertyValue(vcConfig, QtMoc.Property.OutputFile); + case FileItemType.QtRcc: + return qtMsBuild.GetPropertyValue(vcConfig, QtRcc.Property.OutputFile); + case FileItemType.QtRepc: + return qtMsBuild.GetPropertyValue(vcConfig, QtRepc.Property.OutputFile); + case FileItemType.QtUic: + return qtMsBuild.GetPropertyValue(vcConfig, QtUic.Property.OutputFile); } return ""; } |