Search in sources :

Example 51 with XtendClass

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

the class AssignmentLinkingTest method testSugaredAssignment_onThis.

@Test
public void testSugaredAssignment_onThis() throws Exception {
    XtendClass clazz = clazz("class SomeClass {\n" + "  def void method() {\n" + "    string = 'foo'\n" + "  }" + "  def setString(String aString) {}\n" + "}");
    XAssignment assignment = getLastAssignment(clazz);
    assertLinksTo("SomeClass.setString(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 52 with XtendClass

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

the class AssignmentLinkingTest method testSugaredAssignment_onThis_withIt.

@Test
public void testSugaredAssignment_onThis_withIt() throws Exception {
    XtendClass clazz = clazz("class SomeClass {\n" + "  def void method(String it) {\n" + "    value = 'foo'\n" + "  }\n" + "  def void setValue(String receiver, String value) {}" + "}");
    XAssignment assignment = getLastAssignment(clazz);
    assertLinksTo("SomeClass.setValue(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 53 with XtendClass

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

the class EObjectLocationTests method testFullLocationInFile.

@Test
public void testFullLocationInFile() throws Exception {
    String model = "class Foo extends Object { def Foo foo() {this }}";
    XtendClass clazz = clazz(model);
    JvmGenericType inferredType = xtendjvmAssociations.getInferredType(clazz);
    assertEquals(locationInFileProvider.getFullTextRegion(clazz), locationInFileProvider.getFullTextRegion(inferredType));
    JvmConstructor inferredConstructor = xtendjvmAssociations.getInferredConstructor(clazz);
    assertEquals(locationInFileProvider.getFullTextRegion(clazz), locationInFileProvider.getFullTextRegion(inferredConstructor));
    XtendFunction xtendFunction = (XtendFunction) clazz.getMembers().get(0);
    JvmOperation inferredOperation = xtendjvmAssociations.getDirectlyInferredOperation(xtendFunction);
    assertEquals(locationInFileProvider.getFullTextRegion(xtendFunction), locationInFileProvider.getFullTextRegion(inferredOperation));
}
Also used : XtendFunction(org.eclipse.xtend.core.xtend.XtendFunction) JvmOperation(org.eclipse.xtext.common.types.JvmOperation) XtendClass(org.eclipse.xtend.core.xtend.XtendClass) JvmGenericType(org.eclipse.xtext.common.types.JvmGenericType) JvmConstructor(org.eclipse.xtext.common.types.JvmConstructor) Test(org.junit.Test)

Example 54 with XtendClass

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

the class InferredJvmModelShadowingJavaLinkingTests method testLinkInferredJvmOperation.

@Test
public void testLinkInferredJvmOperation() throws Exception {
    XtendClass foo = classFile("test/Foo", "package test class Foo { def foo() { this } }");
    XtendClass bar = classFile("test/Bar", "package test class Bar { def bar(Foo foo) {foo.foo()} }");
    final XBlockExpression block = (XBlockExpression) ((XtendFunction) bar.getMembers().get(0)).getExpression();
    XMemberFeatureCall methodCall = (XMemberFeatureCall) block.getExpressions().get(0);
    assertEquals(associations.getDirectlyInferredOperation((XtendFunction) foo.getMembers().get(0)), methodCall.getFeature());
}
Also used : XBlockExpression(org.eclipse.xtext.xbase.XBlockExpression) XtendFunction(org.eclipse.xtend.core.xtend.XtendFunction) XtendClass(org.eclipse.xtend.core.xtend.XtendClass) XMemberFeatureCall(org.eclipse.xtext.xbase.XMemberFeatureCall) Test(org.junit.Test)

Example 55 with XtendClass

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

the class InferredJvmModelShadowingJavaLinkingTests method testLinkInferredJvmClass.

@Test
public void testLinkInferredJvmClass() throws Exception {
    XtendClass foo = classFile("test/Foo", "package test class Foo {}");
    XtendClass bar = classFile("test/Bar", "package test class Bar extends Foo {}");
    assertEquals(associations.getInferredType(foo), bar.getExtends().getType());
}
Also used : XtendClass(org.eclipse.xtend.core.xtend.XtendClass) 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