Search in sources :

Example 76 with Procedure1

use of org.eclipse.xtext.xbase.lib.Procedures.Procedure1 in project xtext-core by eclipse.

the class ContentAssistFragment2 method generateGenJavaProposalProvider.

protected GeneratedJavaFileAccess generateGenJavaProposalProvider() {
    GeneratedJavaFileAccess _xblockexpression = null;
    {
        final Set<String> excludedFqnFeatureNames = this.getFQFeatureNamesToExclude(this.getGrammar());
        final HashSet<String> processedNames = CollectionLiterals.<String>newHashSet();
        final Function2<ArrayList<Assignment>, Assignment, ArrayList<Assignment>> _function = (ArrayList<Assignment> candidates, Assignment assignment) -> {
            ArrayList<Assignment> _xblockexpression_1 = null;
            {
                final String fqFeatureName = this.getFQFeatureName(assignment);
                if (((!processedNames.contains(fqFeatureName)) && (!excludedFqnFeatureNames.contains(fqFeatureName)))) {
                    processedNames.add(fqFeatureName);
                    candidates.add(assignment);
                }
                _xblockexpression_1 = candidates;
            }
            return _xblockexpression_1;
        };
        final ArrayList<Assignment> assignments = IterableExtensions.<Assignment, ArrayList<Assignment>>fold(GrammarUtil.containedAssignments(this.getGrammar()), CollectionLiterals.<Assignment>newArrayList(), _function);
        final Function2<ArrayList<AbstractRule>, AbstractRule, ArrayList<AbstractRule>> _function_1 = (ArrayList<AbstractRule> candidates, AbstractRule rule) -> {
            ArrayList<AbstractRule> _xblockexpression_1 = null;
            {
                final String fqnFeatureName = this.getFQFeatureName(rule);
                if (((!processedNames.contains(fqnFeatureName)) && (!excludedFqnFeatureNames.contains(fqnFeatureName)))) {
                    processedNames.add(fqnFeatureName);
                    candidates.add(rule);
                }
                _xblockexpression_1 = candidates;
            }
            return _xblockexpression_1;
        };
        final ArrayList<AbstractRule> remainingRules = IterableExtensions.<AbstractRule, ArrayList<AbstractRule>>fold(this.getGrammar().getRules(), CollectionLiterals.<AbstractRule>newArrayList(), _function_1);
        TypeReference _xifexpression = null;
        boolean _isGenerateStub = this.isGenerateStub();
        if (_isGenerateStub) {
            _xifexpression = this.getGenProposalProviderClass(this.getGrammar());
        } else {
            _xifexpression = this.getProposalProviderClass(this.getGrammar());
        }
        final TypeReference genClass = _xifexpression;
        GeneratedJavaFileAccess _createGeneratedJavaFile = this.fileAccessFactory.createGeneratedJavaFile(genClass);
        final Procedure1<GeneratedJavaFileAccess> _function_2 = (GeneratedJavaFileAccess it) -> {
            final TypeReference superClass = this.getGenProposalProviderSuperClass(this.getGrammar());
            StringConcatenationClient _client = new StringConcatenationClient() {

                @Override
                protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
                    _builder.append("/**");
                    _builder.newLine();
                    _builder.append(" ");
                    _builder.append("* Represents a generated, default implementation of superclass {@link ");
                    _builder.append(superClass, " ");
                    _builder.append("}.");
                    _builder.newLineIfNotEmpty();
                    _builder.append(" ");
                    _builder.append("* Methods are dynamically dispatched on the first parameter, i.e., you can override them ");
                    _builder.newLine();
                    _builder.append(" ");
                    _builder.append("* with a more concrete subtype. ");
                    _builder.newLine();
                    _builder.append(" ");
                    _builder.append("*/");
                    _builder.newLine();
                }
            };
            it.setTypeComment(_client);
            StringConcatenationClient _client_1 = new StringConcatenationClient() {

                @Override
                protected void appendTo(StringConcatenationClient.TargetStringConcatenation _builder) {
                    _builder.append("public ");
                    {
                        boolean _isGenerateStub = ContentAssistFragment2.this.isGenerateStub();
                        if (_isGenerateStub) {
                            _builder.append("abstract ");
                        }
                    }
                    _builder.append("class ");
                    String _simpleName = genClass.getSimpleName();
                    _builder.append(_simpleName);
                    _builder.append(" extends ");
                    _builder.append(superClass);
                    _builder.append(" {");
                    _builder.newLineIfNotEmpty();
                    _builder.newLine();
                    {
                        boolean _isEmpty = assignments.isEmpty();
                        boolean _not = (!_isEmpty);
                        if (_not) {
                            {
                                for (final Assignment assignment : assignments) {
                                    _builder.append("\t");
                                    StringConcatenationClient _handleAssignment = ContentAssistFragment2.this.handleAssignment(assignment);
                                    _builder.append(_handleAssignment, "\t");
                                    _builder.newLineIfNotEmpty();
                                }
                            }
                            _builder.newLine();
                        }
                    }
                    {
                        for (final AbstractRule rule : remainingRules) {
                            _builder.append("\t");
                            _builder.append("public void complete");
                            String _fQFeatureName = ContentAssistFragment2.this.getFQFeatureName(rule);
                            _builder.append(_fQFeatureName, "\t");
                            _builder.append("(");
                            _builder.append(EObject.class, "\t");
                            _builder.append(" model, ");
                            _builder.append(RuleCall.class, "\t");
                            _builder.append(" ruleCall, ");
                            TypeReference _contentAssistContextClass = ContentAssistFragment2.this.getContentAssistContextClass();
                            _builder.append(_contentAssistContextClass, "\t");
                            _builder.append(" context, ");
                            TypeReference _iCompletionProposalAcceptorClass = ContentAssistFragment2.this.getICompletionProposalAcceptorClass();
                            _builder.append(_iCompletionProposalAcceptorClass, "\t");
                            _builder.append(" acceptor) {");
                            _builder.newLineIfNotEmpty();
                            _builder.append("\t");
                            _builder.append("\t");
                            _builder.append("// subclasses may override");
                            _builder.newLine();
                            _builder.append("\t");
                            _builder.append("}");
                            _builder.newLine();
                        }
                    }
                    _builder.append("}");
                    _builder.newLine();
                }
            };
            it.setContent(_client_1);
            it.writeTo(this.getProjectConfig().getEclipsePlugin().getSrcGen());
        };
        _xblockexpression = ObjectExtensions.<GeneratedJavaFileAccess>operator_doubleArrow(_createGeneratedJavaFile, _function_2);
    }
    return _xblockexpression;
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) StringConcatenationClient(org.eclipse.xtend2.lib.StringConcatenationClient) ArrayList(java.util.ArrayList) Function2(org.eclipse.xtext.xbase.lib.Functions.Function2) RuleCall(org.eclipse.xtext.RuleCall) Assignment(org.eclipse.xtext.Assignment) Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1) EObject(org.eclipse.emf.ecore.EObject) GeneratedJavaFileAccess(org.eclipse.xtext.xtext.generator.model.GeneratedJavaFileAccess) TypeReference(org.eclipse.xtext.xtext.generator.model.TypeReference) AbstractRule(org.eclipse.xtext.AbstractRule) HashSet(java.util.HashSet)

