aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt14
-rw-r--r--core/src/test/kotlin/model/KotlinAsJavaTest.kt3
2 files changed, 12 insertions, 5 deletions
diff --git a/core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt b/core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt
index 3b368329..d6743e60 100644
--- a/core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt
+++ b/core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt
@@ -29,7 +29,7 @@ fun getSignature(element: PsiElement?) = when(element) {
}
private fun methodSignature(method: PsiMethod): String {
- return method.containingClass!!.qualifiedName + "$" + method.name + "(" +
+ return method.containingClass?.qualifiedName + "$" + method.name + "(" +
method.parameterList.parameters.map { it.type.typeSignature() }.joinToString(",") + ")"
}
@@ -167,7 +167,7 @@ class JavaPsiDocumentationBuilder : JavaDocumentationBuilder {
element.isInternal())
private fun skipElementBySuppressedFiles(element: Any): Boolean =
- element is PsiElement && element.containingFile.virtualFile.path in passConfiguration.suppressedFiles
+ element is PsiElement && element.containingFile.virtualFile?.path in passConfiguration.suppressedFiles
private fun PsiElement.isInternal(): Boolean {
val ktElement = (this as? KtLightElement<*, *>)?.kotlinOrigin ?: return false
@@ -196,8 +196,16 @@ class JavaPsiDocumentationBuilder : JavaDocumentationBuilder {
link(superClass, node, RefKind.Inheritor)
}
}
+
+ var methodsAndConstructors = methods
+ if (constructors.isEmpty()) {
+ // Having no constructor represents a class that only has an implicit/default constructor
+ // so we create one synthetically for documentation
+ val factory = JavaPsiFacade.getElementFactory(this.project)
+ methodsAndConstructors += factory.createMethodFromText("public $name() {}", this)
+ }
node.appendDetails(typeParameters) { build() }
- node.appendMembers(methods) { build() }
+ node.appendMembers(methodsAndConstructors) { build() }
node.appendMembers(fields) { build() }
node.appendMembers(innerClasses) { build() }
register(this, node)
diff --git a/core/src/test/kotlin/model/KotlinAsJavaTest.kt b/core/src/test/kotlin/model/KotlinAsJavaTest.kt
index 8249dd0f..c29776be 100644
--- a/core/src/test/kotlin/model/KotlinAsJavaTest.kt
+++ b/core/src/test/kotlin/model/KotlinAsJavaTest.kt
@@ -16,9 +16,8 @@ class KotlinAsJavaTest {
val facadeClass = pkg.members.single { it.name == "FunctionKt" }
assertEquals(NodeKind.Class, facadeClass.kind)
- val fn = facadeClass.members.single()
+ val fn = facadeClass.members.single { it.kind == NodeKind.Function}
assertEquals("fn", fn.name)
- assertEquals(NodeKind.Function, fn.kind)
}
}