mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
IJPL-207762 fix semicolon after completing a void method
GitOrigin-RevId: ebb2f664df09a21147423b5a6bd91932850ee618
This commit is contained in:
committed by
intellij-monorepo-bot
parent
6070d3d255
commit
b5da251981
+4
-2
@@ -28,6 +28,7 @@ object JavaFrontendCompletionUtil {
|
||||
overloadsMatter: Boolean,
|
||||
hasParams: ThreeState, // UNSURE if providing no arguments is a valid situation
|
||||
forceClosingParenthesis: Boolean,
|
||||
isVoidMethod: Boolean,
|
||||
) {
|
||||
var hasParams = hasParams
|
||||
val editor = context.editor
|
||||
@@ -85,7 +86,7 @@ object JavaFrontendCompletionUtil {
|
||||
return
|
||||
}
|
||||
|
||||
if (!insertTail(context, item, tailType, hasTail)) {
|
||||
if (!insertTail(context, item, tailType, hasTail, isVoidMethod)) {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -104,6 +105,7 @@ object JavaFrontendCompletionUtil {
|
||||
item: LookupElement,
|
||||
tailType: TailType,
|
||||
hasTail: Boolean,
|
||||
isVoidMethod: Boolean,
|
||||
): Boolean {
|
||||
var toInsert = tailType
|
||||
if (toInsert === EqTailType.INSTANCE) {
|
||||
@@ -112,7 +114,7 @@ object JavaFrontendCompletionUtil {
|
||||
|
||||
val lookupItem = item.`as`(LookupItem.CLASS_CONDITION_KEY)
|
||||
if (lookupItem == null || lookupItem.getAttribute(LookupItem.TAIL_TYPE_ATTR) !== TailTypes.unknownType()) {
|
||||
if (!hasTail && item.getObject() is PsiMethod && PsiTypes.voidType() == (item.getObject() as PsiMethod).returnType) {
|
||||
if (!hasTail && isVoidMethod) {
|
||||
PsiDocumentManager.getInstance(context.project).commitAllDocuments()
|
||||
if (PlatformPatterns.psiElement().beforeLeaf(PlatformPatterns.psiElement().withText(".")).accepts(context.file.findElementAt(context.tailOffset - 1))) {
|
||||
return false
|
||||
|
||||
+5
-3
@@ -10,13 +10,14 @@ import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
class FrontendFriendlyParenthesesInsertHandler(
|
||||
private val hasParameters: Boolean
|
||||
private val hasParameters: Boolean,
|
||||
private val isVoidMethod: Boolean,
|
||||
) : FrontendFriendlyInsertHandler {
|
||||
override fun handleInsert(context: InsertionContext, item: LookupElement) {
|
||||
// todo FrontendFriendlyParenthInsertHandler differs from ParenthInsertHandler
|
||||
// in that it does not check lookup elements for overloads with `MethodParenthesesHandler.overloadsHaveParameters`
|
||||
// not sure if this can be reliably implemented on frontend
|
||||
insertParenthesesForJavaMethod(item, context, ThreeState.fromBoolean(hasParameters))
|
||||
insertParenthesesForJavaMethod(item, context, ThreeState.fromBoolean(hasParameters), isVoidMethod)
|
||||
}
|
||||
|
||||
companion object {
|
||||
@@ -24,8 +25,9 @@ class FrontendFriendlyParenthesesInsertHandler(
|
||||
item: LookupElement,
|
||||
context: InsertionContext,
|
||||
hasParams: ThreeState,
|
||||
isVoidMethod: Boolean,
|
||||
) {
|
||||
JavaFrontendCompletionUtil.insertParentheses(context, item, false, hasParams, false)
|
||||
JavaFrontendCompletionUtil.insertParentheses(context, item, false, hasParams, false, isVoidMethod)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user