Skip to content

Commit

Permalink
Current proposal update.
Browse files Browse the repository at this point in the history
  • Loading branch information
333fred committed Oct 11, 2018
1 parent dc5dedf commit a21916e
Show file tree
Hide file tree
Showing 14 changed files with 138 additions and 101 deletions.
51 changes: 51 additions & 0 deletions src/Compilers/Core/Portable/Compilation/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ public static class ModelExtensions
return semanticModel.GetSymbolInfo(node, cancellationToken);
}

// If there is no single symbol, return will be the same as GetSymbolInfoWithNullability
public static SymbolInfo GetSymbolInfoWithNullability(this SemanticModel semanticModel, SyntaxNode, CancellationToken ct = default)
{
throw new NotImplementedException();
}

/// <summary>
/// Binds the node in the context of the specified location and get semantic information
/// such as type, symbols and diagnostics. This method is used to get semantic information
Expand Down Expand Up @@ -60,6 +66,11 @@ public static SymbolInfo GetSpeculativeSymbolInfo(this SemanticModel semanticMod
return semanticModel.GetTypeInfo(node, cancellationToken);
}

public static TypeInfo GetTypeInfoWithNullability(this SemanticModel semanticModel, SyntaxNode node, CancellationToken cancellationToken = default)
{
throw new NotImplementedException();
}

/// <summary>
/// If "nameSyntax" resolves to an alias name, return the IAliasSymbol corresponding
/// to A. Otherwise return null.
Expand Down Expand Up @@ -135,6 +146,46 @@ public static TypeInfo GetSpeculativeTypeInfo(this SemanticModel semanticModel,
return semanticModel.GetDeclaredSymbolForNode(declaration, cancellationToken);
}

public static TypeInfo GetTypeWithNullability(this SemanticModel semanticModel, IDiscardSymbol discard, CancellationToken ct = default)
{
throw new NotImplementedException();
}

public static TypeInfo GetTypeWithNullability(this SemanticModel semanticModel, IEventSymbol eventSymbol, CancellationToken ct = default)
{
throw new NotImplementedException();
}

public static TypeInfo GetTypeWithNullability(this SemanticModel semanticModel, IFieldSymbol field, CancellationToken ct = default)
{
throw new NotImplementedException();
}

public static TypeInfo GetTypeWithNullability(this SemanticModel semanticModel, ILocalSymbol local, CancellationToken ct = default)
{
throw new NotImplementedException();
}

public static TypeInfo GetReturnTypeWithNullability(this SemanticModel semanticModel, IMethodSymbol method, CancellationToken ct = default)
{
throw new NotImplementedException();
}

public static ImmutableArray<TypeInfo> GetTypeParametersWithNullability(this SemanticModel semanticModel, IMethodSymbol method, CancellationToken ct = default)
{
throw new NotImplementedException();
}

public static TypeInfo GetReceiverTypeWithNullability(this SemanticModel semanticModel, IMethodSymbol method, CancellationToken ct = default)
{
throw new NotImplementedException();
}

public static TypeInfo GetTypeWithNullability(this SemanticModel semanticModel, IParameterSymbol local, CancellationToken ct = default)
{
throw new NotImplementedException();
}

/// <summary>
/// Gets a list of method or indexed property symbols for a syntax node.
/// </summary>
Expand Down
4 changes: 3 additions & 1 deletion src/Compilers/Core/Portable/Compilation/TypeInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ public struct TypeInfo : IEquatable<TypeInfo>
/// </summary>
public Nullability ConvertedNullability { get; }

internal TypeInfo(ITypeSymbol type, ITypeSymbol convertedType)
internal TypeInfo(ITypeSymbol type, ITypeSymbol convertedType, Nullability nullability = Nullability.NotComputed, Nullability convertedNullability = Nullability.NotComputed)
: this()
{
this.Type = type;
this.ConvertedType = convertedType;
this.Nullability = nullability;
this.ConvertedNullability = convertedNullability;
}

