Skip to content

Commit 9db29d9

Browse files
committed
Add NewLines Resource class
1 parent 84c2173 commit 9db29d9

File tree

4 files changed

+19
-12
lines changed

4 files changed

+19
-12
lines changed

Rubberduck.Refactorings/EncapsulateField/EncapsulateFieldInsertNewCode/EncapsulateFieldInsertNewCodeRefactoringAction.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,7 @@ private void InsertBlocks(EncapsulateFieldInsertNewCodeModel model, IRewriteSess
9090
return;
9191
}
9292

93-
var doubleSpace = $"{Environment.NewLine}{Environment.NewLine}";
94-
95-
var allNewContent = string.Join(doubleSpace, new string[] { newDeclarationSectionBlock });
93+
var allNewContent = string.Join(NewLines.DOUBLE_SPACE, new string[] { newDeclarationSectionBlock });
9694

9795
var previewMarker = model.NewContentAggregator.RetrieveBlock(RubberduckUI.EncapsulateField_PreviewMarker);
9896
if (!string.IsNullOrEmpty(previewMarker))
@@ -109,10 +107,10 @@ private void InsertBlocks(EncapsulateFieldInsertNewCodeModel model, IRewriteSess
109107

110108
if (codeSectionStartIndex.HasValue)
111109
{
112-
rewriter.InsertBefore(codeSectionStartIndex.Value, $"{allNewContent}{doubleSpace}");
110+
rewriter.InsertBefore(codeSectionStartIndex.Value, $"{allNewContent}{NewLines.DOUBLE_SPACE}");
113111
return;
114112
}
115-
rewriter.InsertBefore(rewriter.TokenStream.Size - 1, $"{doubleSpace}{allNewContent}");
113+
rewriter.InsertBefore(rewriter.TokenStream.Size - 1, $"{NewLines.DOUBLE_SPACE}{allNewContent}");
116114
}
117115
}
118116
}

Rubberduck.Refactorings/EncapsulateField/EncapsulateFieldInsertNewCode/NewContentAggregator.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System;
22
using System.Collections.Generic;
33
using System.Linq;
4+
using Rubberduck.Resources;
45

56
namespace Rubberduck.Refactorings.EncapsulateField
67
{
@@ -49,7 +50,6 @@ public interface INewContentAggregator
4950
/// </summary>
5051
public class NewContentAggregator : INewContentAggregator
5152
{
52-
private readonly static string _doubleSpace = $"{Environment.NewLine}{Environment.NewLine}";
5353
private readonly Dictionary<NewContentType, List<string>> _newContent;
5454
private Dictionary<string, List<string>> _unStructuredContent;
5555

@@ -90,12 +90,12 @@ public string RetrieveBlock(params NewContentType[] newContentTypes)
9090
var block = string.Empty;
9191
foreach (var newContentType in newContentTypes)
9292
{
93-
var newContent = string.Join(_doubleSpace, _newContent[newContentType]);
93+
var newContent = string.Join(NewLines.DOUBLE_SPACE, _newContent[newContentType]);
9494
if (!string.IsNullOrEmpty(newContent))
9595
{
9696
block = string.IsNullOrEmpty(block)
9797
? newContent
98-
: $"{block}{_doubleSpace}{newContent}";
98+
: $"{block}{NewLines.DOUBLE_SPACE}{newContent}";
9999
}
100100
}
101101
return LimitNewLines(block.Trim(), NewLineLimit);
@@ -108,12 +108,12 @@ public string RetrieveBlock(params string[] contentIdentifiers)
108108
{
109109
if (_unStructuredContent.TryGetValue(identifier, out var adHocContent))
110110
{
111-
var newContent = string.Join(_doubleSpace, adHocContent);
111+
var newContent = string.Join(NewLines.DOUBLE_SPACE, adHocContent);
112112
if (!string.IsNullOrEmpty(newContent))
113113
{
114114
block = string.IsNullOrEmpty(block)
115115
? newContent
116-
: $"{block}{_doubleSpace}{newContent}";
116+
: $"{block}{NewLines.DOUBLE_SPACE}{newContent}";
117117
}
118118
}
119119
}

Rubberduck.Refactorings/ImplementInterface/AddInterfaceImplementations/AddInterfaceImplementationsRefactoringAction.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
using Rubberduck.Parsing.Grammar;
55
using Rubberduck.Parsing.Rewriter;
66
using Rubberduck.Parsing.Symbols;
7-
7+
using Rubberduck.Resources;
88

99
namespace Rubberduck.Refactorings.AddInterfaceImplementations
1010
{
@@ -68,7 +68,7 @@ private string GetInterfaceMember(Declaration member, string interfaceName)
6868
members.Add(propertySet);
6969
}
7070

71-
return string.Join($"{Environment.NewLine}{Environment.NewLine}", members);
71+
return string.Join($"{NewLines.DOUBLE_SPACE}", members);
7272
}
7373

7474
return string.Empty;

Rubberduck.Resources/NewLines.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using System;
2+
3+
namespace Rubberduck.Resources
4+
{
5+
public static class NewLines
6+
{
7+
public static readonly string DOUBLE_SPACE = $"{Environment.NewLine}{Environment.NewLine}";
8+
}
9+
}

0 commit comments

Comments
 (0)