Search in sources :

Example 1 with EPackageInfo

use of org.eclipse.xtext.xtext.wizard.EPackageInfo in project xtext-core by eclipse.

the class Ecore2XtextExtensions method allConcreteRuleClassifiers.

public static Iterable<EClassifier> allConcreteRuleClassifiers(final Ecore2XtextConfiguration it) {
    Iterable<EClassifier> _xifexpression = null;
    EClass _rootElementClass = it.getRootElementClass();
    boolean _tripleEquals = (_rootElementClass == null);
    if (_tripleEquals) {
        final Function1<EPackageInfo, Set<EClassifier>> _function = (EPackageInfo it_1) -> {
            return Ecore2XtextExtensions.allReferencedClassifiers(it_1.getEPackage(), false);
        };
        final Function1<EClassifier, Boolean> _function_1 = (EClassifier it_1) -> {
            return Boolean.valueOf(Ecore2XtextExtensions.needsConcreteRule(it_1));
        };
        _xifexpression = IterableExtensions.<EClassifier>filter(IterableExtensions.<EClassifier>toSet(Iterables.<EClassifier>concat(IterableExtensions.<EPackageInfo, Set<EClassifier>>map(it.getEPackageInfos(), _function))), _function_1);
    } else {
        Set<EClassifier> _xblockexpression = null;
        {
            final ArrayList<EClassifier> c = CollectionLiterals.<EClassifier>newArrayList(EClassifier.class.cast(it.getRootElementClass()));
            Ecore2XtextExtensions.allAssignedClassifiers(it.getRootElementClass(), c);
            final Function1<EClassifier, Boolean> _function_2 = (EClassifier cl) -> {
                return Boolean.valueOf(Ecore2XtextExtensions.needsConcreteRule(cl));
            };
            _xblockexpression = IterableExtensions.<EClassifier>toSet(IterableExtensions.<EClassifier>filter(c, _function_2));
        }
        _xifexpression = _xblockexpression;
    }
    return _xifexpression;
}
Also used : EClass(org.eclipse.emf.ecore.EClass) Set(java.util.Set) ArrayList(java.util.ArrayList) Function1(org.eclipse.xtext.xbase.lib.Functions.Function1) EClassifier(org.eclipse.emf.ecore.EClassifier) EPackageInfo(org.eclipse.xtext.xtext.wizard.EPackageInfo)

Example 2 with EPackageInfo

use of org.eclipse.xtext.xtext.wizard.EPackageInfo in project xtext-core by eclipse.

the class Ecore2XtextExtensions method allDispatcherRuleClasses.

public static Collection<EClass> allDispatcherRuleClasses(final Ecore2XtextConfiguration it) {
    Set<EClass> _xifexpression = null;
    EClass _rootElementClass = it.getRootElementClass();
    boolean _tripleEquals = (_rootElementClass == null);
    if (_tripleEquals) {
        final Function1<EPackageInfo, Set<EClassifier>> _function = (EPackageInfo it_1) -> {
            return Ecore2XtextExtensions.allReferencedClassifiers(it_1.getEPackage(), false);
        };
        final Function1<EClassifier, Boolean> _function_1 = (EClassifier c) -> {
            return Boolean.valueOf(Ecore2XtextExtensions.needsDispatcherRule(c));
        };
        _xifexpression = IterableExtensions.<EClass>toSet(Iterables.<EClass>filter(IterableExtensions.<EClassifier>filter(IterableExtensions.<EClassifier>toSet(Iterables.<EClassifier>concat(IterableExtensions.<EPackageInfo, Set<EClassifier>>map(it.getEPackageInfos(), _function))), _function_1), EClass.class));
    } else {
        final Function1<EClass, Iterable<EClassifier>> _function_2 = (EClass c) -> {
            final Function1<EReference, Boolean> _function_3 = (EReference r) -> {
                return Boolean.valueOf(Ecore2XtextExtensions.needsAssignment(r));
            };
            final Function1<EReference, EClassifier> _function_4 = (EReference it_1) -> {
                return it_1.getEType();
            };
            return IterableExtensions.<EReference, EClassifier>map(IterableExtensions.<EReference>filter(c.getEAllReferences(), _function_3), _function_4);
        };
        _xifexpression = IterableExtensions.<EClass>toSet(Iterables.<EClass>filter(Iterables.<EClassifier>concat(IterableExtensions.<EClass, Iterable<EClassifier>>map(Iterables.<EClass>filter(Ecore2XtextExtensions.allConcreteRuleClassifiers(it), EClass.class), _function_2)), EClass.class));
    }
    return _xifexpression;
}
Also used : Set(java.util.Set) Function1(org.eclipse.xtext.xbase.lib.Functions.Function1) EClassifier(org.eclipse.emf.ecore.EClassifier) EClass(org.eclipse.emf.ecore.EClass) EPackageInfo(org.eclipse.xtext.xtext.wizard.EPackageInfo) EReference(org.eclipse.emf.ecore.EReference)

