boolean (@NotNull JavaScratchConfiguration configuration, @NotNull ConfigurationContext context) { final PsiElement location = context.getPsiLocation(); final PsiClass aClass = ApplicationConfigurationType.getMainClass(location); if (aClass != null && Objects.equals(JavaExecutionUtil.getRuntimeQualifiedName(aClass), configuration.getMainClassName())) { // for scratches it is enough to check that the configuration is associated with the same scratch file final VirtualFile scratchFile = configuration.getScratchVirtualFile(); if (scratchFile != null) { final PsiFile containingFile = aClass.getContainingFile(); if (containingFile != null && scratchFile.equals(containingFile.getVirtualFile())) { return true; } } } return false; }