@NotNull private static PsiClass findCorrespondingLightClass( @NotNull JetClassOrObject decompiledClassOrObject, @NotNull PsiClass rootLightClassForDecompiledFile) { FqName relativeFqName = getClassRelativeName(decompiledClassOrObject); Iterator<Name> iterator = relativeFqName.pathSegments().iterator(); Name base = iterator.next(); assert rootLightClassForDecompiledFile.getName().equals(base.asString()) : "Light class for file:\n" + decompiledClassOrObject.getContainingJetFile().getVirtualFile().getCanonicalPath() + "\nwas expected to have name: " + base.asString() + "\n Actual: " + rootLightClassForDecompiledFile.getName(); PsiClass current = rootLightClassForDecompiledFile; while (iterator.hasNext()) { Name name = iterator.next(); PsiClass innerClass = current.findInnerClassByName(name.asString(), false); assert innerClass != null : "Could not find corresponding inner/nested class " + relativeFqName + " in class " + decompiledClassOrObject.getFqName() + "\n" + "File: " + decompiledClassOrObject.getContainingJetFile().getVirtualFile().getName(); current = innerClass; } return current; }
@Nullable private static PsiClass getLightClassForDecompiledClassOrObject( @NotNull JetClassOrObject decompiledClassOrObject) { if (decompiledClassOrObject instanceof JetEnumEntry) { return null; } JetFile containingJetFile = decompiledClassOrObject.getContainingJetFile(); if (!containingJetFile.isCompiled()) { return null; } PsiClass rootLightClassForDecompiledFile = createLightClassForDecompiledKotlinFile(containingJetFile); if (rootLightClassForDecompiledFile == null) return null; return findCorrespondingLightClass(decompiledClassOrObject, rootLightClassForDecompiledFile); }