Search in sources :

Example 66 with Function1

use of org.eclipse.xtext.xbase.lib.Functions.Function1 in project xtext-core by eclipse.

the class ContentAssistFragment2 method getFQFeatureNamesToExclude.

public Set<String> getFQFeatureNamesToExclude(final Grammar g) {
    Set<String> _xifexpression = null;
    Grammar _nonTerminalsSuperGrammar = GrammarUtil2.getNonTerminalsSuperGrammar(g);
    boolean _tripleNotEquals = (_nonTerminalsSuperGrammar != null);
    if (_tripleNotEquals) {
        Sets.SetView<String> _xblockexpression = null;
        {
            final Set<String> thisGrammarFqFeatureNames = IterableExtensions.<String>toSet(this.computeFQFeatureNames(g));
            final Function1<Grammar, Iterable<String>> _function = (Grammar it) -> {
                return this.computeFQFeatureNames(it);
            };
            final Set<String> superGrammarsFqFeatureNames = IterableExtensions.<String>toSet(Iterables.<String>concat(ListExtensions.<Grammar, Iterable<String>>map(GrammarUtil.allUsedGrammars(g), _function)));
            _xblockexpression = Sets.<String>intersection(thisGrammarFqFeatureNames, superGrammarsFqFeatureNames);
        }
        _xifexpression = _xblockexpression;
    } else {
        _xifexpression = CollectionLiterals.<String>emptySet();
    }
    return _xifexpression;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) Sets(com.google.common.collect.Sets) Function1(org.eclipse.xtext.xbase.lib.Functions.Function1) Grammar(org.eclipse.xtext.Grammar)

Example 67 with Function1

use of org.eclipse.xtext.xbase.lib.Functions.Function1 in project xtext-core by eclipse.

the class WizardConfigurationTest method inlinedTestProjectsAddTheirDependenciesToTheMainProject.

@Test
public void inlinedTestProjectsAddTheirDependenciesToTheMainProject() {
    TestProjectDescriptor _testProject = this.config.getRuntimeProject().getTestProject();
    _testProject.setEnabled(true);
    this.config.setSourceLayout(SourceLayout.MAVEN);
    final Consumer<ExternalDependency> _function = (ExternalDependency testDependency) -> {
        final Function1<ExternalDependency, Boolean> _function_1 = (ExternalDependency it) -> {
            return Boolean.valueOf(((Objects.equal(it.getMaven().getArtifactId(), testDependency.getMaven().getArtifactId()) && Objects.equal(it.getP2().getBundleId(), testDependency.getP2().getBundleId())) && Objects.equal(it.getP2().getPackages(), testDependency.getP2().getPackages())));
        };
        Assert.assertTrue(IterableExtensions.<ExternalDependency>exists(this.config.getRuntimeProject().getExternalDependencies(), _function_1));
    };
    this.config.getRuntimeProject().getTestProject().getExternalDependencies().forEach(_function);
}
Also used : ExternalDependency(org.eclipse.xtext.xtext.wizard.ExternalDependency) Function1(org.eclipse.xtext.xbase.lib.Functions.Function1) TestProjectDescriptor(org.eclipse.xtext.xtext.wizard.TestProjectDescriptor) Test(org.junit.Test)

Example 68 with Function1

use of org.eclipse.xtext.xbase.lib.Functions.Function1 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 69 with Function1

use of org.eclipse.xtext.xbase.lib.Functions.Function1 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 70 with Function1

use of org.eclipse.xtext.xbase.lib.Functions.Function1 in project xtext-core by eclipse.

the class AntlrGrammarGenerator method compileParserImports.

@Override
protected String compileParserImports(final Grammar it, final AntlrOptions options) {
    StringConcatenation _builder = new StringConcatenation();
    _builder.newLine();
    _builder.append("import org.eclipse.xtext.*;");
    _builder.newLine();
    _builder.append("import org.eclipse.xtext.parser.*;");
    _builder.newLine();
    _builder.append("import org.eclipse.xtext.parser.impl.*;");
    _builder.newLine();
    _builder.append("import org.eclipse.emf.ecore.util.EcoreUtil;");
    _builder.newLine();
    _builder.append("import org.eclipse.emf.ecore.EObject;");
    _builder.newLine();
    {
        boolean _isEmpty = GrammarUtil.allEnumRules(it).isEmpty();
        boolean _not = (!_isEmpty);
        if (_not) {
            _builder.append("import org.eclipse.emf.common.util.Enumerator;");
            _builder.newLine();
        }
    }
    _builder.append("import ");
    String _name = this.getGrammarNaming().getInternalParserSuperClass(it).getName();
    _builder.append(_name);
    _builder.append(";");
    _builder.newLineIfNotEmpty();
    _builder.append("import org.eclipse.xtext.parser.antlr.XtextTokenStream;");
    _builder.newLine();
    _builder.append("import org.eclipse.xtext.parser.antlr.XtextTokenStream.HiddenTokens;");
    _builder.newLine();
    {
        if (((!IterableExtensions.isEmpty(Iterables.<UnorderedGroup>filter(Iterables.<EObject>concat(ListExtensions.<ParserRule, List<EObject>>map(GrammarUtil.allParserRules(it), ((Function1<ParserRule, List<EObject>>) (ParserRule it_1) -> {
            return EcoreUtil2.eAllContentsAsList(it_1);
        }))), UnorderedGroup.class))) && options.isBacktrack())) {
            _builder.append("import org.eclipse.xtext.parser.antlr.IUnorderedGroupHelper.UnorderedGroupState;");
            _builder.newLine();
        }
    }
    _builder.append("import org.eclipse.xtext.parser.antlr.AntlrDatatypeRuleToken;");
    _builder.newLine();
    _builder.append("import ");
    String _name_1 = this._grammarAccessExtensions.getGrammarAccess(it).getName();
    _builder.append(_name_1);
    _builder.append(";");
    _builder.newLineIfNotEmpty();
    _builder.newLine();
    return _builder.toString();
}
Also used : ParserRule(org.eclipse.xtext.ParserRule) UnorderedGroup(org.eclipse.xtext.UnorderedGroup) EObject(org.eclipse.emf.ecore.EObject) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Function1(org.eclipse.xtext.xbase.lib.Functions.Function1) List(java.util.List)

Aggregations

Function1 (org.eclipse.xtext.xbase.lib.Functions.Function1)131 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)80 Test (org.junit.Test)54 List (java.util.List)20 ArrayList (java.util.ArrayList)19 AbstractXtendCompilerTest (org.eclipse.xtend.core.tests.compiler.AbstractXtendCompilerTest)17 CompilationTestHelper (org.eclipse.xtext.xbase.testing.CompilationTestHelper)17 EList (org.eclipse.emf.common.util.EList)14 EObject (org.eclipse.emf.ecore.EObject)14 ColumnSource (com.robotoworks.mechanoid.db.sqliteModel.ColumnSource)13 Method (java.lang.reflect.Method)12 Set (java.util.Set)10 IMethod (org.eclipse.jdt.core.IMethod)10 CompilationUnitImpl (org.eclipse.xtend.core.macro.declaration.CompilationUnitImpl)9 ScreenListItemCell (org.applause.lang.applauseDsl.ScreenListItemCell)8 XtendClass (org.eclipse.xtend.core.xtend.XtendClass)8 StringConcatenationClient (org.eclipse.xtend2.lib.StringConcatenationClient)8 ColumnType (com.robotoworks.mechanoid.db.sqliteModel.ColumnType)7 URI (org.eclipse.emf.common.util.URI)7 Resource (org.eclipse.emf.ecore.resource.Resource)7