Lines 1-5
Link Here
|
1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
2 |
* Copyright (c) 2000, 2010 IBM Corporation and others. |
2 |
* Copyright (c) 2000, 2011 IBM Corporation and others. |
3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
Lines 1106-1112
Link Here
|
1106 |
} |
1106 |
} |
1107 |
this.acceptedAnswer = true; |
1107 |
this.acceptedAnswer = true; |
1108 |
} else if (binding instanceof MethodBinding) { |
1108 |
} else if (binding instanceof MethodBinding) { |
1109 |
MethodBinding methodBinding = (MethodBinding) binding; |
1109 |
MethodBinding methodBinding = getCorrectMethodBinding((MethodBinding) binding); |
1110 |
this.noProposal = false; |
1110 |
this.noProposal = false; |
1111 |
|
1111 |
|
1112 |
boolean isValuesOrValueOf = false; |
1112 |
boolean isValuesOrValueOf = false; |
Lines 1608-1611
Link Here
|
1608 |
|
1608 |
|
1609 |
return false; |
1609 |
return false; |
1610 |
} |
1610 |
} |
|
|
1611 |
|
1612 |
private MethodBinding getCorrectMethodBinding(MethodBinding binding) { |
1613 |
if (this.parser.javadocParser instanceof SelectionJavadocParser) { |
1614 |
if (((SelectionJavadocParser)this.parser.javadocParser).inheritDocTagSelected){ |
1615 |
ReferenceBinding superclass = binding.declaringClass.superclass(); |
1616 |
try { |
1617 |
MethodBinding res = null; |
1618 |
res = findOverriddenMethodInHierarchy(superclass, binding); |
1619 |
if (res != null) |
1620 |
return res; |
1621 |
if (!binding.isConstructor()) { |
1622 |
ReferenceBinding[] superInterfaces= binding.declaringClass.superInterfaces(); |
1623 |
for (int i= 0; i < superInterfaces.length; i++) { |
1624 |
res= findOverriddenMethodInHierarchy(superInterfaces[i], binding); |
1625 |
if (res != null) { |
1626 |
return res; |
1627 |
} |
1628 |
} |
1629 |
} |
1630 |
|
1631 |
} catch (JavaModelException e) { |
1632 |
return null; |
1633 |
} |
1634 |
} |
1635 |
} |
1636 |
return binding; |
1637 |
} |
1638 |
|
1639 |
private MethodBinding findOverriddenMethodInType(ReferenceBinding overriddenType, MethodBinding overriding) throws JavaModelException { |
1640 |
if (overriddenType == null) |
1641 |
return null; |
1642 |
MethodBinding[] overriddenMethods= overriddenType.availableMethods(); |
1643 |
LookupEnvironment lookupEnv = this.lookupEnvironment; |
1644 |
if (lookupEnv != null && overriddenMethods != null) { |
1645 |
for (int i= 0; i < overriddenMethods.length; i++) { |
1646 |
if (lookupEnv.methodVerifier().isMethodSubsignature(overriding, overriddenMethods[i])) { |
1647 |
return overriddenMethods[i]; |
1648 |
} |
1649 |
} |
1650 |
} |
1651 |
return null; |
1652 |
} |
1653 |
|
1654 |
/** |
1655 |
* Finds the directly overridden method in a type and its super types. First the super class is examined and then the implemented interfaces. |
1656 |
* With generics it is possible that 2 methods in the same type are overidden at the same time. In that case, the first overridden method found is returned. |
1657 |
* @param type The type to find methods in |
1658 |
* @param overriding The overriding method |
1659 |
* @return The first overridden method or <code>null</code> if no method is overridden |
1660 |
* @throws JavaModelException |
1661 |
*/ |
1662 |
private MethodBinding findOverriddenMethodInHierarchy(ReferenceBinding type, MethodBinding overriding) throws JavaModelException { |
1663 |
if (type == null) |
1664 |
return null; |
1665 |
MethodBinding method= findOverriddenMethodInType(type, overriding); |
1666 |
if (method != null) { |
1667 |
return method; |
1668 |
} |
1669 |
ReferenceBinding superClass= type.superclass(); |
1670 |
if (superClass != null) { |
1671 |
MethodBinding res= findOverriddenMethodInHierarchy(superClass, overriding); |
1672 |
if (res != null) { |
1673 |
return res; |
1674 |
} |
1675 |
} |
1676 |
if (!overriding.isConstructor()) { |
1677 |
ReferenceBinding[] superInterfaces= type.superInterfaces(); |
1678 |
for (int i= 0; i < superInterfaces.length; i++) { |
1679 |
MethodBinding res= findOverriddenMethodInHierarchy(superInterfaces[i], overriding); |
1680 |
if (res != null) { |
1681 |
return res; |
1682 |
} |
1683 |
} |
1684 |
} |
1685 |
return method; |
1686 |
} |
1611 |
} |
1687 |
} |