77using Rubberduck . VBEditor ;
88using System ;
99using System . Collections . Generic ;
10+ using System . Diagnostics ;
1011using System . Linq ;
1112using System . Runtime . InteropServices ;
1213using Antlr4 . Runtime . Misc ;
14+ using NLog ;
1315
1416namespace 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