-
Notifications
You must be signed in to change notification settings - Fork 418
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix gathering inherited properties in PSI
- Loading branch information
1 parent
9309da2
commit 2f42d93
Showing
4 changed files
with
209 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package org.jetbrains.dokka.model | ||
|
||
import org.jetbrains.dokka.links.DRI | ||
|
||
fun DRI.isJvmField(): Boolean = packageName == "kotlin.jvm" && classNames == "JvmField" | ||
|
||
fun Annotations.Annotation.isJvmField(): Boolean = dri.isJvmName() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
133 changes: 133 additions & 0 deletions
133
plugins/base/src/test/kotlin/superFields/PsiSuperFieldsTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,133 @@ | ||
package superFields | ||
|
||
import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest | ||
import org.jetbrains.dokka.links.DRI | ||
import org.jetbrains.dokka.model.InheritedMember | ||
import org.junit.jupiter.api.Assertions.assertNotNull | ||
import org.junit.jupiter.api.Assertions.assertNull | ||
import org.junit.jupiter.api.Test | ||
import kotlin.test.assertEquals | ||
|
||
|
||
class PsiSuperFieldsTest : BaseAbstractTest() { | ||
|
||
@Test | ||
fun `java inheriting java`() { | ||
testInline( | ||
""" | ||
|/src/test/A.java | ||
|package test; | ||
|public class A { | ||
| public int a = 1; | ||
|} | ||
| | ||
|/src/test/B.java | ||
|package test; | ||
|public class B extends A {} | ||
""".trimIndent(), | ||
dokkaConfiguration { | ||
sourceSets { | ||
sourceSet { | ||
sourceRoots = listOf("src/") | ||
analysisPlatform = "jvm" | ||
name = "jvm" | ||
} | ||
} | ||
} | ||
) { | ||
documentablesMergingStage = { | ||
it.packages.single().classlikes.single { it.name == "B" }.properties.single { it.name == "a" }.run { | ||
assertNotNull(this) | ||
this.extra[InheritedMember]?.inheritedFrom?.values?.single()?.run { | ||
assertEquals( | ||
DRI(packageName = "test", classNames = "A"), | ||
this | ||
) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
fun `java inheriting kotlin`() { | ||
testInline( | ||
""" | ||
|/src/test/A.kt | ||
|package test | ||
|open class A { | ||
| var a: Int = 1 | ||
|} | ||
| | ||
|/src/test/B.java | ||
|package test; | ||
|public class B extends A {} | ||
""".trimIndent(), | ||
dokkaConfiguration { | ||
sourceSets { | ||
sourceSet { | ||
sourceRoots = listOf("src/") | ||
analysisPlatform = "jvm" | ||
name = "jvm" | ||
} | ||
} | ||
} | ||
) { | ||
documentablesMergingStage = { | ||
it.packages.single().classlikes.single { it.name == "B" }.properties.single { it.name == "a" }.run { | ||
assertNotNull(this) | ||
assertNotNull(this.getter) | ||
assertNotNull(this.setter) | ||
this.extra[InheritedMember]?.inheritedFrom?.values?.single()?.run { | ||
assertEquals( | ||
DRI(packageName = "test", classNames = "A"), | ||
this | ||
) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
fun `java inheriting kotlin with @JvmField should not inherit beans`() { | ||
testInline( | ||
""" | ||
|/src/test/A.kt | ||
|package test | ||
|open class A { | ||
| @kotlin.jvm.JvmField | ||
| var a: Int = 1 | ||
|} | ||
| | ||
|/src/test/B.java | ||
|package test; | ||
|public class B extends A {} | ||
""".trimIndent(), | ||
dokkaConfiguration { | ||
sourceSets { | ||
sourceSet { | ||
sourceRoots = listOf("src/") | ||
analysisPlatform = "jvm" | ||
name = "jvm" | ||
classpath += jvmStdlibPath!! | ||
} | ||
} | ||
} | ||
) { | ||
documentablesMergingStage = { | ||
it.packages.single().classlikes.single { it.name == "B" }.properties.single { it.name == "a" }.run { | ||
assertNotNull(this) | ||
assertNull(this.getter) | ||
assertNull(this.setter) | ||
this.extra[InheritedMember]?.inheritedFrom?.values?.single()?.run { | ||
assertEquals( | ||
DRI(packageName = "test", classNames = "A"), | ||
this | ||
) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |