<commit_before>package com.github.blindpirate.gogradle;

import com.github.blindpirate.gogradle.build.BuildManager;
import com.github.blindpirate.gogradle.build.DefaultBuildManager;
import com.github.blindpirate.gogradle.core.BuildConstraintManager;
import com.github.blindpirate.gogradle.core.DefaultBuildConstraintManager;
import com.github.blindpirate.gogradle.core.GolangConfigurationContainer;
import com.github.blindpirate.gogradle.core.cache.DefaultGlobalCacheManager;
import com.github.blindpirate.gogradle.core.cache.GlobalCacheManager;
import com.github.blindpirate.gogradle.core.dependency.DefaultDependencyRegistry;
import com.github.blindpirate.gogradle.core.dependency.DependencyRegistry;
import com.github.blindpirate.gogradle.core.dependency.lock.DefaultLockedDependencyManager;
import com.github.blindpirate.gogradle.core.dependency.lock.LockedDependencyManager;
import com.github.blindpirate.gogradle.core.dependency.parse.DefaultMapNotationParser;
import com.github.blindpirate.gogradle.core.dependency.parse.DefaultNotationConverter;
import com.github.blindpirate.gogradle.core.dependency.parse.DefaultNotationParser;
import com.github.blindpirate.gogradle.core.dependency.parse.GitMapNotationParser;
import com.github.blindpirate.gogradle.core.dependency.parse.GitNotationConverter;
import com.github.blindpirate.gogradle.core.dependency.parse.MapNotationParser;
import com.github.blindpirate.gogradle.core.dependency.parse.NotationConverter;
import com.github.blindpirate.gogradle.core.dependency.parse.NotationParser;
import com.github.blindpirate.gogradle.core.dependency.produce.DefaultDependencyVisitor;
import com.github.blindpirate.gogradle.core.dependency.produce.DependencyVisitor;
import com.github.blindpirate.gogradle.core.dependency.produce.ExternalDependencyFactory;
import com.github.blindpirate.gogradle.core.dependency.produce.external.glide.GlideDependencyFactory;
import com.github.blindpirate.gogradle.core.dependency.produce.external.glock.GlockDependencyFactory;
import com.github.blindpirate.gogradle.core.dependency.produce.external.godep.GodepDependencyFactory;
import com.github.blindpirate.gogradle.core.dependency.produce.external.gopm.GopmDependencyFactory;
import com.github.blindpirate.gogradle.core.dependency.produce.external.govendor.GovendorDependencyFactory;
import com.github.blindpirate.gogradle.core.dependency.produce.external.gvtgbvendor.GvtGbvendorDependencyFactory;
import com.github.blindpirate.gogradle.core.dependency.produce.external.trash.TrashDependencyFactory;
import com.github.blindpirate.gogradle.core.pack.BitbucketPackagePathResolver;
import com.github.blindpirate.gogradle.core.pack.DefaultPackagePathResolver;
import com.github.blindpirate.gogradle.core.pack.GithubPackagePathResolver;
import com.github.blindpirate.gogradle.core.pack.GlobalCachePackagePathResolver;
import com.github.blindpirate.gogradle.core.pack.IBMDevOpsPackagePathResolver;
import com.github.blindpirate.gogradle.core.pack.MetadataPackagePathResolver;
import com.github.blindpirate.gogradle.core.pack.PackagePathResolver;
import com.github.blindpirate.gogradle.core.pack.StandardPackagePathResolver;
import com.github.blindpirate.gogradle.core.pack.UnrecognizedPackagePathResolver;
import com.github.blindpirate.gogradle.crossplatform.DefaultGoBinaryManager;
import com.github.blindpirate.gogradle.crossplatform.GoBinaryManager;
import com.github.blindpirate.gogradle.util.CollectionUtils;
import com.github.blindpirate.gogradle.util.logging.DebugLog;
import com.github.blindpirate.gogradle.util.logging.DebugLogMethodInterceptor;
import com.github.blindpirate.gogradle.vcs.Bazaar;
import com.github.blindpirate.gogradle.vcs.Git;
import com.github.blindpirate.gogradle.vcs.Mercurial;
import com.github.blindpirate.gogradle.vcs.Svn;
import com.github.blindpirate.gogradle.vcs.VcsAccessor;
import com.github.blindpirate.gogradle.vcs.bazaar.BazaarAccessor;
import com.github.blindpirate.gogradle.vcs.bazaar.BazaarMapNotationParser;
import com.github.blindpirate.gogradle.vcs.bazaar.BazaarNotationConverter;
import com.github.blindpirate.gogradle.vcs.git.GitAccessor;
import com.github.blindpirate.gogradle.vcs.mercurial.MercurialMapNotationParser;
import com.github.blindpirate.gogradle.vcs.mercurial.MercurialNotationConverter;
import com.github.blindpirate.gogradle.vcs.mercurial.client.HgClientMercurialAccessor;
import com.github.blindpirate.gogradle.vcs.svn.SvnAccessor;
import com.github.blindpirate.gogradle.vcs.svn.SvnMapNotationParser;
import com.github.blindpirate.gogradle.vcs.svn.SvnNotationConverter;
import com.google.inject.AbstractModule;
import com.google.inject.Provides;
import com.google.inject.matcher.AbstractMatcher;
import com.google.inject.matcher.Matchers;
import org.gradle.api.Project;
import org.gradle.api.artifacts.ConfigurationContainer;
import org.gradle.api.internal.project.DefaultProject;
import org.gradle.internal.reflect.Instantiator;
import org.gradle.internal.service.ServiceRegistry;

