Search in sources :

Example 6 with XAbstractFeatureCall

use of org.eclipse.xtext.xbase.XAbstractFeatureCall in project xtext-xtend by eclipse.

the class LinkingTest method testImplicitFirstArgument_05.

@Test
public void testImplicitFirstArgument_05() throws Exception {
    XtendClass clazz = clazz("import static extension test.ImplicitFirstArgumentStatics.*\n" + "class MyXtendClass {\n" + "  def testExtensionMethods(CharSequence it) {\n" + "    withObject\n" + "  }\n" + "  extension String" + "  def withObject(Object obj) { null }" + "}");
    XtendFunction func = (XtendFunction) clazz.getMembers().get(0);
    XFeatureCall fifth = (XFeatureCall) ((XBlockExpression) func.getExpression()).getExpressions().get(0);
    JvmOperation fifthFeature = (JvmOperation) fifth.getFeature();
    assertEquals("MyXtendClass.withObject(java.lang.Object)", fifthFeature.getIdentifier());
    assertEquals(1, fifthFeature.getParameters().size());
    assertNotNull(fifth.getImplicitFirstArgument());
    assertEquals("it", ((XAbstractFeatureCall) fifth.getImplicitFirstArgument()).getFeature().getSimpleName());
    XFeatureCall fifthReceiver = (XFeatureCall) fifth.getImplicitReceiver();
    assertTrue(fifthReceiver.getFeature() instanceof JvmGenericType);
    assertNull(fifth.getInvalidFeatureIssueCode(), fifth.getInvalidFeatureIssueCode());
}
Also used : XtendFunction(org.eclipse.xtend.core.xtend.XtendFunction) XBlockExpression(org.eclipse.xtext.xbase.XBlockExpression) JvmOperation(org.eclipse.xtext.common.types.JvmOperation) XtendClass(org.eclipse.xtend.core.xtend.XtendClass) XFeatureCall(org.eclipse.xtext.xbase.XFeatureCall) JvmGenericType(org.eclipse.xtext.common.types.JvmGenericType) XAbstractFeatureCall(org.eclipse.xtext.xbase.XAbstractFeatureCall) Test(org.junit.Test)

Example 7 with XAbstractFeatureCall

use of org.eclipse.xtext.xbase.XAbstractFeatureCall in project xtext-xtend by eclipse.

the class LinkingTest method testFeatureScope_3.

@Test
public void testFeatureScope_3() throws Exception {
    XtendFile file = file("import java.lang.String class X { def String foo(String foo) {[String foo|foo]}}");
    XtendClass xClass = ((XtendClass) file.getXtendTypes().get(0));
    XtendFunction func = (XtendFunction) xClass.getMembers().get(0);
    XClosure closure = (XClosure) ((XBlockExpression) func.getExpression()).getExpressions().get(0);
    XAbstractFeatureCall featureCall1 = (XAbstractFeatureCall) (((XBlockExpression) closure.getExpression()).getExpressions().get(0));
    assertEquals(closure.getFormalParameters().get(0), featureCall1.getFeature());
}
Also used : XtendFile(org.eclipse.xtend.core.xtend.XtendFile) XtendFunction(org.eclipse.xtend.core.xtend.XtendFunction) XBlockExpression(org.eclipse.xtext.xbase.XBlockExpression) XtendClass(org.eclipse.xtend.core.xtend.XtendClass) XClosure(org.eclipse.xtext.xbase.XClosure) XAbstractFeatureCall(org.eclipse.xtext.xbase.XAbstractFeatureCall) Test(org.junit.Test)

Example 8 with XAbstractFeatureCall

use of org.eclipse.xtext.xbase.XAbstractFeatureCall in project xtext-xtend by eclipse.

the class LinkingTest method testInstanceOverExtension_04.

