From 54c62ace5403f6b644152fbb67fb98dca5005ca4 Mon Sep 17 00:00:00 2001 From: Alex Saveau Date: Tue, 30 Jun 2020 21:47:15 +0000 Subject: Don't use fully qualified names in Dokka Javadoc Bug: 149340317 Test: updated existing tests, ran ./gradlew test Change-Id: I1abe2886ff634ce38ff148565917d4305c891bc9 --- core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt | 3 ++- core/src/test/kotlin/javadoc/JavadocTest.kt | 6 +++--- core/testdata/format/dac/deprecation/dac-as-java/Bar.html | 2 +- .../format/dac/deprecation/dac-as-java/DeprecatedBar.html | 2 +- .../format/dac/deprecation/dac-as-java/DeprecatedFoo.html | 2 +- core/testdata/format/dac/deprecation/dac-as-java/Foo.html | 2 +- .../format/dac/inheritedMethods/dac-as-java/Parent.html | 2 +- .../format/dac/javaClassLinks/dac-as-java/Bar.html | 14 +++++++------- .../format/dac/javaClassLinks/dac-as-java/Foo.html | 2 +- .../format/dac/javaConstructor/dac-as-java/Foo.html | 2 +- .../format/dac/javaDefaultConstructor/dac-as-java/Foo.html | 2 +- .../format/dac/javaMethodVisibilities/dac-as-java/Foo.html | 2 +- core/testdata/format/dac/javaSeeTag/dac-as-java/Bar.html | 2 +- core/testdata/format/dac/javaSeeTag/dac-as-java/Foo.html | 2 +- 14 files changed, 23 insertions(+), 22 deletions(-) diff --git a/core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt b/core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt index ed4d36687..be989ad37 100644 --- a/core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt +++ b/core/src/main/kotlin/Java/JavaPsiDocumentationBuilder.kt @@ -29,12 +29,13 @@ fun getSignature(element: PsiElement?) = when(element) { private fun PsiType.typeSignature(): String = when(this) { is PsiArrayType -> "Array((${componentType.typeSignature()}))" is PsiPrimitiveType -> "kotlin." + canonicalText.capitalize() + is PsiClassType -> resolve()?.qualifiedName ?: className else -> mapTypeName(this) } private fun mapTypeName(psiType: PsiType): String = when (psiType) { is PsiPrimitiveType -> psiType.canonicalText - is PsiClassType -> psiType.resolve()?.qualifiedName ?: psiType.className + is PsiClassType -> psiType.resolve()?.name ?: psiType.className is PsiEllipsisType -> mapTypeName(psiType.componentType) is PsiArrayType -> "kotlin.Array" else -> psiType.canonicalText diff --git a/core/src/test/kotlin/javadoc/JavadocTest.kt b/core/src/test/kotlin/javadoc/JavadocTest.kt index 74265cbb8..a42d63933 100644 --- a/core/src/test/kotlin/javadoc/JavadocTest.kt +++ b/core/src/test/kotlin/javadoc/JavadocTest.kt @@ -16,8 +16,8 @@ class JavadocTest { val type = method.returnType() assertFalse(type.asClassDoc().isIncluded) - assertEquals("java.lang.String", type.qualifiedTypeName()) - assertEquals("java.lang.String", type.asClassDoc().qualifiedName()) + assertEquals("String", type.qualifiedTypeName()) + assertEquals("String", type.asClassDoc().qualifiedName()) val params = method.parameters() assertTrue(params[0].type().isPrimitive) @@ -119,7 +119,7 @@ class JavadocTest { val methodParamType = doc.classNamed("TypealiasesKt")!!.methods() .find { it.name() == "some" }!!.parameters().first() .type() - assertEquals("kotlin.jvm.functions.Function1", methodParamType.qualifiedTypeName()) + assertEquals("Function1", methodParamType.qualifiedTypeName()) assertEquals("? super A, C", methodParamType.asParameterizedType().typeArguments() .map(Type::qualifiedTypeName).joinToString()) } diff --git a/core/testdata/format/dac/deprecation/dac-as-java/Bar.html b/core/testdata/format/dac/deprecation/dac-as-java/Bar.html index d77fa9e64..68d559ab0 100644 --- a/core/testdata/format/dac/deprecation/dac-as-java/Bar.html +++ b/core/testdata/format/dac/deprecation/dac-as-java/Bar.html @@ -7,7 +7,7 @@

Bar

-
public final class Bar implements java.lang.Object
+
public final class Bar implements Object
diff --git a/core/testdata/format/dac/deprecation/dac-as-java/DeprecatedBar.html b/core/testdata/format/dac/deprecation/dac-as-java/DeprecatedBar.html index 56283f6e5..c5fe8492b 100644 --- a/core/testdata/format/dac/deprecation/dac-as-java/DeprecatedBar.html +++ b/core/testdata/format/dac/deprecation/dac-as-java/DeprecatedBar.html @@ -7,7 +7,7 @@

DeprecatedBar

-
public final class DeprecatedBar implements java.lang.Object
+
public final class DeprecatedBar implements Object
Bar
diff --git a/core/testdata/format/dac/deprecation/dac-as-java/DeprecatedFoo.html b/core/testdata/format/dac/deprecation/dac-as-java/DeprecatedFoo.html index e7e2fecb0..360b24ef3 100644 --- a/core/testdata/format/dac/deprecation/dac-as-java/DeprecatedFoo.html +++ b/core/testdata/format/dac/deprecation/dac-as-java/DeprecatedFoo.html @@ -7,7 +7,7 @@

DeprecatedFoo