Example 77 with Procedure1

use of org.eclipse.xtext.xbase.lib.Procedures.Procedure1 in project xtext-core by eclipse.

the class XtextGeneratorStandaloneSetup method setup.

private void setup() {
    final StandaloneSetup delegate = new StandaloneSetup();
    delegate.setScanClassPath(this.scanClasspath);
    final Consumer<Pair<String, String>> _function = (Pair<String, String> mapping) -> {
        ProjectMapping _projectMapping = new ProjectMapping();
        final Procedure1<ProjectMapping> _function_1 = (ProjectMapping it) -> {
            it.setProjectName(mapping.getKey());
            it.setPath(mapping.getValue());
        };
        ProjectMapping _doubleArrow = ObjectExtensions.<ProjectMapping>operator_doubleArrow(_projectMapping, _function_1);
        delegate.addProjectMapping(_doubleArrow);
    };
    this.getProjectMappings().forEach(_function);
}
Also used : Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1) StandaloneSetup(org.eclipse.emf.mwe.utils.StandaloneSetup) ProjectMapping(org.eclipse.emf.mwe.utils.ProjectMapping) Pair(org.eclipse.xtext.xbase.lib.Pair)

Example 78 with Procedure1

use of org.eclipse.xtext.xbase.lib.Procedures.Procedure1 in project xtext-core by eclipse.

