Search in sources :

Example 21 with XtendParameter

use of org.eclipse.xtend.core.xtend.XtendParameter in project xtext-xtend by eclipse.

the class XtendCopyQualifiedNameService method toQualifiedName.

protected String toQualifiedName(final XtendFunction it) {
    StringConcatenation _builder = new StringConcatenation();
    String _fullyQualifiedName = this.toFullyQualifiedName(it);
    _builder.append(_fullyQualifiedName);
    _builder.append("(");
    final Function1<XtendParameter, String> _function = (XtendParameter it_1) -> {
        return it_1.getParameterType().getSimpleName();
    };
    CharSequence _qualifiedNames = this.<XtendParameter>toQualifiedNames(it.getParameters(), _function);
    _builder.append(_qualifiedNames);
    _builder.append(")");
    return _builder.toString();
}
Also used : XtendParameter(org.eclipse.xtend.core.xtend.XtendParameter) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation)

Example 22 with XtendParameter

use of org.eclipse.xtend.core.xtend.XtendParameter in project xtext-xtend by eclipse.

the class Bug464760Test method testBug464760.

@Test
public void testBug464760() {
    try {
        StringConcatenation _builder = new StringConcatenation();
        _builder.append("class Foo {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("def void myMethod() {");
        _builder.newLine();
        _builder.append("\t\t");
        _builder.append("\"foo\".myExtension");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("}");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("def void myExtension(/*will be deleted programmatically*/Object notype) {");
        _builder.newLine();
        _builder.append("\t");
        _builder.append("}");
        _builder.newLine();
        _builder.append("}");
        _builder.newLine();
        Resource _resource = this.resourceHelper.resource(_builder);
        final XtextResource resource = ((XtextResource) _resource);
        EObject _rootASTElement = resource.getParseResult().getRootASTElement();
        final XtendFile xtendFile = ((XtendFile) _rootASTElement);
        XtendMember _get = IterableExtensions.<XtendTypeDeclaration>head(xtendFile.getXtendTypes()).getMembers().get(1);
        XtendParameter _head = IterableExtensions.<XtendParameter>head(((XtendFunction) _get).getParameters());
        _head.setParameterType(null);
        final Runnable _function = () -> {
            EcoreUtil.resolveAll(resource);
        };
        final LoggingTester.LogCapture loggings = LoggingTester.captureLogging(Level.ERROR, BatchLinkableResource.class, _function);
        loggings.assertNoLogEntries();
    } catch (Throwable _e) {
        throw Exceptions.sneakyThrow(_e);
    }
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) LoggingTester(org.eclipse.xtext.testing.logging.LoggingTester) XtendParameter(org.eclipse.xtend.core.xtend.XtendParameter) XtendMember(org.eclipse.xtend.core.xtend.XtendMember) EObject(org.eclipse.emf.ecore.EObject) StringConcatenation(org.eclipse.xtend2.lib.StringConcatenation) XtextResource(org.eclipse.xtext.resource.XtextResource) Resource(org.eclipse.emf.ecore.resource.Resource) BatchLinkableResource(org.eclipse.xtext.xbase.resource.BatchLinkableResource) XtendTypeDeclaration(org.eclipse.xtend.core.xtend.XtendTypeDeclaration) XtextResource(org.eclipse.xtext.resource.XtextResource) Test(org.junit.Test)

Example 23 with XtendParameter

use of org.eclipse.xtend.core.xtend.XtendParameter in project xtext-xtend by eclipse.

the class CompilationUnitImpl method toXtendParameterDeclaration.

public XtendParameterDeclarationImpl toXtendParameterDeclaration(final XtendParameter delegate) {
    final Function1<XtendParameter, XtendParameterDeclarationImpl> _function = (XtendParameter it) -> {
        XtendParameterDeclarationImpl _xtendParameterDeclarationImpl = new XtendParameterDeclarationImpl();
        final Procedure1<XtendParameterDeclarationImpl> _function_1 = (XtendParameterDeclarationImpl it_1) -> {
            it_1.setDelegate(delegate);
            it_1.setCompilationUnit(this);
        };
        return ObjectExtensions.<XtendParameterDeclarationImpl>operator_doubleArrow(_xtendParameterDeclarationImpl, _function_1);
    };
    return this.<XtendParameter, XtendParameterDeclarationImpl>getOrCreate(delegate, _function);
}
Also used : XtendParameter(org.eclipse.xtend.core.xtend.XtendParameter) Procedure1(org.eclipse.xtext.xbase.lib.Procedures.Procedure1) XtendParameterDeclarationImpl(org.eclipse.xtend.core.macro.declaration.XtendParameterDeclarationImpl)

Example 24 with XtendParameter

use of org.eclipse.xtend.core.xtend.XtendParameter in project xtext-xtend by eclipse.

the class ParserTest method testExtensionOnMethodParameter_01.

@Test
public void testExtensionOnMethodParameter_01() throws Exception {
    XtendClass clazz = clazz("class Foo { def m(extension Object o) {} }");
    assertEquals(1, clazz.getMembers().size());
    XtendFunction m = (XtendFunction) clazz.getMembers().get(0);
    List<XtendParameter> parameters = m.getParameters();
    assertEquals(1, parameters.size());
    XtendParameter singleParameter = parameters.get(0);
    assertTrue(singleParameter.isExtension());
}
Also used : XtendFunction(org.eclipse.xtend.core.xtend.XtendFunction) XtendParameter(org.eclipse.xtend.core.xtend.XtendParameter) XtendClass(org.eclipse.xtend.core.xtend.XtendClass) Test(org.junit.Test)

Example 25 with XtendParameter

use of org.eclipse.xtend.core.xtend.XtendParameter in project xtext-xtend by eclipse.

the class TypeProviderTest method testBug380063NoException.

@Test
public void testBug380063NoException() throws Exception {
    XtendClass clazz = clazz("class Foo<T> { " + "def foo(java.util.List<? extends T> l) { " + "	l.add(null)" + "}}");
    XtendFunction function = (XtendFunction) clazz.getMembers().get(0);
    XtendParameter xtendParameter = function.getParameters().get(0);
    XBlockExpression expr = (XBlockExpression) function.getExpression();
    XMemberFeatureCall call = (XMemberFeatureCall) expr.getExpressions().get(0);
    LightweightTypeReference type = getType(call.getMemberCallTarget());
    assertEquals("List<? extends T>", type.getSimpleName());
    assertEquals("List<? extends T>", xtendParameter.getParameterType().getSimpleName());
}
Also used : XtendFunction(org.eclipse.xtend.core.xtend.XtendFunction) XBlockExpression(org.eclipse.xtext.xbase.XBlockExpression) XtendParameter(org.eclipse.xtend.core.xtend.XtendParameter) LightweightTypeReference(org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference) XtendClass(org.eclipse.xtend.core.xtend.XtendClass) XMemberFeatureCall(org.eclipse.xtext.xbase.XMemberFeatureCall) Test(org.junit.Test)

Aggregations

XtendParameter (org.eclipse.xtend.core.xtend.XtendParameter)26 XtendFunction (org.eclipse.xtend.core.xtend.XtendFunction)12 Test (org.junit.Test)12 XtendFile (org.eclipse.xtend.core.xtend.XtendFile)11 XtendMember (org.eclipse.xtend.core.xtend.XtendMember)11 XtendClass (org.eclipse.xtend.core.xtend.XtendClass)10 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)9 XtendTypeDeclaration (org.eclipse.xtend.core.xtend.XtendTypeDeclaration)5 XtendAnnotationTarget (org.eclipse.xtend.core.xtend.XtendAnnotationTarget)4 JvmTypeReference (org.eclipse.xtext.common.types.JvmTypeReference)4 EObject (org.eclipse.emf.ecore.EObject)3 XtendField (org.eclipse.xtend.core.xtend.XtendField)3 Declaration (org.eclipse.xtend.lib.macro.declaration.Declaration)3 MutableNamedElement (org.eclipse.xtend.lib.macro.declaration.MutableNamedElement)3 NamedElement (org.eclipse.xtend.lib.macro.declaration.NamedElement)3 JvmOperation (org.eclipse.xtext.common.types.JvmOperation)3 XBlockExpression (org.eclipse.xtext.xbase.XBlockExpression)3 XMemberFeatureCall (org.eclipse.xtext.xbase.XMemberFeatureCall)3 Function1 (org.eclipse.xtext.xbase.lib.Functions.Function1)3 List (java.util.List)2