use of org.eclipse.xtext.xtext.generator.model.TypeReference in project xtext-core by eclipse.
the class XbaseGeneratorFragment2 method contributeRuntimeGuiceBindings.
protected void contributeRuntimeGuiceBindings() {
final GuiceModuleAccess.BindingFactory bindingFactory = new GuiceModuleAccess.BindingFactory().addTypeToType(TypeReference.typeRef(IQualifiedNameProvider.class), TypeReference.typeRef("org.eclipse.xtext.xbase.scoping.XbaseQualifiedNameProvider"));
boolean _usesXImportSection = this._xbaseUsageDetector.usesXImportSection(this.getGrammar());
boolean _not = (!_usesXImportSection);
if (_not) {
StringConcatenationClient _client = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
_builder.append("binder.bind(");
_builder.append(Boolean.class);
_builder.append(".TYPE)");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append(".annotatedWith(");
_builder.append(Names.class, "\t");
_builder.append(".named(");
TypeReference _typeReference = new TypeReference("org.eclipse.xtext.xbase.imports", "RewritableImportSection.Factory");
_builder.append(_typeReference, "\t");
_builder.append(".REWRITABLEIMPORTSECTION_ENABLEMENT))");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append(".toInstance(");
_builder.append(Boolean.class, "\t");
_builder.append(".FALSE);");
_builder.newLineIfNotEmpty();
}
};
bindingFactory.addConfiguredBinding("RewritableImportSectionEnablement", _client);
}
if (this.useInferredJvmModel) {
bindingFactory.addTypeToType(TypeReference.typeRef(ILocationInFileProvider.class), TypeReference.typeRef("org.eclipse.xtext.xbase.jvmmodel.JvmLocationInFileProvider")).addTypeToType(TypeReference.typeRef(IGlobalScopeProvider.class), TypeReference.typeRef("org.eclipse.xtext.common.types.xtext.TypesAwareDefaultGlobalScopeProvider")).addTypeToType(TypeReference.typeRef("org.eclipse.xtext.xbase.validation.FeatureNameValidator"), TypeReference.typeRef("org.eclipse.xtext.xbase.validation.LogicalContainerAwareFeatureNameValidator")).addTypeToType(TypeReference.typeRef("org.eclipse.xtext.xbase.typesystem.internal.DefaultBatchTypeResolver"), TypeReference.typeRef("org.eclipse.xtext.xbase.typesystem.internal.LogicalContainerAwareBatchTypeResolver")).addTypeToType(TypeReference.typeRef("org.eclipse.xtext.xbase.typesystem.internal.DefaultReentrantTypeResolver"), TypeReference.typeRef("org.eclipse.xtext.xbase.typesystem.internal.LogicalContainerAwareReentrantTypeResolver")).addTypeToType(TypeReference.typeRef(IResourceValidator.class), TypeReference.typeRef("org.eclipse.xtext.xbase.annotations.validation.DerivedStateAwareResourceValidator"));
if (this.generateXtendInferrer) {
bindingFactory.addTypeToType(TypeReference.typeRef("org.eclipse.xtext.xbase.jvmmodel.IJvmModelInferrer"), this.getJvmModelInferrer());
}
} else {
bindingFactory.addTypeToType(TypeReference.typeRef(ILocationInFileProvider.class), TypeReference.typeRef("org.eclipse.xtext.xbase.resource.XbaseLocationInFileProvider"));
}
bindingFactory.contributeTo(this.getLanguage().getRuntimeGenModule());
boolean _inheritsXbaseWithAnnotations = this._xbaseUsageDetector.inheritsXbaseWithAnnotations(this.getLanguage().getGrammar());
if (_inheritsXbaseWithAnnotations) {
GuiceModuleAccess _runtimeGenModule = this.getLanguage().getRuntimeGenModule();
_runtimeGenModule.setSuperClass(TypeReference.typeRef("org.eclipse.xtext.xbase.annotations.DefaultXbaseWithAnnotationsRuntimeModule"));
} else {
GuiceModuleAccess _runtimeGenModule_1 = this.getLanguage().getRuntimeGenModule();
_runtimeGenModule_1.setSuperClass(TypeReference.typeRef("org.eclipse.xtext.xbase.DefaultXbaseRuntimeModule"));
}
}
use of org.eclipse.xtext.xtext.generator.model.TypeReference in project xtext-core by eclipse.
the class ImplicitFragment method generate.
@Override
public void generate() {
ManifestAccess _manifest = this.getProjectConfig().getRuntime().getManifest();
boolean _tripleNotEquals = (_manifest != null);
if (_tripleNotEquals) {
this.getProjectConfig().getRuntime().getManifest().getRequiredBundles().addAll(Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList("org.eclipse.xtext", "org.eclipse.xtext.util")));
boolean _isGenerateXtendStub = this.isGenerateXtendStub();
if (_isGenerateXtendStub) {
Set<String> _requiredBundles = this.getProjectConfig().getRuntime().getManifest().getRequiredBundles();
String _xtendLibVersionLowerBound = this.getProjectConfig().getRuntime().getXtendLibVersionLowerBound();
String _plus = ("org.eclipse.xtend.lib;bundle-version=\"" + _xtendLibVersionLowerBound);
String _plus_1 = (_plus + "\"");
_requiredBundles.add(_plus_1);
}
this.getProjectConfig().getRuntime().getManifest().getImportedPackages().add("org.apache.log4j");
}
ManifestAccess _manifest_1 = this.getProjectConfig().getEclipsePlugin().getManifest();
boolean _tripleNotEquals_1 = (_manifest_1 != null);
if (_tripleNotEquals_1) {
this.getProjectConfig().getEclipsePlugin().getManifest().getRequiredBundles().addAll(Collections.<String>unmodifiableList(CollectionLiterals.<String>newArrayList("org.eclipse.xtext.ui", "org.eclipse.xtext.ui.shared", "org.eclipse.ui.editors", "org.eclipse.ui")));
boolean _isGenerateXtendStub_1 = this.isGenerateXtendStub();
if (_isGenerateXtendStub_1) {
Set<String> _requiredBundles_1 = this.getProjectConfig().getEclipsePlugin().getManifest().getRequiredBundles();
String _xtendLibVersionLowerBound_1 = this.getProjectConfig().getRuntime().getXtendLibVersionLowerBound();
String _plus_2 = ("org.eclipse.xtend.lib;bundle-version=\"" + _xtendLibVersionLowerBound_1);
String _plus_3 = (_plus_2 + "\"");
_requiredBundles_1.add(_plus_3);
}
this.getProjectConfig().getEclipsePlugin().getManifest().getImportedPackages().add("org.apache.log4j");
}
PluginXmlAccess _pluginXml = this.getProjectConfig().getEclipsePlugin().getPluginXml();
boolean _tripleNotEquals_2 = (_pluginXml != null);
if (_tripleNotEquals_2) {
List<CharSequence> _entries = this.getProjectConfig().getEclipsePlugin().getPluginXml().getEntries();
CharSequence _implicitPluginXmlEnties = this.getImplicitPluginXmlEnties(this.getGrammar());
_entries.add(_implicitPluginXmlEnties);
}
StringConcatenationClient _client = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
TypeReference _typeRef = TypeReference.typeRef("org.eclipse.xtext.ui.shared.Access");
_builder.append(_typeRef);
_builder.append(".getJavaProjectsState()");
}
};
final StringConcatenationClient expression = _client;
final GuiceModuleAccess.BindingFactory bindingFactory = new GuiceModuleAccess.BindingFactory().addTypeToProviderInstance(TypeReference.typeRef(IAllContainersState.class), expression);
boolean _inheritsXbase = this._xbaseUsageDetector.inheritsXbase(this.getGrammar());
if (_inheritsXbase) {
bindingFactory.addTypeToType(TypeReference.typeRef("org.eclipse.xtext.ui.editor.model.XtextDocumentProvider"), TypeReference.typeRef("org.eclipse.xtext.xbase.ui.editor.XbaseDocumentProvider")).addTypeToType(TypeReference.typeRef("org.eclipse.xtext.ui.generator.trace.OpenGeneratedFileHandler"), TypeReference.typeRef("org.eclipse.xtext.xbase.ui.generator.trace.XbaseOpenGeneratedFileHandler"));
}
bindingFactory.contributeTo(this.getLanguage().getEclipsePluginGenModule());
}
use of org.eclipse.xtext.xtext.generator.model.TypeReference in project xtext-core by eclipse.
the class XtextGeneratorTemplates method createBindingMethod.
private StringConcatenationClient createBindingMethod(final GuiceModuleAccess.Binding it) {
StringConcatenationClient _client = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
{
if (((!it.getValue().isProvider()) && it.getValue().getStatements().isEmpty())) {
_builder.append("// contributed by ");
String _contributedBy = it.getContributedBy();
_builder.append(_contributedBy);
_builder.newLineIfNotEmpty();
{
boolean _isSingleton = it.getKey().isSingleton();
if (_isSingleton) {
_builder.append("@");
_builder.append(SingletonBinding.class);
{
boolean _isEagerSingleton = it.getKey().isEagerSingleton();
if (_isEagerSingleton) {
_builder.append("(eager=true)");
}
}
}
}
_builder.newLineIfNotEmpty();
_builder.append("public ");
{
Object _expression = it.getValue().getExpression();
boolean _tripleEquals = (_expression == null);
if (_tripleEquals) {
_builder.append("Class<? extends ");
TypeReference _type = it.getKey().getType();
_builder.append(_type);
_builder.append(">");
} else {
TypeReference _type_1 = it.getKey().getType();
_builder.append(_type_1);
}
}
_builder.append(" ");
CharSequence _bindMethodName = XtextGeneratorTemplates.this.getBindMethodName(it);
_builder.append(_bindMethodName);
_builder.append("() {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("return ");
{
Object _expression_1 = it.getValue().getExpression();
boolean _tripleNotEquals = (_expression_1 != null);
if (_tripleNotEquals) {
Object _expression_2 = it.getValue().getExpression();
_builder.append(_expression_2, "\t");
} else {
TypeReference _type_2 = it.getValue().getType();
_builder.append(_type_2, "\t");
_builder.append(".class");
}
}
_builder.append(";");
_builder.newLineIfNotEmpty();
_builder.append("}");
_builder.newLine();
} else {
boolean _isEmpty = it.getValue().getStatements().isEmpty();
if (_isEmpty) {
_builder.append("// contributed by ");
String _contributedBy_1 = it.getContributedBy();
_builder.append(_contributedBy_1);
_builder.newLineIfNotEmpty();
{
boolean _isSingleton_1 = it.getKey().isSingleton();
if (_isSingleton_1) {
_builder.append("@");
_builder.append(SingletonBinding.class);
{
boolean _isEagerSingleton_1 = it.getKey().isEagerSingleton();
if (_isEagerSingleton_1) {
_builder.append("(eager=true)");
}
}
}
}
_builder.newLineIfNotEmpty();
_builder.append("public ");
{
Object _expression_3 = it.getValue().getExpression();
boolean _tripleEquals_1 = (_expression_3 == null);
if (_tripleEquals_1) {
_builder.append("Class<? extends ");
_builder.append(Provider.class);
_builder.append("<? extends ");
TypeReference _type_3 = it.getKey().getType();
_builder.append(_type_3);
_builder.append(">>");
} else {
_builder.append(Provider.class);
_builder.append("<? extends ");
TypeReference _type_4 = it.getKey().getType();
_builder.append(_type_4);
_builder.append(">");
}
}
_builder.append(" ");
CharSequence _bindMethodName_1 = XtextGeneratorTemplates.this.getBindMethodName(it);
_builder.append(_bindMethodName_1);
_builder.append("() {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("return ");
{
Object _expression_4 = it.getValue().getExpression();
boolean _tripleNotEquals_1 = (_expression_4 != null);
if (_tripleNotEquals_1) {
Object _expression_5 = it.getValue().getExpression();
_builder.append(_expression_5, "\t");
} else {
TypeReference _type_5 = it.getValue().getType();
_builder.append(_type_5, "\t");
_builder.append(".class");
}
}
_builder.append(";");
_builder.newLineIfNotEmpty();
_builder.append("}");
_builder.newLine();
} else {
_builder.append("// contributed by ");
String _contributedBy_2 = it.getContributedBy();
_builder.append(_contributedBy_2);
_builder.newLineIfNotEmpty();
_builder.append("public void ");
CharSequence _bindMethodName_2 = XtextGeneratorTemplates.this.getBindMethodName(it);
_builder.append(_bindMethodName_2);
_builder.append("(");
_builder.append(Binder.class);
_builder.append(" binder) {");
_builder.newLineIfNotEmpty();
{
List<Object> _statements = it.getValue().getStatements();
for (final Object statement : _statements) {
_builder.append("\t");
_builder.append(statement, "\t");
_builder.newLineIfNotEmpty();
}
}
_builder.append("}");
_builder.newLine();
}
}
}
}
};
return _client;
}
use of org.eclipse.xtext.xtext.generator.model.TypeReference in project xtext-core by eclipse.
the class XtextGeneratorTemplates method createRuntimeSetup.
public JavaFileAccess createRuntimeSetup(final IXtextGeneratorLanguage langConfig) {
final Grammar it = langConfig.getGrammar();
boolean _isPreferXtendStubs = this.codeConfig.isPreferXtendStubs();
if (_isPreferXtendStubs) {
TypeReference _runtimeSetup = this.naming.getRuntimeSetup(it);
StringConcatenationClient _client = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
_builder.append("/**");
_builder.newLine();
_builder.append(" ");
_builder.append("* Initialization support for running Xtext languages without Equinox extension registry.");
_builder.newLine();
_builder.append(" ");
_builder.append("*/");
_builder.newLine();
_builder.append("class ");
String _simpleName = XtextGeneratorTemplates.this.naming.getRuntimeSetup(it).getSimpleName();
_builder.append(_simpleName);
_builder.append(" extends ");
TypeReference _runtimeGenSetup = XtextGeneratorTemplates.this.naming.getRuntimeGenSetup(it);
_builder.append(_runtimeGenSetup);
_builder.append(" {");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("\t");
_builder.append("def static void doSetup() {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("new ");
String _simpleName_1 = XtextGeneratorTemplates.this.naming.getRuntimeSetup(it).getSimpleName();
_builder.append(_simpleName_1, "\t\t");
_builder.append("().createInjectorAndDoEMFRegistration()");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
}
};
return this.fileAccessFactory.createXtendFile(_runtimeSetup, _client);
} else {
TypeReference _runtimeSetup_1 = this.naming.getRuntimeSetup(it);
StringConcatenationClient _client_1 = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
_builder.append("/**");
_builder.newLine();
_builder.append(" ");
_builder.append("* Initialization support for running Xtext languages without Equinox extension registry.");
_builder.newLine();
_builder.append(" ");
_builder.append("*/");
_builder.newLine();
_builder.append("public class ");
String _simpleName = XtextGeneratorTemplates.this.naming.getRuntimeSetup(it).getSimpleName();
_builder.append(_simpleName);
_builder.append(" extends ");
TypeReference _runtimeGenSetup = XtextGeneratorTemplates.this.naming.getRuntimeGenSetup(it);
_builder.append(_runtimeGenSetup);
_builder.append(" {");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("\t");
_builder.append("public static void doSetup() {");
_builder.newLine();
_builder.append("\t\t");
_builder.append("new ");
String _simpleName_1 = XtextGeneratorTemplates.this.naming.getRuntimeSetup(it).getSimpleName();
_builder.append(_simpleName_1, "\t\t");
_builder.append("().createInjectorAndDoEMFRegistration();");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
}
};
return this.fileAccessFactory.createJavaFile(_runtimeSetup_1, _client_1);
}
}
use of org.eclipse.xtext.xtext.generator.model.TypeReference in project xtext-core by eclipse.
the class XtextGeneratorTemplates method createWebGenModule.
public JavaFileAccess createWebGenModule(final IXtextGeneratorLanguage langConfig) {
final Grammar it = langConfig.getGrammar();
TypeReference _elvis = null;
TypeReference _superClass = langConfig.getWebGenModule().getSuperClass();
if (_superClass != null) {
_elvis = _superClass;
} else {
TypeReference _webDefaultModule = this.naming.getWebDefaultModule(it);
_elvis = _webDefaultModule;
}
final TypeReference superClass = _elvis;
final GeneratedJavaFileAccess file = this.fileAccessFactory.createGeneratedJavaFile(this.naming.getWebGenModule(it));
file.setImportNestedTypeThreshold(JavaFileAccess.DONT_IMPORT_NESTED_TYPES);
StringConcatenationClient _client = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
_builder.append("/**");
_builder.newLine();
_builder.append(" ");
_builder.append("* Manual modifications go to {@link ");
String _simpleName = XtextGeneratorTemplates.this.naming.getWebModule(it).getSimpleName();
_builder.append(_simpleName, " ");
_builder.append("}.");
_builder.newLineIfNotEmpty();
_builder.append(" ");
_builder.append("*/");
_builder.newLine();
}
};
file.setTypeComment(_client);
List<IClassAnnotation> _annotations = file.getAnnotations();
SuppressWarningsAnnotation _suppressWarningsAnnotation = new SuppressWarningsAnnotation();
_annotations.add(_suppressWarningsAnnotation);
StringConcatenationClient _client_1 = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
_builder.append("public abstract class ");
String _simpleName = XtextGeneratorTemplates.this.naming.getWebGenModule(it).getSimpleName();
_builder.append(_simpleName);
_builder.append(" extends ");
_builder.append(superClass);
_builder.append(" {");
_builder.newLineIfNotEmpty();
_builder.newLine();
{
Set<GuiceModuleAccess.Binding> _bindings = langConfig.getWebGenModule().getBindings();
for (final GuiceModuleAccess.Binding binding : _bindings) {
_builder.append("\t");
StringConcatenationClient _createBindingMethod = XtextGeneratorTemplates.this.createBindingMethod(binding);
_builder.append(_createBindingMethod, "\t");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.newLine();
}
}
_builder.append("}");
_builder.newLine();
}
};
file.setContent(_client_1);
file.setMarkedAsGenerated(true);
return file;
}
Aggregations