the class UiProjectDescriptor method getExternalDependencies.

@Override
public Set<ExternalDependency> getExternalDependencies() {
    LinkedHashSet<ExternalDependency> _xblockexpression = null;
    {
        final LinkedHashSet<ExternalDependency> deps = CollectionLiterals.<ExternalDependency>newLinkedHashSet();
        Set<ExternalDependency> _externalDependencies = super.getExternalDependencies();
        Iterables.<ExternalDependency>addAll(deps, _externalDependencies);
        ExternalDependency _createXtextDependency = ExternalDependency.createXtextDependency("org.eclipse.xtext.ui");
        deps.add(_createXtextDependency);
        ExternalDependency _createXtextDependency_1 = ExternalDependency.createXtextDependency("org.eclipse.xtext.ui.shared");
        deps.add(_createXtextDependency_1);
        ExternalDependency _createXtextDependency_2 = ExternalDependency.createXtextDependency("org.eclipse.xtext.ui.codetemplates.ui");
        deps.add(_createXtextDependency_2);
        ExternalDependency _externalDependency = new ExternalDependency();
        final Procedure1<ExternalDependency> _function = (ExternalDependency it) -> {
            final Procedure1<ExternalDependency.P2Coordinates> _function_1 = (ExternalDependency.P2Coordinates it_1) -> {
                it_1.setBundleId("org.eclipse.ui.editors");
                it_1.setVersion("3.5.0");
            };
            it.p2(_function_1);
        };
        ExternalDependency _doubleArrow = ObjectExtensions.<ExternalDependency>operator_doubleArrow(_externalDependency, _function);
        deps.add(_doubleArrow);
        ExternalDependency _externalDependency_1 = new ExternalDependency();
        final Procedure1<ExternalDependency> _function_1 = (ExternalDependency it) -> {
            final Procedure1<ExternalDependency.P2Coordinates> _function_2 = (ExternalDependency.P2Coordinates it_1) -> {
                it_1.setBundleId("org.eclipse.ui.ide");
                it_1.setVersion("3.5.0");
            };
            it.p2(_function_2);
        };
        ExternalDependency _doubleArrow_1 = ObjectExtensions.<ExternalDependency>operator_doubleArrow(_externalDependency_1, _function_1);
        deps.add(_doubleArrow_1);
        boolean _isEnabled = this.getConfig().getIdeProject().isEnabled();
        boolean _not = (!_isEnabled);
        if (_not) {
            Set<ExternalDependency> _externalDependencies_1 = this.getConfig().getIdeProject().getExternalDependencies();
            Iterables.<ExternalDependency>addAll(deps, _externalDependencies_1);
        }
        _xblockexpression = deps;
    }
    return _xblockexpression;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ExternalDependency(org.eclipse.xtext.xtext.wizard.ExternalDependency) Set(java.util.Set) LinkedHashSet(java.util.LinkedHashSet) Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1)

Example 79 with Procedure1

use of org.eclipse.xtext.xbase.lib.Procedures.Procedure1 in project xtext-core by eclipse.

the class DefaultTaskTagProvider method getTaskTags.

@Override
public TaskTags getTaskTags(final Resource resouce) {
    TaskTags _taskTags = new TaskTags();
    final Procedure1<TaskTags> _function = (TaskTags it) -> {
        it.setCaseSensitive(true);
        List<TaskTag> _taskTags_1 = it.getTaskTags();
        TaskTag _taskTag = new TaskTag();
        final Procedure1<TaskTag> _function_1 = (TaskTag it_1) -> {
            it_1.setName("TODO");
            it_1.setPriority(Priority.NORMAL);
        };
        TaskTag _doubleArrow = ObjectExtensions.<TaskTag>operator_doubleArrow(_taskTag, _function_1);
        TaskTag _taskTag_1 = new TaskTag();
        final Procedure1<TaskTag> _function_2 = (TaskTag it_1) -> {
            it_1.setName("FIXME");
            it_1.setPriority(Priority.HIGH);
        };
        TaskTag _doubleArrow_1 = ObjectExtensions.<TaskTag>operator_doubleArrow(_taskTag_1, _function_2);
        TaskTag _taskTag_2 = new TaskTag();
        final Procedure1<TaskTag> _function_3 = (TaskTag it_1) -> {
            it_1.setName("XXX");
            it_1.setPriority(Priority.NORMAL);
        };
        TaskTag _doubleArrow_2 = ObjectExtensions.<TaskTag>operator_doubleArrow(_taskTag_2, _function_3);
        Iterables.<TaskTag>addAll(_taskTags_1, Collections.<TaskTag>unmodifiableList(CollectionLiterals.<TaskTag>newArrayList(_doubleArrow, _doubleArrow_1, _doubleArrow_2)));
    };
    return ObjectExtensions.<TaskTags>operator_doubleArrow(_taskTags, _function);
}
Also used : TaskTag(org.eclipse.xtext.tasks.TaskTag) Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1) TaskTags(org.eclipse.xtext.tasks.TaskTags) List(java.util.List)

