mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Java: don't suggest name starting with "get" when extract method from expression with void type (IDEA-293740)
GitOrigin-RevId: 9e685871187a33c9327835c466e83df4d9b55402
This commit is contained in:
committed by
intellij-monorepo-bot
parent
35aab21776
commit
9d6f3cd20a
+3
-3
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.refactoring.extractMethod.newImpl
|
||||
|
||||
import com.intellij.codeInsight.Nullability
|
||||
@@ -230,11 +230,11 @@ object ExtractMethodHelper {
|
||||
fun guessMethodName(options: ExtractOptions): List<String> {
|
||||
val project = options.project
|
||||
val variableNames: MutableSet<String> = LinkedHashSet()
|
||||
val codeStyleManager = JavaCodeStyleManager.getInstance(project) as JavaCodeStyleManagerImpl
|
||||
val codeStyleManager = JavaCodeStyleManager.getInstance(project)
|
||||
val returnType = options.dataOutput.type
|
||||
|
||||
val expression = options.elements.singleOrNull() as? PsiExpression
|
||||
if (expression != null || returnType !is PsiPrimitiveType) {
|
||||
if (expression != null && PsiTypes.voidType() != expression.type || returnType !is PsiPrimitiveType) {
|
||||
codeStyleManager.suggestVariableName(VariableKind.FIELD, null, expression, returnType).names
|
||||
.forEach { name ->
|
||||
variableNames += codeStyleManager.variableNameToPropertyName(name, VariableKind.FIELD)
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
class Test {
|
||||
|
||||
private void getTest() {
|
||||
private void extracted() {
|
||||
test();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user