use of org.eclipse.xtext.xtext.generator.model.TypeReference in project xtext-core by eclipse.
the class XtextGeneratorTemplates method createRuntimeGenModule.
public JavaFileAccess createRuntimeGenModule(final IXtextGeneratorLanguage langConfig) {
final Grammar it = langConfig.getGrammar();
TypeReference _elvis = null;
TypeReference _superClass = langConfig.getRuntimeGenModule().getSuperClass();
if (_superClass != null) {
_elvis = _superClass;
} else {
TypeReference _runtimeDefaultModule = this.naming.getRuntimeDefaultModule(it);
_elvis = _runtimeDefaultModule;
}
final TypeReference superClass = _elvis;
final GeneratedJavaFileAccess file = this.fileAccessFactory.createGeneratedJavaFile(this.naming.getRuntimeGenModule(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.getRuntimeModule(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.getRuntimeGenModule(it).getSimpleName();
_builder.append(_simpleName);
_builder.append(" extends ");
_builder.append(superClass);
_builder.append(" {");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("\t");
_builder.append("protected ");
_builder.append(Properties.class, "\t");
_builder.append(" properties = null;");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("\t");
_builder.append("@Override");
_builder.newLine();
_builder.append("\t");
_builder.append("public void configure(");
_builder.append(Binder.class, "\t");
_builder.append(" binder) {");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("properties = tryBindProperties(binder, \"");
String _replaceAll = langConfig.getGrammar().getName().replaceAll("\\.", "/");
_builder.append(_replaceAll, "\t\t");
_builder.append(".properties\");");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("super.configure(binder);");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
_builder.append("public void configureLanguageName(");
_builder.append(Binder.class, "\t");
_builder.append(" binder) {");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("binder.bind(String.class).annotatedWith(");
_builder.append(Names.class, "\t\t");
_builder.append(".named(");
_builder.append(Constants.class, "\t\t");
_builder.append(".LANGUAGE_NAME)).toInstance(\"");
String _name = langConfig.getGrammar().getName();
_builder.append(_name, "\t\t");
_builder.append("\");");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
_builder.append("public void configureFileExtensions(");
_builder.append(Binder.class, "\t");
_builder.append(" binder) {");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("if (properties == null || properties.getProperty(Constants.FILE_EXTENSIONS) == null)");
_builder.newLine();
_builder.append("\t\t\t");
_builder.append("binder.bind(String.class).annotatedWith(");
_builder.append(Names.class, "\t\t\t");
_builder.append(".named(");
_builder.append(Constants.class, "\t\t\t");
_builder.append(".FILE_EXTENSIONS)).toInstance(\"");
String _join = IterableExtensions.join(langConfig.getFileExtensions(), ",");
_builder.append(_join, "\t\t\t");
_builder.append("\");");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.newLine();
{
Set<GuiceModuleAccess.Binding> _bindings = langConfig.getRuntimeGenModule().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;
}
use of org.eclipse.xtext.xtext.generator.model.TypeReference in project xtext-core by eclipse.
the class XtextGeneratorTemplates method createWebSetup.
public JavaFileAccess createWebSetup(final IXtextGeneratorLanguage langConfig) {
final Grammar it = langConfig.getGrammar();
boolean _isPreferXtendStubs = this.codeConfig.isPreferXtendStubs();
if (_isPreferXtendStubs) {
TypeReference _webSetup = this.naming.getWebSetup(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 in web applications.");
_builder.newLine();
_builder.append(" ");
_builder.append("*/");
_builder.newLine();
_builder.append("class ");
String _simpleName = XtextGeneratorTemplates.this.naming.getWebSetup(it).getSimpleName();
_builder.append(_simpleName);
_builder.append(" extends ");
TypeReference _runtimeSetup = XtextGeneratorTemplates.this.naming.getRuntimeSetup(it);
_builder.append(_runtimeSetup);
_builder.append(" {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
_builder.append("override ");
_builder.append(Injector.class, "\t");
_builder.append(" createInjector() {");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("return ");
_builder.append(Guice.class, "\t\t");
_builder.append(".createInjector(");
_builder.append(Modules2.class, "\t\t");
_builder.append(".mixin(new ");
TypeReference _runtimeModule = XtextGeneratorTemplates.this.naming.getRuntimeModule(it);
_builder.append(_runtimeModule, "\t\t");
_builder.append(", new ");
TypeReference _genericIdeModule = XtextGeneratorTemplates.this.naming.getGenericIdeModule(it);
_builder.append(_genericIdeModule, "\t\t");
_builder.append(", new ");
TypeReference _webModule = XtextGeneratorTemplates.this.naming.getWebModule(it);
_builder.append(_webModule, "\t\t");
_builder.append("))");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.newLine();
_builder.append("}");
_builder.newLine();
}
};
return this.fileAccessFactory.createXtendFile(_webSetup, _client);
} else {
TypeReference _webSetup_1 = this.naming.getWebSetup(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 in web applications.");
_builder.newLine();
_builder.append(" ");
_builder.append("*/");
_builder.newLine();
_builder.append("public class ");
String _simpleName = XtextGeneratorTemplates.this.naming.getWebSetup(it).getSimpleName();
_builder.append(_simpleName);
_builder.append(" extends ");
TypeReference _runtimeSetup = XtextGeneratorTemplates.this.naming.getRuntimeSetup(it);
_builder.append(_runtimeSetup);
_builder.append(" {");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.newLine();
_builder.append("\t");
_builder.append("@Override");
_builder.newLine();
_builder.append("\t");
_builder.append("public ");
_builder.append(Injector.class, "\t");
_builder.append(" createInjector() {");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("return ");
_builder.append(Guice.class, "\t\t");
_builder.append(".createInjector(");
_builder.append(Modules2.class, "\t\t");
_builder.append(".mixin(new ");
TypeReference _runtimeModule = XtextGeneratorTemplates.this.naming.getRuntimeModule(it);
_builder.append(_runtimeModule, "\t\t");
_builder.append("(), new ");
TypeReference _genericIdeModule = XtextGeneratorTemplates.this.naming.getGenericIdeModule(it);
_builder.append(_genericIdeModule, "\t\t");
_builder.append("(), new ");
TypeReference _webModule = XtextGeneratorTemplates.this.naming.getWebModule(it);
_builder.append(_webModule, "\t\t");
_builder.append("()));");
_builder.newLineIfNotEmpty();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.newLine();
_builder.append("}");
_builder.newLine();
}
};
return this.fileAccessFactory.createJavaFile(_webSetup_1, _client_1);
}
}
use of org.eclipse.xtext.xtext.generator.model.TypeReference in project xtext-core by eclipse.
the class XtextGeneratorTemplates method createIdeModule.
public JavaFileAccess createIdeModule(final IXtextGeneratorLanguage langConfig) {
final Grammar it = langConfig.getGrammar();
boolean _isPreferXtendStubs = this.codeConfig.isPreferXtendStubs();
if (_isPreferXtendStubs) {
TypeReference _genericIdeModule = this.naming.getGenericIdeModule(it);
StringConcatenationClient _client = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
_builder.append("/**");
_builder.newLine();
_builder.append(" ");
_builder.append("* Use this class to register ide components.");
_builder.newLine();
_builder.append(" ");
_builder.append("*/");
_builder.newLine();
_builder.append("class ");
String _simpleName = XtextGeneratorTemplates.this.naming.getGenericIdeModule(it).getSimpleName();
_builder.append(_simpleName);
_builder.append(" extends ");
TypeReference _genericIdeGenModule = XtextGeneratorTemplates.this.naming.getGenericIdeGenModule(it);
_builder.append(_genericIdeGenModule);
_builder.append(" {");
_builder.newLineIfNotEmpty();
_builder.append("}");
_builder.newLine();
}
};
return this.fileAccessFactory.createXtendFile(_genericIdeModule, _client);
} else {
TypeReference _genericIdeModule_1 = this.naming.getGenericIdeModule(it);
StringConcatenationClient _client_1 = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
_builder.append("/**");
_builder.newLine();
_builder.append(" ");
_builder.append("* Use this class to register ide components.");
_builder.newLine();
_builder.append(" ");
_builder.append("*/");
_builder.newLine();
_builder.append("public class ");
String _simpleName = XtextGeneratorTemplates.this.naming.getGenericIdeModule(it).getSimpleName();
_builder.append(_simpleName);
_builder.append(" extends ");
TypeReference _genericIdeGenModule = XtextGeneratorTemplates.this.naming.getGenericIdeGenModule(it);
_builder.append(_genericIdeGenModule);
_builder.append(" {");
_builder.newLineIfNotEmpty();
_builder.append("}");
_builder.newLine();
}
};
return this.fileAccessFactory.createJavaFile(_genericIdeModule_1, _client_1);
}
}
use of org.eclipse.xtext.xtext.generator.model.TypeReference in project xtext-core by eclipse.
the class XtextGeneratorTemplates method createWebModule.
public JavaFileAccess createWebModule(final IXtextGeneratorLanguage langConfig) {
final Grammar it = langConfig.getGrammar();
boolean _isPreferXtendStubs = this.codeConfig.isPreferXtendStubs();
if (_isPreferXtendStubs) {
TypeReference _webModule = this.naming.getWebModule(it);
StringConcatenationClient _client = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
_builder.append("/**");
_builder.newLine();
_builder.append(" ");
_builder.append("* Use this class to register additional components to be used within the web application.");
_builder.newLine();
_builder.append(" ");
_builder.append("*/");
_builder.newLine();
_builder.append("class ");
String _simpleName = XtextGeneratorTemplates.this.naming.getWebModule(it).getSimpleName();
_builder.append(_simpleName);
_builder.append(" extends ");
TypeReference _webGenModule = XtextGeneratorTemplates.this.naming.getWebGenModule(it);
_builder.append(_webGenModule);
_builder.append(" {");
_builder.newLineIfNotEmpty();
_builder.append("}");
_builder.newLine();
}
};
return this.fileAccessFactory.createXtendFile(_webModule, _client);
} else {
TypeReference _webModule_1 = this.naming.getWebModule(it);
StringConcatenationClient _client_1 = new StringConcatenationClient() {
@Override
protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
_builder.append("/**");
_builder.newLine();
_builder.append(" ");
_builder.append("* Use this class to register additional components to be used within the web application.");
_builder.newLine();
_builder.append(" ");
_builder.append("*/");
_builder.newLine();
_builder.append("public class ");
String _simpleName = XtextGeneratorTemplates.this.naming.getWebModule(it).getSimpleName();
_builder.append(_simpleName);
_builder.append(" extends ");
TypeReference _webGenModule = XtextGeneratorTemplates.this.naming.getWebGenModule(it);
_builder.append(_webGenModule);
_builder.append(" {");
_builder.newLineIfNotEmpty();
_builder.append("}");
_builder.newLine();
}
};
return this.fileAccessFactory.createJavaFile(_webModule_1, _client_1);
}
}
use of org.eclipse.xtext.xtext.generator.model.TypeReference in project xtext-core by eclipse.
the class XtextGeneratorTemplates method createEclipsePluginGenModule.
public JavaFileAccess createEclipsePluginGenModule(final IXtextGeneratorLanguage langConfig) {
final Grammar it = langConfig.getGrammar();
TypeReference _elvis = null;
TypeReference _superClass = langConfig.getEclipsePluginGenModule().getSuperClass();
if (_superClass != null) {
_elvis = _superClass;
} else {
TypeReference _eclipsePluginDefaultModule = this.naming.getEclipsePluginDefaultModule(it);
_elvis = _eclipsePluginDefaultModule;
}
final TypeReference superClass = _elvis;
final GeneratedJavaFileAccess file = this.fileAccessFactory.createGeneratedJavaFile(this.naming.getEclipsePluginGenModule(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.getEclipsePluginModule(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.getEclipsePluginGenModule(it).getSimpleName();
_builder.append(_simpleName);
_builder.append(" extends ");
_builder.append(superClass);
_builder.append(" {");
_builder.newLineIfNotEmpty();
_builder.newLine();
_builder.append("\t");
_builder.append("public ");
String _simpleName_1 = XtextGeneratorTemplates.this.naming.getEclipsePluginGenModule(it).getSimpleName();
_builder.append(_simpleName_1, "\t");
_builder.append("(");
TypeReference _typeRef = TypeReference.typeRef("org.eclipse.ui.plugin.AbstractUIPlugin");
_builder.append(_typeRef, "\t");
_builder.append(" plugin) {");
_builder.newLineIfNotEmpty();
_builder.append("\t\t");
_builder.append("super(plugin);");
_builder.newLine();
_builder.append("\t");
_builder.append("}");
_builder.newLine();
_builder.append("\t");
_builder.newLine();
{
Set<GuiceModuleAccess.Binding> _bindings = langConfig.getEclipsePluginGenModule().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