package org.eclipse.emf.parsley.dsl.generator; import com.google.common.base.Objects; import com.google.common.collect.Iterables; import com.google.inject.Inject; import java.util.Arrays; import java.util.List; import org.eclipse.emf.common.util.EList; import org.eclipse.emf.common.util.TreeIterator; import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.resource.Resource; import org.eclipse.emf.parsley.dsl.generator.EmfParsleyDslOutputConfigurationProvider; import org.eclipse.emf.parsley.dsl.jvmmodel.EmfParsleyDslJvmModelInferrer; import org.eclipse.emf.parsley.dsl.model.Module; import org.eclipse.emf.parsley.dsl.model.PartSpecification; import org.eclipse.emf.parsley.dsl.model.ViewSpecification; import org.eclipse.xtend2.lib.StringConcatenation; import org.eclipse.xtext.common.types.JvmTypeReference; import org.eclipse.xtext.generator.IFileSystemAccess; import org.eclipse.xtext.generator.IGenerator; import org.eclipse.xtext.xbase.lib.Functions.Function1; import org.eclipse.xtext.xbase.lib.IterableExtensions; import org.eclipse.xtext.xbase.lib.IteratorExtensions; import org.eclipse.xtext.xbase.lib.ListExtensions; @SuppressWarnings("all") public class EmfParsleyDslPluginXmlGenerator implements IGenerator { @Inject private EmfParsleyDslJvmModelInferrer inferrer; public void doGenerate(final Resource resource, final IFileSystemAccess fsa) { TreeIterator _allContents = resource.getAllContents(); Iterable _iterable = IteratorExtensions.toIterable(_allContents); Iterable _filter = Iterables.filter(_iterable, Module.class); for (final Module module : _filter) { { final CharSequence contents = this.generatePluginXml(module); int _length = 0; if (contents!=null) { _length=contents.length(); } boolean _greaterThan = (_length > 0); if (_greaterThan) { fsa.generateFile( EmfParsleyDslOutputConfigurationProvider.PLUGIN_XML_EMFPARSLEY_GEN_PATH, EmfParsleyDslOutputConfigurationProvider.PROJECT_ROOT_OUTPUT, contents); } } } } public CharSequence generatePluginXml(final Module module) { CharSequence _xblockexpression = null; { EList _parts = null; if (module!=null) { _parts=module.getParts(); } final EList partSpecs = _parts; CharSequence _xifexpression = null; boolean _or = false; boolean _equals = Objects.equal(partSpecs, null); if (_equals) { _or = true; } else { boolean _isEmpty = partSpecs.isEmpty(); _or = (_equals || _isEmpty); } if (_or) { StringConcatenation _builder = new StringConcatenation(); return _builder.toString(); } else { StringConcatenation _builder_1 = new StringConcatenation(); _builder_1.append(""); _builder_1.newLine(); _builder_1.append(" "); final Function1 _function = new Function1() { public CharSequence apply(final PartSpecification it) { CharSequence _generateExtensionPoint = EmfParsleyDslPluginXmlGenerator.this.generateExtensionPoint(it); return _generateExtensionPoint; } }; List _map = ListExtensions.map(partSpecs, _function); String _join = IterableExtensions.join(_map, ""); _builder_1.append(_join, " "); _builder_1.newLineIfNotEmpty(); _builder_1.append(""); _builder_1.newLine(); CharSequence _generatePluginXml = this.generatePluginXml(_builder_1); _xifexpression = _generatePluginXml; } _xblockexpression = (_xifexpression); } return _xblockexpression; } protected CharSequence _generateExtensionPoint(final PartSpecification partSpecification) { return null; } protected CharSequence _generateExtensionPoint(final ViewSpecification viewSpecification) { StringConcatenation _builder = new StringConcatenation(); _builder.append(""); _builder.newLine(); _builder.append(""); _builder.newLine(); return _builder; } public CharSequence generatePluginXml(final CharSequence contents) { StringConcatenation _builder = new StringConcatenation(); _builder.append(""); _builder.newLine(); _builder.append(""); _builder.newLine(); _builder.append(""); _builder.newLine(); _builder.append("\t"); _builder.append(contents, " "); _builder.newLineIfNotEmpty(); _builder.append(""); _builder.newLine(); return _builder; } public CharSequence generateExtensionPoint(final PartSpecification viewSpecification) { if (viewSpecification instanceof ViewSpecification) { return _generateExtensionPoint((ViewSpecification)viewSpecification); } else if (viewSpecification != null) { return _generateExtensionPoint(viewSpecification); } else { throw new IllegalArgumentException("Unhandled parameter types: " + Arrays.asList(viewSpecification).toString()); } } }