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);
}
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);
}
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));
}
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());
}
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());
}
Aggregations