<commit_before>package org.jetbrains.haskell.run.haskell

import com.intellij.execution.actions.ConfigurationContext
import com.intellij.execution.actions.RunConfigurationProducer
import com.intellij.openapi.diagnostic.Logger
import com.intellij.openapi.module.Module
import com.intellij.openapi.project.Project
import com.intellij.openapi.roots.ProjectRootManager
import com.intellij.openapi.util.Ref
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiFile
import org.jetbrains.cabal.CabalFile
import org.jetbrains.cabal.CabalInterface
import org.jetbrains.haskell.fileType.HaskellFile


public class CabalRunConfigurationProducer() : RunConfigurationProducer<CabalRunConfiguration>(HaskellRunConfigurationType.INSTANCE) {


    override fun setupConfigurationFromContext(configuration: CabalRunConfiguration?,
                                               context: ConfigurationContext?,
                                               sourceElement: Ref<PsiElement>?): Boolean {
        val file = sourceElement!!.get()!!.getContainingFile()
        if (!(file is HaskellFile)) {
            return false
        }
        try {
            val virtualFile = file.getVirtualFile()
            if (virtualFile == null) {
                return false
            }
            val project = file.getProject()

            val module = ProjectRootManager.getInstance(project)!!.getFileIndex().getModuleForFile(virtualFile)

            val psiFile = CabalInterface(project).getPsiFile(CabalInterface.findCabal(module!!)!!)
            val executables = psiFile.getExecutables()

            val name = if (executables.size > 0) {
                executables.get(0).getExecutableName()
            } else {
                "Default"
            }
<commit_msg>Fix NPE<commit_after>package org.jetbrains.haskell.run.haskell

import com.intellij.execution.actions.ConfigurationContext
import com.intellij.execution.actions.RunConfigurationProducer
import com.intellij.openapi.diagnostic.Logger
import com.intellij.openapi.module.Module
import com.intellij.openapi.project.Project
import com.intellij.openapi.roots.ProjectRootManager
import com.intellij.openapi.util.Ref
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.psi.PsiElement
import com.intellij.psi.PsiFile
import org.jetbrains.cabal.CabalFile
import org.jetbrains.cabal.CabalInterface
import org.jetbrains.haskell.fileType.HaskellFile


public class CabalRunConfigurationProducer() : RunConfigurationProducer<CabalRunConfiguration>(HaskellRunConfigurationType.INSTANCE) {


    override fun setupConfigurationFromContext(configuration: CabalRunConfiguration?,
                                               context: ConfigurationContext?,
                                               sourceElement: Ref<PsiElement>?): Boolean {
        val file = sourceElement!!.get()!!.getContainingFile()
        if (!(file is HaskellFile)) {
            return false
        }
        try {
            val virtualFile = file.getVirtualFile()
            if (virtualFile == null) {
                return false
            }
            val project = file.getProject()

            val module = ProjectRootManager.getInstance(project)!!.getFileIndex().getModuleForFile(virtualFile)

            val cabal = CabalInterface.findCabal(module!!)
            if (cabal == null) {
                return false
            }
            val psiFile = CabalInterface(project).getPsiFile(cabal)
            val executables = psiFile.getExecutables()

            val name = if (executables.size > 0) {
                executables.get(0).getExecutableName()
            } else {
                "Default"
            }

{'fraction_non_alphanumeric': 0.08566058002148227, 'fraction_numerical': 0.0010741138560687433, 'mean_word_length': 2.602514506769826, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3143358', 'n_tokens_mistral': 1019, 'n_tokens_neox': 979, 'n_words': 167}