Skip to content

Commit

Permalink
Merge pull request #3470 from rubberduck-vba/next
Browse files Browse the repository at this point in the history
v2.1.0 ...take 3
  • Loading branch information
retailcoder authored Oct 16, 2017
2 parents 8e5dfcb + 7ffd582 commit 538dfca
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,78 @@ public void AddAttributes(Attributes attributes)
#endregion
}

public partial class UdtDeclarationContext : IIdentifierContext, IAnnotatedContext
{
#region IIdentifierContext
public Interval IdentifierTokens
{
get
{
Interval tokenInterval;
Identifier.GetName(this, out tokenInterval);
return tokenInterval;
}
}
#endregion

#region IAnnotatedContext
public Attributes Attributes { get; } = new Attributes();
public int AttributeTokenIndex => Start.TokenIndex - 1;

private readonly List<AnnotationContext> _annotations = new List<AnnotationContext>();
public IEnumerable<AnnotationContext> Annotations => _annotations;

public void Annotate(AnnotationContext annotation)
{
_annotations.Add(annotation);
}

public void AddAttributes(Attributes attributes)
{
foreach (var attribute in attributes)
{
Attributes.Add(new AttributeNode(attribute.Name, attribute.Values));
}
}
#endregion
}

public partial class UdtMemberContext : IIdentifierContext, IAnnotatedContext
{
#region IIdentifierContext
public Interval IdentifierTokens
{
get
{
Interval tokenInterval;
Identifier.GetName(this, out tokenInterval);
return tokenInterval;
}
}
#endregion

#region IAnnotatedContext
public Attributes Attributes { get; } = new Attributes();
public int AttributeTokenIndex => Start.TokenIndex - 1;

private readonly List<AnnotationContext> _annotations = new List<AnnotationContext>();
public IEnumerable<AnnotationContext> Annotations => _annotations;

public void Annotate(AnnotationContext annotation)
{
_annotations.Add(annotation);
}

public void AddAttributes(Attributes attributes)
{
foreach (var attribute in attributes)
{
Attributes.Add(new AttributeNode(attribute.Name, attribute.Values));
}
}
#endregion
}

public partial class IdentifierStatementLabelContext : IIdentifierContext, IAnnotatedContext
{
#region IIdentifierContext
Expand Down
17 changes: 17 additions & 0 deletions Rubberduck.Parsing/Symbols/Identifier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,23 @@ public static string GetName(VBAParser.EnumerationStmtContext context)
return GetName(context.identifier());
}

public static string GetName(VBAParser.UdtDeclarationContext context, out Interval tokenInterval)
{
return GetName(context.untypedIdentifier(), out tokenInterval);
}

public static string GetName(VBAParser.UdtMemberContext context, out Interval tokenInterval)
{
var untypedIdentifier = context.untypedNameMemberDeclaration()?.untypedIdentifier();
if (untypedIdentifier != null)
{
return GetName(untypedIdentifier, out tokenInterval);
}

var unrestrictedIdentifier = context.reservedNameMemberDeclaration().unrestrictedIdentifier();
return GetName(unrestrictedIdentifier, out tokenInterval);
}

public static string GetName(VBAParser.EnumerationStmt_ConstantContext context, out Interval tokenInterval)
{
var nameContext = context.identifier();
Expand Down

0 comments on commit 538dfca

Please sign in to comment.