1
- using Rubberduck . Parsing . Grammar ;
1
+ using Rubberduck . Common ;
2
+ using Rubberduck . Parsing . Grammar ;
2
3
using Rubberduck . Parsing . Symbols ;
3
4
using System ;
4
5
using System . Collections . Generic ;
@@ -11,19 +12,13 @@ public interface ICodeBuilder
11
12
/// <summary>
12
13
/// Returns ModuleBodyElementDeclaration signature with an ImprovedArgument list
13
14
/// </summary>
14
- /// <param name="declaration"></param>
15
- /// <returns></returns>
16
15
string ImprovedFullMemberSignature ( ModuleBodyElementDeclaration declaration ) ;
17
16
18
17
/// <summary>
19
18
/// Returns a ModuleBodyElementDeclaration block
20
19
/// with an ImprovedArgument List
21
20
/// </summary>
22
- /// <param name="declaration"></param>
23
21
/// <param name="content">Main body content/logic of the member</param>
24
- /// <param name="accessibility"></param>
25
- /// <param name="newIdentifier"></param>
26
- /// <returns></returns>
27
22
string BuildMemberBlockFromPrototype ( ModuleBodyElementDeclaration declaration ,
28
23
string content = null ,
29
24
string accessibility = null ,
@@ -34,19 +29,14 @@ string BuildMemberBlockFromPrototype(ModuleBodyElementDeclaration declaration,
34
29
/// 1. Explicitly declares Property Let\Set value parameter as ByVal
35
30
/// 2. Ensures UserDefined Type parameters are declared either explicitly or implicitly as ByRef
36
31
/// </summary>
37
- /// <param name="declaration"></param>
38
- /// <returns></returns>
39
32
string ImprovedArgumentList ( ModuleBodyElementDeclaration declaration ) ;
40
33
41
34
/// <summary>
42
35
/// Generates a Property Get codeblock based on the prototype declaration
43
36
/// </summary>
44
37
/// <param name="prototype">VariableDeclaration or UserDefinedTypeMember</param>
45
- /// <param name="propertyIdentifier"></param>
46
- /// <param name="accessibility"></param>
47
38
/// <param name="content">Member body content. Formatting is the responsibility of the caller</param>
48
- /// <param name="parameterIdentifier">Defaults to 'value' unless otherwise specified</param>
49
- /// <returns></returns>
39
+ /// <param name="parameterIdentifier">Defaults to '<paramref name="propertyIdentifier"/>Value' unless otherwise specified</param>
50
40
bool TryBuildPropertyGetCodeBlock ( Declaration prototype ,
51
41
string propertyIdentifier ,
52
42
out string codeBlock ,
@@ -57,11 +47,8 @@ bool TryBuildPropertyGetCodeBlock(Declaration prototype,
57
47
/// Generates a Property Let codeblock based on the prototype declaration
58
48
/// </summary>
59
49
/// <param name="prototype">VariableDeclaration or UserDefinedTypeMember</param>
60
- /// <param name="propertyIdentifier"></param>
61
- /// <param name="accessibility"></param>
62
- /// <param name="content">Membmer body content. Formatting is the responsibility of the caller</param>
63
- /// <param name="parameterIdentifier">Defaults to 'value' unless otherwise specified</param>
64
- /// <returns></returns>
50
+ /// <param name="content">Member body content. Formatting is the responsibility of the caller</param>
51
+ /// <param name="parameterIdentifier">Defaults to '<paramref name="propertyIdentifier"/>Value' unless otherwise specified</param>
65
52
bool TryBuildPropertyLetCodeBlock ( Declaration prototype ,
66
53
string propertyIdentifier ,
67
54
out string codeBlock ,
@@ -73,21 +60,28 @@ bool TryBuildPropertyLetCodeBlock(Declaration prototype,
73
60
/// Generates a Property Set codeblock based on the prototype declaration
74
61
/// </summary>
75
62
/// <param name="prototype">VariableDeclaration or UserDefinedTypeMember</param>
76
- /// <param name="propertyIdentifier"></param>
77
- /// <param name="accessibility"></param>
78
- /// <param name="content">Membmer body content. Formatting is the responsibility of the caller</param>
79
- /// <param name="parameterIdentifier">Defaults to 'value' unless otherwise specified</param>
80
- /// <returns></returns>
63
+ /// <param name="content">Member body content. Formatting is the responsibility of the caller</param>
64
+ /// <param name="parameterIdentifier">Defaults to '<paramref name="propertyIdentifier"/>Value' unless otherwise specified</param>
81
65
bool TryBuildPropertySetCodeBlock ( Declaration prototype ,
82
66
string propertyIdentifier ,
83
67
out string codeBlock ,
84
68
string accessibility = null ,
85
69
string content = null ,
86
70
string parameterIdentifier = null ) ;
71
+ /// <summary>
72
+ /// Generates a default RHS property parameter IdentifierName
73
+ /// </summary>
74
+ /// <param name="propertyIdentifier">Let/Set Property IdentifierName</param>
75
+ string DefaultPropertyValueParamIdentifier ( string propertyIdentifier ) ;
87
76
}
88
77
89
78
public class CodeBuilder : ICodeBuilder
90
79
{
80
+ private static string ParameterSuffix => Resources . RubberduckUI . EncapsulateField_DefaultPropertyParameter . Capitalize ( ) ;
81
+
82
+ public string DefaultPropertyValueParamIdentifier ( string propertyIdentifier )
83
+ => $ "{ propertyIdentifier . ToLowerCaseFirstLetter ( ) } { ParameterSuffix } ";
84
+
91
85
public string BuildMemberBlockFromPrototype ( ModuleBodyElementDeclaration declaration ,
92
86
string content = null ,
93
87
string accessibility = null ,
@@ -127,7 +121,7 @@ private bool TryBuildPropertyBlockFromTarget<T>(T prototype, DeclarationType let
127
121
return false ;
128
122
}
129
123
130
- var propertyValueParam = parameterIdentifier ?? Resources . RubberduckUI . EncapsulateField_DefaultPropertyParameter ;
124
+ var propertyValueParam = parameterIdentifier ?? DefaultPropertyValueParamIdentifier ( propertyIdentifier ) ;
131
125
132
126
var asType = prototype . IsArray
133
127
? $ "{ Tokens . Variant } "
0 commit comments