Search in sources :

Example 46 with XtendClass

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

the class DispatchHelperTest method testSort_01.

@Test
public void testSort_01() throws Exception {
    XtendClass clazz = clazz("class X {\n" + " def dispatch foo(Integer i) {null}" + " def dispatch foo(Boolean i) {null}" + " def dispatch foo(String i) {null}" + "}");
    JvmGenericType type = associations.getInferredType(clazz);
    ListMultimap<DispatchSignature, JvmOperation> multimap = dispatchHelper.getDeclaredOrEnhancedDispatchMethods(type);
    List<JvmOperation> list = multimap.get(new DispatchHelper.DispatchSignature("foo", 1));
    Iterator<JvmOperation> i = list.iterator();
    assertEquals(Integer.class.getName(), i.next().getParameters().get(0).getParameterType().getIdentifier());
    assertEquals(Boolean.class.getName(), i.next().getParameters().get(0).getParameterType().getIdentifier());
    assertEquals(String.class.getName(), i.next().getParameters().get(0).getParameterType().getIdentifier());
}
Also used : JvmOperation(org.eclipse.xtext.common.types.JvmOperation) DispatchSignature(org.eclipse.xtend.core.jvmmodel.DispatchHelper.DispatchSignature) XtendClass(org.eclipse.xtend.core.xtend.XtendClass) JvmGenericType(org.eclipse.xtext.common.types.JvmGenericType) DispatchSignature(org.eclipse.xtend.core.jvmmodel.DispatchHelper.DispatchSignature) DispatchHelper(org.eclipse.xtend.core.jvmmodel.DispatchHelper) Test(org.junit.Test)

Example 47 with XtendClass

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

the class AssignmentLinkingTest method testSugaredAssignment_asExtension.

@Test
public void testSugaredAssignment_asExtension() throws Exception {
    XtendClass clazz = clazz("class SomeClass {\n" + "  def void method(String something) {\n" + "    something.myValue = 'foo'\n" + "  }\n" + "  def void setMyValue(String something, String value) {}" + "}");
    XAssignment assignment = getLastAssignment(clazz);
    assertLinksTo("SomeClass.setMyValue(java.lang.String,java.lang.String)", assignment);
    assertImplicitReceiver("SomeClass", assignment);
}
Also used : XtendClass(org.eclipse.xtend.core.xtend.XtendClass) XAssignment(org.eclipse.xtext.xbase.XAssignment) Test(org.junit.Test)

Example 48 with XtendClass

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

the class AssignmentLinkingTest method testUnqualifiedField_onExtension.

@Test
public void testUnqualifiedField_onExtension() throws Exception {
    XtendClass clazz = clazz("class SomeClass {\n" + "  def void method() {\n" + "    stringField = 'foo'\n" + "  }\n" + "  extension testdata.FieldAccess" + "}");
    XAssignment assignment = getLastAssignment(clazz);
    assertLinksTo("testdata.FieldAccess.stringField", assignment);
    assertImplicitReceiver("SomeClass._fieldAccess", assignment);
}
Also used : XtendClass(org.eclipse.xtend.core.xtend.XtendClass) XAssignment(org.eclipse.xtext.xbase.XAssignment) Test(org.junit.Test)

Example 49 with XtendClass

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

the class AssignmentLinkingTest method testBug447982_05.

@Test
public void testBug447982_05() throws Exception {
    XtendClass clazz = clazz("class C {\n" + "	def m(String it) {\n" + "		x = 1\n" + "	} \n" + "	def x(String s, int x) {}\n" + "	def setX(String s, int x) {}\n" + "}");
    XAssignment assignment = getLastAssignment(clazz);
    assertLinksTo("C.setX(java.lang.String,int)", TypesPackage.Literals.JVM_OPERATION, assignment);
}
Also used : XtendClass(org.eclipse.xtend.core.xtend.XtendClass) XAssignment(org.eclipse.xtext.xbase.XAssignment) Test(org.junit.Test)

Example 50 with XtendClass

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

the class AssignmentLinkingTest method testBug447982_04.

@Test
public void testBug447982_04() throws Exception {
    XtendClass clazz = clazz("class C {\n" + "	def static m() {\n" + "		x = 1\n" + "	} \n" + "	static int x\n" + "	def static setX(int x) {}\n" + "}");
    XAssignment assignment = getLastAssignment(clazz);
    assertLinksTo("C.x", TypesPackage.Literals.JVM_FIELD, assignment);
}
Also used : XtendClass(org.eclipse.xtend.core.xtend.XtendClass) XAssignment(org.eclipse.xtext.xbase.XAssignment) Test(org.junit.Test)

Aggregations

XtendClass (org.eclipse.xtend.core.xtend.XtendClass)1017 Test (org.junit.Test)988 XtendFunction (org.eclipse.xtend.core.xtend.XtendFunction)249 XtendFile (org.eclipse.xtend.core.xtend.XtendFile)229 XBlockExpression (org.eclipse.xtext.xbase.XBlockExpression)169 StringConcatenation (org.eclipse.xtend2.lib.StringConcatenation)129 XAbstractFeatureCall (org.eclipse.xtext.xbase.XAbstractFeatureCall)104 XtendMember (org.eclipse.xtend.core.xtend.XtendMember)101 XMemberFeatureCall (org.eclipse.xtext.xbase.XMemberFeatureCall)74 JvmOperation (org.eclipse.xtext.common.types.JvmOperation)73 JvmIdentifiableElement (org.eclipse.xtext.common.types.JvmIdentifiableElement)63 XExpression (org.eclipse.xtext.xbase.XExpression)62 XFeatureCall (org.eclipse.xtext.xbase.XFeatureCall)62 JvmGenericType (org.eclipse.xtext.common.types.JvmGenericType)56 XtendField (org.eclipse.xtend.core.xtend.XtendField)37 XtendTypeDeclaration (org.eclipse.xtend.core.xtend.XtendTypeDeclaration)36 JvmTypeReference (org.eclipse.xtext.common.types.JvmTypeReference)35 XAssignment (org.eclipse.xtext.xbase.XAssignment)19 EObject (org.eclipse.emf.ecore.EObject)18 RichString (org.eclipse.xtend.core.xtend.RichString)17