import javax.inject.Inject;
import javax.inject.Singleton;
import java.lang.reflect.Method;
import java.util.List;

/**
 * Provides configurations for Guice dependency injection.
 */
public class GogradleModule extends AbstractModule {
    private final Project project;
    private final Instantiator instantiator;
    private final ServiceRegistry serviceRegistry;

    public GogradleModule(Project project, Instantiator instantiator) {
        this.project = new ProjectDecorator(project);
        this.instantiator = instantiator;
        this.serviceRegistry = DefaultProject.class.cast(project).getServices();
    }

    @Override
    protected void configure() {
        bind(Project.class).toInstance(project);
        bind(Instantiator.class).toInstance(instantiator);
        bind(ServiceRegistry.class).toInstance(serviceRegistry);

        bind(NotationParser.class).to(DefaultNotationParser.class);
        bind(BuildManager.class).to(DefaultBuildManager.class);
        bind(GoBinaryManager.class).to(DefaultGoBinaryManager.class);
        bind(MapNotationParser.class).to(DefaultMapNotationParser.class);
        bind(GlobalCacheManager.class).to(DefaultGlobalCacheManager.class);
        bind(ConfigurationContainer.class).to(GolangConfigurationContainer.class);
        bind(DependencyRegistry.class).to(DefaultDependencyRegistry.class);
        bind(PackagePathResolver.class).to(DefaultPackagePathResolver.class);
        bind(NotationConverter.class).to(DefaultNotationConverter.class);
        bind(BuildConstraintManager.class).to(DefaultBuildConstraintManager.class);
        bind(DependencyVisitor.class).to(DefaultDependencyVisitor.class);
        bind(LockedDependencyManager.class).to(DefaultLockedDependencyManager.class);

        bind(MapNotationParser.class).annotatedWith(Git.class).to(GitMapNotationParser.class);
        bind(NotationConverter.class).annotatedWith(Git.class).to(GitNotationConverter.class);
        bind(VcsAccessor.class).annotatedWith(Git.class).to(GitAccessor.class);

        bind(MapNotationParser.class).annotatedWith(Mercurial.class).to(MercurialMapNotationParser.class);
        bind(NotationConverter.class).annotatedWith(Mercurial.class).to(MercurialNotationConverter.class);
        bind(VcsAccessor.class).annotatedWith(Mercurial.class).to(HgClientMercurialAccessor.class);

        bind(MapNotationParser.class).annotatedWith(Svn.class).to(SvnMapNotationParser.class);
        bind(NotationConverter.class).annotatedWith(Svn.class).to(SvnNotationConverter.class);
        bind(VcsAccessor.class).annotatedWith(Svn.class).to(SvnAccessor.class);

        bind(MapNotationParser.class).annotatedWith(Bazaar.class).to(BazaarMapNotationParser.class);
        bind(NotationConverter.class).annotatedWith(Bazaar.class).to(BazaarNotationConverter.class);
        bind(VcsAccessor.class).annotatedWith(Bazaar.class).to(BazaarAccessor.class);

        bindInterceptor(Matchers.any(), new AbstractMatcher<Method>() {
            @Override
            public boolean matches(Method method) {
                return method.isAnnotationPresent(DebugLog.class)
                        && !method.isSynthetic();
            }
        }, new DebugLogMethodInterceptor());


    }


