package org.metaborg.sunshine;

import org.metaborg.spoofax.core.SpoofaxModule;
import org.metaborg.spoofax.core.stratego.StrategoRuntimeService;
import org.metaborg.sunshine.drivers.SunshineMainDriver;
import org.metaborg.sunshine.environment.LaunchConfiguration;
import org.metaborg.sunshine.environment.SunshineMainArguments;
import org.metaborg.sunshine.prims.SunshineLibrary;
import org.metaborg.sunshine.statistics.Statistics;
import org.spoofax.interpreter.library.IOperatorRegistry;

import com.google.inject.multibindings.Multibinder;
import com.google.inject.name.Names;

public class SunshineModule extends SpoofaxModule {
    private final SunshineMainArguments args;

    public SunshineModule(SunshineMainArguments args) {
        this.args = args;
    }

    @Override protected void bindOther() {
        bind(SunshineMainArguments.class).toInstance(args);
        bind(LaunchConfiguration.class).asEagerSingleton();
        bind(SunshineMainDriver.class).asEagerSingleton();
        bind(StrategoRuntimeService.class).asEagerSingleton();
        bind(Statistics.class).asEagerSingleton();

        final Multibinder<IOperatorRegistry> strategoLibraryBinder =
            Multibinder.newSetBinder(binder(), IOperatorRegistry.class);
        strategoLibraryBinder.addBinding().toInstance(new SunshineLibrary());

        bind(String.class).annotatedWith(Names.named("LanguageDiscoveryAnalysisOverride")).toInstance("analysis-cmd");
        bind(ClassLoader.class).annotatedWith(Names.named("ResourceClassLoader")).toInstance(
            this.getClass().getClassLoader());
    }
}

@@ -540,45 +540,8 @@
 der;
-%0Aimport com.google.inject.name.Names;
 %0A%0Apu
@@ -637,16 +637,21 @@
  args;%0A%0A
+    %0A
     publ
@@ -731,16 +731,17 @@
 %0A    %7D%0A%0A
+%0A
     @Ove
@@ -765,21 +765,49 @@
 oid 
-bindOther() %7B
+configure() %7B%0A        super.configure();%0A
 %0A   
@@ -1235,24 +1235,24 @@
 try.class);%0A
+
         stra
@@ -1320,269 +1320,8 @@
 ());
-%0A%0A        bind(String.class).annotatedWith(Names.named(%22LanguageDiscoveryAnalysisOverride%22)).toInstance(%22analysis-cmd%22);%0A        bind(ClassLoader.class).annotatedWith(Names.named(%22ResourceClassLoader%22)).toInstance(%0A            this.getClass().getClassLoader());
 %0A   

Split up Spoofax module.