Introduce isExpect/ActualDeclaration in KotlinLineMarkerProvider
Treat every member of expect declaration as expect declaration itself So #KT-18455 Fixed
This commit is contained in:
@@ -48,6 +48,7 @@ import org.jetbrains.kotlin.idea.facet.implementingDescriptors
|
|||||||
import org.jetbrains.kotlin.idea.util.ProjectRootsUtil
|
import org.jetbrains.kotlin.idea.util.ProjectRootsUtil
|
||||||
import org.jetbrains.kotlin.lexer.KtTokens
|
import org.jetbrains.kotlin.lexer.KtTokens
|
||||||
import org.jetbrains.kotlin.psi.*
|
import org.jetbrains.kotlin.psi.*
|
||||||
|
import org.jetbrains.kotlin.psi.psiUtil.containingClassOrObject
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.hasExpectModifier
|
import org.jetbrains.kotlin.psi.psiUtil.hasExpectModifier
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.hasActualModifier
|
import org.jetbrains.kotlin.psi.psiUtil.hasActualModifier
|
||||||
import java.awt.event.MouseEvent
|
import java.awt.event.MouseEvent
|
||||||
@@ -61,6 +62,12 @@ class KotlinLineMarkerProvider : LineMarkerProvider {
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun KtNamedDeclaration.isExpectDeclaration(): Boolean =
|
||||||
|
hasExpectModifier() || containingClassOrObject?.isExpectDeclaration() == true
|
||||||
|
|
||||||
|
private fun KtNamedDeclaration.isActualDeclaration(): Boolean =
|
||||||
|
hasActualModifier()
|
||||||
|
|
||||||
override fun collectSlowLineMarkers(elements: List<PsiElement>, result: MutableCollection<LineMarkerInfo<*>>) {
|
override fun collectSlowLineMarkers(elements: List<PsiElement>, result: MutableCollection<LineMarkerInfo<*>>) {
|
||||||
if (elements.isEmpty()) return
|
if (elements.isEmpty()) return
|
||||||
|
|
||||||
@@ -100,10 +107,10 @@ class KotlinLineMarkerProvider : LineMarkerProvider {
|
|||||||
for (element in elements) {
|
for (element in elements) {
|
||||||
if (element !is KtNamedDeclaration) continue
|
if (element !is KtNamedDeclaration) continue
|
||||||
|
|
||||||
if (element.hasExpectModifier()) {
|
if (element.isExpectDeclaration()) {
|
||||||
collectActualMarkers(element, result)
|
collectActualMarkers(element, result)
|
||||||
}
|
}
|
||||||
else if (element.hasActualModifier()) {
|
else if (element.isActualDeclaration()) {
|
||||||
collectExpectedMarkers(element, result)
|
collectExpectedMarkers(element, result)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
expect class <lineMarker>Header</lineMarker> {
|
expect class <lineMarker>Header</lineMarker> {
|
||||||
fun foo(): Int
|
fun <lineMarker>foo</lineMarker>(): Int
|
||||||
}
|
}
|
||||||
|
|
||||||
expect fun <lineMarker>foo</lineMarker>(arg: Int): String
|
expect fun <lineMarker>foo</lineMarker>(arg: Int): String
|
||||||
|
|||||||
+1
-1
@@ -1,3 +1,3 @@
|
|||||||
expect class <lineMarker>SecondaryConstructor</lineMarker>{
|
expect class <lineMarker>SecondaryConstructor</lineMarker>{
|
||||||
constructor(name: String, surname: String)
|
<lineMarker>constructor</lineMarker>(name: String, surname: String)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user