Simplified method.

This commit is contained in:
Evgeny Gerashchenko
2012-12-29 16:01:57 +04:00
parent 1f665e35f1
commit 5314b7a81e
@@ -144,8 +144,7 @@ public class JetSourceNavigationHelper {
PsiElement declarationContainer = decompiledDeclaration.getParent(); PsiElement declarationContainer = decompiledDeclaration.getParent();
if (declarationContainer instanceof JetFile) { if (declarationContainer instanceof JetFile) {
Pair<BindingContext, NamespaceDescriptor> contextAndNamespace = Pair<BindingContext, NamespaceDescriptor> contextAndNamespace = getBindingContextAndNamespaceDescriptor(decompiledDeclaration);
getBindingContextAndNamespaceDescriptor(decompiledDeclaration);
if (contextAndNamespace == null) { if (contextAndNamespace == null) {
return null; return null;
} }
@@ -153,29 +152,32 @@ public class JetSourceNavigationHelper {
} }
if (declarationContainer instanceof JetClassBody) { if (declarationContainer instanceof JetClassBody) {
JetClassOrObject decompiledClassOrObject = (JetClassOrObject) declarationContainer.getParent(); JetClassOrObject decompiledClassOrObject = (JetClassOrObject) declarationContainer.getParent();
boolean isClassObject = assert decompiledClassOrObject != null;
decompiledClassOrObject instanceof JetObjectDeclaration && decompiledClassOrObject.getParent() instanceof JetClassObject;
JetClassOrObject namedClassOrObject =
isClassObject ? PsiTreeUtil.getParentOfType(decompiledClassOrObject, JetClass.class) : decompiledClassOrObject;
assert namedClassOrObject != null;
Pair<BindingContext, ClassDescriptor> contextAndClass = if (decompiledClassOrObject instanceof JetObjectDeclaration && decompiledClassOrObject.getParent() instanceof JetClassObject) {
getBindingContextAndClassOrNamespaceDescriptor(BindingContext.FQNAME_TO_CLASS_DESCRIPTOR, namedClassOrObject, // class object case
JetPsiUtil.getFQName((JetNamedDeclaration) namedClassOrObject));
if (contextAndClass == null) {
return null;
}
BindingContext bindingContext = contextAndClass.first; JetClass klass = PsiTreeUtil.getParentOfType(decompiledClassOrObject, JetClass.class);
ClassDescriptor classDescriptor = contextAndClass.second; assert klass != null;
Pair<BindingContext, ClassDescriptor> contextAndClass = getBindingContextAndClassDescriptor(klass);
if (isClassObject) { if (contextAndClass == null) {
JetType classObjectType = classDescriptor.getClassObjectType(); return null;
}
JetType classObjectType = contextAndClass.second.getClassObjectType();
assert classObjectType != null; assert classObjectType != null;
return Pair.create(bindingContext, classObjectType.getMemberScope()); return Pair.create(contextAndClass.first, classObjectType.getMemberScope());
} }
else {
Pair<BindingContext, ClassDescriptor> contextAndClass = getBindingContextAndClassDescriptor(decompiledClassOrObject);
return Pair.create(bindingContext, classDescriptor.getDefaultType().getMemberScope()); if (contextAndClass == null) {
return null;
}
return Pair.create(contextAndClass.first, contextAndClass.second.getDefaultType().getMemberScope());
}
} }
throw new IllegalStateException("Unexpected container of decompiled declaration: " throw new IllegalStateException("Unexpected container of decompiled declaration: "