@@ -197,12 +197,10 @@ object JVMMarkerUtils {
197
197
methodParams + = " []"
198
198
}
199
199
} else if (it.typeElement != null ) {
200
- methodParams + = if (it.typeElement!! .text == " String" ) {
201
- " java.lang.String"
202
- } else if (it.typeElement!! .text == " String[]" ) {
203
- " java.lang.String[]"
204
- } else {
205
- it.typeElement!! .text
200
+ methodParams + = findFullyQualifiedName(it.type, it.containingFile) ? : when (it.typeElement!! .text) {
201
+ " String" -> " java.lang.String"
202
+ " String[]" -> " java.lang.String[]"
203
+ else -> it.typeElement!! .text
206
204
}
207
205
} else if (it.type is PsiPrimitiveType ) {
208
206
methodParams + = if (ArtifactTypeService .isKotlin(it)) {
@@ -217,6 +215,22 @@ object JVMMarkerUtils {
217
215
return " $methodName ($methodParams )"
218
216
}
219
217
218
+ /* *
219
+ * Search imports for a fully qualified name that ends with the simple name of the type.
220
+ */
221
+ private fun findFullyQualifiedName (psiType : PsiType , psiFile : PsiFile ): String? {
222
+ val simpleName = psiType.presentableText
223
+ val psiJavaFile = psiFile as ? PsiJavaFile ? : return null
224
+ val importList = psiJavaFile.importList ? : return null
225
+ for (importStatement in importList.allImportStatements) {
226
+ val qualifiedName = importStatement.importReference?.qualifiedName
227
+ if (qualifiedName?.endsWith(" .$simpleName " ) == true ) {
228
+ return qualifiedName
229
+ }
230
+ }
231
+ return null
232
+ }
233
+
220
234
// todo: better
221
235
private fun getQualifiedName (method : KtNamedFunction ): String {
222
236
val methodName = method.nameIdentifier?.text ? : method.name ? : " unknown"
0 commit comments