Skip to content

Commit c74a87a

Browse files
committed
Merge branch 'next' into IntroducingDisposalActionContainer
2 parents 91f4c5f + 8e13d6e commit c74a87a

File tree

73 files changed

+580
-511
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+580
-511
lines changed

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ If you like this project and would like to thank its contributors, you are welco
88
[![GoFundMe campaign](https://user-images.githubusercontent.com/5751684/29191799-e3d20b72-7dec-11e7-8ec6-0c69da4a3135.png)](https://www.gofundme.com/rubberduckvba)
99
-->
1010

11-
Branch | Description | Build Status |
12-
|------------|---|--------------|
13-
| **master** | The last released build | ![master branch build status][masterBuildStatus] |
14-
| **next** | The current build (dev) | ![next branch build status][nextBuildStatus] |
11+
|Branch | Description | Build Status | Download link |
12+
|------------|---|--------------|-|
13+
| **master** | The last released build | ![master branch build status][masterBuildStatus] | [stable](https://github.com/rubberduck-vba/Rubberduck/releases/latest) |
14+
| **next** | The current build (dev) | ![next branch build status][nextBuildStatus] | [dev](https://github.com/rubberduck-vba/Rubberduck/releases) |
1515

1616
[nextBuildStatus]:https://ci.appveyor.com/api/projects/status/we3pdnkeebo4nlck/branch/next?svg=true
1717
[masterBuildStatus]:https://ci.appveyor.com/api/projects/status/we3pdnkeebo4nlck/branch/master?svg=true
@@ -26,7 +26,8 @@ Branch | Description | Build Status |
2626

2727
* [Attributions](https://github.com/rubberduck-vba/Rubberduck/blob/next/docs/Attributions.md)
2828
* [About](https://github.com/rubberduck-vba/Rubberduck/blob/next/docs/About.md)
29-
* [Getting Started](https://github.com/rubberduck-vba/Rubberduck/blob/next/docs/GettingStarted.md)
29+
* [Installing](https://github.com/rubberduck-vba/Rubberduck/wiki/Installing)
30+
* [Getting Started](https://github.com/rubberduck-vba/Rubberduck/blob/next/docs/GettingStarted.md) using Rubberduck
3031
* [Contributing](https://github.com/rubberduck-vba/Rubberduck/blob/next/CONTRIBUTING.md)
3132

3233
---

RetailCoder.VBE/Navigation/CodeExplorer/CodeExplorerViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ private void UpdateNodes(IEnumerable<CodeExplorerItemViewModel> oldList, IEnumer
360360
}
361361
}
362362

363-
private void ParserState_ModuleStateChanged(object sender, Parsing.ParseProgressEventArgs e)
363+
private void ParserState_ModuleStateChanged(object sender, ParseProgressEventArgs e)
364364
{
365365
// if we are resolving references, we already have the declarations and don't need to display error
366366
if (!(e.State == ParserState.Error ||

RetailCoder.VBE/UI/Inspections/InspectionResultsViewModel.cs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ private void _configService_SettingsChanged(object sender, ConfigurationChangedE
102102
{
103103
if (e.InspectionSettingsChanged)
104104
{
105-
RefreshInspections();
105+
RefreshCommand.Execute(null);
106106
}
107107
_runInspectionsOnReparse = e.RunInspectionsOnReparse;
108108
}
@@ -269,7 +269,7 @@ public bool IsBusy
269269
}
270270

271271
private bool _runInspectionsOnReparse;
272-
private void HandleStateChanged(object sender, EventArgs e)
272+
private void HandleStateChanged(object sender, ParserStateEventArgs e)
273273
{
274274
if(!IsRefreshing && (_state.Status == ParserState.Pending || _state.Status == ParserState.Error || _state.Status == ParserState.ResolverError))
275275
{
@@ -284,16 +284,27 @@ private void HandleStateChanged(object sender, EventArgs e)
284284

285285
if (_runInspectionsOnReparse || IsRefreshing)
286286
{
287-
RefreshInspections();
287+
RefreshInspections(e.Token);
288288
}
289289
}
290290

291-
private async void RefreshInspections()
291+
private async void RefreshInspections(CancellationToken token)
292292
{
293293
var stopwatch = Stopwatch.StartNew();
294294
IsBusy = true;
295295

296-
var results = (await _inspector.FindIssuesAsync(_state, CancellationToken.None)).ToList();
296+
List<IInspectionResult> results;
297+
try
298+
{
299+
var inspectionResults = await _inspector.FindIssuesAsync(_state, token);
300+
results = inspectionResults.ToList();
301+
}
302+
catch (OperationCanceledException)
303+
{
304+
Logger.Debug("Inspections got canceled.");
305+
return; //We throw away the partial results.
306+
}
307+
297308
if (GroupByInspectionType)
298309
{
299310
results = results.OrderBy(o => o.Inspection.InspectionType)

Rubberduck.Inspections/Abstract/InspectionBase.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using Rubberduck.Parsing.VBA;
1010
using Rubberduck.VBEditor;
1111
using System.Diagnostics;
12+
using System.Threading;
1213
using NLog;
1314

1415
namespace Rubberduck.Inspections.Abstract
@@ -156,8 +157,9 @@ public int CompareTo(object obj)
156157
/// <summary>
157158
/// A method that inspects the parser state and returns all issues it can find.
158159
/// </summary>
160+
/// <param name="token"></param>
159161
/// <returns></returns>
160-
public IEnumerable<IInspectionResult> GetInspectionResults()
162+
public IEnumerable<IInspectionResult> GetInspectionResults(CancellationToken token)
161163
{
162164
var _stopwatch = new Stopwatch();
163165
_stopwatch.Start();

Rubberduck.Inspections/Inspector.cs

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,23 +61,27 @@ public async Task<IEnumerable<IInspectionResult>> FindIssuesAsync(RubberduckPars
6161
{
6262
return new IInspectionResult[] { };
6363
}
64+
token.ThrowIfCancellationRequested();
6465

6566
state.OnStatusMessageUpdate(RubberduckUI.CodeInspections_Inspecting);
6667
var allIssues = new ConcurrentBag<IInspectionResult>();
68+
token.ThrowIfCancellationRequested();
6769

6870
var config = _configService.LoadConfiguration();
6971
UpdateInspectionSeverity(config);
72+
token.ThrowIfCancellationRequested();
7073

7174
var parseTreeInspections = _inspections
7275
.Where(inspection => inspection.Severity != CodeInspectionSeverity.DoNotShow)
7376
.OfType<IParseTreeInspection>()
7477
.ToArray();
78+
token.ThrowIfCancellationRequested();
7579

76-
foreach(var listener in parseTreeInspections.Select(inspection => inspection.Listener))
80+
foreach (var listener in parseTreeInspections.Select(inspection => inspection.Listener))
7781
{
7882
listener.ClearContexts();
7983
}
80-
84+
8185
// Prepare ParseTreeWalker based inspections
8286
var passes = Enum.GetValues(typeof (ParsePass)).Cast<ParsePass>();
8387
foreach (var parsePass in passes)
@@ -91,8 +95,10 @@ public async Task<IEnumerable<IInspectionResult>> FindIssuesAsync(RubberduckPars
9195
LogManager.GetCurrentClassLogger().Warn(e);
9296
}
9397
}
98+
token.ThrowIfCancellationRequested();
9499

95100
var inspectionsToRun = _inspections.Where(inspection => inspection.Severity != CodeInspectionSeverity.DoNotShow);
101+
token.ThrowIfCancellationRequested();
96102

97103
try
98104
{
@@ -102,12 +108,15 @@ public async Task<IEnumerable<IInspectionResult>> FindIssuesAsync(RubberduckPars
102108
{
103109
if (exception.Flatten().InnerExceptions.All(ex => ex is OperationCanceledException))
104110
{
105-
LogManager.GetCurrentClassLogger().Debug("Inspections got canceled.");
106-
}
107-
else
108-
{
109-
LogManager.GetCurrentClassLogger().Error(exception);
111+
//This eliminates the stack trace, but for the cancellation, this is irrelevant.
112+
throw exception.InnerException ?? exception;
110113
}
114+
115+
LogManager.GetCurrentClassLogger().Error(exception);
116+
}
117+
catch (OperationCanceledException)
118+
{
119+
throw;
111120
}
112121
catch (Exception e)
113122
{
@@ -137,21 +146,27 @@ private static void RunInspectionsInParallel(IEnumerable<IInspection> inspection
137146

138147
Parallel.ForEach(inspectionsToRun,
139148
options,
140-
inspection => RunInspection(inspection, allIssues)
149+
inspection => RunInspection(inspection, allIssues, token)
141150
);
142151
}
143152

144-
private static void RunInspection(IInspection inspection, ConcurrentBag<IInspectionResult> allIssues)
153+
private static void RunInspection(IInspection inspection, ConcurrentBag<IInspectionResult> allIssues, CancellationToken token)
145154
{
146155
try
147156
{
148-
var inspectionResults = inspection.GetInspectionResults();
157+
var inspectionResults = inspection.GetInspectionResults(token);
158+
159+
token.ThrowIfCancellationRequested();
149160

150161
foreach (var inspectionResult in inspectionResults)
151162
{
152163
allIssues.Add(inspectionResult);
153164
}
154165
}
166+
catch (OperationCanceledException)
167+
{
168+
throw;
169+
}
155170
catch (Exception e)
156171
{
157172
LogManager.GetCurrentClassLogger().Warn(e);

Rubberduck.Parsing/IParseResultProvider.cs

Lines changed: 0 additions & 24 deletions
This file was deleted.

Rubberduck.Parsing/Inspections/Abstract/IInspection.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.Threading;
34

45
namespace Rubberduck.Parsing.Inspections.Abstract
56
{
@@ -11,7 +12,8 @@ public interface IInspection : IInspectionModel, IComparable<IInspection>, IComp
1112
/// <summary>
1213
/// Runs code inspection and returns inspection results.
1314
/// </summary>
15+
/// <param name="token"></param>
1416
/// <returns>Returns inspection results, if any.</returns>
15-
IEnumerable<IInspectionResult> GetInspectionResults();
17+
IEnumerable<IInspectionResult> GetInspectionResults(CancellationToken token);
1618
}
1719
}

Rubberduck.Parsing/Rubberduck.Parsing.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,6 @@
233233
<Compile Include="Binding\Expressions\SimpleNameExpression.cs" />
234234
<Compile Include="Binding\Bindings\SimpleNameTypeBinding.cs" />
235235
<Compile Include="ComHelper.cs" />
236-
<Compile Include="IParseResultProvider.cs" />
237236
<Compile Include="IParseCoordinator.cs" />
238237
<Compile Include="ParsingText.Designer.cs">
239238
<AutoGen>True</AutoGen>

Rubberduck.Parsing/VBA/ParseCoordinator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ private void ExecuteCommonParseActivities(IReadOnlyCollection<QualifiedModuleNam
239239

240240
//Explicitly setting the overall state here guarantees that the handlers attached
241241
//to the state change to ResolvedDeclarations always run, provided there is no error.
242-
State.SetStatusAndFireStateChanged(this, ParserState.ResolvedDeclarations);
242+
_parserStateManager.SetStatusAndFireStateChanged(this, ParserState.ResolvedDeclarations, token);
243243

244244
if (token.IsCancellationRequested || State.Status >= ParserState.Error)
245245
{

Rubberduck.Parsing/VBA/ParserStateManagerBase.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public ParserState GetModuleState(QualifiedModuleName module)
3838

3939
public void EvaluateOverallParserState(CancellationToken token)
4040
{
41-
_state.EvaluateParserState();
41+
_state.EvaluateParserState(token);
4242
}
4343

4444
public void SetModuleState(QualifiedModuleName module, ParserState parserState, CancellationToken token, bool evaluateOverallParserState = true)
@@ -48,7 +48,7 @@ public void SetModuleState(QualifiedModuleName module, ParserState parserState,
4848

4949
public void SetStatusAndFireStateChanged(object requestor, ParserState status, CancellationToken token)
5050
{
51-
_state.SetStatusAndFireStateChanged(requestor, status);
51+
_state.SetStatusAndFireStateChanged(requestor, status, token);
5252
}
5353
}
5454
}

0 commit comments

Comments
 (0)