Skip to content

Commit 6e1b8d6

Browse files
authored
Merge pull request #3775 from MDoerner/FixForHasDefaultMember
Fix for AttributeNode
2 parents 0a8fcdb + 6bcc6b4 commit 6e1b8d6

File tree

1 file changed

+6
-9
lines changed

1 file changed

+6
-9
lines changed

Rubberduck.Parsing/VBA/Attributes.cs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.Diagnostics;
43
using System.Linq;
54
using Rubberduck.Parsing.Annotations;
65
using Rubberduck.Parsing.Grammar;
@@ -21,33 +20,31 @@ public enum Instancing
2120

2221
public class AttributeNode : IEquatable<AttributeNode>
2322
{
24-
private readonly string _name;
2523
private readonly IList<string> _values;
2624

2725
public AttributeNode(VBAParser.AttributeStmtContext context)
2826
{
2927
Context = context;
28+
Name = Context?.attributeName().GetText() ?? String.Empty;
29+
_values = Context?.attributeValue().Select(a => a.GetText()).ToList() ?? new List<string>();
3030
}
3131

3232
public AttributeNode(string name, IEnumerable<string> values)
3333
{
34-
_name = name;
34+
Name = name;
3535
_values = values.ToList();
3636
}
3737

3838
public VBAParser.AttributeStmtContext Context { get; }
3939

40-
public string Name => Context?.attributeName().GetText() ?? _name;
41-
40+
public string Name { get; }
41+
4242
public void AddValue(string value)
4343
{
4444
_values.Add(value);
4545
}
4646

47-
public IReadOnlyList<string> Values
48-
{
49-
get { return Context?.attributeValue().Select(a => a.GetText()).ToArray() ?? _values.ToArray(); }
50-
}
47+
public IReadOnlyCollection<string> Values => _values.AsReadOnly();
5148

5249
public bool HasValue(string value)
5350
{

0 commit comments

Comments
 (0)