Skip to content

Commit 1afea24

Browse files
committed
xml looks right, resolver still works.
1 parent dcdf7d5 commit 1afea24

File tree

3 files changed

+16
-23
lines changed

3 files changed

+16
-23
lines changed

Rubberduck.Parsing/Symbols/ReferencedDeclarationsCollector.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -228,19 +228,15 @@ public List<Declaration> GetDeclarationsForReference(IReference reference)
228228
moduleDeclaration = module;
229229
break;
230230
default:
231-
string pseudoModuleName = string.Format("_{0}", typeName);
231+
var pseudoModuleName = string.Format("_{0}", typeName);
232232
var pseudoParentModule = new ProceduralModuleDeclaration(
233233
new QualifiedMemberName(projectQualifiedModuleName, pseudoModuleName),
234234
projectDeclaration,
235235
pseudoModuleName,
236236
true,
237237
new List<IAnnotation>(),
238238
new Attributes());
239-
// Enums don't define their own type but have a declared type of "Long".
240-
if (typeDeclarationType == DeclarationType.Enumeration)
241-
{
242-
typeName = Tokens.Long;
243-
}
239+
244240
// UDTs and ENUMs don't seem to have a module parent that's why we add a "fake" module
245241
// so that the rest of the application can treat it normally.
246242
moduleDeclaration = new Declaration(
@@ -260,6 +256,8 @@ public List<Declaration> GetDeclarationsForReference(IReference reference)
260256
true,
261257
null,
262258
attributes);
259+
260+
output.Add(pseudoParentModule);
263261
break;
264262
}
265263

Rubberduck.Parsing/VBA/RubberduckParser.cs

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -435,27 +435,21 @@ private void SyncComReferences(IReadOnlyList<IVBProject> projects)
435435
var comReflector = new ReferencedDeclarationsCollector(State);
436436

437437
var items = comReflector.GetDeclarationsForReference(localReference);
438-
var root = items.SingleOrDefault(x => x.DeclarationType == DeclarationType.Project);
438+
var root = items.OfType<ProjectDeclaration>().SingleOrDefault();
439439
var serialize = new List<Declaration>(items);
440+
foreach (var declaration in serialize)
441+
{
442+
State.AddDeclaration(declaration);
443+
}
440444
serialize.Remove(root);
441445
var tree = GetSerializableTreeForDeclaration(root, serialize);
442446

443447
if (tree != null)
444448
{
445-
State.BuiltInDeclarationTrees.Add(tree);
446-
}
447-
448-
//var items = comReflector.GetDeclarationsForReference(localReference, out tree);
449-
//if (tree != null)
450-
//{
451-
// State.BuiltInDeclarationTrees.Add(tree);
452-
//}
453-
454-
//foreach (var declaration in items)
455-
//{
456-
// State.AddDeclaration(declaration);
457-
//}
449+
var added = State.BuiltInDeclarationTrees.TryAdd(tree);
450+
//if (!added) { throw new Exception();}
458451
}
452+
}
459453
catch (Exception exception)
460454
{
461455
unmapped.Add(reference);
@@ -500,7 +494,7 @@ private void SyncComReferences(IReadOnlyList<IVBProject> projects)
500494
private SerializableDeclarationTree GetSerializableTreeForDeclaration(Declaration declaration, List<Declaration> declarations)
501495
{
502496
var children = new List<SerializableDeclarationTree>();
503-
var nodes = declarations.Where(x => x.ParentDeclaration != null && x.ParentDeclaration.Equals(declaration)).ToList();
497+
var nodes = declarations.Where(x => x.ParentDeclaration.Equals(declaration)).ToList();
504498
declarations.RemoveAll(nodes.Contains);
505499
foreach (var item in nodes)
506500
{

Rubberduck.Parsing/VBA/RubberduckParserState.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Collections;
23
using System.Collections.Concurrent;
34
using System.Collections.Generic;
45
using System.Diagnostics;
@@ -585,8 +586,8 @@ public IReadOnlyList<Declaration> AllDeclarations
585586
}
586587
}
587588

588-
private readonly List<SerializableDeclarationTree> _builtInDeclarationTrees = new List<SerializableDeclarationTree>();
589-
public IList<SerializableDeclarationTree> BuiltInDeclarationTrees { get { return _builtInDeclarationTrees; } }
589+
private readonly ConcurrentBag<SerializableDeclarationTree> _builtInDeclarationTrees = new ConcurrentBag<SerializableDeclarationTree>();
590+
public IProducerConsumerCollection<SerializableDeclarationTree> BuiltInDeclarationTrees { get { return _builtInDeclarationTrees; } }
590591

591592
/// <summary>
592593
/// Gets a copy of the collected declarations, excluding the built-in ones.

0 commit comments

Comments
 (0)