Browse Source

Fix #574: Wrong error highlighting with interface implementation

pull/573/merge
Andreas Weizel 12 years ago
parent
commit
872a8bf762
  1. 50
      src/Libraries/NRefactory/ICSharpCode.NRefactory.CSharp.Refactoring/CodeActions/ImplementInterfaceAction.cs

50
src/Libraries/NRefactory/ICSharpCode.NRefactory.CSharp.Refactoring/CodeActions/ImplementInterfaceAction.cs

@ -131,8 +131,8 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring @@ -131,8 +131,8 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
continue;
bool needsExplicitly = explicitly;
alreadyImplemented = implementingType.GetMembers().Any(m => m.ImplementedInterfaceMembers.Any(im => IsImplementation (im, ev)));
var implementingMember = implementingType.GetInterfaceImplementation(ev);
alreadyImplemented = (implementingMember != null);
if (!alreadyImplemented) {
toImplement.Add(new Tuple<IMember, bool>(ev, needsExplicitly));
} else {
@ -148,16 +148,17 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring @@ -148,16 +148,17 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
bool needsExplicitly = explicitly;
alreadyImplemented = false;
foreach (var cmet in implementingType.GetMethods ()) {
alreadyImplemented |= cmet.ImplementedInterfaceMembers.Any(m => IsImplementation (m, method));
if (CompareMembers(method, cmet)) {
if (!needsExplicitly && !cmet.ReturnType.Equals(method.ReturnType))
needsExplicitly = true;
else
alreadyImplemented |= !needsExplicitly /*|| cmet.InterfaceImplementations.Any (impl => impl.InterfaceType.Equals (interfaceType))*/;
var implementingMethod = implementingType.GetInterfaceImplementation(method);
alreadyImplemented = (implementingMethod != null);
if (alreadyImplemented) {
if (!needsExplicitly && !implementingMethod.ReturnType.Equals(method.ReturnType)) {
needsExplicitly = true;
alreadyImplemented = false;
} else {
alreadyImplemented = !needsExplicitly;
}
}
if (toImplement.Where(t => t.Item1 is IMethod).Any(t => CompareMembers(method, (IMethod)t.Item1)))
needsExplicitly = true;
if (!alreadyImplemented) {
@ -174,27 +175,18 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring @@ -174,27 +175,18 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
continue;
bool needsExplicitly = explicitly;
alreadyImplemented = implementingType.GetMembers().Any(m => m.ImplementedInterfaceMembers.Any(im => IsImplementation (im, prop)));
foreach (var t in implementingType.GetAllBaseTypeDefinitions ()) {
if (t.Kind == TypeKind.Interface) {
foreach (var cprop in t.Properties) {
if (cprop.Name == prop.Name && cprop.IsShadowing) {
if (!needsExplicitly && !cprop.ReturnType.Equals(prop.ReturnType))
needsExplicitly = true;
}
}
continue;
}
foreach (var cprop in t.Properties) {
if (cprop.Name == prop.Name) {
if (!needsExplicitly && !cprop.ReturnType.Equals(prop.ReturnType))
needsExplicitly = true;
else
alreadyImplemented |= !needsExplicitly/* || cprop.InterfaceImplementations.Any (impl => impl.InterfaceType.Resolve (ctx).Equals (interfaceType))*/;
}
var implementingProp = implementingType.GetInterfaceImplementation(prop);
alreadyImplemented = (implementingProp != null);
if (alreadyImplemented) {
if (!needsExplicitly && !implementingProp.ReturnType.Equals(prop.ReturnType)) {
needsExplicitly = true;
alreadyImplemented = false;
} else {
alreadyImplemented = !needsExplicitly;
}
}
if (!alreadyImplemented) {
toImplement.Add(new Tuple<IMember, bool>(prop, needsExplicitly));
} else {

Loading…
Cancel
Save