Browse Source

Moved members of ParametrizedType to IType (for consistency with the

IMethod changes).
pull/32/merge
Mike Krüger 13 years ago
parent
commit
295a70e721
  1. 9
      ICSharpCode.NRefactory/TypeSystem/IMethod.cs
  2. 27
      ICSharpCode.NRefactory/TypeSystem/IType.cs
  3. 17
      ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractResolvedTypeParameter.cs
  4. 17
      ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractType.cs
  5. 17
      ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultResolvedTypeDefinition.cs
  6. 6
      ICSharpCode.NRefactory/TypeSystem/ParameterizedType.cs

9
ICSharpCode.NRefactory/TypeSystem/IMethod.cs

@ -88,20 +88,27 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -88,20 +88,27 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// Gets the unresolved method parts.
/// For partial methods, this returns all parts.
/// Otherwise, this returns an array with a single element (new[] { UnresolvedMember }).
/// NOTE: The type will change to IReadOnlyList<IUnresolvedMethod> in future versions.
/// </summary>
IList<IUnresolvedMethod> Parts { get; }
/// <summary>
/// Gets the attributes associated with the return type. (e.g. [return: MarshalAs(...)])
/// NOTE: The type will change to IReadOnlyList<IAttribute> in future versions.
/// </summary>
IList<IAttribute> ReturnTypeAttributes { get; }
/// <summary>
/// NOTE: The type will change to IReadOnlyList<ITypeParameter> in future versions.
/// </summary>
IList<ITypeParameter> TypeParameters { get; }
/// <summary>
/// Gets the type arguments passed to this method.
/// If only the type parameters for the class were specified and the generic method
/// itself is not specialized yet, this property will return an empty list.
/// NOTE: The type will change to IReadOnlyList<IType> in future versions.
/// </summary>
IList<IType> TypeArguments {
get;

27
ICSharpCode.NRefactory/TypeSystem/IType.cs

@ -18,6 +18,7 @@ @@ -18,6 +18,7 @@
using System;
using System.Collections.Generic;
using ICSharpCode.NRefactory.TypeSystem.Implementation;
namespace ICSharpCode.NRefactory.TypeSystem
{
@ -80,7 +81,15 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -80,7 +81,15 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// Gets the number of type parameters.
/// </summary>
int TypeParameterCount { get; }
/// <summary>
/// Gets the type arguments passed to this type.
/// If only the type parameters for the class were specified and the generic type
/// itself is not specialized yet or the TypeParameterCount is 0, this property will return an empty list.
/// NOTE: The type will change to IReadOnlyList<IType> in future versions.
/// </summary>
IList<IType> TypeArguments { get; }
/// <summary>
/// Calls ITypeVisitor.Visit for this type.
/// </summary>
@ -110,6 +119,22 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -110,6 +119,22 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// Otherwise, the main resolve context of a compilation is sufficient.
/// </remarks>
ITypeReference ToTypeReference();
/// <summary>
/// Gets a type visitor that performs the substitution of class type parameters with the type arguments
/// of this parameterized type.
/// Returns TypeParameterSubstitution.Identity if the type is not parametrized.
/// </summary>
TypeParameterSubstitution GetSubstitution();
/// <summary>
/// Gets a type visitor that performs the substitution of class type parameters with the type arguments
/// of this parameterized type,
/// and also substitutes method type parameters with the specified method type arguments.
/// Returns TypeParameterSubstitution.Identity if the type is not parametrized.
/// </summary>
TypeParameterSubstitution GetSubstitution(IList<IType> methodTypeArguments);
/// <summary>
/// Gets inner classes (including inherited inner classes).

17
ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractResolvedTypeParameter.cs

@ -206,7 +206,12 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation @@ -206,7 +206,12 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
int IType.TypeParameterCount {
get { return 0; }
}
readonly static IList<IType> emptyTypeArguments = new IType[0];
IList<IType> IType.TypeArguments {
get { return emptyTypeArguments; }
}
public abstract IEnumerable<IType> DirectBaseTypes { get; }
public string Name {
@ -326,7 +331,17 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation @@ -326,7 +331,17 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
else
return GetMembersHelper.GetAccessors(this, FilterNonStatic(filter), options);
}
public TypeParameterSubstitution GetSubstitution()
{
return TypeParameterSubstitution.Identity;
}
public TypeParameterSubstitution GetSubstitution(IList<IType> methodTypeArguments)
{
return TypeParameterSubstitution.Identity;
}
static Predicate<T> FilterNonStatic<T>(Predicate<T> filter) where T : class, IUnresolvedMember
{
if (filter == null)

17
ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractType.cs

@ -58,7 +58,12 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation @@ -58,7 +58,12 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
public virtual int TypeParameterCount {
get { return 0; }
}
readonly static IList<IType> emptyTypeArguments = new IType[0];
IList<IType> IType.TypeArguments {
get { return emptyTypeArguments; }
}
public virtual IType DeclaringType {
get { return null; }
}
@ -128,6 +133,16 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation @@ -128,6 +133,16 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
return EmptyList<IMethod>.Instance;
}
public TypeParameterSubstitution GetSubstitution()
{
return TypeParameterSubstitution.Identity;
}
public TypeParameterSubstitution GetSubstitution(IList<IType> methodTypeArguments)
{
return TypeParameterSubstitution.Identity;
}
public override sealed bool Equals(object obj)
{
return Equals(obj as IType);

17
ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultResolvedTypeDefinition.cs

@ -492,7 +492,12 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation @@ -492,7 +492,12 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
public int TypeParameterCount {
get { return parts[0].TypeParameters.Count; }
}
readonly static IList<IType> emptyTypeArguments = new IType[0];
IList<IType> IType.TypeArguments {
get { return emptyTypeArguments; }
}
#region DirectBaseTypes
IList<IType> directBaseTypes;
@ -904,6 +909,16 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation @@ -904,6 +909,16 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
}
#endregion
public TypeParameterSubstitution GetSubstitution()
{
return TypeParameterSubstitution.Identity;
}
public TypeParameterSubstitution GetSubstitution(IList<IType> methodTypeArguments)
{
return TypeParameterSubstitution.Identity;
}
public bool Equals(IType other)
{
return this == other;

6
ICSharpCode.NRefactory/TypeSystem/ParameterizedType.cs

@ -137,12 +137,12 @@ namespace ICSharpCode.NRefactory.TypeSystem @@ -137,12 +137,12 @@ namespace ICSharpCode.NRefactory.TypeSystem
return ReflectionName;
}
public ReadOnlyCollection<IType> TypeArguments {
public IList<IType> TypeArguments {
get {
return Array.AsReadOnly(typeArguments);
return typeArguments;
}
}
/// <summary>
/// Same as 'parameterizedType.TypeArguments[index]', but is a bit more efficient (doesn't require the read-only wrapper).
/// </summary>

Loading…
Cancel
Save