mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-05 01:50:56 +07:00
[java] Don't set protected visibility for final classes in override/implement chooser
#IDEA-364331 Fixed GitOrigin-RevId: f3ac6ff3e423b23681f92b1ccc92727b0e06fad3
This commit is contained in:
committed by
intellij-monorepo-bot
parent
341758ee1c
commit
4e204e68ba
@@ -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.codeInsight.generation;
|
||||
|
||||
import com.intellij.application.options.CodeStyle;
|
||||
@@ -15,6 +15,7 @@ import com.intellij.ide.fileTemplates.JavaTemplateUtil;
|
||||
import com.intellij.ide.util.MemberChooser;
|
||||
import com.intellij.java.JavaBundle;
|
||||
import com.intellij.lang.java.JavaLanguage;
|
||||
import com.intellij.lang.jvm.JvmModifier;
|
||||
import com.intellij.openapi.actionSystem.KeyboardShortcut;
|
||||
import com.intellij.openapi.actionSystem.Shortcut;
|
||||
import com.intellij.openapi.actionSystem.ex.ActionUtil;
|
||||
@@ -186,6 +187,10 @@ public final class OverrideImplementUtil extends OverrideImplementExploreUtil {
|
||||
PsiUtil.setModifierProperty(result, PsiModifier.ABSTRACT, aClass.isInterface() && method.hasModifierProperty(PsiModifier.ABSTRACT));
|
||||
PsiUtil.setModifierProperty(result, PsiModifier.NATIVE, false);
|
||||
|
||||
if (method.isConstructor() && aClass.hasModifier(JvmModifier.FINAL) && method.hasModifier(JvmModifier.PROTECTED)) {
|
||||
result.getModifierList().setModifierProperty(PsiModifier.PROTECTED, false);
|
||||
}
|
||||
|
||||
if (!toCopyJavaDoc){
|
||||
deleteDocComment(result);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
public class Parent {
|
||||
protected Parent(int x) { }
|
||||
}
|
||||
|
||||
final class Derived extends Parent {
|
||||
Derived(int x) {
|
||||
super(x);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return super.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
return super.equals(obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object clone() throws CloneNotSupportedException {
|
||||
return super.clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return super.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void finalize() throws Throwable {
|
||||
super.finalize();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
public class Parent {
|
||||
protected Parent(int x) { }
|
||||
}
|
||||
|
||||
final class Derived extends Parent {
|
||||
<caret>
|
||||
}
|
||||
@@ -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.java.codeInsight;
|
||||
|
||||
import com.intellij.JavaTestUtil;
|
||||
@@ -57,6 +57,10 @@ public class OverrideImplementTest extends LightJavaCodeInsightFixtureTestCase {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
public void testProtectedConstructorInFinalClass() {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
public void testOverrideForImplicitClass() {
|
||||
doTest(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user