@@ -11,16 +11,17 @@ namespace Semmle.Extraction.CSharp.Populators
1111{
1212 public class TypeContainerVisitor : CSharpSyntaxVisitor
1313 {
14- protected Context cx { get ; }
15- protected IEntity parent { get ; }
16- protected TextWriter trapFile { get ; }
14+ protected Context Cx { get ; }
15+ protected IEntity Parent { get ; }
16+ protected TextWriter TrapFile { get ; }
1717 private readonly Lazy < Func < SyntaxNode , AttributeData > > attributeLookup ;
1818
1919 public TypeContainerVisitor ( Context cx , TextWriter trapFile , IEntity parent )
2020 {
21- this . cx = cx ;
22- this . parent = parent ;
23- this . trapFile = trapFile ;
21+ Cx = cx ;
22+ Parent = parent ;
23+ TrapFile = trapFile ;
24+
2425 attributeLookup = new Lazy < Func < SyntaxNode , AttributeData > > ( ( ) =>
2526 {
2627 var dict = new Dictionary < SyntaxNode , AttributeData > ( ) ;
@@ -40,46 +41,51 @@ public override void DefaultVisit(SyntaxNode node)
4041
4142 public override void VisitDelegateDeclaration ( DelegateDeclarationSyntax node )
4243 {
43- Entities . NamedType . Create ( cx , cx . GetModel ( node ) . GetDeclaredSymbol ( node ) ) . ExtractRecursive ( trapFile , parent ) ;
44+ Entities . NamedType . Create ( Cx , Cx . GetModel ( node ) . GetDeclaredSymbol ( node ) ) . ExtractRecursive ( TrapFile , Parent ) ;
4445 }
4546
4647 public override void VisitRecordDeclaration ( RecordDeclarationSyntax node )
4748 {
48- Entities . Type . Create ( cx , cx . GetModel ( node ) . GetDeclaredSymbol ( node ) ) . ExtractRecursive ( trapFile , parent ) ;
49+ ExtractTypeDeclaration ( node ) ;
4950 }
5051
51- public override void VisitClassDeclaration ( ClassDeclarationSyntax classDecl )
52+ public override void VisitClassDeclaration ( ClassDeclarationSyntax node )
5253 {
53- Entities . Type . Create ( cx , cx . GetModel ( classDecl ) . GetDeclaredSymbol ( classDecl ) ) . ExtractRecursive ( trapFile , parent ) ;
54+ ExtractTypeDeclaration ( node ) ;
5455 }
5556
5657 public override void VisitStructDeclaration ( StructDeclarationSyntax node )
5758 {
58- Entities . Type . Create ( cx , cx . GetModel ( node ) . GetDeclaredSymbol ( node ) ) . ExtractRecursive ( trapFile , parent ) ;
59+ ExtractTypeDeclaration ( node ) ;
5960 }
6061
6162 public override void VisitEnumDeclaration ( EnumDeclarationSyntax node )
6263 {
63- Entities . Type . Create ( cx , cx . GetModel ( node ) . GetDeclaredSymbol ( node ) ) . ExtractRecursive ( trapFile , parent ) ;
64+ ExtractTypeDeclaration ( node ) ;
6465 }
6566
6667 public override void VisitInterfaceDeclaration ( InterfaceDeclarationSyntax node )
6768 {
68- Entities . Type . Create ( cx , cx . GetModel ( node ) . GetDeclaredSymbol ( node ) ) . ExtractRecursive ( trapFile , parent ) ;
69+ ExtractTypeDeclaration ( node ) ;
70+ }
71+
72+ private void ExtractTypeDeclaration ( BaseTypeDeclarationSyntax node )
73+ {
74+ Entities . Type . Create ( Cx , Cx . GetModel ( node ) . GetDeclaredSymbol ( node ) ) . ExtractRecursive ( TrapFile , Parent ) ;
6975 }
7076
7177 public override void VisitAttributeList ( AttributeListSyntax node )
7278 {
73- if ( cx . Extractor . Standalone )
79+ if ( Cx . Extractor . Standalone )
7480 return ;
7581
76- var outputAssembly = Assembly . CreateOutputAssembly ( cx ) ;
82+ var outputAssembly = Assembly . CreateOutputAssembly ( Cx ) ;
7783 foreach ( var attribute in node . Attributes )
7884 {
7985 if ( attributeLookup . Value ( attribute ) is AttributeData attributeData )
8086 {
81- var ae = Semmle . Extraction . CSharp . Entities . Attribute . Create ( cx , attributeData , outputAssembly ) ;
82- cx . BindComments ( ae , attribute . GetLocation ( ) ) ;
87+ var ae = Semmle . Extraction . CSharp . Entities . Attribute . Create ( Cx , attributeData , outputAssembly ) ;
88+ Cx . BindComments ( ae , attribute . GetLocation ( ) ) ;
8389 }
8490 }
8591 }
0 commit comments