Introduce isExpect/ActualDeclaration in KotlinLineMarkerProvider

Treat every member of expect declaration as expect declaration itself
So #KT-18455 Fixed
This commit is contained in:
Mikhail Glukhikh
2017-10-09 12:07:52 +03:00
parent ceab148b09
commit 4e56fda439
3 changed files with 11 additions and 4 deletions
@@ -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,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)
} }