    // The order is based on https://github.com/blindpirate/report-of-go-package-management-tool
    @Inject
    @Provides
    @Singleton<commit_msg>Bind service to correct implementation<commit_after>package com.github.blindpirate.gogradle;

import com.github.blindpirate.gogradle.build.BuildManager;
import com.github.blindpirate.gogradle.build.DefaultBuildManager;
import com.github.blindpirate.gogradle.core.BuildConstraintManager;
import com.github.blindpirate.gogradle.core.DefaultBuildConstraintManager;
import com.github.blindpirate.gogradle.core.GolangConfigurationContainer;
import com.github.blindpirate.gogradle.core.cache.DefaultGlobalCacheManager;
import com.github.blindpirate.gogradle.core.cache.GlobalCacheManager;
import com.github.blindpirate.gogradle.core.dependency.DefaultDependencyRegistry;
import com.github.blindpirate.gogradle.core.dependency.DependencyRegistry;
import com.github.blindpirate.gogradle.core.dependency.lock.DefaultLockedDependencyManager;
import com.github.blindpirate.gogradle.core.dependency.lock.LockedDependencyManager;
import com.github.blindpirate.gogradle.core.dependency.parse.DefaultMapNotationParser;
import com.github.blindpirate.gogradle.core.dependency.parse.DefaultNotationConverter;
import com.github.blindpirate.gogradle.core.dependency.parse.DefaultNotationParser;
import com.github.blindpirate.gogradle.core.dependency.parse.GitMercurialMapNotationParser;
import com.github.blindpirate.gogradle.core.dependency.parse.GitMercurialNotationConverter;
import com.github.blindpirate.gogradle.core.dependency.parse.MapNotationParser;
import com.github.blindpirate.gogradle.core.dependency.parse.NotationConverter;
import com.github.blindpirate.gogradle.core.dependency.parse.NotationParser;
import com.github.blindpirate.gogradle.core.dependency.produce.DefaultDependencyVisitor;
import com.github.blindpirate.gogradle.core.dependency.produce.DependencyVisitor;
import com.github.blindpirate.gogradle.core.dependency.produce.ExternalDependencyFactory;
import com.github.blindpirate.gogradle.core.dependency.produce.external.glide.GlideDependencyFactory;
import com.github.blindpirate.gogradle.core.dependency.produce.external.glock.GlockDependencyFactory;
import com.github.blindpirate.gogradle.core.dependency.produce.external.godep.GodepDependencyFactory;
import com.github.blindpirate.gogradle.core.dependency.produce.external.gopm.GopmDependencyFactory;
import com.github.blindpirate.gogradle.core.dependency.produce.external.govendor.GovendorDependencyFactory;
import com.github.blindpirate.gogradle.core.dependency.produce.external.gvtgbvendor.GvtGbvendorDependencyFactory;
import com.github.blindpirate.gogradle.core.dependency.produce.external.trash.TrashDependencyFactory;
import com.github.blindpirate.gogradle.core.pack.BitbucketPackagePathResolver;
import com.github.blindpirate.gogradle.core.pack.DefaultPackagePathResolver;
import com.github.blindpirate.gogradle.core.pack.GithubPackagePathResolver;
import com.github.blindpirate.gogradle.core.pack.GlobalCachePackagePathResolver;
import com.github.blindpirate.gogradle.core.pack.IBMDevOpsPackagePathResolver;
import com.github.blindpirate.gogradle.core.pack.MetadataPackagePathResolver;
import com.github.blindpirate.gogradle.core.pack.PackagePathResolver;
import com.github.blindpirate.gogradle.core.pack.StandardPackagePathResolver;
import com.github.blindpirate.gogradle.core.pack.UnrecognizedPackagePathResolver;
import com.github.blindpirate.gogradle.crossplatform.DefaultGoBinaryManager;
import com.github.blindpirate.gogradle.crossplatform.GoBinaryManager;
import com.github.blindpirate.gogradle.util.CollectionUtils;
import com.github.blindpirate.gogradle.util.logging.DebugLog;
import com.github.blindpirate.gogradle.util.logging.DebugLogMethodInterceptor;
import com.github.blindpirate.gogradle.vcs.Bazaar;
import com.github.blindpirate.gogradle.vcs.Git;
import com.github.blindpirate.gogradle.vcs.Mercurial;
import com.github.blindpirate.gogradle.vcs.Svn;
import com.github.blindpirate.gogradle.vcs.VcsAccessor;
import com.github.blindpirate.gogradle.vcs.bazaar.BazaarAccessor;
import com.github.blindpirate.gogradle.vcs.bazaar.BazaarMapNotationParser;
import com.github.blindpirate.gogradle.vcs.bazaar.BazaarNotationConverter;
import com.github.blindpirate.gogradle.vcs.git.GitAccessor;
import com.github.blindpirate.gogradle.vcs.mercurial.MercurialAccessor;
import com.github.blindpirate.gogradle.vcs.mercurial.client.HgClientMercurialAccessor;
import com.github.blindpirate.gogradle.vcs.svn.SvnAccessor;
import com.github.blindpirate.gogradle.vcs.svn.SvnMapNotationParser;
import com.github.blindpirate.gogradle.vcs.svn.SvnNotationConverter;
import com.google.inject.AbstractModule;
import com.google.inject.Provides;
import com.google.inject.matcher.AbstractMatcher;
import com.google.inject.matcher.Matchers;
import org.gradle.api.Project;
import org.gradle.api.artifacts.ConfigurationContainer;
import org.gradle.api.internal.project.DefaultProject;
import org.gradle.internal.reflect.Instantiator;
import org.gradle.internal.service.ServiceRegistry;

import javax.inject.Inject;
import javax.inject.Singleton;
import java.lang.reflect.Method;
import java.util.List;

/**
 * Provides configurations for Guice dependency injection.
 */
public class GogradleModule extends AbstractModule {
    private final Project project;
    private final Instantiator instantiator;
    private final ServiceRegistry serviceRegistry;

