[name suggestion] prefer CamelCase names for locals (IDEA-297161)

GitOrigin-RevId: e2f019772f56cd9208346e85a6e73c834f5576c5
This commit is contained in:
Anna Kozlova
2022-07-20 09:24:46 +00:00
committed by intellij-monorepo-bot
parent 98c5f31bd6
commit ecbea7d7fb
5 changed files with 11 additions and 38 deletions
@@ -3,10 +3,10 @@ public class ATest {
public static final String FOO1 = "foo1";
String m_interval = "";
void foo(String m_interval1) {
if (FOO.equals(m_interval1.substring(1))) {
void foo(String mInterval) {
if (FOO.equals(mInterval.substring(1))) {
System.out.println(FOO);
} else if (FOO1.equals(m_interval1.substring(1))) {
} else if (FOO1.equals(mInterval.substring(1))) {
System.out.println();
}
}
@@ -1,8 +1,8 @@
class InStaticInitializer {
public static final String hello_world = "Hello World";
public static final String helloWorld = "Hello World";
static {
System.out.println(hello_world);
System.out.println(helloWorld);
}
//Field must be placed before initializer or illegal forward reference will happen
}
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.java.refactoring;
import com.intellij.openapi.util.text.StringUtil;
@@ -35,6 +21,7 @@ public class JavaIntroduceVariableTest extends LightJavaCodeInsightTestCase {
doTest("getA(\"SimpleName\")", "simpleName", "name");
doTest("getA(\"simpleName\")", "simpleName", "name");
doTest("getA(\"simpleClass\")", "simpleClass", "aClass");
doTest("getA(\"simple_class\")", "simpleClass", "simple_class", "aClass");
doTest("getA(\"short\")", "aShort");
doTest("getA(\"boolean\")", "aBoolean");
doTest("getA().getB(1, \"name\")", "name");
@@ -1,18 +1,4 @@
/*
* Copyright 2000-2017 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.java.refactoring;
import com.intellij.psi.PsiExpression;
@@ -33,7 +19,7 @@ public class NameSuggestionsByExpressionTest extends LightJavaCodeInsightFixture
SuggestedNameInfo nameInfo = JavaCodeStyleManager.getInstance(getProject())
.suggestVariableName(VariableKind.LOCAL_VARIABLE, null, expression, null);
Assert.assertArrayEquals("Suggested: " + Arrays.toString(nameInfo.names),
new String[] {"string_with_spaces", "stringWithSpaces", "with_spaces", "withSpaces", "spaces", "string", "s"},
new String[] {"stringWithSpaces", "string_with_spaces", "withSpaces", "with_spaces", "spaces", "string", "s"},
nameInfo.names);
}
@@ -1,4 +1,4 @@
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
// Copyright 2000-2022 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.psi.codeStyle;
import com.intellij.openapi.util.text.Strings;
@@ -193,8 +193,8 @@ public final class NameUtil {
continue;
}
answer.add(compoundSuggestion(prefix, upperCaseStyle, words, wordCount, startWord, c, isArray, false) + suffix);
answer.add(compoundSuggestion(prefix, upperCaseStyle, words, wordCount, startWord, c, isArray, true) + suffix);
answer.add(compoundSuggestion(prefix, upperCaseStyle, words, wordCount, startWord, c, isArray, false) + suffix);
}
return answer;
}