Skip to content

Commit 0eb5b8d

Browse files
committed
Addressed comments to PR #3735.
1 parent 2a67236 commit 0eb5b8d

File tree

5 files changed

+37
-23
lines changed

5 files changed

+37
-23
lines changed

RetailCoder.VBE/UI/Command/AddTestMethodCommand.cs

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,16 +84,18 @@ protected override void OnExecute(object parameter)
8484
var declaration = _state.GetTestModules()
8585
.FirstOrDefault(f => _state.ProjectsProvider.Component(f.QualifiedModuleName).HasEqualCodeModule(module));
8686

87-
if (declaration != null)
87+
if (declaration == null)
8888
{
89-
string name;
90-
using (var component = module.Parent)
91-
{
92-
name = GetNextTestMethodName(component);
93-
}
94-
var body = TestMethodTemplate.Replace(NamePlaceholder, name);
95-
module.InsertLines(module.CountOfLines, body);
89+
return;
9690
}
91+
92+
string name;
93+
using (var component = module.Parent)
94+
{
95+
name = GetNextTestMethodName(component);
96+
}
97+
var body = TestMethodTemplate.Replace(NamePlaceholder, name);
98+
module.InsertLines(module.CountOfLines, body);
9799
}
98100
}
99101
_state.OnParseRequested(this);

Rubberduck.Parsing/Symbols/DeclarationSymbolsListener.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,6 @@ private IEnumerable<IAnnotation> FindAnnotations()
9494
}
9595

9696
int lastDeclarationsSectionLine;
97-
9897
using (var codeModule = _state.ProjectsProvider.Component(_qualifiedModuleName).CodeModule)
9998
{
10099
lastDeclarationsSectionLine = codeModule.CountOfDeclarationLines;

Rubberduck.Parsing/VBA/ParseRunnerBase.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,10 @@ private void ProcessComponentParseResults(QualifiedModuleName module, Task<Compo
104104
lock (_state)
105105
{
106106
token.ThrowIfCancellationRequested();
107-
_state.SetModuleAttributes(module, result.Attributes); //This has to come first because it creates the module state if not present.
107+
108+
//This has to come first because it creates the module state if not present.
109+
_state.SetModuleAttributes(module, result.Attributes);
110+
108111
_state.AddTokenStream(module, result.Tokens);
109112
_state.AddParseTree(module, result.ParseTree);
110113
_state.AddParseTree(module, result.AttributesTree, ParsePass.AttributesPass);

Rubberduck.Parsing/VBA/ReferenceResolveRunnerBase.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ private Declaration SupertypeForDocument(QualifiedModuleName module, RubberduckP
173173
var allNamesMatch = true;
174174
for (var i = 0; i < coclass.Key.Count; i++)
175175
{
176-
using(var property = properties[i+1])
176+
using (var property = properties[i+1])
177177
{
178178
if (coclass.Key[i] != property?.Name)
179179
{

Rubberduck.VBEEditor/ComManagement/ProjectsRepository.cs

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ private void ExecuteWithinWriteLock(Action action)
8686
{
8787
if (_disposed)
8888
{
89-
return; //The lock has already been diposed.
89+
return; //The lock has already been disposed.
9090
}
9191

9292
var writeLockTaken = false;
@@ -113,11 +113,16 @@ private void RefreshCollections()
113113
var componentCollections = ClearComWrapperDictionary(_componentsCollections);
114114
var components = ClearComWrapperDictionary(_components);
115115

116-
LoadCollections();
117-
118-
DisposeWrapperEnumerable(projects);
119-
DisposeWrapperEnumerable(componentCollections);
120-
DisposeWrapperEnumerable(components);
116+
try
117+
{
118+
LoadCollections();
119+
}
120+
finally
121+
{
122+
DisposeWrapperEnumerable(projects);
123+
DisposeWrapperEnumerable(componentCollections);
124+
DisposeWrapperEnumerable(components);
125+
}
121126
}
122127

123128
private IEnumerable<TWrapper> ClearComWrapperDictionary<TKey, TWrapper>(IDictionary<TKey, TWrapper> dictionary)
@@ -152,11 +157,16 @@ private void RefreshCollections(string projectId)
152157
_components.Remove(qmn);
153158
}
154159

155-
_componentsCollections[projectId] = project.VBComponents;
156-
LoadComponents(_componentsCollections[projectId]);
157-
158-
componentsCollection.Dispose();
159-
DisposeWrapperEnumerable(components.Select(kvp => kvp.Value));
160+
try
161+
{
162+
_componentsCollections[projectId] = project.VBComponents;
163+
LoadComponents(_componentsCollections[projectId]);
164+
}
165+
finally
166+
{
167+
componentsCollection.Dispose();
168+
DisposeWrapperEnumerable(components.Select(kvp => kvp.Value));
169+
}
160170
}
161171

162172
public void Refresh(string projectId)
@@ -178,7 +188,7 @@ private T EvaluateWithinReadLock<T>(Func<T> function) where T: class
178188
{
179189
if (_disposed)
180190
{
181-
return default(T); //The lock has already been diposed.
191+
return default(T); //The lock has already been disposed.
182192
}
183193

184194
var readLockTaken = false;

0 commit comments

Comments
 (0)