Browse Source

Fixed resolving accessors.

newNRvisualizers
Daniel Grunwald 13 years ago
parent
commit
a2798aa7a7
  1. 2
      src/Libraries/NRefactory/ICSharpCode.NRefactory/TypeSystem/IMethod.cs
  2. 27
      src/Libraries/NRefactory/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultUnresolvedMethod.cs

2
src/Libraries/NRefactory/ICSharpCode.NRefactory/TypeSystem/IMethod.cs

@ -43,7 +43,7 @@ namespace ICSharpCode.NRefactory.TypeSystem
/// If this method is an accessor, returns a reference to the corresponding property/event. /// If this method is an accessor, returns a reference to the corresponding property/event.
/// Otherwise, returns null. /// Otherwise, returns null.
/// </summary> /// </summary>
IMemberReference AccessorOwner { get; } IUnresolvedMember AccessorOwner { get; }
/// <summary> /// <summary>
/// Resolves the member. /// Resolves the member.

27
src/Libraries/NRefactory/ICSharpCode.NRefactory/TypeSystem/Implementation/DefaultUnresolvedMethod.cs

@ -32,7 +32,7 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
IList<IUnresolvedAttribute> returnTypeAttributes; IList<IUnresolvedAttribute> returnTypeAttributes;
IList<IUnresolvedTypeParameter> typeParameters; IList<IUnresolvedTypeParameter> typeParameters;
IList<IUnresolvedParameter> parameters; IList<IUnresolvedParameter> parameters;
IMemberReference accessorOwner; IUnresolvedMember accessorOwner;
protected override void FreezeInternal() protected override void FreezeInternal()
{ {
@ -126,7 +126,7 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
} }
} }
public IMemberReference AccessorOwner { public IUnresolvedMember AccessorOwner {
get { return accessorOwner; } get { return accessorOwner; }
set { set {
ThrowIfFrozen(); ThrowIfFrozen();
@ -159,6 +159,29 @@ namespace ICSharpCode.NRefactory.TypeSystem.Implementation
public override IMember Resolve(ITypeResolveContext context) public override IMember Resolve(ITypeResolveContext context)
{ {
if (accessorOwner != null) {
var owner = accessorOwner.Resolve(context);
if (owner != null) {
IProperty p = owner as IProperty;
if (p != null) {
if (p.CanGet && p.Getter.Name == this.Name)
return p.Getter;
if (p.CanSet && p.Setter.Name == this.Name)
return p.Setter;
}
IEvent e = owner as IEvent;
if (e != null) {
if (e.CanAdd && e.AddAccessor.Name == this.Name)
return e.AddAccessor;
if (e.CanRemove && e.RemoveAccessor.Name == this.Name)
return e.RemoveAccessor;
if (e.CanInvoke && e.InvokeAccessor.Name == this.Name)
return e.InvokeAccessor;
}
}
return null;
}
ITypeReference interfaceTypeReference = null; ITypeReference interfaceTypeReference = null;
if (this.IsExplicitInterfaceImplementation && this.ExplicitInterfaceImplementations.Count == 1) if (this.IsExplicitInterfaceImplementation && this.ExplicitInterfaceImplementations.Count == 1)
interfaceTypeReference = this.ExplicitInterfaceImplementations[0].DeclaringTypeReference; interfaceTypeReference = this.ExplicitInterfaceImplementations[0].DeclaringTypeReference;

Loading…
Cancel
Save