inheritor navigation works from Java to Kotlin

This commit is contained in:
Dmitry Jemerov
2012-05-23 19:40:30 +02:00
parent 783dbdd605
commit 39fe59d40a
5 changed files with 88 additions and 21 deletions
@@ -207,20 +207,15 @@ public class JetClass extends JetTypeParameterListOwner
*/
@NotNull
public List<String> getSuperNames() {
final JetDelegationSpecifierList delegationSpecifierList = getDelegationSpecifierList();
if (delegationSpecifierList == null) return Collections.emptyList();
final List<JetDelegationSpecifier> specifiers = delegationSpecifierList.getDelegationSpecifiers();
final List<JetDelegationSpecifier> specifiers = getDelegationSpecifiers();
if (specifiers.size() == 0) return Collections.emptyList();
List<String> result = new ArrayList<String>();
for (JetDelegationSpecifier specifier : specifiers) {
final JetTypeReference typeReference = specifier.getTypeReference();
if (typeReference != null) {
final JetTypeElement typeElement = typeReference.getTypeElement();
if (typeElement instanceof JetUserType) {
final String referencedName = ((JetUserType) typeElement).getReferencedName();
if (referencedName != null) {
addSuperName(result, referencedName);
}
final JetUserType superType = specifier.getTypeAsUserType();
if (superType != null) {
final String referencedName = superType.getReferencedName();
if (referencedName != null) {
addSuperName(result, referencedName);
}
}
}
@@ -43,4 +43,16 @@ public class JetDelegationSpecifier extends JetElement{
public JetTypeReference getTypeReference() {
return (JetTypeReference) findChildByType(JetNodeTypes.TYPE_REFERENCE);
}
@Nullable
public JetUserType getTypeAsUserType() {
final JetTypeReference reference = getTypeReference();
if (reference != null) {
final JetTypeElement element = reference.getTypeElement();
if (element instanceof JetUserType) {
return ((JetUserType) element);
}
}
return null;
}
}
@@ -82,16 +82,8 @@ public class JetDelegatorToSuperCall extends JetDelegationSpecifier implements J
@Override
public JetTypeArgumentList getTypeArgumentList() {
JetTypeReference typeReference = getTypeReference();
if (typeReference == null) {
return null;
}
JetTypeElement typeElement = typeReference.getTypeElement();
if (typeElement instanceof JetUserType) {
JetUserType userType = (JetUserType) typeElement;
return userType.getTypeArgumentList();
}
return null;
final JetUserType userType = getTypeAsUserType();
return userType != null ? userType.getTypeArgumentList() : null;
}
}