@@ -197,12 +197,10 @@ object JVMMarkerUtils {
197197 methodParams + = " []"
198198 }
199199 } 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
206204 }
207205 } else if (it.type is PsiPrimitiveType ) {
208206 methodParams + = if (ArtifactTypeService .isKotlin(it)) {
@@ -217,6 +215,22 @@ object JVMMarkerUtils {
217215 return " $methodName ($methodParams )"
218216 }
219217
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+
220234 // todo: better
221235 private fun getQualifiedName (method : KtNamedFunction ): String {
222236 val methodName = method.nameIdentifier?.text ? : method.name ? : " unknown"
0 commit comments