org.eclipse.xtext.generator.IGenerator2 Java Examples

The following examples show how to use org.eclipse.xtext.generator.IGenerator2. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ExtraLanguageGeneratorSupport.java    From sarl with Apache License 2.0 6 votes vote down vote up
@Override
public void afterGenerate(Resource input, IFileSystemAccess2 fsa, IGeneratorContext context) {
	final IGenerator2 mainGenerator = getMainGenerator();
	if (mainGenerator != null) {
		mainGenerator.afterGenerate(input, fsa, context);
	}
	final Iterable<IRootGenerator> generators = getExtraGeneratorProvider().getGenerators(context, input);
	if (generators != null) {
		for (final IGenerator2 generator : generators) {
			try {
				generator.afterGenerate(input, fsa, context);
			} catch (Throwable exception) {
				getLogger().log(Level.SEVERE, exception.getLocalizedMessage(), exception);
			}
		}
	}
}
 
Example #2
Source File: ExtraLanguageGeneratorSupport.java    From sarl with Apache License 2.0 6 votes vote down vote up
@Override
public void beforeGenerate(Resource input, IFileSystemAccess2 fsa, IGeneratorContext context) {
	final IGenerator2 mainGenerator = getMainGenerator();
	if (mainGenerator != null) {
		mainGenerator.beforeGenerate(input, fsa, context);
	}
	final Iterable<IRootGenerator> generators = getExtraGeneratorProvider().getGenerators(context, input);
	if (generators != null) {
		for (final IGenerator2 generator : generators) {
			try {
				generator.beforeGenerate(input, fsa, context);
			} catch (Throwable exception) {
				getLogger().log(Level.SEVERE, exception.getLocalizedMessage(), exception);
			}
		}
	}
}
 
Example #3
Source File: ExtraLanguageGeneratorSupport.java    From sarl with Apache License 2.0 6 votes vote down vote up
@Override
public void doGenerate(Resource input, IFileSystemAccess2 fsa, IGeneratorContext context) {
	final IGenerator2 mainGenerator = getMainGenerator();
	if (mainGenerator != null) {
		mainGenerator.doGenerate(input, fsa, context);
	}
	final Iterable<IRootGenerator> generators = getExtraGeneratorProvider().getGenerators(context, input);
	if (generators != null) {
		for (final IGenerator2 generator : generators) {
			try {
				generator.doGenerate(input, fsa, context);
			} catch (Throwable exception) {
				getLogger().log(Level.SEVERE, exception.getLocalizedMessage(), exception);
			}
		}
	}
}
 
Example #4
Source File: RDOutputStandaloneSetup.java    From Getaviz with Apache License 2.0 5 votes vote down vote up
public Injector createInjector() {
	return Guice.createInjector(new RDRuntimeModule() {
		@Override
		public Class<? extends IGenerator2> bindIGenerator2() {
			return RDOutput.class;
		}
	});
}
 
Example #5
Source File: MultiSphere2X3DStandaloneSetup.java    From Getaviz with Apache License 2.0 5 votes vote down vote up
public Injector createInjector() {
	return Guice.createInjector(new GraphRuntimeModule() {

		@Override
		public Class<? extends IGenerator2> bindIGenerator2() {
			return MultiSphere2X3D.class;
		}
	});
}
 
Example #6
Source File: CityOutputStandaloneSetup.java    From Getaviz with Apache License 2.0 5 votes vote down vote up
public Injector createInjector() {
	return Guice.createInjector(new CityRuntimeModule() {

		@Override
		public Class<? extends IGenerator2> bindIGenerator2() {
			return CityOutput.class;
		}
	});
}
 
Example #7
Source File: Famix2JSONStandaloneSetup.java    From Getaviz with Apache License 2.0 5 votes vote down vote up
public Injector createInjector() {
	return Guice.createInjector(new FamixRuntimeModule() {

		@Override
		public Class<? extends IGenerator2> bindIGenerator2() {
			return Famix2JSON.class;
		}
	});
}
 
Example #8
Source File: Hismo2JSONStandaloneSetup.java    From Getaviz with Apache License 2.0 5 votes vote down vote up
public Injector createInjector() {
	return Guice.createInjector(new HismoRuntimeModule() {

		@Override
		public Class<? extends IGenerator2> bindIGenerator2() {
			return Hismo2JSON.class;
		}
	});
}
 
