use of org.eclipse.xtext.common.types.JvmField in project xtext-xtend by eclipse.
the class MutableJvmFieldDeclarationImpl method internalGenericSetConstantValue.
private void internalGenericSetConstantValue(final Object value) {
this.checkMutable();
Preconditions.checkArgument((value != null), "value cannot be null");
JvmField _delegate = this.getDelegate();
_delegate.setConstant(true);
JvmField _delegate_1 = this.getDelegate();
_delegate_1.setFinal(true);
JvmField _delegate_2 = this.getDelegate();
_delegate_2.setStatic(true);
JvmField _delegate_3 = this.getDelegate();
_delegate_3.setConstantValue(value);
}
use of org.eclipse.xtext.common.types.JvmField in project xtext-xtend by eclipse.
the class LinkingTest method testDeclaredConstructor_01.
@Test
public void testDeclaredConstructor_01() throws Exception {
XtendClass clazz = clazz("class Foo { " + " int i" + " new(int i) { this.i = i }" + "}");
assertEquals(2, clazz.getMembers().size());
XtendConstructor constructor = (XtendConstructor) clazz.getMembers().get(1);
XAssignment assignment = (XAssignment) ((XBlockExpression) constructor.getExpression()).getExpressions().get(0);
JvmField field = (JvmField) assignment.getFeature();
assertEquals("i", field.getSimpleName());
XFeatureCall target = (XFeatureCall) assignment.getAssignable();
JvmDeclaredType identifiableElement = (JvmDeclaredType) target.getFeature();
assertEquals("Foo", identifiableElement.getSimpleName());
XFeatureCall value = (XFeatureCall) assignment.getValue();
JvmFormalParameter parameter = (JvmFormalParameter) value.getFeature();
assertEquals("i", parameter.getSimpleName());
}
use of org.eclipse.xtext.common.types.JvmField in project xtext-xtend by eclipse.
the class InferredJvmModelTest method testXtendField_01.
@Test
public void testXtendField_01() throws Exception {
XtendFile xtendFile = file("class Foo { public String publicField protected String protectedField private String privateField }");
JvmGenericType type = getInferredType(xtendFile);
for (JvmField field : type.getDeclaredFields()) {
assertEquals(JvmVisibility.get(field.getSimpleName().replace("Field", "").toUpperCase()), field.getVisibility());
}
}
use of org.eclipse.xtext.common.types.JvmField in project xtext-xtend by eclipse.
the class InferredJvmModelTest method testNameClashWithAnonymousExtension_01.
@Test
public void testNameClashWithAnonymousExtension_01() throws Exception {
XtendFile xtendFile = file("package foo import com.google.inject.Inject class Foo { @Inject extension String @Inject extension String }");
JvmGenericType inferredType = getInferredType(xtendFile);
JvmField extension0 = (JvmField) inferredType.getMembers().get(1);
assertEquals("_string", extension0.getSimpleName());
JvmField extension1 = (JvmField) inferredType.getMembers().get(2);
assertEquals("_string_1", extension1.getSimpleName());
}
use of org.eclipse.xtext.common.types.JvmField in project xtext-xtend by eclipse.
the class InferredJvmModelTest method testFinalFunction.
@Test
public void testFinalFunction() throws Exception {
XtendFile xtendFile = file("final class C { final String s = '' def final void m() {} }");
JvmGenericType inferredType = getInferredType(xtendFile);
assertTrue(inferredType.isFinal());
Iterable<JvmOperation> operations = inferredType.getDeclaredOperations();
JvmOperation operation = operations.iterator().next();
assertTrue(operation.isFinal());
Iterable<JvmField> fields = inferredType.getDeclaredFields();
JvmField field = fields.iterator().next();
assertTrue(field.isFinal());
}
Aggregations