<commit_before><commit_msg>Add utility class to work with packages<commit_after>package org.jetbrains.kotlin.core.utils;

import java.util.Arrays;
import java.util.Collection;

import org.eclipse.core.resources.IFile;
import org.jetbrains.jet.lang.resolve.java.PackageClassUtils;
import org.jetbrains.jet.lang.resolve.name.FqName;
import org.jetbrains.jet.plugin.JetMainDetector;

public class ProjectUtils {
    
    public static IFile getMainClass(Collection<IFile> files) {
        KotlinEnvironment kotlinEnvironment = new KotlinEnvironment();
        
        for (IFile file : files) {
            if (JetMainDetector.hasMain(kotlinEnvironment.getJetFile(file).getDeclarations())) {
                return file;
            }
        }
                
        return null;
    }
    
    public static boolean hasMain(IFile file) {
        return getMainClass(Arrays.asList(file)) != null;
    }
    
    public static String getPackageByFile(IFile file) {
        return new KotlinEnvironment().getJetFile(file).getPackageName();
    }
    
    public static FqName createPackageClassName(IFile file) {
        return PackageClassUtils.getPackageClassFqName(new FqName(getPackageByFile(file)));
    }
}
{'fraction_non_alphanumeric': 0.09083402146985962, 'fraction_numerical': 0.0, 'mean_word_length': 3.1084745762711865, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2017307', 'n_tokens_mistral': 357, 'n_tokens_neox': 348, 'n_words': 66}