mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-05 01:50:56 +07:00
Java: add space between field/method name and type (IDEA-138681)
GitOrigin-RevId: 913bf430a86cec149e99cdad5f4f52eeaa196555
This commit is contained in:
committed by
intellij-monorepo-bot
parent
b867759f5c
commit
ab8455f916
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2024 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.psi.util;
|
||||
|
||||
import com.intellij.core.JavaPsiBundle;
|
||||
@@ -92,7 +92,7 @@ public class PsiFormatUtil extends PsiFormatUtilBase {
|
||||
}
|
||||
if (BitUtil.isSet(options, SHOW_TYPE) && BitUtil.isSet(options, TYPE_AFTER)) {
|
||||
if (BitUtil.isSet(options, SHOW_NAME) && variable.getName() != null) {
|
||||
buffer.append(':');
|
||||
buffer.append(": ");
|
||||
}
|
||||
buffer.append(formatTypeSafe(variable, variable.getType(), options, substitutor));
|
||||
}
|
||||
@@ -190,7 +190,7 @@ public class PsiFormatUtil extends PsiFormatUtilBase {
|
||||
if (BitUtil.isSet(options, SHOW_TYPE) && BitUtil.isSet(options, TYPE_AFTER)) {
|
||||
PsiType type = method.getReturnType();
|
||||
if (type != null) {
|
||||
if (buffer.length() > 0) buffer.append(':');
|
||||
if (buffer.length() > 0) buffer.append(": ");
|
||||
buffer.append(formatTypeSafe(method, type, options, substitutor));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package com.intellij.ide.structureView.impl.java;
|
||||
|
||||
import com.intellij.ide.util.treeView.smartTree.SortableTreeElement;
|
||||
import com.intellij.openapi.project.DumbService;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.psi.PsiSubstitutor;
|
||||
import com.intellij.psi.PsiVariable;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
@@ -25,11 +24,9 @@ public abstract class JavaVariableBaseTreeElement<T extends PsiVariable> extends
|
||||
if (field == null) return "";
|
||||
|
||||
final boolean dumb = DumbService.isDumb(field.getProject());
|
||||
final String text = formatVariable(field,
|
||||
SHOW_NAME | (dumb ? 0 : SHOW_TYPE) | TYPE_AFTER | (dumb ? 0 : SHOW_INITIALIZER),
|
||||
PsiSubstitutor.EMPTY);
|
||||
final int colon = text.indexOf(':');
|
||||
return colon >= 0 ? text.substring(0, colon + 1) + ' ' + text.substring(colon + 1) : text;
|
||||
return formatVariable(field,
|
||||
SHOW_NAME | (dumb ? 0 : SHOW_TYPE) | TYPE_AFTER | (dumb ? 0 : SHOW_INITIALIZER),
|
||||
PsiSubstitutor.EMPTY);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -51,14 +51,13 @@ public class PsiMethodTreeElement extends JavaClassTreeElementBase<PsiMethod> im
|
||||
|
||||
@Override
|
||||
public String getPresentableText() {
|
||||
final PsiMethod psiMethod = getElement();
|
||||
if (psiMethod == null) return "";
|
||||
final boolean dumb = DumbService.isDumb(psiMethod.getProject());
|
||||
String method = PsiFormatUtil.formatMethod(psiMethod,
|
||||
PsiSubstitutor.EMPTY,
|
||||
SHOW_NAME | TYPE_AFTER | SHOW_PARAMETERS | (dumb ? 0 : SHOW_TYPE),
|
||||
dumb ? SHOW_NAME : SHOW_TYPE);
|
||||
return StringUtil.replace(method, ":", ": ");
|
||||
final PsiMethod method = getElement();
|
||||
if (method == null) return "";
|
||||
final boolean dumb = DumbService.isDumb(method.getProject());
|
||||
return PsiFormatUtil.formatMethod(method,
|
||||
PsiSubstitutor.EMPTY,
|
||||
SHOW_NAME | TYPE_AFTER | SHOW_PARAMETERS | (dumb ? 0 : SHOW_TYPE),
|
||||
dumb ? SHOW_NAME : SHOW_TYPE);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.projectView;
|
||||
|
||||
import com.intellij.ide.projectView.ProjectView;
|
||||
@@ -91,10 +91,10 @@ public class NestedFilesInProjectViewTest extends BasePlatformTestCase {
|
||||
-Bar.java
|
||||
Bar.txt
|
||||
-Baz
|
||||
baz:int
|
||||
baz: int
|
||||
-Foo
|
||||
Foo.txt
|
||||
foo:int
|
||||
foo: int
|
||||
""");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.projectView;
|
||||
|
||||
import com.intellij.ide.projectView.impl.AbstractProjectViewPane;
|
||||
@@ -71,15 +71,15 @@ public class ProjectTreeBuilderTest extends BaseProjectViewTestCase {
|
||||
-InnerClass23
|
||||
-InnerClass24
|
||||
+InnerClass25
|
||||
myFieldToSelect:int
|
||||
myInnerClassField:int
|
||||
myInnerClassField:int
|
||||
myInnerClassField:int
|
||||
getValue():int
|
||||
myField1:boolean
|
||||
myField2:boolean
|
||||
myField3:boolean
|
||||
myField4:boolean
|
||||
myFieldToSelect: int
|
||||
myInnerClassField: int
|
||||
myInnerClassField: int
|
||||
myInnerClassField: int
|
||||
getValue(): int
|
||||
myField1: boolean
|
||||
myField2: boolean
|
||||
myField3: boolean
|
||||
myField4: boolean
|
||||
+External Libraries
|
||||
"""
|
||||
);
|
||||
|
||||
@@ -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-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.projectView;
|
||||
|
||||
import com.intellij.ide.projectView.PresentationData;
|
||||
@@ -184,9 +184,9 @@ public class ProjectViewUpdatingTest extends BaseProjectViewTestCase {
|
||||
-PsiDirectory: package1
|
||||
-[Class1]
|
||||
+InnerClass
|
||||
getValue():int
|
||||
myField1:boolean
|
||||
myField2:boolean
|
||||
getValue(): int
|
||||
myField1: boolean
|
||||
myField2: boolean
|
||||
+Class2
|
||||
+External Libraries
|
||||
""", true);
|
||||
@@ -212,9 +212,9 @@ public class ProjectViewUpdatingTest extends BaseProjectViewTestCase {
|
||||
-PsiDirectory: package1
|
||||
-[Class1]
|
||||
+InnerClass
|
||||
getValue():int
|
||||
myField1:boolean
|
||||
myField2:boolean
|
||||
getValue(): int
|
||||
myField1: boolean
|
||||
myField2: boolean
|
||||
+Class2
|
||||
+External Libraries
|
||||
""", true);
|
||||
@@ -233,9 +233,9 @@ public class ProjectViewUpdatingTest extends BaseProjectViewTestCase {
|
||||
-PsiDirectory: package1
|
||||
-Class1
|
||||
+InnerClass
|
||||
getValue():int
|
||||
myField1:boolean
|
||||
[myField2:boolean]
|
||||
getValue(): int
|
||||
myField1: boolean
|
||||
[myField2: boolean]
|
||||
+Class2
|
||||
+External Libraries
|
||||
""", true);
|
||||
@@ -263,9 +263,9 @@ public class ProjectViewUpdatingTest extends BaseProjectViewTestCase {
|
||||
-PsiDirectory: package1
|
||||
-Class1
|
||||
+InnerClass
|
||||
getValue():int
|
||||
[_firstField:boolean]
|
||||
myField1:boolean
|
||||
getValue(): int
|
||||
[_firstField: boolean]
|
||||
myField1: boolean
|
||||
+Class2
|
||||
+External Libraries
|
||||
""", true);
|
||||
@@ -444,7 +444,7 @@ public class ProjectViewUpdatingTest extends BaseProjectViewTestCase {
|
||||
" -PsiDirectory: src\n" +
|
||||
" -PsiDirectory: name\n" + // com.company.name
|
||||
" -I\n" +
|
||||
" m():void\n");
|
||||
" m(): void\n");
|
||||
|
||||
directory = createSubdirectory(directory, "a");
|
||||
// PSI listener is notified synchronously and starts modifying new tree model
|
||||
@@ -458,7 +458,7 @@ public class ProjectViewUpdatingTest extends BaseProjectViewTestCase {
|
||||
" PsiDirectory: a\n" +
|
||||
" -PsiDirectory: name\n" +
|
||||
" -I\n" +
|
||||
" m():void\n");
|
||||
" m(): void\n");
|
||||
|
||||
directory = createSubdirectory(directory, "b");
|
||||
|
||||
@@ -468,7 +468,7 @@ public class ProjectViewUpdatingTest extends BaseProjectViewTestCase {
|
||||
" PsiDirectory: b\n" + // a.b
|
||||
" -PsiDirectory: name\n" +
|
||||
" -I\n" +
|
||||
" m():void\n");
|
||||
" m(): void\n");
|
||||
|
||||
directory = createSubdirectory(directory, "z");
|
||||
|
||||
@@ -478,7 +478,7 @@ public class ProjectViewUpdatingTest extends BaseProjectViewTestCase {
|
||||
" PsiDirectory: z\n" + // a.b.z
|
||||
" -PsiDirectory: name\n" +
|
||||
" -I\n" +
|
||||
" m():void\n");
|
||||
" m(): void\n");
|
||||
}
|
||||
|
||||
private static void assertTreeEqual(@NotNull JTree tree, @NotNull String expected) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2019 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-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
|
||||
package com.intellij.testIntegration;
|
||||
|
||||
import com.intellij.ide.highlighter.JavaFileType;
|
||||
@@ -17,12 +17,12 @@ import java.util.List;
|
||||
public class TestIntegrationUtilsTest extends LightPlatformTestCase {
|
||||
|
||||
public void testExtractClassMethods() {
|
||||
doTest("class Foo {void bar() {} private void baz() {}}", false, "bar():void");
|
||||
doTest("class Foo extends Super {void bar() {}} class Super {void qux() {}}", false, "bar():void");
|
||||
doTest("class Foo extends Super {void bar() {}} class Super {void qux() {}}", true, "qux():void", "bar():void");
|
||||
doTest("class Foo implements I {void bar() {}} interface I {void qux();}", true, "bar():void");
|
||||
doTest("class Foo implements I {void bar() {}} interface I {default void qux() {}}", true, "qux():void", "bar():void");
|
||||
doTest("interface Foo extends I {void bar();} interface I {void qux();}", true, "bar():void");
|
||||
doTest("class Foo {void bar() {} private void baz() {}}", false, "bar(): void");
|
||||
doTest("class Foo extends Super {void bar() {}} class Super {void qux() {}}", false, "bar(): void");
|
||||
doTest("class Foo extends Super {void bar() {}} class Super {void qux() {}}", true, "qux(): void", "bar(): void");
|
||||
doTest("class Foo implements I {void bar() {}} interface I {void qux();}", true, "bar(): void");
|
||||
doTest("class Foo implements I {void bar() {}} interface I {default void qux() {}}", true, "qux(): void", "bar(): void");
|
||||
doTest("interface Foo extends I {void bar();} interface I {void qux();}", true, "bar(): void");
|
||||
}
|
||||
|
||||
private void doTest(@Language("JAVA") String text, boolean inherited, String... expected) {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2024 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.testFramework
|
||||
|
||||
import com.intellij.ide.projectView.PresentationData
|
||||
@@ -70,7 +70,7 @@ fun assertLogicalStructure(
|
||||
expectedRoot.expectedStructureInitializer()
|
||||
if (!expectedRoot.isEqualTo(actualRoot, false)) {
|
||||
expectedRoot.synchronizeImportantElements(actualRoot)
|
||||
throw ComparisonFailure("The models are not equals: ",
|
||||
throw ComparisonFailure("The models are not equal: ",
|
||||
expectedRoot.print("", false),
|
||||
actualRoot.print("", false))
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2023 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.ide.commander;
|
||||
|
||||
import com.intellij.ide.projectView.impl.AbstractProjectTreeStructure;
|
||||
@@ -114,9 +114,9 @@ public class CommanderListBuilderTest extends BaseProjectViewTestCase {
|
||||
checkListInRightPanel("""
|
||||
[ .. ]
|
||||
InnerClass
|
||||
getValue():int
|
||||
myField1:boolean
|
||||
myField2:boolean
|
||||
getValue(): int
|
||||
myField1: boolean
|
||||
myField2: boolean
|
||||
""");
|
||||
checkSelectedElement(field, myCommander.getRightPanel());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user