示例#1
0
        public virtual TResult VisitPointerType(IPointerTypeSymbol symbol)
        {
#pragma warning disable CS8717 // A member returning a [MaybeNull] value introduces a null value when 'TResult' is a non-nullable reference type.
            return(DefaultVisit(symbol));

#pragma warning restore CS8717 // A member returning a [MaybeNull] value introduces a null value when 'TResult' is a non-nullable reference type.
        }
示例#2
0
        private static bool CompareTypes(Compilation ca, Compilation cb, ITypeSymbol a, ITypeSymbol b)
        {
            if (a.TypeKind != b.TypeKind)
            {
                return(false);
            }
            switch (a.TypeKind)
            {
            case TypeKind.Array:
                IArrayTypeSymbol arrayA = (IArrayTypeSymbol)a, arrayB = (IArrayTypeSymbol)b;
                return(arrayA.Rank == arrayB.Rank && arrayA.Sizes.SequenceEqual(arrayB.Sizes) && CompareTypes(ca, cb, arrayA.ElementType, arrayB.ElementType));

            case TypeKind.Pointer:
                IPointerTypeSymbol ptrA = (IPointerTypeSymbol)a, ptrB = (IPointerTypeSymbol)b;
                return(CompareTypes(ca, cb, ptrA.PointedAtType, ptrB.PointedAtType));

            case TypeKind.Class:
            case TypeKind.Delegate:
            case TypeKind.Dynamic:
            case TypeKind.Enum:
            case TypeKind.Error:
            case TypeKind.Interface:
            case TypeKind.Module:
            case TypeKind.Struct:
            case TypeKind.TypeParameter:
            case TypeKind.Unknown:
                return(GetName(ca, a) == GetName(cb, b));
            }
            throw new ArgumentException("unknown type kind: " + a.TypeKind);
        }
 private int CombineHashCodes(IPointerTypeSymbol x, int currentHash)
 {
     return(Hash.Combine(
                typeof(IPointerTypeSymbol).GetHashCode(),
                GetHashCode(x.PointedAtType, currentHash)
                ));
 }
