@@ -11,16 +11,17 @@ namespace Semmle.Extraction.CSharp.Populators
11
11
{
12
12
public class TypeContainerVisitor : CSharpSyntaxVisitor
13
13
{
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 ; }
17
17
private readonly Lazy < Func < SyntaxNode , AttributeData > > attributeLookup ;
18
18
19
19
public TypeContainerVisitor ( Context cx , TextWriter trapFile , IEntity parent )
20
20
{
21
- this . cx = cx ;
22
- this . parent = parent ;
23
- this . trapFile = trapFile ;
21
+ Cx = cx ;
22
+ Parent = parent ;
23
+ TrapFile = trapFile ;
24
+
24
25
attributeLookup = new Lazy < Func < SyntaxNode , AttributeData > > ( ( ) =>
25
26
{
26
27
var dict = new Dictionary < SyntaxNode , AttributeData > ( ) ;
@@ -40,46 +41,51 @@ public override void DefaultVisit(SyntaxNode node)
40
41
41
42
public override void VisitDelegateDeclaration ( DelegateDeclarationSyntax node )
42
43
{
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 ) ;
44
45
}
45
46
46
47
public override void VisitRecordDeclaration ( RecordDeclarationSyntax node )
47
48
{
48
- Entities . Type . Create ( cx , cx . GetModel ( node ) . GetDeclaredSymbol ( node ) ) . ExtractRecursive ( trapFile , parent ) ;
49
+ ExtractTypeDeclaration ( node ) ;
49
50
}
50
51
51
- public override void VisitClassDeclaration ( ClassDeclarationSyntax classDecl )
52
+ public override void VisitClassDeclaration ( ClassDeclarationSyntax node )
52
53
{
53
- Entities . Type . Create ( cx , cx . GetModel ( classDecl ) . GetDeclaredSymbol ( classDecl ) ) . ExtractRecursive ( trapFile , parent ) ;
54
+ ExtractTypeDeclaration ( node ) ;
54
55
}
55
56
56
57
public override void VisitStructDeclaration ( StructDeclarationSyntax node )
57
58
{
58
- Entities . Type . Create ( cx , cx . GetModel ( node ) . GetDeclaredSymbol ( node ) ) . ExtractRecursive ( trapFile , parent ) ;
59
+ ExtractTypeDeclaration ( node ) ;
59
60
}
60
61
61
62
public override void VisitEnumDeclaration ( EnumDeclarationSyntax node )
62
63
{
63
- Entities . Type . Create ( cx , cx . GetModel ( node ) . GetDeclaredSymbol ( node ) ) . ExtractRecursive ( trapFile , parent ) ;
64
+ ExtractTypeDeclaration ( node ) ;
64
65
}
65
66
66
67
public override void VisitInterfaceDeclaration ( InterfaceDeclarationSyntax node )
67
68
{
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 ) ;
69
75
}
70
76
71
77
public override void VisitAttributeList ( AttributeListSyntax node )
72
78
{
73
- if ( cx . Extractor . Standalone )
79
+ if ( Cx . Extractor . Standalone )
74
80
return ;
75
81
76
- var outputAssembly = Assembly . CreateOutputAssembly ( cx ) ;
82
+ var outputAssembly = Assembly . CreateOutputAssembly ( Cx ) ;
77
83
foreach ( var attribute in node . Attributes )
78
84
{
79
85
if ( attributeLookup . Value ( attribute ) is AttributeData attributeData )
80
86
{
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 ( ) ) ;
83
89
}
84
90
}
85
91
}
0 commit comments