Example 3 with EPackageInfo

use of org.eclipse.xtext.xtext.wizard.EPackageInfo in project xtext-core by eclipse.

the class ProjectDescriptor method getExternalDependencies.

public Set<ExternalDependency> getExternalDependencies() {
    final LinkedHashSet<ExternalDependency> deps = CollectionLiterals.<ExternalDependency>newLinkedHashSet();
    Set<EPackageInfo> _ePackageInfos = this.config.getEcore2Xtext().getEPackageInfos();
    for (final EPackageInfo ePackage : _ePackageInfos) {
        ExternalDependency _createBundleDependency = ExternalDependency.createBundleDependency(ePackage.getBundleID());
        deps.add(_createBundleDependency);
    }
    return deps;
}
Also used : ExternalDependency(org.eclipse.xtext.xtext.wizard.ExternalDependency) EPackageInfo(org.eclipse.xtext.xtext.wizard.EPackageInfo)

Example 4 with EPackageInfo

use of org.eclipse.xtext.xtext.wizard.EPackageInfo in project xtext-core by eclipse.

the class RuntimeProjectDescriptor method workflow.

public CharSequence workflow() {
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("module ");
    String _basePackagePath = this.getConfig().getLanguage().getBasePackagePath();
    String _plus = (_basePackagePath + "/Generate");
    String _simpleName = this.getConfig().getLanguage().getSimpleName();
    String _replaceAll = (_plus + _simpleName).replaceAll("/", ".");
    _builder.append(_replaceAll);
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    _builder.append("import org.eclipse.xtext.xtext.generator.*");
    _builder.newLine();
    _builder.append("import org.eclipse.xtext.xtext.generator.model.project.*");
    _builder.newLine();
    _builder.newLine();
    _builder.append("var rootPath = \"..\"");
    _builder.newLine();
    _builder.newLine();
    _builder.append("Workflow {");
    _builder.newLine();
    _builder.append("\t");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("component = XtextGenerator {");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("configuration = {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("project = StandardProjectConfig {");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("baseName = \"");
    String _name = this.getName();
    _builder.append(_name, "\t\t\t\t");
    _builder.append("\"");
    _builder.newLineIfNotEmpty();
    _builder.append("\t\t\t\t");
    _builder.append("rootPath = rootPath");
    _builder.newLine();
    {
        boolean _isEnabled = this.testProject.isEnabled();
        if (_isEnabled) {
            _builder.append("\t\t\t\t");
            _builder.append("runtimeTest = {");
            _builder.newLine();
            _builder.append("\t\t\t\t");
            _builder.append("\t");
            _builder.append("enabled = true");
            _builder.newLine();
            _builder.append("\t\t\t\t");
            _builder.append("}");
            _builder.newLine();
        }
    }
    {
        if ((this.getConfig().getIdeProject().isEnabled() && (!IterableExtensions.exists(Collections.<ProjectDescriptor>unmodifiableList(CollectionLiterals.<ProjectDescriptor>newArrayList(this.getConfig().getWebProject(), this.getConfig().getIntellijProject(), this.getConfig().getUiProject())), ((Function1<ProjectDescriptor, Boolean>) (ProjectDescriptor it) -> {
            return Boolean.valueOf(it.isEnabled());
        }))))) {
            _builder.append("\t\t\t\t");
            _builder.append("genericIde = {");
            _builder.newLine();
            _builder.append("\t\t\t\t");
            _builder.append("\t");
            _builder.append("enabled = true");
            _builder.newLine();
            _builder.append("\t\t\t\t");
            _builder.append("}");
            _builder.newLine();
        }
    }
    {
        boolean _isEnabled_1 = this.getConfig().getUiProject().isEnabled();
        if (_isEnabled_1) {
            _builder.append("\t\t\t\t");
            _builder.append("eclipsePlugin = {");
            _builder.newLine();
            _builder.append("\t\t\t\t");
            _builder.append("\t");
            _builder.append("enabled = true");
            _builder.newLine();
            _builder.append("\t\t\t\t");
            _builder.append("}");
            _builder.newLine();
        }
    }
    {
        boolean _isEnabled_2 = this.getConfig().getUiProject().getTestProject().isEnabled();
        if (_isEnabled_2) {
            _builder.append("\t\t\t\t");
            _builder.append("eclipsePluginTest = {");
            _builder.newLine();
            _builder.append("\t\t\t\t");
            _builder.append("\t");
            _builder.append("enabled = true");
            _builder.newLine();
            _builder.append("\t\t\t\t");
            _builder.append("}");
            _builder.newLine();
        }
    }
    {
        boolean _isEnabled_3 = this.getConfig().getIntellijProject().isEnabled();
        if (_isEnabled_3) {
            _builder.append("\t\t\t\t");
            _builder.append("ideaPlugin = {");
            _builder.newLine();
            _builder.append("\t\t\t\t");
            _builder.append("\t");
            _builder.append("enabled = true");
            _builder.newLine();
            _builder.append("\t\t\t\t");
            _builder.append("}");
            _builder.newLine();
        }
    }
    {
        boolean _isEnabled_4 = this.getConfig().getWebProject().isEnabled();
        if (_isEnabled_4) {
            _builder.append("\t\t\t\t");
            _builder.append("web = {");
            _builder.newLine();
            _builder.append("\t\t\t\t");
            _builder.append("\t");
            _builder.append("enabled = true");
            _builder.newLine();
            _builder.append("\t\t\t\t");
            _builder.append("}");
            _builder.newLine();
        }
    }
    {
        SourceLayout _sourceLayout = this.getConfig().getSourceLayout();
        boolean _equals = Objects.equal(_sourceLayout, SourceLayout.MAVEN);
        if (_equals) {
            _builder.append("\t\t\t\t");
            _builder.append("mavenLayout = true");
            _builder.newLine();
        }
    }
    {
        boolean _isEclipsePluginProject = this.isEclipsePluginProject();
        if (_isEclipsePluginProject) {
            _builder.append("\t\t\t\t");
            _builder.append("createEclipseMetaData = true");
            _builder.newLine();
        }
    }
    _builder.append("\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("code = {");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("encoding = \"");
    Charset _encoding = this.getConfig().getEncoding();
    _builder.append(_encoding, "\t\t\t\t");
    _builder.append("\"");
    _builder.newLineIfNotEmpty();
    _builder.append("\t\t\t\t");
    _builder.append("lineDelimiter = \"");
    String _convertToJavaString = Strings.convertToJavaString(this.getConfig().getLineDelimiter());
    _builder.append(_convertToJavaString, "\t\t\t\t");
    _builder.append("\"");
    _builder.newLineIfNotEmpty();
    _builder.append("\t\t\t\t");
    _builder.append("fileHeader = \"/*\\n * generated by Xtext \\${version}\\n */\"");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("language = StandardLanguage {");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("name = \"");
    String _name_1 = this.getConfig().getLanguage().getName();
    _builder.append(_name_1, "\t\t\t");
    _builder.append("\"");
    _builder.newLineIfNotEmpty();
    _builder.append("\t\t\t");
    _builder.append("fileExtensions = \"");
    LanguageDescriptor.FileExtensions _fileExtensions = this.getConfig().getLanguage().getFileExtensions();
    _builder.append(_fileExtensions, "\t\t\t");
    _builder.append("\"");
    _builder.newLineIfNotEmpty();
    {
        boolean _isEmpty = this.getConfig().getEcore2Xtext().getEPackageInfos().isEmpty();
        boolean _not = (!_isEmpty);
        if (_not) {
            {
                final Function1<EPackageInfo, String> _function = (EPackageInfo it) -> {
                    return it.getGenmodelURI().toString();
                };
                Set<String> _set = IterableExtensions.<String>toSet(IterableExtensions.<EPackageInfo, String>map(this.getConfig().getEcore2Xtext().getEPackageInfos(), _function));
                for (final String genmodelURI : _set) {
                    _builder.append("\t\t\t");
                    _builder.append("referencedResource = \"");
                    _builder.append(genmodelURI, "\t\t\t");
                    _builder.append("\"");
                    _builder.newLineIfNotEmpty();
                }
            }
        }
    }
    {
        boolean _isFromExistingEcoreModels = this.isFromExistingEcoreModels();
        if (_isFromExistingEcoreModels) {
            _builder.append("\t\t\t");
            _builder.newLine();
            _builder.append("\t\t\t");
            _builder.append("fragment = ecore2xtext.Ecore2XtextValueConverterServiceFragment2 auto-inject {}");
            _builder.newLine();
            _builder.newLine();
            _builder.append("\t\t\t");
            _builder.append("formatter = {");
            _builder.newLine();
            _builder.append("\t\t\t");
            _builder.append("\t");
            _builder.append("generateStub = true");
            _builder.newLine();
            _builder.append("\t\t\t");
            _builder.append("}");
            _builder.newLine();
        }
    }
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("serializer = {");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("generateStub = false");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("validator = {");
    _builder.newLine();
    _builder.append("\t\t\t\t");
    _builder.append("// composedCheck = \"org.eclipse.xtext.validation.NamesAreUniqueValidator\"");
    _builder.newLine();
    _builder.append("\t\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("\t");
    _builder.append("}");
    _builder.newLine();
    _builder.append("}");
    _builder.newLine();
    return _builder;
}
Also used : SourceLayout(org.eclipse.xtext.xtext.wizard.SourceLayout) RuntimeTestProjectDescriptor(org.eclipse.xtext.xtext.wizard.RuntimeTestProjectDescriptor) WebProjectDescriptor(org.eclipse.xtext.xtext.wizard.WebProjectDescriptor) TestProjectDescriptor(org.eclipse.xtext.xtext.wizard.TestProjectDescriptor) TestedProjectDescriptor(org.eclipse.xtext.xtext.wizard.TestedProjectDescriptor) ProjectDescriptor(org.eclipse.xtext.xtext.wizard.ProjectDescriptor) IdeProjectDescriptor(org.eclipse.xtext.xtext.wizard.IdeProjectDescriptor) UiProjectDescriptor(org.eclipse.xtext.xtext.wizard.UiProjectDescriptor) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Charset(java.nio.charset.Charset) LanguageDescriptor(org.eclipse.xtext.xtext.wizard.LanguageDescriptor) EPackageInfo(org.eclipse.xtext.xtext.wizard.EPackageInfo)

Aggregations

EPackageInfo (org.eclipse.xtext.xtext.wizard.EPackageInfo)4 Set (java.util.Set)2 EClass (org.eclipse.emf.ecore.EClass)2 EClassifier (org.eclipse.emf.ecore.EClassifier)2 Function1 (org.eclipse.xtext.xbase.lib.Functions.Function1)2 Charset (java.nio.charset.Charset)1 ArrayList (java.util.ArrayList)1 EReference (org.eclipse.emf.ecore.EReference)1 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)1 ExternalDependency (org.eclipse.xtext.xtext.wizard.ExternalDependency)1 IdeProjectDescriptor (org.eclipse.xtext.xtext.wizard.IdeProjectDescriptor)1 LanguageDescriptor (org.eclipse.xtext.xtext.wizard.LanguageDescriptor)1 ProjectDescriptor (org.eclipse.xtext.xtext.wizard.ProjectDescriptor)1 RuntimeTestProjectDescriptor (org.eclipse.xtext.xtext.wizard.RuntimeTestProjectDescriptor)1 SourceLayout (org.eclipse.xtext.xtext.wizard.SourceLayout)1 TestProjectDescriptor (org.eclipse.xtext.xtext.wizard.TestProjectDescriptor)1 TestedProjectDescriptor (org.eclipse.xtext.xtext.wizard.TestedProjectDescriptor)1 UiProjectDescriptor (org.eclipse.xtext.xtext.wizard.UiProjectDescriptor)1 WebProjectDescriptor (org.eclipse.xtext.xtext.wizard.WebProjectDescriptor)1