/**
 * generated by Xtext 2.9.2
 */
package com.justeat.mickeydb.generator;

import com.google.inject.Inject;
import com.google.inject.Provider;
import com.justeat.mickeydb.MickeyAssembler;
import com.justeat.mickeydb.MickeyDatabaseModel;
import com.justeat.mickeydb.Strings;
import com.justeat.mickeydb.generator.ActiveRecordGenerator;
import com.justeat.mickeydb.generator.ContentProviderContractGenerator;
import com.justeat.mickeydb.generator.ContentProviderGenerator;
import com.justeat.mickeydb.generator.CustomActionsGenerator;
import com.justeat.mickeydb.generator.SqliteMigrationGenerator;
import com.justeat.mickeydb.generator.SqliteOpenHelperGenerator;
import com.justeat.mickeydb.mickeyLang.CreateTableStatement;
import com.justeat.mickeydb.mickeyLang.CreateViewStatement;
import com.justeat.mickeydb.mickeyLang.MickeyFile;
import com.justeat.mickeydb.mickeyLang.MigrationBlock;
import org.eclipse.emf.common.util.EList;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.xtext.generator.AbstractGenerator;
import org.eclipse.xtext.generator.IFileSystemAccess;
import org.eclipse.xtext.generator.IFileSystemAccess2;
import org.eclipse.xtext.generator.IGeneratorContext;
import org.eclipse.xtext.xbase.lib.IterableExtensions;

/**
 * Generates code from your model files on save.
 * 
 * See https://www.eclipse.org/Xtext/documentation/303_runtime_concepts.html#code-generation
 */
@SuppressWarnings("all")
public class MickeyLangGenerator extends AbstractGenerator {
  @Inject
  private SqliteOpenHelperGenerator mOpenHelperGenerator;
  
  @Inject
  private ContentProviderContractGenerator mContentProviderContractGenerator;
  
  @Inject
  private ContentProviderGenerator mContentProviderGenerator;
  
  @Inject
  private Provider<SqliteMigrationGenerator> mMigrationGenerator;
  
  @Inject
  private ActiveRecordGenerator mActiveRecordGenerator;
  
  @Inject
  private CustomActionsGenerator mCustomActionsGenerator;
  
  @Inject
  private MickeyAssembler assembler;
  
  @Override
  public void doGenerate(final Resource resource, final IFileSystemAccess2 fsa, final IGeneratorContext context) {
    throw new Error("Unresolved compilation problems:"
      + "\nThe method getSnapshot() from the type MickeyDatabaseModel refers to the missing type SqliteDatabaseSnapshot"
      + "\nThe method getSnapshot() from the type MickeyDatabaseModel refers to the missing type SqliteDatabaseSnapshot"
      + "\nThe method getSnapshot() from the type MickeyDatabaseModel refers to the missing type SqliteDatabaseSnapshot"
      + "\nThere is no context to infer the closure\'s argument types from. Consider typing the arguments or put the closures into a typed context."
      + "\nThe method getSnapshot() from the type MickeyDatabaseModel refers to the missing type SqliteDatabaseSnapshot"
      + "\nThere is no context to infer the closure\'s argument types from. Consider typing the arguments or put the closures into a typed context."
      + "\nThe field MickeyDatabaseModel.initTables refers to the missing type CreateTableStatement"
      + "\nThe field MickeyDatabaseModel.initViews refers to the missing type CreateViewStatement"
      + "\nThe field MickeyDatabaseModel.migrations refers to the missing type MigrationBlock"
      + "\ntables cannot be resolved"
      + "\nforEach cannot be resolved"
      + "\nviews cannot be resolved"
      + "\nforEach cannot be resolved");
  }
  
  public void generateActiveRecordEntity(final MickeyDatabaseModel model, final Resource resource, final IFileSystemAccess fsa, final CreateTableStatement statement) {
    throw new Error("Unresolved compilation problems:"
      + "\nThe method or field hasAndroidPrimaryKey is undefined for the type CreateTableStatement");
  }
  
  public void generateActiveRecordEntity(final MickeyDatabaseModel model, final Resource resource, final IFileSystemAccess fsa, final CreateViewStatement statement) {
    throw new Error("Unresolved compilation problems:"
      + "\nThe method or field hasAndroidPrimaryKey is undefined for the type CreateViewStatement");
  }
  
  public void generateMigration(final String packageName, final String databaseName, final Resource resource, final IFileSystemAccess fsa, final MigrationBlock migration) {
    EList<EObject> _contents = resource.getContents();
    EObject _head = IterableExtensions.<EObject>head(_contents);
    MickeyFile model = ((MickeyFile) _head);
    String _concat = packageName.concat(".migrations");
    String _pascalize = Strings.pascalize(databaseName);
    String _concat_1 = "Default".concat(_pascalize);
    String _concat_2 = _concat_1.concat("Migration");
    String _name = migration.getName();
    String _pascalize_1 = Strings.pascalize(_name);
    String _valueOf = String.valueOf(_pascalize_1);
    String _concat_3 = _concat_2.concat(_valueOf);
    String genFileName = Strings.resolveFileName(_concat, _concat_3);
    SqliteMigrationGenerator generator = this.mMigrationGenerator.get();
    CharSequence _generate = generator.generate(model, packageName, databaseName, migration);
    fsa.generateFile(genFileName, _generate);
  }
}
