mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java] delete "move member into class" as error elements are not created for such members
GitOrigin-RevId: c50d6e0c6de204c5f290047f1ff99bf11ef14a4d
This commit is contained in:
committed by
intellij-monorepo-bot
parent
d0a6bb9fdc
commit
739e54a28e
@@ -515,6 +515,11 @@ public abstract class QuickFixFactory {
|
||||
|
||||
public abstract @NotNull IntentionAction createRemoveDuplicateExtendsAction(@NotNull String className);
|
||||
|
||||
/**
|
||||
* @deprecated error elements are not provided anymore for members declared out of class.
|
||||
* Now they are members of an unnamed class and can be moved as usual members.
|
||||
*/
|
||||
@Deprecated
|
||||
public abstract @NotNull IntentionAction createMoveMemberIntoClassFix(@NotNull PsiErrorElement errorElement);
|
||||
|
||||
/**
|
||||
|
||||
-17
@@ -25,8 +25,6 @@ import com.intellij.openapi.util.NlsContexts;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.io.FileUtilRt;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import com.intellij.psi.*;
|
||||
@@ -311,21 +309,6 @@ public final class HighlightClassUtil {
|
||||
return errorResult;
|
||||
}
|
||||
|
||||
static HighlightInfo.Builder checkClassMemberDeclaredOutside(@NotNull PsiErrorElement errorElement) {
|
||||
PsiJavaFile file = ObjectUtils.tryCast(errorElement.getContainingFile(), PsiJavaFile.class);
|
||||
if (file == null) return null;
|
||||
String fileName = FileUtilRt.getNameWithoutExtension(file.getName());
|
||||
if (!StringUtil.isJavaIdentifier(fileName)) return null;
|
||||
MemberModel model = MemberModel.create(errorElement);
|
||||
if (model == null) return null;
|
||||
HighlightInfo.Builder info = HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR)
|
||||
.range(model.textRange())
|
||||
.description(JavaErrorBundle.message("class.member.declared.outside"));
|
||||
IntentionAction action = QuickFixFactory.getInstance().createMoveMemberIntoClassFix(errorElement);
|
||||
info.registerFix(action, null, null, null, null);
|
||||
return info;
|
||||
}
|
||||
|
||||
static HighlightInfo.Builder checkClassRestrictedKeyword(@NotNull LanguageLevel level, @NotNull PsiIdentifier identifier) {
|
||||
String className = identifier.getText();
|
||||
if (isRestrictedIdentifier(className, level)) {
|
||||
|
||||
-1
@@ -990,7 +990,6 @@ public class HighlightVisitorImpl extends JavaElementVisitor implements Highligh
|
||||
@Override
|
||||
public void visitErrorElement(@NotNull PsiErrorElement element) {
|
||||
super.visitErrorElement(element);
|
||||
add(HighlightClassUtil.checkClassMemberDeclaredOutside(element));
|
||||
String text = element.getText();
|
||||
if ((text.equals(PsiKeyword.NON_SEALED) || text.equals(PsiKeyword.SEALED)) &&
|
||||
PsiTreeUtil.skipWhitespacesAndCommentsForward(element) instanceof PsiClass) {
|
||||
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
// "Move member into class" "true-preview"
|
||||
|
||||
|
||||
|
||||
public abstract class beforeAbstractMethodNoClass {
|
||||
public abstract void doSmth();
|
||||
}
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
// "Move member into class" "true"
|
||||
|
||||
|
||||
|
||||
public class beforeFieldNoModifiers {
|
||||
int foo;
|
||||
}
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
// "Move member into class" "true"
|
||||
|
||||
|
||||
|
||||
public class beforeFieldQualifiedType {
|
||||
public String foo;
|
||||
}
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
// "Move member into class" "true"
|
||||
|
||||
class Pair<T, V> {}
|
||||
|
||||
|
||||
|
||||
public class beforeFieldWithAnnos {
|
||||
@NotNull
|
||||
Pair<String, String> foo;
|
||||
}
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
// "Move member into class" "true"
|
||||
|
||||
class Pair<T, V> {}
|
||||
|
||||
|
||||
|
||||
public class beforeFieldWithTypeParams {
|
||||
Pair<String, String> foo;
|
||||
}
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
// "Move member into class" "true"
|
||||
|
||||
class Pair<T, V> {}
|
||||
|
||||
|
||||
|
||||
public class beforeFieldWithTypeParamsWithAnnos {
|
||||
Pair<@NotNull String, String> foo;
|
||||
}
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
// "Move member into class" "true"
|
||||
|
||||
|
||||
|
||||
public interface beforeMethodNoBodyNoClass {
|
||||
void foo();
|
||||
}
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
// "Move member into class" "true"
|
||||
|
||||
|
||||
|
||||
public class beforeMethodNoModifiers {
|
||||
void test() {
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
// "Move member into class" "true"
|
||||
|
||||
|
||||
|
||||
|
||||
public class beforeMethodWithAnnos {
|
||||
@NotNull
|
||||
String withQualifiedReturnType() {
|
||||
}
|
||||
}
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
// "Move member into class" "true"
|
||||
|
||||
|
||||
|
||||
|
||||
public class beforeMethodWithQualifiedReturnType {
|
||||
final String withQualifiedReturnType() {
|
||||
|
||||
}
|
||||
}
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
// "Move member into class" "true"
|
||||
|
||||
|
||||
|
||||
|
||||
public class beforeMethodWithQualifiedReturnTypeWithAnnos {
|
||||
@NotNull String withQualifiedReturnType() {
|
||||
|
||||
}
|
||||
}
|
||||
-11
@@ -1,11 +0,0 @@
|
||||
// "Move member into class" "true"
|
||||
|
||||
class Pair<T, V> {}
|
||||
|
||||
|
||||
|
||||
public class beforeMethodWithTypeParams {
|
||||
|
||||
Pair<String, String> doSmth() {
|
||||
}
|
||||
}
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
// "Move member into class" "true"
|
||||
|
||||
|
||||
|
||||
public class beforeNativeMethodNoClass {
|
||||
native void doSmth();
|
||||
}
|
||||
-13
@@ -1,13 +0,0 @@
|
||||
// "Move member into class" "true"
|
||||
|
||||
class beforeTwoMethods {
|
||||
|
||||
void bar() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void bar() {
|
||||
|
||||
}
|
||||
|
||||
-3
@@ -1,3 +0,0 @@
|
||||
// "Move member into class" "true-preview"
|
||||
|
||||
public abs<caret>tract void doSmth();
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
// "Move member into class" "true"
|
||||
|
||||
int f<caret>oo;
|
||||
|
||||
public class beforeFieldNoModifiers {
|
||||
}
|
||||
-6
@@ -1,6 +0,0 @@
|
||||
// "Move member into class" "true"
|
||||
|
||||
public <caret>java.lang.String foo;
|
||||
|
||||
public class beforeFieldQualifiedType {
|
||||
}
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
// "Move member into class" "true"
|
||||
|
||||
class Pair<T, V> {}
|
||||
|
||||
@NotNull Pair<String<caret>, String> foo;
|
||||
|
||||
public class beforeFieldWithAnnos {
|
||||
}
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
// "Move member into class" "true"
|
||||
|
||||
class Pair<T, V> {}
|
||||
|
||||
Pair<String<caret>, String> foo;
|
||||
|
||||
public class beforeFieldWithTypeParams {
|
||||
}
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
// "Move member into class" "true"
|
||||
|
||||
class Pair<T, V> {}
|
||||
|
||||
Pair<@NotNull String<caret>, String> foo;
|
||||
|
||||
public class beforeFieldWithTypeParamsWithAnnos {
|
||||
}
|
||||
-19
@@ -1,19 +0,0 @@
|
||||
// "Move member into class" "false"
|
||||
|
||||
public class beforeIncompleteMethodInClass {
|
||||
private String testInt;
|
||||
|
||||
public beforeIncompleteMethodInClass(int testInt) {
|
||||
this.testInt = "aaaa";
|
||||
}
|
||||
|
||||
public String getTestInt() {
|
||||
return testInt;
|
||||
}
|
||||
|
||||
public void setTestInt(String testInt) {
|
||||
this.testInt = testInt;
|
||||
}
|
||||
|
||||
public<caret>
|
||||
}
|
||||
-3
@@ -1,3 +0,0 @@
|
||||
// "Move member into class" "true"
|
||||
|
||||
void foo<caret>();
|
||||
-10
@@ -1,10 +0,0 @@
|
||||
// "Move member into class" "true"
|
||||
|
||||
void test() {
|
||||
<caret>
|
||||
|
||||
|
||||
}
|
||||
|
||||
public class beforeMethodNoModifiers {
|
||||
}
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
// "Move member into class" "true"
|
||||
|
||||
|
||||
@NotNull String w<caret>ithQualifiedReturnType() {
|
||||
}
|
||||
|
||||
public class beforeMethodWithAnnos {
|
||||
}
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
// "Move member into class" "true"
|
||||
|
||||
|
||||
final ja<caret>va.lang.String withQualifiedReturnType() {
|
||||
|
||||
}
|
||||
|
||||
public class beforeMethodWithQualifiedReturnType {
|
||||
}
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
// "Move member into class" "true"
|
||||
|
||||
|
||||
ja<caret>va.lang.@NotNull String withQualifiedReturnType() {
|
||||
|
||||
}
|
||||
|
||||
public class beforeMethodWithQualifiedReturnTypeWithAnnos {
|
||||
}
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
// "Move member into class" "true"
|
||||
|
||||
class Pair<T, V> {}
|
||||
|
||||
Pair<String, String> doS<caret>mth() {}
|
||||
|
||||
public class beforeMethodWithTypeParams {
|
||||
|
||||
}
|
||||
-3
@@ -1,3 +0,0 @@
|
||||
// "Move member into class" "true"
|
||||
|
||||
native void <caret>doSmth();
|
||||
-13
@@ -1,13 +0,0 @@
|
||||
// "Move member into class" "true"
|
||||
|
||||
class beforeTwoMethods {
|
||||
|
||||
}
|
||||
|
||||
void bar() {
|
||||
|
||||
}
|
||||
|
||||
void bar<caret>() {
|
||||
|
||||
}
|
||||
-1
@@ -1 +0,0 @@
|
||||
<p><icon src="source_doSmth"/> doSmth → <icon src="target_beforeAbstractMethodNoClass"/> beforeAbstractMethodNoClass</p>
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
// 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.quickFix.LightQuickFixParameterizedTestCase;
|
||||
|
||||
public class MoveMemberIntoClassTest extends LightQuickFixParameterizedTestCase {
|
||||
|
||||
@Override
|
||||
protected String getBasePath() {
|
||||
return "/codeInsight/daemonCodeAnalyzer/quickFix/moveMemberIntoClass";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user