-
Notifications
You must be signed in to change notification settings - Fork 392
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
b0faaf0
commit cb2360a
Showing
3 changed files
with
182 additions
and
20 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
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
110 changes: 110 additions & 0 deletions
110
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,110 @@ | ||
package superFields | ||
|
||
import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest | ||
import org.junit.jupiter.api.Assertions.assertNotNull | ||
import org.junit.jupiter.api.Assertions.assertNull | ||
import org.junit.jupiter.api.Test | ||
|
||
|
||
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) | ||
} | ||
} | ||
} | ||
|
||
@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) | ||
} | ||
} | ||
} | ||
} | ||
|
||
@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) | ||
} | ||
} | ||
} | ||
} | ||
} |