Search in sources :

Example 11 with AbstractParameterBuilder

use of org.eclipse.xtend.ide.codebuilder.AbstractParameterBuilder in project xtext-xtend by eclipse.

the class MemberFromSuperImplementor method initializeExecutableBuilder.

protected void initializeExecutableBuilder(final AbstractExecutableBuilder builder, final JvmDeclaredType overrider, final IResolvedExecutable overridden) {
    final JvmExecutable executable = overridden.getDeclaration();
    builder.setContext(overrider);
    builder.setVisibility(overridden.getDeclaration().getVisibility());
    final Procedure2<LightweightTypeReference, Integer> _function = (LightweightTypeReference it, Integer index) -> {
        final JvmFormalParameter declaredParameter = executable.getParameters().get((index).intValue());
        final AbstractParameterBuilder parameterBuilder = builder.newParameterBuilder();
        parameterBuilder.setName(declaredParameter.getSimpleName());
        parameterBuilder.setType(it);
        JvmAnnotationReference _findAnnotation = this.annotationLookup.findAnnotation(declaredParameter, Extension.class);
        boolean _tripleNotEquals = (_findAnnotation != null);
        parameterBuilder.setExtensionFlag(_tripleNotEquals);
    };
    IterableExtensions.<LightweightTypeReference>forEach(overridden.getResolvedParameterTypes(), _function);
    builder.setVarArgsFlag(executable.isVarArgs());
    builder.setExceptions(overridden.getResolvedExceptions());
}
Also used : Extension(org.eclipse.xtext.xbase.lib.Extension) JvmExecutable(org.eclipse.xtext.common.types.JvmExecutable) LightweightTypeReference(org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference) JvmFormalParameter(org.eclipse.xtext.common.types.JvmFormalParameter) AbstractParameterBuilder(org.eclipse.xtend.ide.codebuilder.AbstractParameterBuilder) JvmAnnotationReference(org.eclipse.xtext.common.types.JvmAnnotationReference)

Example 12 with AbstractParameterBuilder

use of org.eclipse.xtend.ide.codebuilder.AbstractParameterBuilder in project xtext-xtend by eclipse.

the class ConstructorBuilderTest method testXtendParameterNames.

@Test
public void testXtendParameterNames() {
    AbstractConstructorBuilder _createConstructorBuilder = this._codeBuilderFactory.createConstructorBuilder(this.getXtendClass());
    final Procedure1<AbstractConstructorBuilder> _function = (AbstractConstructorBuilder it) -> {
        it.setContext(this.getXtendClass());
        it.setVisibility(JvmVisibility.PROTECTED);
        AbstractParameterBuilder _newParameterBuilder = it.newParameterBuilder();
        final Procedure1<AbstractParameterBuilder> _function_1 = (AbstractParameterBuilder it_1) -> {
            it_1.setType(this.createTypeRef(this.getXtendClass()));
            it_1.setName("bar");
        };
        ObjectExtensions.<AbstractParameterBuilder>operator_doubleArrow(_newParameterBuilder, _function_1);
        AbstractParameterBuilder _newParameterBuilder_1 = it.newParameterBuilder();
        final Procedure1<AbstractParameterBuilder> _function_2 = (AbstractParameterBuilder it_1) -> {
            it_1.setType(this.createTypeRef(this.getJavaClass()));
            it_1.setName("foo");
        };
        ObjectExtensions.<AbstractParameterBuilder>operator_doubleArrow(_newParameterBuilder_1, _function_2);
    };
    AbstractConstructorBuilder _doubleArrow = ObjectExtensions.<AbstractConstructorBuilder>operator_doubleArrow(_createConstructorBuilder, _function);
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("protected new(Foo bar, Bar foo) {");
    _builder.newLine();
    _builder.append("  ");
    _builder.append(AbstractBuilderTest.DEFAULT_BODY, "  ");
    _builder.newLineIfNotEmpty();
    _builder.append("}");
    this.assertBuilds(_doubleArrow, _builder.toString());
}
Also used : AbstractConstructorBuilder(org.eclipse.xtend.ide.codebuilder.AbstractConstructorBuilder) AbstractParameterBuilder(org.eclipse.xtend.ide.codebuilder.AbstractParameterBuilder) Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) Test(org.junit.Test) AbstractBuilderTest(org.eclipse.xtend.ide.tests.codebuilder.AbstractBuilderTest)