Example #9
Source File: GenerateHismoStandaloneSetup.java    From Getaviz with Apache License 2.0 5 votes vote down vote up
public Injector createInjector() {
	return Guice.createInjector(new HismoRuntimeModule() {
		@Override
		public Class<? extends IGenerator2> bindIGenerator2() {
			return GenerateHismo.class;
		}
	});
}
 
Example #10
Source File: Plant2X3DStandaloneSetup.java    From Getaviz with Apache License 2.0 5 votes vote down vote up
public Injector createInjector() {
	return Guice.createInjector(new RDRuntimeModule() {

		@Override
		public Class<? extends IGenerator2> bindIGenerator2() {
			return Plant2X3D.class;
		}
	});
}
 
Example #11
Source File: AbstractFileAwareTestLanguageRuntimeModule.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends IGenerator2> bindIGenerator2() {
	return FileAwareTestLanguageGenerator.class;
}
 
Example #12
Source File: AbstractRegularExpressionRuntimeModule.java    From n4js with Eclipse Public License 1.0 4 votes vote down vote up
public Class<? extends IGenerator2> bindIGenerator2() {
	return RegularExpressionGenerator.class;
}
 
Example #13
Source File: AbstractStatemachineRuntimeModule.java    From xtext-web with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends IGenerator2> bindIGenerator2() {
	return StatemachineGenerator.class;
}
 
Example #14
Source File: ExtraLanguageGeneratorSupport.java    From sarl with Apache License 2.0 4 votes vote down vote up
/** Change the main generator that should be used for generating files from SARL resource.
 *
 * @param generator the generator.
 */
@Inject
public void setMainGenerator(@Named(MAIN_GENERATOR_NAME) IGenerator2 generator) {
	this.mainGenerator = generator;
}
 
Example #15
Source File: AbstractSARLRuntimeModule.java    From sarl with Apache License 2.0 4 votes vote down vote up
public void configureIGenerator2ExtraLanguageMainGenerator(Binder binder) {
	binder.bind(IGenerator2.class).annotatedWith(Names.named(io.sarl.lang.extralanguage.compiler.ExtraLanguageGeneratorSupport.MAIN_GENERATOR_NAME)).to(SARLJvmGenerator.class);
}
 
Example #16
Source File: AbstractGamlRuntimeModule.java    From gama with GNU General Public License v3.0 4 votes vote down vote up
public Class<? extends IGenerator2> bindIGenerator2() {
	return GamlGenerator.class;
}
 
Example #17
Source File: IndexTestLanguageRuntimeModule.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends IGenerator2> bindIGenerator2() {
	return IndexTestLanguageGenerator.class;
}
 
Example #18
Source File: AbstractNestedRefsTestLanguageRuntimeModule.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends IGenerator2> bindIGenerator2() {
	return NestedRefsTestLanguageGenerator.class;
}
 
Example #19
Source File: AbstractNoJdtTestLanguageRuntimeModule.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends IGenerator2> bindIGenerator2() {
	return NoJdtTestLanguageGenerator.class;
}
 
Example #20
Source File: AbstractMyDslRuntimeModule.java    From M2Doc with Eclipse Public License 1.0 4 votes vote down vote up
public Class<? extends IGenerator2> bindIGenerator2() {
	return MyDslGenerator.class;
}
 
