Skip to content

Commit 7788cc6

Browse files
committed
Fix cancellation bug. Don't request reparse on startup--request it when the project is loaded.
1 parent b657f37 commit 7788cc6

File tree

58 files changed

+654
-582
lines changed

Some content is hidden

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

58 files changed

+654
-582
lines changed

RetailCoder.VBE/API/ParserState.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public void Initialize(VBE vbe)
7878
public void Parse()
7979
{
8080
// blocking call
81-
_parser.Parse();
81+
_parser.Parse(new System.Threading.CancellationTokenSource());
8282
}
8383

8484
/// <summary>

RetailCoder.VBE/App.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
using Rubberduck.UI.Command.MenuItems;
1212
using System;
1313
using System.Globalization;
14-
using System.Threading.Tasks;
1514
using System.Windows.Forms;
1615

1716
namespace Rubberduck
@@ -141,7 +140,6 @@ public void Startup()
141140
_appMenus.Initialize();
142141
_hooks.HookHotkeys(); // need to hook hotkeys before we localize menus, to correctly display ShortcutTexts
143142
_appMenus.Localize();
144-
Task.Delay(1000).ContinueWith(t => UiDispatcher.Invoke(() => _parser.State.OnParseRequested(this)));
145143
UpdateLoggingLevel();
146144
}
147145

Rubberduck.Parsing/Symbols/DeclarationSymbolsListener.cs

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@
77
using Rubberduck.VBEditor;
88
using System;
99
using System.Collections.Generic;
10+
using System.Diagnostics;
1011
using System.Linq;
1112
using System.Runtime.InteropServices;
1213
using Antlr4.Runtime.Misc;
14+
using NLog;
1315

1416
namespace Rubberduck.Parsing.Symbols
1517
{
@@ -38,6 +40,9 @@ public DeclarationSymbolsListener(
3840
IDictionary<Tuple<string, DeclarationType>, Attributes> attributes,
3941
Declaration projectDeclaration)
4042
{
43+
var log = LogManager.GetCurrentClassLogger();
44+
var stop = Stopwatch.StartNew();
45+
4146
_state = state;
4247
_qualifiedName = qualifiedName;
4348
_annotations = annotations;
@@ -68,6 +73,10 @@ public DeclarationSymbolsListener(
6873
{
6974
bool hasDefaultInstanceVariable = type != vbext_ComponentType.vbext_ct_ClassModule && type != vbext_ComponentType.vbext_ct_StdModule;
7075

76+
var stop1 = Stopwatch.StartNew();
77+
var stop2 = new Stopwatch();
78+
var stop3 = new Stopwatch();
79+
7180
Declaration superType = null;
7281
if (type == vbext_ComponentType.vbext_ct_Document)
7382
{
@@ -83,7 +92,15 @@ public DeclarationSymbolsListener(
8392
var allNamesMatch = true;
8493
for (var i = 0; i < coclass.Key.Count; i++)
8594
{
86-
if (coclass.Key[i] != _qualifiedName.Component.Properties.Item(i + 1).Name)
95+
stop2.Start();
96+
var propName = _qualifiedName.Component.Properties.Item(i + 1).Name;
97+
stop2.Stop();
98+
99+
stop3.Start();
100+
var namesMatch = coclass.Key[i] != propName;
101+
stop3.Stop();
102+
103+
if (namesMatch)
87104
{
88105
allNamesMatch = false;
89106
break;
@@ -101,6 +118,10 @@ public DeclarationSymbolsListener(
101118
}
102119
}
103120
}
121+
stop1.Stop();
122+
log.Debug("{0}ms getting property name", stop2.ElapsedMilliseconds);
123+
log.Debug("{0}ms comparing property name", stop3.ElapsedMilliseconds);
124+
log.Debug("{0}ms resolving coclass", stop1.ElapsedMilliseconds);
104125

105126
_moduleDeclaration = new ClassModuleDeclaration(
106127
_qualifiedName.QualifyMemberName(_qualifiedName.Component.Name),
@@ -123,6 +144,9 @@ public DeclarationSymbolsListener(
123144
{
124145
DeclareControlsAsMembers(component);
125146
}
147+
148+
stop.Stop();
149+
log.Debug("{0}ms in declaration listener ctor", stop.ElapsedMilliseconds);
126150
}
127151

128152
private IEnumerable<IAnnotation> FindAnnotations()
@@ -801,8 +825,8 @@ public override void ExitPrivateTypeDeclaration(VBAParser.PrivateTypeDeclaration
801825
{
802826
_parentDeclaration = _moduleDeclaration;
803827
}
804-
805-
public void AddUdtDeclaration(VBAParser.UdtDeclarationContext udtDeclaration, Accessibility accessibility, ParserRuleContext context)
828+
829+
private void AddUdtDeclaration(VBAParser.UdtDeclarationContext udtDeclaration, Accessibility accessibility, ParserRuleContext context)
806830
{
807831
var identifier = Identifier.GetName(udtDeclaration.untypedIdentifier());
808832
var identifierSelection = Identifier.GetNameSelection(udtDeclaration.untypedIdentifier());

0 commit comments

Comments
 (0)