mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-05 01:50:56 +07:00
[java] avoid reformat inside psi operation (IDEA-287332)
GitOrigin-RevId: 387a7fe6e41da1f967b05dfa7da246e70e02b30f
This commit is contained in:
committed by
intellij-monorepo-bot
parent
1ca29cf435
commit
0a3d001b76
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2021 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.codeInsight.daemon.impl.quickfix;
|
||||
|
||||
import com.intellij.codeInsight.daemon.QuickFixBundle;
|
||||
@@ -57,6 +57,10 @@ public class MakeReceiverParameterFirstFix extends LocalQuickFixAndIntentionActi
|
||||
moveComments(startElement, movedParameter, parameterList, true);
|
||||
moveComments(startElement, movedParameter, parameterList, false);
|
||||
startElement.delete();
|
||||
PsiElement next = firstChild.getNextSibling();
|
||||
if (next instanceof PsiWhiteSpace) {
|
||||
next.delete();
|
||||
}
|
||||
}
|
||||
|
||||
private static void moveComments(@NotNull PsiElement oldParameter,
|
||||
|
||||
@@ -1,30 +1,14 @@
|
||||
/*
|
||||
* Copyright 2000-2015 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.psi.impl.source.tree.java;
|
||||
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.psi.JavaTokenType;
|
||||
import com.intellij.psi.codeStyle.CodeStyleManager;
|
||||
import com.intellij.psi.impl.source.Constants;
|
||||
import com.intellij.psi.impl.source.tree.*;
|
||||
import com.intellij.psi.tree.ChildRoleBase;
|
||||
import com.intellij.psi.tree.IElementType;
|
||||
import com.intellij.psi.tree.TokenSet;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -57,14 +41,7 @@ public class ParameterListElement extends CompositeElement implements Constants
|
||||
if (first == last && PARAMETER_SET.contains(first.getElementType())) {
|
||||
JavaSourceUtil.addSeparatingComma(this, first, PARAMETER_SET);
|
||||
}
|
||||
|
||||
//todo[max] hack?
|
||||
try {
|
||||
CodeStyleManager.getInstance(getManager().getProject()).reformat(getPsi());
|
||||
}
|
||||
catch (IncorrectOperationException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
|
||||
return firstAdded;
|
||||
}
|
||||
|
||||
@@ -111,14 +88,6 @@ public class ParameterListElement extends CompositeElement implements Constants
|
||||
replaceChild(newFirstNodeInsideParens, (ASTNode)oldFirstNodeInsideParens.clone());
|
||||
}
|
||||
}
|
||||
|
||||
//todo[max] hack?
|
||||
try {
|
||||
CodeStyleManager.getInstance(getManager().getProject()).reformat(getPsi());
|
||||
}
|
||||
catch (IncorrectOperationException e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -8,7 +8,7 @@ class A {
|
||||
A(A field) {
|
||||
this("", field);
|
||||
}
|
||||
A(String s, A field) {
|
||||
A (String s, A field) {
|
||||
//here
|
||||
this.field = field;<caret>
|
||||
}
|
||||
|
||||
@@ -16,5 +16,5 @@ class Derived extends ChangeSignatureTest {
|
||||
super(null);
|
||||
}
|
||||
|
||||
void foo(Class clazz) {}
|
||||
void foo (Class clazz) {}
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
class Test {
|
||||
void f (String s) {}
|
||||
|
||||
void u(final String anObject) {
|
||||
void u (final String anObject) {
|
||||
f(anObject);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
interface Foreign {
|
||||
default void foo(Test1 test1) {
|
||||
default void foo (Test1 test1) {
|
||||
test1.field++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ class Foreign {
|
||||
/**
|
||||
* @param test1
|
||||
*/
|
||||
void foo(Test1 test1) {
|
||||
void foo (Test1 test1) {
|
||||
test1.bar();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
public class MoveMethodTest {
|
||||
void foo() {
|
||||
void foo () {
|
||||
foo();
|
||||
foo();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class Foreign {
|
||||
void foo(Test test) {
|
||||
void foo (Test test) {
|
||||
test.field++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class Foreign {
|
||||
void foo(Test1 test1) {
|
||||
void foo (Test1 test1) {
|
||||
test1.field++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
class Foreign {
|
||||
void foo(Test1.Inner i, Test1 test1) {
|
||||
void foo (Test1.Inner i, Test1 test1) {
|
||||
test1.new Inner();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2021 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.structuralsearch;
|
||||
|
||||
import com.intellij.ide.highlighter.JavaFileType;
|
||||
@@ -2094,7 +2094,7 @@ public class StructuralReplaceTest extends StructuralReplaceTestCase {
|
||||
String s3 = "$type$ $var$ = $init$;";
|
||||
|
||||
String expected = "class Foo {\n" +
|
||||
" void foo(int i, int i2, int i3) {\n" +
|
||||
" void foo(int i,int i2, int i3) {\n" +
|
||||
" int x = 5;\n" +
|
||||
" }\n" +
|
||||
"}";
|
||||
|
||||
Reference in New Issue
Block a user