Supported navigation to source of named object and its members.
This commit is contained in:
@@ -197,6 +197,13 @@ public class DecompiledDataFactory {
|
||||
PsiElement clsMember = BindingContextUtils.descriptorToDeclaration(bindingContext, descriptor);
|
||||
if (clsMember != null) {
|
||||
clsMembersToRanges.put(clsMember, new TextRange(startOffset, endOffset));
|
||||
|
||||
if (descriptor instanceof ClassDescriptor && ((ClassDescriptor) descriptor).getKind() == ClassKind.OBJECT) {
|
||||
assert clsMember instanceof PsiClass;
|
||||
PsiField instanceField = ((PsiClass) clsMember).findFieldByName(JvmAbi.INSTANCE_FIELD, false);
|
||||
assert instanceField != null;
|
||||
clsMembersToRanges.put(instanceField, new TextRange(startOffset, endOffset));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -73,6 +73,12 @@ public class JetClsNavigationPolicy implements ClsCustomNavigationPolicy {
|
||||
return sourceProperty;
|
||||
}
|
||||
}
|
||||
else if (jetDeclaration instanceof JetClassOrObject) {
|
||||
JetClassOrObject sourceClass = JetSourceNavigationHelper.getSourceClassOrObject((JetClassOrObject) jetDeclaration);
|
||||
if (sourceClass != null) {
|
||||
return sourceClass;
|
||||
}
|
||||
}
|
||||
return jetDeclaration;
|
||||
}
|
||||
|
||||
|
||||
@@ -188,13 +188,12 @@ public class JetSourceNavigationHelper {
|
||||
}
|
||||
else if (declarationContainer instanceof JetClassBody) {
|
||||
JetClassOrObject parent = (JetClassOrObject)declarationContainer.getParent();
|
||||
boolean isClassObject = parent instanceof JetObjectDeclaration;
|
||||
JetClass jetClass =
|
||||
isClassObject ? PsiTreeUtil.getParentOfType(parent, JetClass.class) : (JetClass)parent;
|
||||
if (jetClass == null) {
|
||||
boolean isClassObject = parent instanceof JetObjectDeclaration && parent.getParent() instanceof JetClassObject;
|
||||
JetClassOrObject classOrObject = isClassObject ? PsiTreeUtil.getParentOfType(parent, JetClass.class) : parent;
|
||||
if (classOrObject == null) {
|
||||
return null;
|
||||
}
|
||||
Pair<BindingContext, ClassDescriptor> bindingContextAndClassDescriptor = getBindingContextAndClassDescriptor(jetClass);
|
||||
Pair<BindingContext, ClassDescriptor> bindingContextAndClassDescriptor = getBindingContextAndClassDescriptor(classOrObject);
|
||||
if (bindingContextAndClassDescriptor != null) {
|
||||
BindingContext bindingContext = bindingContextAndClassDescriptor.first;
|
||||
ClassDescriptor classDescriptor = bindingContextAndClassDescriptor.second;
|
||||
|
||||
Reference in New Issue
Block a user