@@ -18,27 +18,18 @@ public class AssignedByValParameterMakeLocalCopyQuickFix : QuickFixBase
18
18
{
19
19
private readonly Declaration _target ;
20
20
private readonly IAssignedByValParameterQuickFixDialogFactory _dialogFactory ;
21
- //<<<<<<< HEAD
22
21
private readonly RubberduckParserState _parserState ;
23
- // private string[] _variableNamesAccessibleToProcedureContext;
24
- //=======
25
22
private readonly IEnumerable < string > _forbiddenNames ;
26
- //>>>>>>> rubberduck-vba/next
27
23
private string _localCopyVariableName ;
28
24
29
25
public AssignedByValParameterMakeLocalCopyQuickFix ( Declaration target , QualifiedSelection selection , RubberduckParserState parserState , IAssignedByValParameterQuickFixDialogFactory dialogFactory )
30
26
: base ( target . Context , selection , InspectionsUI . AssignedByValParameterMakeLocalCopyQuickFix )
31
27
{
32
28
_target = target ;
33
29
_dialogFactory = dialogFactory ;
34
- //<<<<<<< HEAD
35
30
_parserState = parserState ;
36
- //_variableNamesAccessibleToProcedureContext = GetUserDefinedNamesAccessibleToProcedureContext(_target.Context.Parent.Parent);
37
- //SetValidLocalCopyVariableNameSuggestion();
38
- //=======
39
31
_forbiddenNames = GetIdentifierNamesAccessibleToProcedureContext ( target . Context . Parent . Parent ) ;
40
32
_localCopyVariableName = ComputeSuggestedName ( ) ;
41
- //>>>>>>> rubberduck-vba/next
42
33
}
43
34
44
35
public override bool CanFixInModule { get { return false ; } }
@@ -108,16 +99,12 @@ private void ReplaceAssignedByValParameterReferences()
108
99
109
100
private void InsertLocalVariableDeclarationAndAssignment ( )
110
101
{
111
- //<<<<<<< HEAD
112
- //var blocks = QuickFixHelper.GetBlockStmtContexts(_target.Context.Parent.Parent);
113
- //=======
114
102
var block = QuickFixHelper . GetBlockStmtContexts ( _target . Context . Parent . Parent ) . FirstOrDefault ( ) ;
115
103
if ( block == null )
116
104
{
117
105
return ;
118
106
}
119
107
120
- //>>>>>>> rubberduck-vba/next
121
108
string [ ] lines = { BuildLocalCopyDeclaration ( ) , BuildLocalCopyAssignment ( ) } ;
122
109
var module = Selection . QualifiedName . Component . CodeModule ;
123
110
module . InsertLines ( block . Start . Line , lines ) ;
@@ -134,11 +121,7 @@ private string BuildLocalCopyAssignment()
134
121
+ _localCopyVariableName + " = " + _target . IdentifierName ;
135
122
}
136
123
137
- //<<<<<<< HEAD
138
- // private string[] GetUserDefinedNamesAccessibleToProcedureContext(RuleContext ruleContext)
139
- //=======
140
124
private IEnumerable < string > GetIdentifierNamesAccessibleToProcedureContext ( RuleContext ruleContext )
141
- //>>>>>>> rubberduck-vba/next
142
125
{
143
126
var allIdentifiers = new HashSet < string > ( ) ;
144
127
@@ -180,7 +163,6 @@ private IEnumerable<string> GetIdentifierNamesAccessibleToProcedureContext(RuleC
180
163
return allIdentifiers . ToArray ( ) ;
181
164
}
182
165
183
- //<<<<<<< HEAD
184
166
private HashSet < string > GetVariableNamesFromRuleContexts ( RuleContext [ ] ruleContexts )
185
167
{
186
168
var tokenValues = typeof ( Tokens ) . GetFields ( ) . Select ( item => item . GetValue ( null ) ) . Cast < string > ( ) . Select ( item => item ) ;
@@ -203,50 +185,26 @@ private HashSet<RuleContext> GetIdentifierContexts(IReadOnlyList<RuleContext> ru
203
185
foreach ( RuleContext ruleContext in ruleContexts )
204
186
{
205
187
var identifiersForThisContext = GetIdentifierContexts ( ruleContext ) ;
206
- //=======
207
- // private IEnumerable<string> GetIdentifierNames(IEnumerable<RuleContext> ruleContexts)
208
- // {
209
- // var identifiers = new HashSet<string>();
210
- // foreach (var identifiersForThisContext in ruleContexts.Select(GetIdentifierNames))
211
- // {
212
- //>>>>>>> rubberduck-vba/next
213
188
identifiers . UnionWith ( identifiersForThisContext ) ;
214
189
}
215
190
return identifiers ;
216
191
}
217
192
218
- //<<<<<<< HEAD
219
193
private HashSet < RuleContext > GetIdentifierContexts ( RuleContext ruleContext )
220
- //=======
221
- // private static HashSet<string> GetIdentifierNames(RuleContext ruleContext)
222
- //>>>>>>> rubberduck-vba/next
223
194
{
224
195
// note: this looks like something that's already handled somewhere else...
225
196
226
197
//Recursively work through the tree to get all IdentifierContexts
227
- //<<<<<<< HEAD
228
198
var results = new HashSet < RuleContext > ( ) ;
229
- //=======
230
- // var results = new HashSet<string>();
231
- // var tokenValues = typeof(Tokens).GetFields().Select(item => item.GetValue(null)).Cast<string>().Select(item => item).ToArray();
232
- //>>>>>>> rubberduck-vba/next
233
199
var children = GetChildren ( ruleContext ) ;
234
200
235
201
foreach ( var child in children )
236
202
{
237
203
var context = child as VBAParser . IdentifierContext ;
238
204
if ( context != null )
239
205
{
240
- //<<<<<<< HEAD
241
- var childName = Identifier . GetName ( ( VBAParser . IdentifierContext ) child ) ;
206
+ //var childName = Identifier.GetName((VBAParser.IdentifierContext)child);
242
207
results . Add ( ( RuleContext ) child ) ;
243
- //=======
244
- // var childName = Identifier.GetName(context);
245
- // if (!tokenValues.Contains(childName))
246
- // {
247
- // results.Add(childName);
248
- // }
249
- //>>>>>>> rubberduck-vba/next
250
208
}
251
209
else
252
210
{
0 commit comments