Refactoring: HasExpectedMarker (use not-null declarations)
This commit is contained in:
@@ -24,16 +24,16 @@ import org.jetbrains.kotlin.idea.util.expectedDeclarationIfAny
|
|||||||
import org.jetbrains.kotlin.idea.util.hasDeclarationOf
|
import org.jetbrains.kotlin.idea.util.hasDeclarationOf
|
||||||
import org.jetbrains.kotlin.psi.KtDeclaration
|
import org.jetbrains.kotlin.psi.KtDeclaration
|
||||||
|
|
||||||
fun getExpectedDeclarationTooltip(declaration: KtDeclaration?): String? {
|
fun getExpectedDeclarationTooltip(declaration: KtDeclaration): String? {
|
||||||
val descriptor = declaration?.toDescriptor() as? MemberDescriptor ?: return null
|
val descriptor = declaration.toDescriptor() as? MemberDescriptor ?: return null
|
||||||
val platformModuleDescriptor = declaration.containingKtFile.findModuleDescriptor()
|
val platformModuleDescriptor = declaration.containingKtFile.findModuleDescriptor()
|
||||||
|
|
||||||
val commonModuleDescriptors = platformModuleDescriptor.implementedDescriptors ?: return null
|
val commonModuleDescriptors = platformModuleDescriptor.implementedDescriptors
|
||||||
if (!commonModuleDescriptors.any { it.hasDeclarationOf(descriptor) }) return null
|
if (!commonModuleDescriptors.any { it.hasDeclarationOf(descriptor) }) return null
|
||||||
|
|
||||||
return "Has declaration in common module"
|
return "Has declaration in common module"
|
||||||
}
|
}
|
||||||
|
|
||||||
fun navigateToExpectedDeclaration(declaration: KtDeclaration?) {
|
fun navigateToExpectedDeclaration(declaration: KtDeclaration) {
|
||||||
declaration?.expectedDeclarationIfAny()?.navigate(false)
|
declaration.expectedDeclarationIfAny()?.navigate(false)
|
||||||
}
|
}
|
||||||
@@ -210,10 +210,10 @@ private val PLATFORM_ACTUAL = MarkerType(
|
|||||||
|
|
||||||
private val EXPECTED_DECLARATION = MarkerType(
|
private val EXPECTED_DECLARATION = MarkerType(
|
||||||
"EXPECTED_DECLARATION",
|
"EXPECTED_DECLARATION",
|
||||||
{ it?.let { getExpectedDeclarationTooltip(it.markerDeclaration) } },
|
{ element -> element?.markerDeclaration?.let { getExpectedDeclarationTooltip(it) } },
|
||||||
object : LineMarkerNavigator() {
|
object : LineMarkerNavigator() {
|
||||||
override fun browse(e: MouseEvent?, element: PsiElement?) {
|
override fun browse(e: MouseEvent?, element: PsiElement?) {
|
||||||
element?.let { navigateToExpectedDeclaration(it.markerDeclaration) }
|
element?.markerDeclaration?.let { navigateToExpectedDeclaration(it) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user