I have swift source containing various types (struct, enum...etc), decorated with attributes. For example:
@Foo
struct Bar {
let x = 0
var y = 1
// . . .
}
I am using a SyntaxVisitor
to search for SyntaxProtocol
of type AttributeSyntax
and checking the name is "Foo". This all works fine.
The next step after I've collected these together is to get the objects that are decorated by the "Foo" attribute. So in this case, I want the StructDeclSyntax
from the source tree for the Bar
object, so I can inspect its children.
I can't work out how to get this object though. Given an AttributeSyntax
, is there a way to get the object (class, enum, struct...etc) that it is attached to?
Thanks
-Matt