aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt12
-rw-r--r--core/src/main/kotlin/Kotlin/KotlinAsJavaDocumentationBuilder.kt13
-rw-r--r--core/src/test/kotlin/javadoc/JavadocTest.kt11
-rw-r--r--core/src/test/kotlin/model/JavaTest.kt9
-rw-r--r--core/testdata/javadoc/suppress.kt37
5 files changed, 68 insertions, 14 deletions
diff --git a/core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt b/core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt
index e73b19b4..268315ef 100644
--- a/core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt
+++ b/core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt
@@ -3,9 +3,13 @@ package org.jetbrains.dokka
import com.google.inject.Inject
import com.intellij.psi.*
import com.intellij.psi.util.InheritanceUtil
+import com.intellij.psi.util.PsiTreeUtil
+import org.jetbrains.kotlin.asJava.KtLightDeclaration
import org.jetbrains.kotlin.asJava.KtLightElement
-import org.jetbrains.kotlin.lexer.KtModifierKeywordToken
+import org.jetbrains.kotlin.kdoc.parser.KDocKnownTag
+import org.jetbrains.kotlin.kdoc.psi.impl.KDocTag
import org.jetbrains.kotlin.lexer.KtTokens
+import org.jetbrains.kotlin.psi.KtDeclaration
import org.jetbrains.kotlin.psi.KtModifierListOwner
fun getSignature(element: PsiElement?) = when(element) {
@@ -277,6 +281,8 @@ class JavaPsiDocumentationBuilder : JavaDocumentationBuilder {
}
}
-fun hasSuppressDocTag(element: Any?) =
- element is PsiDocCommentOwner && element.docComment?.let { it.findTagByName("suppress") != null } ?: false
+fun hasSuppressDocTag(element: Any?): Boolean {
+ val declaration = (element as? KtLightDeclaration<*, *>)?.kotlinOrigin as? KtDeclaration ?: return false
+ return PsiTreeUtil.findChildrenOfType(declaration.docComment, KDocTag::class.java).any { it.knownTag == KDocKnownTag.SUPPRESS }
+}
diff --git a/core/src/main/kotlin/Kotlin/KotlinAsJavaDocumentationBuilder.kt b/core/src/main/kotlin/Kotlin/KotlinAsJavaDocumentationBuilder.kt
index 1250f463..304b2bf2 100644
--- a/core/src/main/kotlin/Kotlin/KotlinAsJavaDocumentationBuilder.kt
+++ b/core/src/main/kotlin/Kotlin/KotlinAsJavaDocumentationBuilder.kt
@@ -4,12 +4,9 @@ import com.google.inject.Inject
import com.intellij.psi.JavaPsiFacade
import com.intellij.psi.PsiClass
import com.intellij.psi.PsiNamedElement
-import com.intellij.psi.util.PsiTreeUtil
import org.jetbrains.dokka.Kotlin.DescriptorDocumentationParser
import org.jetbrains.kotlin.asJava.KtLightElement
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
-import org.jetbrains.kotlin.kdoc.parser.KDocKnownTag
-import org.jetbrains.kotlin.kdoc.psi.impl.KDocTag
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.psi.KtDeclaration
@@ -40,15 +37,11 @@ class KotlinAsJavaDocumentationBuilder
}
}
- fun KtDeclaration.isNotSuppressed() =
- PsiTreeUtil.findChildrenOfType(this.docComment, KDocTag::class.java).none { it.knownTag == KDocKnownTag.SUPPRESS }
-
- fun PsiClass.isVisibleInDocumentation() : Boolean {
+ fun PsiClass.isVisibleInDocumentation(): Boolean {
val origin: KtDeclaration = (this as KtLightElement<*, *>).kotlinOrigin as? KtDeclaration ?: return true
- return origin.isNotSuppressed() &&
- origin.hasModifier(KtTokens.INTERNAL_KEYWORD) != true &&
- origin.hasModifier(KtTokens.PRIVATE_KEYWORD) != true
+ return origin.hasModifier(KtTokens.INTERNAL_KEYWORD) != true &&
+ origin.hasModifier(KtTokens.PRIVATE_KEYWORD) != true
}
}
diff --git a/core/src/test/kotlin/javadoc/JavadocTest.kt b/core/src/test/kotlin/javadoc/JavadocTest.kt
index 6c572c10..41d22b47 100644
--- a/core/src/test/kotlin/javadoc/JavadocTest.kt
+++ b/core/src/test/kotlin/javadoc/JavadocTest.kt
@@ -96,6 +96,17 @@ class JavadocTest {
}
}
+ @Test fun testSuppress() {
+ verifyJavadoc("testdata/javadoc/suppress.kt", withKotlinRuntime = true) { doc ->
+ assertNull(doc.classNamed("Some"))
+ assertNull(doc.classNamed("SomeAgain"))
+ assertNull(doc.classNamed("Interface"))
+ val classSame = doc.classNamed("Same")!!
+ assertTrue(classSame.fields().isEmpty())
+ assertTrue(classSame.methods().isEmpty())
+ }
+ }
+
private fun verifyJavadoc(name: String,
withJdk: Boolean = false,
withKotlinRuntime: Boolean = false,
diff --git a/core/src/test/kotlin/model/JavaTest.kt b/core/src/test/kotlin/model/JavaTest.kt
index a89b7a11..c0e68304 100644
--- a/core/src/test/kotlin/model/JavaTest.kt
+++ b/core/src/test/kotlin/model/JavaTest.kt
@@ -3,6 +3,7 @@ package org.jetbrains.dokka.tests
import org.jetbrains.dokka.NodeKind
import org.jetbrains.dokka.RefKind
import org.junit.Assert.*
+import org.junit.Ignore
import org.junit.Test
public class JavaTest {
@@ -146,7 +147,13 @@ public class JavaTest {
}
}
- @Test fun suppressTag() {
+ /**
+ * `@suppress` not supported in Java!
+ *
+ * [Proposed tags](http://www.oracle.com/technetwork/java/javase/documentation/proposed-tags-142378.html)
+ * Proposed tag `@exclude` for it, but not supported yet
+ */
+ @Ignore("@suppress not supported in Java!") @Test fun suppressTag() {
verifyJavaPackageMember("testdata/java/suppressTag.java") { cls ->
assertEquals(1, cls.members(NodeKind.Function).size)
}
diff --git a/core/testdata/javadoc/suppress.kt b/core/testdata/javadoc/suppress.kt
new file mode 100644
index 00000000..90f6c131
--- /dev/null
+++ b/core/testdata/javadoc/suppress.kt
@@ -0,0 +1,37 @@
+/**
+ * @suppress
+ */
+class Some {
+
+}
+
+
+/**
+ * @suppress
+ * @author me
+ * @see other
+ */
+class SomeAgain {
+
+}
+
+class Same {
+ /**
+ * @suppress
+ */
+ fun privateApi() {
+
+ }
+
+ /**
+ * @suppress
+ */
+ val privateForSomeReason = ""
+}
+
+/**
+ * @suppress
+ */
+interface Interface {
+
+} \ No newline at end of file