Browse Source

Moved SpecializedMember property 'Substitution' to IMember and

SpecializedMethod property 'TypeArguments' to IMethod.
That should eliminate the need to upcast these objects & makes the
type system more flexible - that's needed for the
ReducedExtensionMethod model.
pull/32/merge
Mike Krüger 13 years ago
parent
commit
d19a6d2c96
  1. 6
      ICSharpCode.NRefactory.CSharp/Resolver/CSharpOperators.cs
  2. 17
      ICSharpCode.NRefactory.CSharp/Resolver/ReducedExtensionMethod.cs
  3. 9
      ICSharpCode.NRefactory/TypeSystem/IMember.cs
  4. 9
      ICSharpCode.NRefactory/TypeSystem/IMethod.cs
  5. 4
      ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractResolvedMember.cs
  6. 3
      ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultResolvedMethod.cs

6
ICSharpCode.NRefactory.CSharp/Resolver/CSharpOperators.cs

@ -228,6 +228,12 @@ namespace ICSharpCode.NRefactory.CSharp.Resolver
throw new NotSupportedException(); throw new NotSupportedException();
} }
TypeParameterSubstitution IMember.Substitution {
get {
return TypeParameterSubstitution.Identity;
}
}
string INamedElement.FullName { string INamedElement.FullName {
get { return "operator"; } get { return "operator"; }
} }

17
ICSharpCode.NRefactory.CSharp/Resolver/ReducedExtensionMethod.cs

@ -27,6 +27,7 @@ using System;
using ICSharpCode.NRefactory.TypeSystem; using ICSharpCode.NRefactory.TypeSystem;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using ICSharpCode.NRefactory.TypeSystem.Implementation;
namespace ICSharpCode.NRefactory.CSharp namespace ICSharpCode.NRefactory.CSharp
{ {
@ -143,6 +144,13 @@ namespace ICSharpCode.NRefactory.CSharp
} }
} }
public TypeParameterSubstitution Substitution {
get {
return baseMethod.Substitution;
}
}
#endregion #endregion
#region IMethod implementation #region IMethod implementation
@ -220,9 +228,16 @@ namespace ICSharpCode.NRefactory.CSharp
} }
public IMethod ReducedFrom { public IMethod ReducedFrom {
get { return baseMethod; } get {
return baseMethod;
}
} }
public IList<IType> TypeArguments {
get {
return baseMethod.TypeArguments;
}
}
#endregion #endregion
#region IParameterizedMember implementation #region IParameterizedMember implementation

9
ICSharpCode.NRefactory/TypeSystem/IMember.cs

@ -170,5 +170,14 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// Otherwise, the main resolve context of a compilation is sufficient. /// Otherwise, the main resolve context of a compilation is sufficient.
/// </remarks> /// </remarks>
IMemberReference ToMemberReference(); IMemberReference ToMemberReference();
/// <summary>
/// Gets the substitution belonging to this specialized member.
/// Returns TypeParameterSubstitution.Identity for not specialized members.
/// </summary>
TypeParameterSubstitution Substitution {
get;
}
} }
} }

9
ICSharpCode.NRefactory/TypeSystem/IMethod.cs

@ -98,6 +98,15 @@ namespace ICSharpCode.NRefactory.TypeSystem
IList<ITypeParameter> TypeParameters { get; } 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.
/// </summary>
IList<IType> TypeArguments {
get;
}
bool IsExtensionMethod { get; } bool IsExtensionMethod { get; }
bool IsConstructor { get; } bool IsConstructor { get; }
bool IsDestructor { get; } bool IsDestructor { get; }

4
ICSharpCode.NRefactory/TypeSystem/Implementation/AbstractResolvedMember.cs

@ -118,6 +118,10 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
get { return unresolved.IsOverridable; } get { return unresolved.IsOverridable; }
} }
public TypeParameterSubstitution Substitution {
get { return TypeParameterSubstitution.Identity; }
}
public virtual IMemberReference ToMemberReference() public virtual IMemberReference ToMemberReference()
{ {
var declTypeRef = this.DeclaringType.ToTypeReference(); var declTypeRef = this.DeclaringType.ToTypeReference();

3
ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultResolvedMethod.cs

@ -173,6 +173,9 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
public IList<IAttribute> ReturnTypeAttributes { get; private set; } public IList<IAttribute> ReturnTypeAttributes { get; private set; }
public IList<ITypeParameter> TypeParameters { get; private set; } public IList<ITypeParameter> TypeParameters { get; private set; }
static readonly IList<IType> emptyArguments = new IType[0];
public IList<IType> TypeArguments { get { return emptyArguments; } }
public bool IsExtensionMethod { get; private set; } public bool IsExtensionMethod { get; private set; }
public IList<IUnresolvedMethod> Parts { public IList<IUnresolvedMethod> Parts {

Loading…
Cancel
Save