-
public class DeprecatedFoo implements java.lang.Object
+
public class DeprecatedFoo implements Object
DeprecatedBar
diff --git a/core/testdata/format/dac/deprecation/dac-as-java/Foo.html b/core/testdata/format/dac/deprecation/dac-as-java/Foo.html index c898800da..b468e4daa 100644 --- a/core/testdata/format/dac/deprecation/dac-as-java/Foo.html +++ b/core/testdata/format/dac/deprecation/dac-as-java/Foo.html @@ -7,7 +7,7 @@

Foo

-
public class Foo implements java.lang.Object
+
public class Foo implements Object
DeprecatedFoo
diff --git a/core/testdata/format/dac/inheritedMethods/dac-as-java/Parent.html b/core/testdata/format/dac/inheritedMethods/dac-as-java/Parent.html index dd305f7f8..977e693d8 100644 --- a/core/testdata/format/dac/inheritedMethods/dac-as-java/Parent.html +++ b/core/testdata/format/dac/inheritedMethods/dac-as-java/Parent.html @@ -7,7 +7,7 @@

Parent

-
public class Parent implements java.lang.Object
+
public class Parent implements Object
Foo
diff --git a/core/testdata/format/dac/javaClassLinks/dac-as-java/Bar.html b/core/testdata/format/dac/javaClassLinks/dac-as-java/Bar.html index cbabc2920..64d0c4cd8 100644 --- a/core/testdata/format/dac/javaClassLinks/dac-as-java/Bar.html +++ b/core/testdata/format/dac/javaClassLinks/dac-as-java/Bar.html @@ -7,7 +7,7 @@

Bar

-
public class Bar implements java.lang.Object
+
public class Bar implements Object
Parent
@@ -40,9 +40,9 @@ - + @@ -100,10 +100,10 @@
Bar
java.util.ArrayList<java.lang.String>ArrayList<String> - +

- +

getMyList

-
public java.util.ArrayList<java.lang.String> getMyList(java.util.HashSet input)
+
public ArrayList<String> getMyList(HashSet input)
@@ -111,7 +111,7 @@ - +
inputjava.util.HashSet: The best set you can afford.HashSet: The best set you can afford.
@@ -121,7 +121,7 @@ Return - java.util.ArrayList<java.lang.String> + ArrayList<String> diff --git a/core/testdata/format/dac/javaClassLinks/dac-as-java/Foo.html b/core/testdata/format/dac/javaClassLinks/dac-as-java/Foo.html index 0ae4d255b..bddb7ff8a 100644 --- a/core/testdata/format/dac/javaClassLinks/dac-as-java/Foo.html +++ b/core/testdata/format/dac/javaClassLinks/dac-as-java/Foo.html @@ -7,7 +7,7 @@

Foo

-
public class Foo implements java.lang.Object
+
public class Foo implements Object
diff --git a/core/testdata/format/dac/javaConstructor/dac-as-java/Foo.html b/core/testdata/format/dac/javaConstructor/dac-as-java/Foo.html index 0ae4d255b..bddb7ff8a 100644 --- a/core/testdata/format/dac/javaConstructor/dac-as-java/Foo.html +++ b/core/testdata/format/dac/javaConstructor/dac-as-java/Foo.html @@ -7,7 +7,7 @@

Foo

-
public class Foo implements java.lang.Object
+
public class Foo implements Object
Foo
diff --git a/core/testdata/format/dac/javaDefaultConstructor/dac-as-java/Foo.html b/core/testdata/format/dac/javaDefaultConstructor/dac-as-java/Foo.html index 0ae4d255b..bddb7ff8a 100644 --- a/core/testdata/format/dac/javaDefaultConstructor/dac-as-java/Foo.html +++ b/core/testdata/format/dac/javaDefaultConstructor/dac-as-java/Foo.html @@ -7,7 +7,7 @@

Foo

-
public class Foo implements java.lang.Object
+
public class Foo implements Object
Foo
diff --git a/core/testdata/format/dac/javaMethodVisibilities/dac-as-java/Foo.html b/core/testdata/format/dac/javaMethodVisibilities/dac-as-java/Foo.html index 1ed04c547..978b1071d 100644 --- a/core/testdata/format/dac/javaMethodVisibilities/dac-as-java/Foo.html +++ b/core/testdata/format/dac/javaMethodVisibilities/dac-as-java/Foo.html @@ -7,7 +7,7 @@

Foo

-
public class Foo implements java.lang.Object
+
public class Foo implements Object
Foo
diff --git a/core/testdata/format/dac/javaSeeTag/dac-as-java/Bar.html b/core/testdata/format/dac/javaSeeTag/dac-as-java/Bar.html index 6b4d75f4a..7eb3cdf85 100644 --- a/core/testdata/format/dac/javaSeeTag/dac-as-java/Bar.html +++ b/core/testdata/format/dac/javaSeeTag/dac-as-java/Bar.html @@ -7,7 +7,7 @@

Bar

-
public final class Bar implements java.lang.Object
+
public final class Bar implements Object
Foo
diff --git a/core/testdata/format/dac/javaSeeTag/dac-as-java/Foo.html b/core/testdata/format/dac/javaSeeTag/dac-as-java/Foo.html index b9f23dc59..4529fd04d 100644 --- a/core/testdata/format/dac/javaSeeTag/dac-as-java/Foo.html +++ b/core/testdata/format/dac/javaSeeTag/dac-as-java/Foo.html @@ -7,7 +7,7 @@

Foo

-
public class Foo implements java.lang.Object
+
public class Foo implements Object
Bar
-- cgit v1.2.3
Foo