Skip to content

Commit eff9da9

Browse files
committed
fixed NRE when (not) exporting empty document modules
1 parent ac6b85d commit eff9da9

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Rubberduck.Parsing/VBA/AttributeParser.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,12 @@ public AttributeParser(IModuleExporter exporter)
3333
public IDictionary<Tuple<string, DeclarationType>, Attributes> Parse(VBComponent component)
3434
{
3535
var path = _exporter.Export(component);
36+
if (!File.Exists(path))
37+
{
38+
// a document component without any code wouldn't be exported (file would be empty anyway).
39+
return new Dictionary<Tuple<string, DeclarationType>, Attributes>();
40+
}
41+
3642
var code = File.ReadAllText(path);
3743
File.Delete(path);
3844

@@ -63,6 +69,7 @@ private class AttributeListener : AttributesBaseListener
6369
public AttributeListener(Tuple<string,DeclarationType> scope)
6470
{
6571
_currentScope = scope;
72+
_currentScopeAttributes = new Attributes();
6673
}
6774

6875
public IDictionary<Tuple<string, DeclarationType>, Attributes> Attributes

0 commit comments

Comments
 (0)