Example 13 with AbstractParameterBuilder

use of org.eclipse.xtend.ide.codebuilder.AbstractParameterBuilder in project xtext-xtend by eclipse.

the class MethodBuilderTest method testJavaNamedParameter.

@Test
public void testJavaNamedParameter() {
    AbstractMethodBuilder _createMethodBuilder = this._codeBuilderFactory.createMethodBuilder(this.getJavaClass());
    final Procedure1<AbstractMethodBuilder> _function = (AbstractMethodBuilder it) -> {
        it.setContext(this.getJavaClass());
        it.setMethodName("foo");
        AbstractParameterBuilder _newParameterBuilder = it.newParameterBuilder();
        final Procedure1<AbstractParameterBuilder> _function_1 = (AbstractParameterBuilder it_1) -> {
            it_1.setName("bar");
            it_1.setType(this.createTypeRef(this.getXtendClass()));
        };
        ObjectExtensions.<AbstractParameterBuilder>operator_doubleArrow(_newParameterBuilder, _function_1);
        AbstractParameterBuilder _newParameterBuilder_1 = it.newParameterBuilder();
        final Procedure1<AbstractParameterBuilder> _function_2 = (AbstractParameterBuilder it_1) -> {
            it_1.setName("baz");
            it_1.setType(this.createTypeRef(this.getXtendClass()));
        };
        ObjectExtensions.<AbstractParameterBuilder>operator_doubleArrow(_newParameterBuilder_1, _function_2);
    };
    AbstractMethodBuilder _doubleArrow = ObjectExtensions.<AbstractMethodBuilder>operator_doubleArrow(_createMethodBuilder, _function);
    StringConcatenation _builder = new StringConcatenation();
    _builder.append("void foo(Foo bar, Foo baz) {");
    _builder.newLine();
    _builder.append("  ");
    _builder.append(AbstractBuilderTest.DEFAULT_BODY, "  ");
    _builder.append(";");
    _builder.newLineIfNotEmpty();
    _builder.append("}");
    this.assertBuilds(_doubleArrow, _builder.toString());
}
Also used : AbstractParameterBuilder(org.eclipse.xtend.ide.codebuilder.AbstractParameterBuilder) Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) AbstractMethodBuilder(org.eclipse.xtend.ide.codebuilder.AbstractMethodBuilder) Test(org.junit.Test) AbstractBuilderTest(org.eclipse.xtend.ide.tests.codebuilder.AbstractBuilderTest)

Aggregations

AbstractParameterBuilder (org.eclipse.xtend.ide.codebuilder.AbstractParameterBuilder)13 AbstractBuilderTest (org.eclipse.xtend.ide.tests.codebuilder.AbstractBuilderTest)11 Test (org.junit.Test)11 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)10 AbstractMethodBuilder (org.eclipse.xtend.ide.codebuilder.AbstractMethodBuilder)7 AbstractConstructorBuilder (org.eclipse.xtend.ide.codebuilder.AbstractConstructorBuilder)4 Procedure1 (org.eclipse.xtext.xbase.lib.Procedures.Procedure1)4 HashSet (java.util.HashSet)1 VariableNameAcceptor (org.eclipse.xtend.ide.codebuilder.VariableNameAcceptor)1 JvmAnnotationReference (org.eclipse.xtext.common.types.JvmAnnotationReference)1 JvmExecutable (org.eclipse.xtext.common.types.JvmExecutable)1 JvmFormalParameter (org.eclipse.xtext.common.types.JvmFormalParameter)1 ISourceAppender (org.eclipse.xtext.xbase.compiler.ISourceAppender)1 ExclusiveRange (org.eclipse.xtext.xbase.lib.ExclusiveRange)1 Extension (org.eclipse.xtext.xbase.lib.Extension)1 LightweightTypeReference (org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference)1