@Test
public void testInstanceOverExtension_04() throws Exception {
    XtendClass clazz = clazz("" + "class C {" + "  def m(java.util.List<String> list) {\n" + "    list.get(0)\n" + "  }\n" + "}");
    XAbstractFeatureCall substring = findSingleFeatureCall(clazz);
    assertEquals("java.util.List.get(int)", substring.getFeature().getIdentifier());
}
Also used : XtendClass(org.eclipse.xtend.core.xtend.XtendClass) XAbstractFeatureCall(org.eclipse.xtext.xbase.XAbstractFeatureCall) Test(org.junit.Test)

Example 9 with XAbstractFeatureCall

use of org.eclipse.xtext.xbase.XAbstractFeatureCall in project xtext-xtend by eclipse.

the class LinkingShadowingTest method testField_staticExtension_shadows_sugarOnIt.

@Test
public void testField_staticExtension_shadows_sugarOnIt() throws Exception {
    XtendClass clazz = clazz("import static extension testdata.LinkingStaticType.*\n" + "class SomeClass {\n" + "  def method(testdata.LinkingType it) {\n" + "    fieldOverloadsMethod\n" + "  }\n" + "}");
    XAbstractFeatureCall featureCall = getFirstFeatureCall(clazz);
    assertLinksTo("testdata.LinkingStaticType.fieldOverloadsMethod", featureCall);
}
Also used : XtendClass(org.eclipse.xtend.core.xtend.XtendClass) XAbstractFeatureCall(org.eclipse.xtext.xbase.XAbstractFeatureCall) Test(org.junit.Test)

Example 10 with XAbstractFeatureCall

use of org.eclipse.xtext.xbase.XAbstractFeatureCall in project xtext-xtend by eclipse.

the class LinkingShadowingTest method testField_inherited_shadows_staticallyImported.

@Test
public void testField_inherited_shadows_staticallyImported() throws Exception {
    XtendClass clazz = clazz("import static testdata.LinkingStaticType.*" + "class SomeClass extends testdata.LinkingType {\n" + "  def method() {\n" + "    publicField\n" + "  }\n" + "}");
    XAbstractFeatureCall featureCall = getFirstFeatureCall(clazz);
    assertLinksTo("testdata.LinkingType.publicField", featureCall);
}
Also used : XtendClass(org.eclipse.xtend.core.xtend.XtendClass) XAbstractFeatureCall(org.eclipse.xtext.xbase.XAbstractFeatureCall) Test(org.junit.Test)

Aggregations

XAbstractFeatureCall (org.eclipse.xtext.xbase.XAbstractFeatureCall)122 Test (org.junit.Test)105 XtendClass (org.eclipse.xtend.core.xtend.XtendClass)104 XtendFile (org.eclipse.xtend.core.xtend.XtendFile)42 XtendFunction (org.eclipse.xtend.core.xtend.XtendFunction)23 XBlockExpression (org.eclipse.xtext.xbase.XBlockExpression)21 XExpression (org.eclipse.xtext.xbase.XExpression)17 JvmOperation (org.eclipse.xtext.common.types.JvmOperation)11 JvmIdentifiableElement (org.eclipse.xtext.common.types.JvmIdentifiableElement)9 XtendMember (org.eclipse.xtend.core.xtend.XtendMember)8 XFeatureCall (org.eclipse.xtext.xbase.XFeatureCall)6 EObject (org.eclipse.emf.ecore.EObject)5 XtendTypeDeclaration (org.eclipse.xtend.core.xtend.XtendTypeDeclaration)5 XMemberFeatureCall (org.eclipse.xtext.xbase.XMemberFeatureCall)4 IFeatureLinkingCandidate (org.eclipse.xtext.xbase.typesystem.computation.IFeatureLinkingCandidate)4 Resource (org.eclipse.emf.ecore.resource.Resource)3 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)3 JvmDeclaredType (org.eclipse.xtext.common.types.JvmDeclaredType)3 AbstractDiagnostic (org.eclipse.xtext.diagnostics.AbstractDiagnostic)3 XClosure (org.eclipse.xtext.xbase.XClosure)3