Skip to content

Commit b3f84f3

Browse files
committed
fix(java): handle null text in method signature builder #324
Ensure `cleanUp(method)?.text` returns a nullable string and handle null case by returning an empty string.
1 parent bc7f724 commit b3f84f3

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

java/src/main/kotlin/cc/unitmesh/idea/context/JavaMethodContextBuilder.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,10 @@ class JavaMethodContextBuilder : MethodContextBuilder {
5959
private fun getSignatureString(method: PsiMethod?): String {
6060
if (method == null) return ""
6161
val text = runReadAction {
62-
cleanUp(method).text
62+
cleanUp(method)?.text
6363
}
64-
val trimmed = text.replace('\n', ' ').trim()
65-
return trimmed
64+
65+
val trimmed = text?.replace('\n', ' ')?.trim()
66+
return trimmed ?: ""
6667
}
6768
}

0 commit comments

Comments
 (0)