diff options
author | Rodrigo Moya <rodrigo.moya@xamarin.com> | 2019-06-20 15:03:26 +0300 |
---|---|---|
committer | Rodrigo Moya <rodrigo.moya@xamarin.com> | 2019-07-01 11:31:36 +0300 |
commit | 36e900db588cd3a70e188dddafc5a3e481b5fd93 (patch) | |
tree | c219413858f95222d4314c37bca7b11650677e82 /main/src/core/MonoDevelop.Core | |
parent | f2d9d3da8cbe60cfefa26aa2ea1a2b63fd8bd55a (diff) |
[Projects] Use FilePath in API refering to files
Diffstat (limited to 'main/src/core/MonoDevelop.Core')
3 files changed, 14 insertions, 13 deletions
diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.FileNesting/FileNestingService.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.FileNesting/FileNestingService.cs index 757b6372aa..20a6043c44 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.FileNesting/FileNestingService.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.FileNesting/FileNestingService.cs @@ -54,7 +54,7 @@ namespace MonoDevelop.Projects.FileNesting } } - public static string GetParentFile (string inputFile) + public static FilePath GetParentFile (FilePath inputFile) { if (rulesProviders == null) { rulesProviders = ImmutableList<NestingRulesProvider>.Empty.AddRange (AddinManager.GetExtensionObjects<NestingRulesProvider> ()); diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.FileNesting/NestingRule.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.FileNesting/NestingRule.cs index 589c5c6362..48b61be3a6 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.FileNesting/NestingRule.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.FileNesting/NestingRule.cs @@ -59,7 +59,7 @@ namespace MonoDevelop.Projects.FileNesting public string AppliesTo { get; private set; } - bool CheckParentForFile (string inputFile, string parentFile) + bool CheckParentForFile (FilePath inputFile, FilePath parentFile) { if (File.Exists (parentFile) && inputFile != parentFile) { LoggingService.LogInfo ($"Applied rule for nesting {inputFile} under {parentFile}"); @@ -69,7 +69,7 @@ namespace MonoDevelop.Projects.FileNesting return false; } - public string GetParentFile (string inputFile) + public FilePath GetParentFile (FilePath inputFile) { string parentFile, inputExtension; @@ -79,7 +79,7 @@ namespace MonoDevelop.Projects.FileNesting case NestingRuleKind.AddedExtension: // This is the simplest rules, and applies to all files, if we find a file // with the same name minus the extension, that's the parent. - parentFile = Path.Combine (Path.GetDirectoryName (inputFile), Path.GetFileNameWithoutExtension (inputFile)); + parentFile = inputFile.ParentDirectory.Combine (inputFile.FileNameWithoutExtension); if (CheckParentForFile (inputFile, parentFile)) return parentFile; break; @@ -87,7 +87,7 @@ namespace MonoDevelop.Projects.FileNesting case NestingRuleKind.AllExtensions: if (AppliesTo == AllFilesWildcard || AppliesTo == inputExtension) { foreach (var pt in patterns) { - parentFile = Path.Combine (Path.GetDirectoryName (inputFile), $"{Path.GetFileNameWithoutExtension (inputFile)}{pt}"); + parentFile = inputFile.ParentDirectory.Combine ($"{Path.GetFileNameWithoutExtension (inputFile)}{pt}"); if (CheckParentForFile (inputFile, parentFile)) return parentFile; } @@ -97,7 +97,7 @@ namespace MonoDevelop.Projects.FileNesting case NestingRuleKind.ExtensionToExtension: if (inputExtension == AppliesTo) { foreach (var pt in patterns) { - parentFile = Path.Combine (Path.GetDirectoryName (inputFile), $"{Path.GetFileNameWithoutExtension (inputFile)}{pt}"); + parentFile = inputFile.ParentDirectory.Combine ($"{Path.GetFileNameWithoutExtension (inputFile)}{pt}"); if (CheckParentForFile (inputFile, parentFile)) return parentFile; } @@ -105,10 +105,11 @@ namespace MonoDevelop.Projects.FileNesting break; case NestingRuleKind.FileSuffixToExtension: - if (inputFile.EndsWith (AppliesTo, StringComparison.OrdinalIgnoreCase)) { - int suffixPosition = inputFile.LastIndexOf (AppliesTo, StringComparison.OrdinalIgnoreCase); + string inputFileString = inputFile; + if (inputFileString.EndsWith (AppliesTo, StringComparison.OrdinalIgnoreCase)) { + int suffixPosition = inputFileString.LastIndexOf (AppliesTo, StringComparison.OrdinalIgnoreCase); foreach (var pt in patterns) { - parentFile = inputFile.Remove (suffixPosition, AppliesTo.Length).Insert (suffixPosition, pt); + parentFile = inputFileString.Remove (suffixPosition, AppliesTo.Length).Insert (suffixPosition, pt); if (CheckParentForFile (inputFile, parentFile)) { return parentFile; } @@ -119,7 +120,7 @@ namespace MonoDevelop.Projects.FileNesting case NestingRuleKind.FileToFile: if (AppliesTo == Path.GetFileName (inputFile)) { foreach (var pt in patterns) { - parentFile = Path.Combine (Path.GetDirectoryName (inputFile), pt); + parentFile = inputFile.ParentDirectory.Combine (pt); if (CheckParentForFile (inputFile, parentFile)) { return parentFile; } @@ -131,7 +132,7 @@ namespace MonoDevelop.Projects.FileNesting if (AppliesTo == AllFilesWildcard || AppliesTo == inputExtension) { foreach (var pt in patterns) { // Search for $filename.$extension for $filename.$path_segment.$extension - parentFile = Path.Combine (Path.GetDirectoryName (inputFile), $"{Path.GetFileNameWithoutExtension (Path.GetFileNameWithoutExtension (inputFile))}{inputExtension}"); + parentFile = inputFile.ParentDirectory.Combine ($"{Path.GetFileNameWithoutExtension (Path.GetFileNameWithoutExtension (inputFile))}{inputExtension}"); if (CheckParentForFile (inputFile, parentFile)) { return parentFile; } diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.FileNesting/NestingRulesProvider.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.FileNesting/NestingRulesProvider.cs index 0fbcd0600d..39d3a04610 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.FileNesting/NestingRulesProvider.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.FileNesting/NestingRulesProvider.cs @@ -125,7 +125,7 @@ namespace MonoDevelop.Projects.FileNesting return false; } - public string GetParentFile (string inputFile) + public FilePath GetParentFile (FilePath inputFile) { if (nestingRules == null) { if (!File.Exists (SourceFile)) { @@ -138,7 +138,7 @@ namespace MonoDevelop.Projects.FileNesting } foreach (var rule in nestingRules) { - string parentFile = rule.GetParentFile (inputFile); + FilePath parentFile = rule.GetParentFile (inputFile); if (!String.IsNullOrEmpty (parentFile)) { // Stop at the 1st rule found return parentFile; |