public bool Equals(TypeInfo other)
Expand Down
19 changes: 16 additions & 3 deletions src/Compilers/Core/Portable/PublicAPI.Unshipped.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,17 @@ Microsoft.CodeAnalysis.ISymbol.ToDisplayString(Microsoft.CodeAnalysis.Nullabilit
Microsoft.CodeAnalysis.ISymbol.ToMinimalDisplayParts(Microsoft.CodeAnalysis.SemanticModel semanticModel, int position, Microsoft.CodeAnalysis.Nullability nullability, Microsoft.CodeAnalysis.SymbolDisplayFormat format = null) -> System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.SymbolDisplayPart>
Microsoft.CodeAnalysis.ISymbol.ToMinimalDisplayString(Microsoft.CodeAnalysis.SemanticModel semanticModel, int position, Microsoft.CodeAnalysis.Nullability nullability, Microsoft.CodeAnalysis.SymbolDisplayFormat format = null) -> string
Microsoft.CodeAnalysis.ITypeParameterSymbol.ConstraintsNullability.get -> System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.Nullability>
Microsoft.CodeAnalysis.ITypeParameterSymbol.ReferenceTypeConstraintNullability.get -> Microsoft.CodeAnalysis.Nullability
Microsoft.CodeAnalysis.ITypeSymbol.ToDisplayParts(Microsoft.CodeAnalysis.Nullability nullability, Microsoft.CodeAnalysis.SymbolDisplayFormat format = null) -> System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.SymbolDisplayPart>
Microsoft.CodeAnalysis.ITypeSymbol.ToDisplayString(Microsoft.CodeAnalysis.Nullability nullability, Microsoft.CodeAnalysis.SymbolDisplayFormat format = null) -> string
Microsoft.CodeAnalysis.ITypeSymbol.ToMinimalDisplayParts(Microsoft.CodeAnalysis.SemanticModel semanticModel, int position, Microsoft.CodeAnalysis.Nullability nullability, Microsoft.CodeAnalysis.SymbolDisplayFormat format = null) -> System.Collections.Immutable.ImmutableArray<Microsoft.CodeAnalysis.SymbolDisplayPart>
Microsoft.CodeAnalysis.ITypeSymbol.ToMinimalDisplayString(Microsoft.CodeAnalysis.SemanticModel semanticModel, int position, Microsoft.CodeAnalysis.Nullability nullability, Microsoft.CodeAnalysis.SymbolDisplayFormat format = null) -> string
Microsoft.CodeAnalysis.Nullability
Microsoft.CodeAnalysis.Nullability.MaybeNull = 3 -> Microsoft.CodeAnalysis.Nullability
Microsoft.CodeAnalysis.Nullability.NonNull = 2 -> Microsoft.CodeAnalysis.Nullability
Microsoft.CodeAnalysis.Nullability.MaybeNull = 4 -> Microsoft.CodeAnalysis.Nullability
Microsoft.CodeAnalysis.Nullability.NonNull = 3 -> Microsoft.CodeAnalysis.Nullability
Microsoft.CodeAnalysis.Nullability.NotApplicable = 0 -> Microsoft.CodeAnalysis.Nullability
Microsoft.CodeAnalysis.Nullability.Unknown = 1 -> Microsoft.CodeAnalysis.Nullability
Microsoft.CodeAnalysis.Nullability.NotComputed = 1 -> Microsoft.CodeAnalysis.Nullability
Microsoft.CodeAnalysis.Nullability.Unknown = 2 -> Microsoft.CodeAnalysis.Nullability
Microsoft.CodeAnalysis.OperationKind.SuppressNullableWarning = 97 -> Microsoft.CodeAnalysis.OperationKind
Microsoft.CodeAnalysis.Operations.CommonConversion.IsImplicit.get -> bool
Microsoft.CodeAnalysis.Operations.ISuppressNullableWarningOperation
Expand Down Expand Up @@ -150,6 +156,13 @@ static Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowGraph.Create(Microsoft.Cod
static Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowGraph.Create(Microsoft.CodeAnalysis.Operations.IParameterInitializerOperation initializer, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowGraph
static Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowGraph.Create(Microsoft.CodeAnalysis.Operations.IPropertyInitializerOperation initializer, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowGraph
static Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowGraph.Create(Microsoft.CodeAnalysis.SyntaxNode node, Microsoft.CodeAnalysis.SemanticModel semanticModel, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> Microsoft.CodeAnalysis.FlowAnalysis.ControlFlowGraph
static Microsoft.CodeAnalysis.ModelExtensions.GetReturnTypeWithNullability(this Microsoft.CodeAnalysis.SemanticModel semanticModel, Microsoft.CodeAnalysis.IMethodSymbol method, System.Threading.CancellationToken ct = default(System.Threading.CancellationToken)) -> Microsoft.CodeAnalysis.TypeInfo
static Microsoft.CodeAnalysis.ModelExtensions.GetSymbolInfoWithNullability(this Microsoft.CodeAnalysis.SemanticModel semanticModel, Microsoft.CodeAnalysis.SyntaxNode , System.Threading.CancellationToken ct = default(System.Threading.CancellationToken)) -> Microsoft.CodeAnalysis.SymbolInfo
static Microsoft.CodeAnalysis.ModelExtensions.GetTypeInfoWithNullability(this Microsoft.CodeAnalysis.SemanticModel semanticModel, Microsoft.CodeAnalysis.SyntaxNode node, System.Threading.CancellationToken cancellationToken = default(System.Threading.CancellationToken)) -> Microsoft.CodeAnalysis.TypeInfo
static Microsoft.CodeAnalysis.ModelExtensions.GetTypeWithNullability(this Microsoft.CodeAnalysis.SemanticModel semanticModel, Microsoft.CodeAnalysis.IEventSymbol eventSymbol, System.Threading.CancellationToken ct = default(System.Threading.CancellationToken)) -> Microsoft.CodeAnalysis.TypeInfo
static Microsoft.CodeAnalysis.ModelExtensions.GetTypeWithNullability(this Microsoft.CodeAnalysis.SemanticModel semanticModel, Microsoft.CodeAnalysis.IFieldSymbol field, System.Threading.CancellationToken ct = default(System.Threading.CancellationToken)) -> Microsoft.CodeAnalysis.TypeInfo
static Microsoft.CodeAnalysis.ModelExtensions.GetTypeWithNullability(this Microsoft.CodeAnalysis.SemanticModel semanticModel, Microsoft.CodeAnalysis.ILocalSymbol local, System.Threading.CancellationToken ct = default(System.Threading.CancellationToken)) -> Microsoft.CodeAnalysis.TypeInfo
static Microsoft.CodeAnalysis.ModelExtensions.GetTypeWithNullability(this Microsoft.CodeAnalysis.SemanticModel semanticModel, Microsoft.CodeAnalysis.IParameterSymbol local, System.Threading.CancellationToken ct = default(System.Threading.CancellationToken)) -> Microsoft.CodeAnalysis.TypeInfo
virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitCaughtException(Microsoft.CodeAnalysis.FlowAnalysis.ICaughtExceptionOperation operation) -> void
virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitFlowCapture(Microsoft.CodeAnalysis.FlowAnalysis.IFlowCaptureOperation operation) -> void
virtual Microsoft.CodeAnalysis.Operations.OperationVisitor.VisitFlowCaptureReference(Microsoft.CodeAnalysis.FlowAnalysis.IFlowCaptureReferenceOperation operation) -> void
Expand Down
5 changes: 0 additions & 5 deletions src/Compilers/Core/Portable/Symbols/IDiscardSymbol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,5 @@ public interface IDiscardSymbol : ISymbol
/// The type of the discarded value.
/// </summary>
ITypeSymbol Type { get; }

/// <summary>
/// The nullability of the discarded value.
/// </summary>
Nullability Nullability { get; }
}
}
5 changes: 0 additions & 5 deletions src/Compilers/Core/Portable/Symbols/IEventSymbol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@ public interface IEventSymbol : ISymbol
/// </summary>
ITypeSymbol Type { get; }

/// <summary>
/// The declareted nullability of the this event.
/// </summary>
Nullability DeclaredNullability { get; }

/// <summary>
/// Returns true if the event is a WinRT type event.
/// </summary>
Expand Down
5 changes: 0 additions & 5 deletions src/Compilers/Core/Portable/Symbols/IFieldSymbol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,6 @@ public interface IFieldSymbol : ISymbol
/// </summary>
ITypeSymbol Type { get; }

/// <summary>
/// The declared nullability of this field.
/// </summary>
Nullability DeclaredNullability { get; }

/// <summary>
/// Returns false if the field wasn't declared as "const", or constant value was omitted or erroneous.
/// True otherwise.
Expand Down
6 changes: 0 additions & 6 deletions src/Compilers/Core/Portable/Symbols/ILocalSymbol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@ public interface ILocalSymbol : ISymbol
/// </summary>
ITypeSymbol Type { get; }

/// <summary>
/// The declared nullability of this local. If the local's type was inferred (i.e. via <code>var</code>), then
/// this declared nullability is inferred from the expression that initialized the local.
/// </summary>
Nullability DeclaredNullability { get; }

/// <summary>
/// Returns true if this local variable was declared as "const" (i.e. is a constant declaration).
/// Also returns true for an enum member.
Expand Down
11 changes: 0 additions & 11 deletions src/Compilers/Core/Portable/Symbols/IMethodSymbol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,24 +90,13 @@ public interface IMethodSymbol : ISymbol
/// </summary>
ITypeSymbol ReturnType { get; }

/// <summary>
/// Gets the declared nullability of the return type of the method.
/// </summary>
Nullability ReturnNullability { get; }

/// <summary>
/// Returns the type arguments that have been substituted for the type parameters.
/// If nothing has been substituted for a given type parameter,
/// then the type parameter itself is consider the type argument.
/// </summary>
ImmutableArray<ITypeSymbol> TypeArguments { get; }

/// <summary>
/// Returns the nullability of the type arguments that have been substituted for the
/// type paramters.
/// </summary>
ImmutableArray<Nullability> TypeArgumentsNullability { get; }

/// <summary>
/// Get the type parameters on this method. If the method has not generic,
/// returns an empty list.
Expand Down
5 changes: 0 additions & 5 deletions src/Compilers/Core/Portable/Symbols/IParameterSymbol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,6 @@ public interface IParameterSymbol : ISymbol
/// </summary>
ITypeSymbol Type { get; }

/// <summary>
/// Gets the declared nullability of the parameter
/// </summary>
Nullability DeclaredNullability { get; }

/// <summary>
/// Custom modifiers associated with the parameter type, or an empty array if there are none.
/// </summary>
Expand Down
5 changes: 0 additions & 5 deletions src/Compilers/Core/Portable/Symbols/IPropertySymbol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,6 @@ public interface IPropertySymbol : ISymbol
/// </summary>
ITypeSymbol Type { get; }

/// <summary>
/// Gets the declared nullability of the property
/// </summary>
Nullability DeclaredNullability { get; }

/// <summary>
/// The parameters of this property. If this property has no parameters, returns
/// an empty list. Parameters are only present on indexers, or on some properties
Expand Down
52 changes: 0 additions & 52 deletions src/Compilers/Core/Portable/Symbols/ISymbol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -213,14 +213,6 @@ public interface ISymbol : IEquatable<ISymbol>
/// <returns>A formatted string representation of the symbol.</returns>
string ToDisplayString(SymbolDisplayFormat format = null);

/// <summary>
/// Converts the symbol to a string representation with given nullability.
/// </summary>
/// <param name="nullability">The nullability to use for the symbol.</param>
/// <param name="format">Format or null for the default.</param>
/// <returns>A formatted string representation of the symbol.</returns>
string ToDisplayString(Nullability nullability, SymbolDisplayFormat format = null);

/// <summary>
/// Convert a symbol to an array of string parts, each of which has a kind. Useful for
/// colorizing the display string.
Expand All @@ -230,16 +222,6 @@ public interface ISymbol : IEquatable<ISymbol>
/// <returns>A read-only array of string parts.</returns>
ImmutableArray<SymbolDisplayPart> ToDisplayParts(SymbolDisplayFormat format = null);

/// <summary>
/// Convert a symbol to an array of string parts, each of which has a kind, with a given
/// nullability. Useful for colorizing the display string.
/// </summary>
/// <param name="nullability">The nullability to use for formatting.</param>
/// <param name="format">Formatting rules - null implies
/// SymbolDisplayFormat.ErrorMessageFormat.</param>
/// <returns>A read-only array of string parts.</returns>
ImmutableArray<SymbolDisplayPart> ToDisplayParts(Nullability nullability, SymbolDisplayFormat format = null);

/// <summary>
/// Convert a symbol to a string that can be displayed to the user. May be tailored to a
/// specific location in the source code.
Expand All @@ -255,22 +237,6 @@ string ToMinimalDisplayString(
int position,
SymbolDisplayFormat format = null);

/// <summary>
/// Convert a symbol to a string that can be displayed to the user. May be tailored to a
/// specific location in the source code.
/// </summary>
/// <param name="semanticModel">Binding information (for determining names appropriate to
/// the context).</param>
/// <param name="position">A position in the source code (context).</param>
/// <param name="nullability">The nullability to use in formatting.</param>
/// <param name="format">Formatting rules - null implies
/// <returns>A formatted string that can be displayed to the user.</returns>
string ToMinimalDisplayString(
SemanticModel semanticModel,
int position,
Nullability nullability,
SymbolDisplayFormat format = null);

/// <summary>
/// Convert a symbol to an array of string parts, each of which has a kind. May be tailored
/// to a specific location in the source code. Useful for colorizing the display string.
Expand All @@ -286,24 +252,6 @@ ImmutableArray<SymbolDisplayPart> ToMinimalDisplayParts(
int position,
SymbolDisplayFormat format = null);

/// <summary>
/// Convert a symbol to an array of string parts, each of which has a kind, including
/// nullability. May be tailored to a specific location in the source code. Useful
/// for colorizing the display string.
/// </summary>
/// <param name="semanticModel">Binding information (for determining names appropriate to
/// the context).</param>
/// <param name="position">A position in the source code (context).</param>
/// <param name="nullability">The nullability to use in formatting.</param>
/// <param name="format">Formatting rules - null implies
/// SymbolDisplayFormat.MinimallyQualifiedFormat.</param>
/// <returns>A read-only array of string parts.</returns>
ImmutableArray<SymbolDisplayPart> ToMinimalDisplayParts(
SemanticModel semanticModel,
int position,
Nullability nullability,
SymbolDisplayFormat format = null);

/// <summary>
/// Indicates that this symbol uses metadata that cannot be supported by the language.
///
Expand Down
5 changes: 5 additions & 0 deletions src/Compilers/Core/Portable/Symbols/ITypeParameterSymbol.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ public interface ITypeParameterSymbol : ITypeSymbol
/// </summary>
bool HasReferenceTypeConstraint { get; }

/// <summary>
/// <see cref="Nullability.NotApplicable"/> if <see cref="HasReferenceTypeConstraint"/> is false.
/// </summary>
Nullability ReferenceTypeConstraintNullability { get; }

/// <summary>
/// True if the value type constraint (<c>struct</c>) was specified for the type parameter.
/// </summary>
Expand Down
Loading

0 comments on commit a21916e

Please sign in to comment.