mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[ktor] KTOR-8776 Fix "cannot access" false-positive in run configuration editor
This occurs when the main method is in a companion object which itself is inside a nested class. Merge-request: IJ-MR-172860 Merged-by: Bartek Pacia <bartek.pacia@jetbrains.com> GitOrigin-RevId: d2d812ba6e84648c922f2ad32942e6360dad12f8
This commit is contained in:
committed by
intellij-monorepo-bot
parent
110f061d5e
commit
d500d31ec2
+14
-11
@@ -128,16 +128,8 @@ public final class KotlinRunConfigurationEditor extends SettingsEditor<KotlinRun
|
||||
|
||||
private void createUIComponents() {
|
||||
mainClass = new LabeledComponent<>();
|
||||
mainClass.setComponent(ClassEditorField.createClassField(project, () -> moduleSelector.getModule(), (declaration, place) -> {
|
||||
if (declaration instanceof KtLightClass aClass) {
|
||||
if (ConfigurationUtil.MAIN_CLASS.value(aClass)
|
||||
&& (PsiMethodUtil.findMainMethod(aClass) != null || place.getParent() != null)
|
||||
&& moduleSelector.findClass(((PsiClass)declaration).getQualifiedName()) != null) {
|
||||
return JavaCodeFragment.VisibilityChecker.Visibility.VISIBLE;
|
||||
}
|
||||
}
|
||||
return JavaCodeFragment.VisibilityChecker.Visibility.NOT_VISIBLE;
|
||||
}, createApplicationClassBrowser(project, () -> moduleSelector.getModule(), moduleChooser)));
|
||||
mainClass.setComponent(ClassEditorField.createClassField(project, () -> moduleSelector.getModule(), VISIBILITY_CHECKER,
|
||||
createApplicationClassBrowser(project, () -> moduleSelector.getModule(), moduleChooser)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -154,4 +146,15 @@ public final class KotlinRunConfigurationEditor extends SettingsEditor<KotlinRun
|
||||
moduleChooser.setAnchor(anchor);
|
||||
shortenClasspathModeCombo.setAnchor(anchor);
|
||||
}
|
||||
}
|
||||
|
||||
public static final JavaCodeFragment.VisibilityChecker VISIBILITY_CHECKER = (declaration, place) -> {
|
||||
if (declaration instanceof KtLightClass aClass) {
|
||||
if (ConfigurationUtil.MAIN_CLASS.value(aClass)
|
||||
&& (PsiMethodUtil.findMainMethod(aClass) != null || place.getParent() != null)
|
||||
&& ModuleUtilCore.findModuleForPsiElement(declaration) != null) {
|
||||
return JavaCodeFragment.VisibilityChecker.Visibility.VISIBLE;
|
||||
}
|
||||
}
|
||||
return JavaCodeFragment.VisibilityChecker.Visibility.NOT_VISIBLE;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user