Search in sources :

Example 56 with JvmTypeParameter

use of org.eclipse.xtext.common.types.JvmTypeParameter in project xtext-xtend by eclipse.

the class LinkingTest method testTypeParameterShadowsType_3.

@Test
public void testTypeParameterShadowsType_3() throws Exception {
    final XtendFile file = file("class A {} class B extends A  { def <A> A foo(A x) {x}}");
    final XtendClass xtendClass = ((XtendClass) file.getXtendTypes().get(1));
    final JvmType extendedType = xtendClass.getExtends().getType();
    assertTrue(extendedType instanceof JvmGenericType);
    XtendFunction func = (XtendFunction) xtendClass.getMembers().get(0);
    JvmTypeReference returnType = func.getReturnType();
    JvmTypeParameter typeParamDecl = (JvmTypeParameter) returnType.getType();
    assertEquals("A", typeParamDecl.getIdentifier());
    JvmTypeParameter param = (JvmTypeParameter) func.getParameters().get(0).getParameterType().getType();
    assertSame(typeParamDecl, param);
    assertNotSame(extendedType, param);
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) XtendFunction(org.eclipse.xtend.core.xtend.XtendFunction) XtendClass(org.eclipse.xtend.core.xtend.XtendClass) JvmTypeReference(org.eclipse.xtext.common.types.JvmTypeReference) JvmTypeParameter(org.eclipse.xtext.common.types.JvmTypeParameter) JvmGenericType(org.eclipse.xtext.common.types.JvmGenericType) JvmType(org.eclipse.xtext.common.types.JvmType) Test(org.junit.Test)

Example 57 with JvmTypeParameter

use of org.eclipse.xtext.common.types.JvmTypeParameter in project xtext-xtend by eclipse.

the class RecursionGuardBenchmark method timeTryNextFailsAvg.

public int timeTryNextFailsAvg(int reps) {
    JvmTypeParameter candidate = parameters.get(size / 2);
    int result = 0;
    for (int i = 0; i < reps; i++) {
        if (populatedGuard.tryNext(candidate)) {
            result++;
        }
    }
    return result;
}
Also used : JvmTypeParameter(org.eclipse.xtext.common.types.JvmTypeParameter)

Aggregations

JvmTypeParameter (org.eclipse.xtext.common.types.JvmTypeParameter)57 Test (org.junit.Test)20 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)16 XtendClass (org.eclipse.xtend.core.xtend.XtendClass)14 XtendFunction (org.eclipse.xtend.core.xtend.XtendFunction)13 JvmGenericType (org.eclipse.xtext.common.types.JvmGenericType)12 JvmTypeReference (org.eclipse.xtext.common.types.JvmTypeReference)12 JvmUpperBound (org.eclipse.xtext.common.types.JvmUpperBound)10 Procedure1 (org.eclipse.xtext.xbase.lib.Procedures.Procedure1)8 XtendTypeDeclaration (org.eclipse.xtend.core.xtend.XtendTypeDeclaration)7 JvmOperation (org.eclipse.xtext.common.types.JvmOperation)7 LightweightTypeReference (org.eclipse.xtext.xbase.typesystem.references.LightweightTypeReference)6 List (java.util.List)5 EList (org.eclipse.emf.common.util.EList)5 XtendFile (org.eclipse.xtend.core.xtend.XtendFile)5 EObject (org.eclipse.emf.ecore.EObject)4 JvmDeclaredType (org.eclipse.xtext.common.types.JvmDeclaredType)4 ArrayList (java.util.ArrayList)3 XtendMember (org.eclipse.xtend.core.xtend.XtendMember)3 AbstractMethodBuilder (org.eclipse.xtend.ide.codebuilder.AbstractMethodBuilder)3