From ce7ebd213a56abd2be6beacbef26b339935baeb6 Mon Sep 17 00:00:00 2001 From: Simon Ogorodnik Date: Fri, 3 Nov 2017 21:30:01 +0300 Subject: Fix not suppressing Android generated files in javadoc format fixes #224, fixes #197 --- core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'core/src/main/kotlin') diff --git a/core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt b/core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt index a950e432..6b1f8cb4 100644 --- a/core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt +++ b/core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt @@ -11,6 +11,7 @@ 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 +import java.io.File fun getSignature(element: PsiElement?) = when(element) { is PsiClass -> element.qualifiedName @@ -131,7 +132,10 @@ class JavaPsiDocumentationBuilder : JavaDocumentationBuilder { } } - private fun skipElement(element: Any) = skipElementByVisibility(element) || hasSuppressDocTag(element) + private fun skipElement(element: Any) = + skipElementByVisibility(element) || + hasSuppressDocTag(element) || + skipElementBySuppressedFiles(element) private fun skipElementByVisibility(element: Any): Boolean = element is PsiModifierListOwner && !(options.effectivePackageOptions((element.containingFile as? PsiJavaFile)?.packageName ?: "").includeNonPublic) && @@ -139,6 +143,9 @@ class JavaPsiDocumentationBuilder : JavaDocumentationBuilder { element.hasModifierProperty(PsiModifier.PACKAGE_LOCAL) || element.isInternal()) + private fun skipElementBySuppressedFiles(element: Any): Boolean = + element is PsiElement && File(element.containingFile.virtualFile.path).absoluteFile in options.suppressedFiles + private fun PsiElement.isInternal(): Boolean { val ktElement = (this as? KtLightElement<*, *>)?.kotlinOrigin ?: return false return (ktElement as? KtModifierListOwner)?.hasModifier(KtTokens.INTERNAL_KEYWORD) ?: false -- cgit