Example #21
Source File: GeneratorFragment2.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public void generate() {
  boolean _isGenerateStub = this.isGenerateStub();
  if (_isGenerateStub) {
    new GuiceModuleAccess.BindingFactory().addTypeToType(TypeReference.typeRef(IGenerator2.class), this.getGeneratorStub(this.getLanguage().getGrammar())).contributeTo(this.getLanguage().getRuntimeGenModule());
    ManifestAccess _manifest = this.getProjectConfig().getRuntime().getManifest();
    boolean _tripleNotEquals = (_manifest != null);
    if (_tripleNotEquals) {
      Set<String> _requiredBundles = this.getProjectConfig().getRuntime().getManifest().getRequiredBundles();
      String _xbaseLibVersionLowerBound = this.getProjectConfig().getRuntime().getXbaseLibVersionLowerBound();
      String _plus = ("org.eclipse.xtext.xbase.lib;bundle-version=\"" + _xbaseLibVersionLowerBound);
      String _plus_1 = (_plus + "\"");
      _requiredBundles.add(_plus_1);
    }
    boolean _isGenerateXtendStub = this.isGenerateXtendStub();
    if (_isGenerateXtendStub) {
      this.doGenerateXtendStubFile();
    } else {
      this.doGenerateJavaStubFile();
    }
  }
  if ((this.isGenerateStub() || this.isGenerateJavaMain())) {
    ManifestAccess _manifest_1 = this.getProjectConfig().getRuntime().getManifest();
    boolean _tripleNotEquals_1 = (_manifest_1 != null);
    if (_tripleNotEquals_1) {
      Set<String> _exportedPackages = this.getProjectConfig().getRuntime().getManifest().getExportedPackages();
      String _packageName = this.getGeneratorStub(this.getLanguage().getGrammar()).getPackageName();
      _exportedPackages.add(_packageName);
    }
  }
  boolean _isGenerateJavaMain = this.isGenerateJavaMain();
  if (_isGenerateJavaMain) {
    this.doGenerateJavaMain();
  }
  boolean _isGenerateXtendMain = this.isGenerateXtendMain();
  if (_isGenerateXtendMain) {
    this.doGenerateXtendMain();
  }
  boolean _isGenerateMwe = this.isGenerateMwe();
  if (_isGenerateMwe) {
    this.doGenerateMweFile();
  }
  this.contributeEclipsePluginGuiceBindings();
  ManifestAccess _manifest_2 = this.getProjectConfig().getEclipsePlugin().getManifest();
  boolean _tripleNotEquals_2 = (_manifest_2 != null);
  if (_tripleNotEquals_2) {
    Set<String> _requiredBundles_1 = this.getProjectConfig().getEclipsePlugin().getManifest().getRequiredBundles();
    _requiredBundles_1.add("org.eclipse.xtext.builder");
  }
  PluginXmlAccess _pluginXml = this.getProjectConfig().getEclipsePlugin().getPluginXml();
  boolean _tripleNotEquals_3 = (_pluginXml != null);
  if (_tripleNotEquals_3) {
    this.contributeEclipsePluginExtensions();
  }
}
 
Example #22
Source File: AbstractTestLanguageRuntimeModule.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends IGenerator2> bindIGenerator2() {
	return TestLanguageGenerator.class;
}
 
Example #23
Source File: AbstractRenameTestLanguageRuntimeModule.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends IGenerator2> bindIGenerator2() {
	return RenameTestLanguageGenerator.class;
}
 
Example #24
Source File: AbstractIndentationAwareUiTestLanguageRuntimeModule.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends IGenerator2> bindIGenerator2() {
	return IndentationAwareUiTestLanguageGenerator.class;
}
 
Example #25
Source File: AbstractPartialSerializationTestLanguageRuntimeModule.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends IGenerator2> bindIGenerator2() {
	return PartialSerializationTestLanguageGenerator.class;
}
 
Example #26
Source File: AbstractPartialContentAssistTestLanguageRuntimeModule.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends IGenerator2> bindIGenerator2() {
	return PartialContentAssistTestLanguageGenerator.class;
}
 
Example #27
Source File: XtendRuntimeModule.java    From xtext-xtend with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends IGenerator2> bindIGenerator2() {
	return XtendGenerator.class;
}
 
Example #28
Source File: BuilderParticipant.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
/**
 * @since 2.9
 */
public IGenerator2 getGenerator2() {
	return generatorDelegate;
}
 
Example #29
Source File: AbstractStatemachineRuntimeModule.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public Class<? extends IGenerator2> bindIGenerator2() {
	return StatemachineGenerator.class;
}
 
Example #30
Source File: ExtraLanguageGeneratorSupport.java    From sarl with Apache License 2.0 2 votes vote down vote up
/** Change the main generator that should be usedd dfor generating files from SARL resource.
 *
 * @return the generator.
 */
public IGenerator2 getMainGenerator() {
	return this.mainGenerator;
}