Example 80 with Procedure1

use of org.eclipse.xtext.xbase.lib.Procedures.Procedure1 in project xtext-core by eclipse.

the class PreferenceTaskTagProvider method getTaskTags.

@Override
public TaskTags getTaskTags(final Resource resource) {
    TaskTags _xblockexpression = null;
    {
        final IPreferenceValues prefs = this.preferenceValuesProvider.getPreferenceValues(resource);
        final String names = prefs.getPreference(PreferenceTaskTagProvider.TAGS_KEY);
        final String priorities = prefs.getPreference(PreferenceTaskTagProvider.PRIORITIES_KEY);
        TaskTags _taskTags = new TaskTags();
        final Procedure1<TaskTags> _function = (TaskTags it) -> {
            it.setCaseSensitive((Boolean.valueOf(prefs.getPreference(PreferenceTaskTagProvider.CASE_SENSITIVE_KEY))).booleanValue());
            List<TaskTag> _taskTags_1 = it.getTaskTags();
            List<TaskTag> _parseTags = PreferenceTaskTagProvider.parseTags(names, priorities);
            Iterables.<TaskTag>addAll(_taskTags_1, _parseTags);
        };
        _xblockexpression = ObjectExtensions.<TaskTags>operator_doubleArrow(_taskTags, _function);
    }
    return _xblockexpression;
}
Also used : TaskTag(org.eclipse.xtext.tasks.TaskTag) IPreferenceValues(org.eclipse.xtext.preferences.IPreferenceValues) Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1) TaskTags(org.eclipse.xtext.tasks.TaskTags)

Aggregations

Procedure1 (org.eclipse.xtext.xbase.lib.Procedures.Procedure1)173 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)99 Test (org.junit.Test)98 IHiddenRegionFormatter (org.eclipse.xtext.formatting2.IHiddenRegionFormatter)28 IFormattableDocument (org.eclipse.xtext.formatting2.IFormattableDocument)20 GenericFormatter (org.eclipse.xtext.formatting2.internal.GenericFormatter)20 ITextRegionExtensions (org.eclipse.xtext.formatting2.regionaccess.ITextRegionExtensions)20 GenericFormatterTestRequest (org.eclipse.xtext.formatting2.internal.GenericFormatterTestRequest)18 AbstractXtendCompilerTest (org.eclipse.xtend.core.tests.compiler.AbstractXtendCompilerTest)16 CompilationTestHelper (org.eclipse.xtext.xbase.testing.CompilationTestHelper)16 EList (org.eclipse.emf.common.util.EList)14 IChangeSerializer (org.eclipse.xtext.ide.serializer.IChangeSerializer)14 MapBasedPreferenceValues (org.eclipse.xtext.preferences.MapBasedPreferenceValues)14 IDList (org.eclipse.xtext.formatting2.internal.formattertestlanguage.IDList)13 EObject (org.eclipse.emf.ecore.EObject)11 Method (java.lang.reflect.Method)10 AbstractBuilderTest (org.eclipse.xtend.ide.tests.codebuilder.AbstractBuilderTest)10 ITextRegionAccess (org.eclipse.xtext.formatting2.regionaccess.ITextRegionAccess)10 MandatoryValue (org.eclipse.xtext.ide.tests.testlanguage.partialSerializationTestLanguage.MandatoryValue)10 Field (java.lang.reflect.Field)9