示例#4
0
        public static T WithNullability <T>(this T typeSymbol, NullableAnnotation nullability) where T : class, ITypeSymbol
        {
            if (typeSymbol == null)
            {
                return(null);
            }

            if (typeSymbol is TypeSymbolWithNullableAnnotation typeSymbolWithNullability)
            {
                // Check if the wrapper already has the same top-level nullability; in that case we don't need to re-create one.
                if (typeSymbolWithNullability.Nullability == nullability)
                {
                    return(typeSymbol);
                }

                // No reason to wrap a wrapper, so unwrap it
                typeSymbol = (T)typeSymbolWithNullability.WrappedSymbol;
            }

            return(typeSymbol switch
            {
                IArrayTypeSymbol arrayTypeSymbol => (ITypeSymbol) new ArrayTypeSymbolWithNullableAnnotation(arrayTypeSymbol, nullability),
                IDynamicTypeSymbol dynamicTypeSymbol => (ITypeSymbol) new DynamicTypeSymbolWithNullableAnnotation(dynamicTypeSymbol, nullability),
                INamedTypeSymbol namedTypeSymbol => (ITypeSymbol) new NamedTypeSymbolWithNullableAnnotation(namedTypeSymbol, nullability),
                IPointerTypeSymbol pointerType => (ITypeSymbol) new PointerTypeSymbolWithNullableAnnotation(pointerType, nullability),
                ITypeParameterSymbol typeParameterSymbol => (ITypeSymbol) new TypeParameterSymbolWithNullableAnnotation(typeParameterSymbol, nullability),
                _ => throw ExceptionUtilities.UnexpectedValue(typeSymbol)
            } as T);
            public override TypeSyntax VisitPointerType(IPointerTypeSymbol symbol)
            {
                ThrowIfNameOnly();

                return(AddInformationTo(
                           SyntaxFactory.PointerType(symbol.PointedAtType.GenerateTypeSyntax()),
                           symbol));
            }
示例#6
0
 private static ISymbol?GetRelevantType(ISymbol?symbol)
 {
     return(symbol switch
     {
         IPointerTypeSymbol pointer => pointer.PointedAtType,
         IArrayTypeSymbol arrayType => arrayType.ElementType,
         _ => symbol
     });
示例#7
0
        private static string ToDisplay(this IPointerTypeSymbol @this)
        {
            var pointedAtType  = @this.PointedAtType;
            var pointedType    = pointedAtType.SimplifyTypeName();
            var returnTypeName = $"{pointedType}*";

            return(returnTypeName);
        }
 public override void VisitPointerType(IPointerTypeSymbol symbol)
 {
     symbol.PointedAtType.Accept(this);
     ReferenceItem.Parts[SyntaxLanguage.VB].Add(new LinkItem
     {
         DisplayName           = "*",
         DisplayQualifiedNames = "*",
     });
 }
示例#9
0
 public static bool ContainsAnonymousType([NotNullWhen(returnValue: true)] this ITypeSymbol?symbol)
 {
     return(symbol switch
     {
         IArrayTypeSymbol a => ContainsAnonymousType(a.ElementType),
         IPointerTypeSymbol p => ContainsAnonymousType(p.PointedAtType),
         INamedTypeSymbol n => ContainsAnonymousType(n),
         _ => false,
     });
            public override bool VisitPointerType(IPointerTypeSymbol symbol)
            {
                if (!_visited.Add(symbol))
                {
                    return(false);
                }

                return(true);
            }
示例#11
0
            public override void VisitPointerType(IPointerTypeSymbol symbol)
            {
                if (!visited.Add(symbol))
                {
                    return;
                }

                symbol.PointedAtType.Accept(this);
            }
            public override void VisitPointerType(IPointerTypeSymbol symbol)
            {
                if (!_visited.Add(symbol))
                {
                    return;
                }

                symbol.PointedAtType.Accept(this);
            }
        public override void VisitPointerType(IPointerTypeSymbol symbol)
        {
            symbol.PointedAtType.Accept(this.NotFirstVisitor);

            if (!this.isFirstSymbolVisited)
            {
                AddCustomModifiersIfRequired(symbol.CustomModifiers, leadingSpace: true);
            }

            AddPunctuation(SyntaxKind.AsteriskToken);
        }
示例#14
0
            public override ITypeSymbol VisitPointerType(IPointerTypeSymbol symbol)
            {
                var pointedAtType = symbol.PointedAtType.Accept(this);

                if (pointedAtType != null && pointedAtType.Equals(symbol.PointedAtType))
                {
                    return(symbol);
                }

                return(typeGenerator.CreatePointerTypeSymbol(pointedAtType));
            }
示例#15
0
        public override void VisitPointerType(IPointerTypeSymbol symbol)
        {
            symbol.PointedAtType.Accept(this.NotFirstVisitor);

            if (!this.isFirstSymbolVisited)
            {
                AddCustomModifiersIfRequired(symbol.CustomModifiers, leadingSpace: true);
            }

            AddPunctuation(SyntaxKind.AsteriskToken);
        }
            public override async ValueTask <ITypeSymbol> VisitPointerType(IPointerTypeSymbol symbol)
            {
                var elementType = await symbol.PointedAtType.Accept(this).ConfigureAwait(false);

                if (elementType != null && elementType.Equals(symbol.PointedAtType))
                {
                    return(symbol);
                }

                return(_compilation.CreatePointerTypeSymbol(elementType));
            }
            public override ITypeSymbol VisitPointerType(IPointerTypeSymbol symbol)
            {
                var elementType = symbol.PointedAtType.Accept(this);

                if (elementType != null && elementType.Equals(symbol.PointedAtType))
                {
                    return(symbol);
                }

                return(compilation.CreatePointerTypeSymbol(elementType));
            }
示例#18
0
 public static bool IsOrReferencesErrorType(this ITypeSymbol type)
 {
     if (!type.ContainingType?.IsOrReferencesErrorType() ?? false)
     {
         return(false);
     }
     return(type switch
     {
         IErrorTypeSymbol => true,
         IArrayTypeSymbol array => array.ElementType.IsOrReferencesErrorType(),
         IPointerTypeSymbol pointer => pointer.PointedAtType.IsOrReferencesErrorType(),
         INamedTypeSymbol named => !named.IsUnboundGenericType && named.TypeArguments.Any(IsOrReferencesErrorType),
         _ => false,
     });
        public override void VisitPointerType(IPointerTypeSymbol symbol)
        {
            var pointer = symbol as PointerTypeSymbol;

            if ((object)pointer == null)
            {
                symbol.PointedAtType.Accept(this.NotFirstVisitor);
            }
            else
            {
                VisitTypeSymbolWithAnnotations(pointer.PointedAtType);
            }

            if (!this.isFirstSymbolVisited)
            {
                AddCustomModifiersIfRequired(symbol.CustomModifiers, leadingSpace: true);
            }

            AddPunctuation(SyntaxKind.AsteriskToken);
        }
示例#20
0
        private static async Task <GraphNodeId> GetPartialForPointerTypeAsync(IPointerTypeSymbol pointerType, GraphNodeIdName nodeName, Solution solution, CancellationToken cancellationToken)
        {
            var indirection = 1;

            while (pointerType.PointedAtType.TypeKind == TypeKind.Pointer)
            {
                indirection++;
                pointerType = (IPointerTypeSymbol)pointerType.PointedAtType;
            }

            var partials = new List <GraphNodeId>();

            partials.Add(GraphNodeId.GetPartial(CodeQualifiedName.Name, pointerType.PointedAtType.Name));
            partials.Add(GraphNodeId.GetPartial(CodeQualifiedName.Indirection, indirection.ToString()));

            if (pointerType.PointedAtType.ContainingType != null)
            {
                partials.Add(await GetPartialForTypeAsync(pointerType.PointedAtType.ContainingType, CodeGraphNodeIdName.ParentType, solution, cancellationToken).ConfigureAwait(false));
            }

            return(GraphNodeId.GetPartial(nodeName, MakeCollectionIfNecessary(false, partials.ToArray())));
        }
示例#21
0
 public override void VisitPointerType(IPointerTypeSymbol symbol)
 {
     symbol.PointedAtType.Accept(this);
     Append("*");
 }
 public override void VisitPointerType(IPointerTypeSymbol pointerTypeSymbol)
 {
     pointerTypeSymbol.PointedAtType.Accept(this);
 }
示例#23
0
 public sealed override void VisitPointerType(IPointerTypeSymbol symbol)
 {
     Visit(symbol.PointedAtType);
 }
示例#24
0
        private static async Task<GraphNodeId> GetPartialForPointerTypeAsync(IPointerTypeSymbol pointerType, GraphNodeIdName nodeName, Solution solution, CancellationToken cancellationToken)
        {
            var indirection = 1;

            while (pointerType.PointedAtType.TypeKind == TypeKind.Pointer)
            {
                indirection++;
                pointerType = (IPointerTypeSymbol)pointerType.PointedAtType;
            }

            var partials = new List<GraphNodeId>();

            partials.Add(GraphNodeId.GetPartial(CodeQualifiedName.Name, pointerType.PointedAtType.Name));
            partials.Add(GraphNodeId.GetPartial(CodeQualifiedName.Indirection, indirection.ToString()));

            if (pointerType.PointedAtType.ContainingType != null)
            {
                partials.Add(await GetPartialForTypeAsync(pointerType.PointedAtType.ContainingType, CodeGraphNodeIdName.ParentType, solution, cancellationToken).ConfigureAwait(false));
            }

            return GraphNodeId.GetPartial(nodeName, MakeCollectionIfNecessary(false, partials.ToArray()));
        }
示例#25
0
 public virtual TResult?VisitPointerType(IPointerTypeSymbol symbol)
 {
     return(DefaultVisit(symbol));
 }
 public static void Create(IPointerTypeSymbol symbol, SymbolKeyWriter visitor)
 {
     visitor.WriteSymbolKey(symbol.PointedAtType);
 }
示例#27
0
 public override void VisitPointerType(IPointerTypeSymbol symbol)
 {
     base.VisitPointerType(symbol);
 }
示例#28
0
 public override void VisitPointerType(IPointerTypeSymbol symbol)
 {
     symbol.PointedAtType.Accept(this);
     ReferenceItem.Parts[SyntaxLanguage.VB].Add(new LinkItem
     {
         DisplayName = "*",
         DisplayQualifiedNames = "*",
     });
 }
示例#29
0
 public override Accessibility VisitPointerType(IPointerTypeSymbol symbol)
 => symbol.PointedAtType.Accept(this);
 private bool PointerTypesAreEquivalent(IPointerTypeSymbol x, IPointerTypeSymbol y, Dictionary<INamedTypeSymbol, INamedTypeSymbol> equivalentTypesWithDifferingAssemblies)
 {
     return AreEquivalent(x.PointedAtType, y.PointedAtType, equivalentTypesWithDifferingAssemblies);
 }
示例#31
0
 public override IEntity VisitPointerType(IPointerTypeSymbol symbol) => PointerType.Create(cx, symbol);
 private bool PointerTypesAreEquivalent(IPointerTypeSymbol x, IPointerTypeSymbol y, Dictionary <INamedTypeSymbol, INamedTypeSymbol> equivalentTypesWithDifferingAssemblies)
 {
     return
         (AreEquivalent(x.CustomModifiers, y.CustomModifiers, equivalentTypesWithDifferingAssemblies) &&
          AreEquivalent(x.PointedAtType, y.PointedAtType, equivalentTypesWithDifferingAssemblies));
 }
示例#33
0
 public override string VisitPointerType(IPointerTypeSymbol symbol)
 {
     return(symbol.PointedAtType.Accept(this) + "*");
 }
 public override void VisitPointerType(IPointerTypeSymbol pointerTypeSymbol)
 => pointerTypeSymbol.PointedAtType.Accept(this);
 public override object VisitPointerType(IPointerTypeSymbol pointerTypeSymbol)
 {
     WriteType(SymbolKeyType.PointerType);
     PointerTypeSymbolKey.Create(pointerTypeSymbol, this);
     return(null);
 }
示例#36
0
 public virtual void VisitPointerType(IPointerTypeSymbol symbol)
 {
     DefaultVisit(symbol);
 }
示例#37
0
        private static void AppendPointerType(IPointerTypeSymbol symbol, StringBuilder builder)
        {
            builder.Append(GetMetadataName(symbol.PointedAtType));

            builder.Append('*');
        }
 public static void Create(IPointerTypeSymbol symbol, SymbolKeyWriter visitor)
 => visitor.WriteSymbolKey(symbol.PointedAtType);
示例#39
0
 public override ValueTask VisitPointerType(IPointerTypeSymbol symbol)
 => symbol.PointedAtType.Accept(this);
示例#40
0
 public override void VisitPointerType(IPointerTypeSymbol symbol)
 {
     symbol.PointedAtType.Accept(this);
     Append("*");
 }
 public sealed override void VisitPointerType(IPointerTypeSymbol symbol)
 {
     Visit(symbol.PointedAtType);
 }
 public override bool VisitPointerType(IPointerTypeSymbol symbol)
 {
     return(Visit(symbol.PointedAtType));
 }
示例#43
0
 private void Visit(IPointerTypeSymbol type)
 {
     Visit(type.PointedAtType);
     builder.Append("*");
 }