boolean (@NotNull T configuration, @NotNull ConfigurationContext context, @NotNull Ref<PsiElement> sourceElement) { final Location<?> contextLocation = context.getLocation(); if (contextLocation == null) { return false; } final Location<?> location = JavaExecutionUtil.stepIntoSingleClass(contextLocation); if (location == null) { return false; } final PsiElement element = location.getPsiElement(); if (!element.isPhysical()) { return false; } final PsiClass aClass = ApplicationConfigurationType.getMainClass(element); if (aClass == null) { return false; } PsiFile containingFile = aClass.getContainingFile(); if (JavaHighlightUtil.isJavaHashBangScript(containingFile)) { return false; } PsiMethod method = PsiMethodUtil.findMainInClass(aClass); if (method != null && PsiTreeUtil.isAncestor(method, element, false)) { sourceElement.set(method); } else { sourceElement.set(aClass); } setupConfiguration(configuration, aClass, context); return true; }