mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-05 08:05:24 +02:00
Bug 479142 - Show correct override marker when multiple overloads in a
base class are overridden in a derived class Change-Id: If31925a5fbffe1425d22894fdff762ef1c733f25 Signed-off-by: Nathan Ridge <zeratul976@hotmail.com>
This commit is contained in:
parent
49b368428f
commit
d0d92c076f
2 changed files with 24 additions and 4 deletions
|
@ -250,4 +250,18 @@ public class OverrideIndicatorTest extends AnnotationTestCase {
|
||||||
checkImplementsAnnotationLines(25, 26);
|
checkImplementsAnnotationLines(25, 26);
|
||||||
checkOverridesAnnotationLines(27);
|
checkOverridesAnnotationLines(27);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// struct Foo {
|
||||||
|
// virtual void waldo(int) = 0;
|
||||||
|
// virtual void waldo(float) = 0;
|
||||||
|
// };
|
||||||
|
//
|
||||||
|
// struct Bar : Foo {
|
||||||
|
// void waldo(int) override;
|
||||||
|
// void waldo(float) override;
|
||||||
|
// };
|
||||||
|
public void testMultipleOverloadsOverridden_479142() throws Exception {
|
||||||
|
loadCodeAndRun(getAboveComment());
|
||||||
|
checkImplementsAnnotationLines(7, 8);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -255,29 +255,35 @@ public class OverrideIndicatorManager implements ICReconcilingListener {
|
||||||
methodsCache.put(aClass, allInheritedMethods);
|
methodsCache.put(aClass, allInheritedMethods);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
boolean foundOverridden = false;
|
||||||
|
ICPPMethod result = null;
|
||||||
for (ICPPMethod method : allInheritedMethods) {
|
for (ICPPMethod method : allInheritedMethods) {
|
||||||
if (method.getName().equals(testedMethodName)) {
|
if (method.getName().equals(testedMethodName)) {
|
||||||
if (method.isVirtual()) {
|
if (method.isVirtual()) {
|
||||||
if (ClassTypeHelper.isOverrider(testedMethod, method)) {
|
if (ClassTypeHelper.isOverrider(testedMethod, method)) {
|
||||||
if (method.isPureVirtual()) {
|
if (method.isPureVirtual()) {
|
||||||
annotationKind = ANNOTATION_IMPLEMENTS;
|
annotationKind = ANNOTATION_IMPLEMENTS;
|
||||||
|
result = method;
|
||||||
} else {
|
} else {
|
||||||
annotationKind = ANNOTATION_OVERRIDES;
|
annotationKind = ANNOTATION_OVERRIDES;
|
||||||
|
result = method;
|
||||||
}
|
}
|
||||||
} else {
|
foundOverridden = true;
|
||||||
|
} else if (!foundOverridden) {
|
||||||
// The method has same name as virtual method in base, but does not override
|
// The method has same name as virtual method in base, but does not override
|
||||||
// it (e.g. because it has a different signature), it shadows it.
|
// it (e.g. because it has a different signature), it shadows it.
|
||||||
annotationKind = ANNOTATION_SHADOWS;
|
annotationKind = ANNOTATION_SHADOWS;
|
||||||
|
result = method;
|
||||||
}
|
}
|
||||||
} else {
|
} else if (!foundOverridden) {
|
||||||
// The method has same name and is not virtual, it hides/shadows the method
|
// The method has same name and is not virtual, it hides/shadows the method
|
||||||
// in the base class.
|
// in the base class.
|
||||||
annotationKind = ANNOTATION_SHADOWS;
|
annotationKind = ANNOTATION_SHADOWS;
|
||||||
}
|
result = method;
|
||||||
return method;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
}
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue