11using Microsoft . CodeAnalysis ;
22using Microsoft . CodeAnalysis . CSharp . Syntax ;
3- using Semmle . Util ;
43using System ;
54using System . Collections . Generic ;
65using System . IO ;
@@ -24,9 +23,9 @@ public static bool ConstructedOrParentIsConstructed(INamedTypeSymbol symbol)
2423 symbol . ContainingType is not null && ConstructedOrParentIsConstructed ( symbol . ContainingType ) ;
2524 }
2625
27- private static Kinds . TypeKind GetClassType ( Context cx , ITypeSymbol t , bool constructUnderlyingTupleType )
26+ public Kinds . TypeKind GetTypeKind ( Context cx , bool constructUnderlyingTupleType )
2827 {
29- switch ( t . SpecialType )
28+ switch ( Symbol . SpecialType )
3029 {
3130 case SpecialType . System_Int32 : return Kinds . TypeKind . INT ;
3231 case SpecialType . System_UInt32 : return Kinds . TypeKind . UINT ;
@@ -44,14 +43,14 @@ private static Kinds.TypeKind GetClassType(Context cx, ITypeSymbol t, bool const
4443 case SpecialType . System_Single : return Kinds . TypeKind . FLOAT ;
4544 case SpecialType . System_IntPtr : return Kinds . TypeKind . INT_PTR ;
4645 default :
47- if ( t . IsBoundNullable ( ) )
46+ if ( Symbol . IsBoundNullable ( ) )
4847 return Kinds . TypeKind . NULLABLE ;
4948
50- switch ( t . TypeKind )
49+ switch ( Symbol . TypeKind )
5150 {
5251 case TypeKind . Class : return Kinds . TypeKind . CLASS ;
5352 case TypeKind . Struct :
54- return ( ( INamedTypeSymbol ) t ) . IsTupleType && ! constructUnderlyingTupleType
53+ return ( ( INamedTypeSymbol ) Symbol ) . IsTupleType && ! constructUnderlyingTupleType
5554 ? Kinds . TypeKind . TUPLE
5655 : Kinds . TypeKind . STRUCT ;
5756 case TypeKind . Interface : return Kinds . TypeKind . INTERFACE ;
@@ -62,7 +61,7 @@ private static Kinds.TypeKind GetClassType(Context cx, ITypeSymbol t, bool const
6261 case TypeKind . FunctionPointer : return Kinds . TypeKind . FUNCTION_POINTER ;
6362 case TypeKind . Error : return Kinds . TypeKind . UNKNOWN ;
6463 default :
65- cx . ModelError ( t , $ "Unhandled type kind '{ t . TypeKind } '") ;
64+ cx . ModelError ( Symbol , $ "Unhandled type kind '{ Symbol . TypeKind } '") ;
6665 return Kinds . TypeKind . UNKNOWN ;
6766 }
6867 }
@@ -76,7 +75,7 @@ protected void PopulateType(TextWriter trapFile, bool constructUnderlyingTupleTy
7675 trapFile . Write ( "types(" ) ;
7776 trapFile . WriteColumn ( this ) ;
7877 trapFile . Write ( ',' ) ;
79- trapFile . WriteColumn ( ( int ) GetClassType ( Context , Symbol , constructUnderlyingTupleType ) ) ;
78+ trapFile . WriteColumn ( ( int ) GetTypeKind ( Context , constructUnderlyingTupleType ) ) ;
8079 trapFile . Write ( ",\" " ) ;
8180 Symbol . BuildDisplayName ( Context , trapFile , constructUnderlyingTupleType ) ;
8281 trapFile . WriteLine ( "\" )" ) ;
0 commit comments