    public GogradleModule(Project project, Instantiator instantiator) {
        this.project = new ProjectDecorator(project);
        this.instantiator = instantiator;
        this.serviceRegistry = DefaultProject.class.cast(project).getServices();
    }

    @Override
    protected void configure() {
        bind(Project.class).toInstance(project);
        bind(Instantiator.class).toInstance(instantiator);
        bind(ServiceRegistry.class).toInstance(serviceRegistry);

        bind(NotationParser.class).to(DefaultNotationParser.class);
        bind(BuildManager.class).to(DefaultBuildManager.class);
        bind(GoBinaryManager.class).to(DefaultGoBinaryManager.class);
        bind(MapNotationParser.class).to(DefaultMapNotationParser.class);
        bind(GlobalCacheManager.class).to(DefaultGlobalCacheManager.class);
        bind(ConfigurationContainer.class).to(GolangConfigurationContainer.class);
        bind(DependencyRegistry.class).to(DefaultDependencyRegistry.class);
        bind(PackagePathResolver.class).to(DefaultPackagePathResolver.class);
        bind(NotationConverter.class).to(DefaultNotationConverter.class);
        bind(BuildConstraintManager.class).to(DefaultBuildConstraintManager.class);
        bind(DependencyVisitor.class).to(DefaultDependencyVisitor.class);
        bind(LockedDependencyManager.class).to(DefaultLockedDependencyManager.class);
        bind(MercurialAccessor.class).to(HgClientMercurialAccessor.class);

        bind(MapNotationParser.class).annotatedWith(Git.class).to(GitMercurialMapNotationParser.class);
        bind(NotationConverter.class).annotatedWith(Git.class).to(GitMercurialNotationConverter.class);
        bind(VcsAccessor.class).annotatedWith(Git.class).to(GitAccessor.class);

        bind(MapNotationParser.class).annotatedWith(Mercurial.class).to(GitMercurialMapNotationParser.class);
        bind(NotationConverter.class).annotatedWith(Mercurial.class).to(GitMercurialNotationConverter.class);
        bind(VcsAccessor.class).annotatedWith(Mercurial.class).to(HgClientMercurialAccessor.class);

        bind(MapNotationParser.class).annotatedWith(Svn.class).to(SvnMapNotationParser.class);
        bind(NotationConverter.class).annotatedWith(Svn.class).to(SvnNotationConverter.class);
        bind(VcsAccessor.class).annotatedWith(Svn.class).to(SvnAccessor.class);

        bind(MapNotationParser.class).annotatedWith(Bazaar.class).to(BazaarMapNotationParser.class);
        bind(NotationConverter.class).annotatedWith(Bazaar.class).to(BazaarNotationConverter.class);
        bind(VcsAccessor.class).annotatedWith(Bazaar.class).to(BazaarAccessor.class);

        bindInterceptor(Matchers.any(), new AbstractMatcher<Method>() {
            @Override
            public boolean matches(Method method) {
                return method.isAnnotationPresent(DebugLog.class)
                        && !method.isSynthetic();
            }
        }, new DebugLogMethodInterceptor());


    }


    // The order is based on https://github.com/blindpirate/report-of-go-package-management-tool
    @Inject
    @Provides
    @Singleton
{'fraction_non_alphanumeric': 0.10019095357441223, 'fraction_numerical': 0.0, 'mean_word_length': 6.026834381551363, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '3109226', 'n_tokens_mistral': 5440, 'n_tokens_neox': 5078, 'n_words': 466}