mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-05-06 05:10:22 +07:00
register make class static for illegal enclosing usage error (IDEA-155700)
This commit is contained in:
@@ -870,7 +870,12 @@ public class HighlightClassUtil {
|
||||
PsiElement elementToHighlight) {
|
||||
if (outerClass != null && !PsiTreeUtil.isContextAncestor(outerClass, place, false)) {
|
||||
String description = JavaErrorMessages.message("is.not.an.enclosing.class", HighlightUtil.formatClass(outerClass));
|
||||
return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(elementToHighlight).descriptionAndTooltip(description).create();
|
||||
HighlightInfo highlightInfo =
|
||||
HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(elementToHighlight).descriptionAndTooltip(description).create();
|
||||
if (aClass != null) {
|
||||
QuickFixAction.registerQuickFixAction(highlightInfo, QUICK_FIX_FACTORY.createModifierListFix(aClass, PsiModifier.STATIC, true, false));
|
||||
}
|
||||
return highlightInfo;
|
||||
}
|
||||
PsiModifierListOwner staticParent = PsiUtil.getEnclosingStaticElement(place, outerClass);
|
||||
if (staticParent != null) {
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
// "Make 'C2' static" "true"
|
||||
class C {
|
||||
public abstract static class C2 {
|
||||
abstract void m();
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
|
||||
public static void main(String[] args) {
|
||||
new C.C2() {
|
||||
@Override
|
||||
void m() {
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
// "Make 'C2' static" "true"
|
||||
class C {
|
||||
public abstract class C2 {
|
||||
abstract void m();
|
||||
}
|
||||
}
|
||||
|
||||
class Test {
|
||||
|
||||
public static void main(String[] args) {
|
||||
new C.<caret>C2() {
|
||||
@Override
|
||||
void m() {
|
||||
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Copyright 2000-2016 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.
|
||||
*/
|
||||
package com.intellij.codeInsight.daemon.quickFix;
|
||||
|
||||
public class MakeInnerClassStaticTest extends LightQuickFixParameterizedTestCase {
|
||||
|
||||
@Override
|
||||
protected String getBasePath() {
|
||||
return "/codeInsight/daemonCodeAnalyzer/quickFix/makeInnerStatic";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user