@@ -211,36 +211,47 @@ public void OnStatusMessageUpdate(string message)
211
211
212
212
public void AddProject ( string projectId )
213
213
{
214
- VBProject project = null ;
214
+ var projects = new List < VBProject > ( ) ;
215
215
foreach ( VBProject p in _vbe . VBProjects )
216
216
{
217
- if ( p . HelpFile == projectId )
217
+ if ( p . HelpFile != null && _projects . Keys . Contains ( p . HelpFile ) )
218
218
{
219
- project = p ;
219
+ continue ;
220
220
}
221
+
222
+ projects . Add ( p ) ;
221
223
}
222
224
223
- if ( project == null )
225
+ if ( projects . Count == 0 )
224
226
{
225
227
Logger . Debug ( "Project was not found and will not be added to parser state." ) ;
226
228
return ;
227
229
}
228
230
229
- if ( project . Protection == vbext_ProjectProtection . vbext_pp_locked )
230
- {
231
- // adding protected project to parser state is asking for COMExceptions..
232
- Logger . Debug ( "Project is protected and will not be added to parser state." ) ;
233
- return ;
234
- }
235
-
236
- if ( ! _projects . ContainsKey ( projectId ) )
231
+ foreach ( var project in projects )
237
232
{
238
- _projects . Add ( projectId , project ) ;
239
- }
233
+ if ( project . Protection == vbext_ProjectProtection . vbext_pp_locked )
234
+ {
235
+ // adding protected project to parser state is asking for COMExceptions..
236
+ Logger . Debug ( "Project is protected and will not be added to parser state." ) ;
237
+ return ;
238
+ }
240
239
241
- foreach ( VBComponent component in project . VBComponents )
242
- {
243
- _moduleStates . TryAdd ( new QualifiedModuleName ( component ) , new ModuleState ( ParserState . Pending ) ) ;
240
+ if ( string . IsNullOrEmpty ( project . HelpFile ) )
241
+ {
242
+ // assigns the help file and returns the value to reduce COM calls
243
+ projectId = project . AssignProjectId ( ) ;
244
+ }
245
+
246
+ if ( ! _projects . ContainsKey ( projectId ) )
247
+ {
248
+ _projects . Add ( projectId , project ) ;
249
+ }
250
+
251
+ foreach ( VBComponent component in project . VBComponents )
252
+ {
253
+ _moduleStates . TryAdd ( new QualifiedModuleName ( component ) , new ModuleState ( ParserState . Pending ) ) ;
254
+ }
244
255
}
245
256
}
246
257
@@ -670,7 +681,7 @@ public void AddDeclaration(Declaration declaration)
670
681
}
671
682
}
672
683
673
- public void ClearStateCache ( VBProject project , bool notifyStateChanged = false )
684
+ private void ClearStateCache ( VBProject project , bool notifyStateChanged = false )
674
685
{
675
686
try
676
687
{
0 commit comments