use of org.eclipse.xtend.core.xtend.XtendField in project xtext-xtend by eclipse.
the class XtendJvmModelInferrer method initialize.
protected void initialize(XtendInterface source, JvmGenericType inferredJvmType) {
inferredJvmType.setVisibility(source.getVisibility());
inferredJvmType.setStatic(source.isStatic() && !isTopLevel(source));
inferredJvmType.setAbstract(true);
inferredJvmType.setStrictFloatingPoint(source.isStrictFloatingPoint());
translateAnnotationsTo(source.getAnnotations(), inferredJvmType);
for (JvmTypeReference intf : source.getExtends()) {
inferredJvmType.getSuperTypes().add(jvmTypesBuilder.cloneWithProxies(intf));
}
fixTypeParameters(inferredJvmType);
for (XtendMember member : source.getMembers()) {
if (member instanceof XtendField || (member instanceof XtendFunction && ((XtendFunction) member).getName() != null)) {
transform(member, inferredJvmType, false);
}
}
jvmTypesBuilder.copyDocumentationTo(source, inferredJvmType);
nameClashResolver.resolveNameClashes(inferredJvmType);
}
use of org.eclipse.xtend.core.xtend.XtendField in project xtext-xtend by eclipse.
the class XtendJvmModelInferrer method initialize.
protected void initialize(XtendClass source, JvmGenericType inferredJvmType) {
inferredJvmType.setVisibility(source.getVisibility());
boolean isStatic = source.isStatic() && !isTopLevel(source);
if (!isStatic) {
JvmDeclaredType declaringType = inferredJvmType.getDeclaringType();
if (declaringType instanceof JvmGenericType) {
if (((JvmGenericType) declaringType).isInterface())
isStatic = true;
} else if (declaringType instanceof JvmAnnotationType) {
isStatic = true;
}
}
inferredJvmType.setStatic(isStatic);
inferredJvmType.setAbstract(source.isAbstract());
inferredJvmType.setStrictFloatingPoint(source.isStrictFloatingPoint());
if (!inferredJvmType.isAbstract()) {
inferredJvmType.setFinal(source.isFinal());
}
translateAnnotationsTo(source.getAnnotations(), inferredJvmType);
JvmTypeReference extendsClause = source.getExtends();
if (extendsClause == null || extendsClause.getType() == null) {
JvmTypeReference typeRefToObject = typeReferences.getTypeForName(Object.class, source);
if (typeRefToObject != null)
inferredJvmType.getSuperTypes().add(typeRefToObject);
} else {
inferredJvmType.getSuperTypes().add(jvmTypesBuilder.cloneWithProxies(extendsClause));
}
for (JvmTypeReference intf : source.getImplements()) {
inferredJvmType.getSuperTypes().add(jvmTypesBuilder.cloneWithProxies(intf));
}
fixTypeParameters(inferredJvmType);
addDefaultConstructor(source, inferredJvmType);
for (XtendMember member : source.getMembers()) {
if (member instanceof XtendField || (member instanceof XtendFunction && ((XtendFunction) member).getName() != null) || member instanceof XtendConstructor) {
transform(member, inferredJvmType, true);
}
}
appendSyntheticDispatchMethods(source, inferredJvmType);
jvmTypesBuilder.copyDocumentationTo(source, inferredJvmType);
nameClashResolver.resolveNameClashes(inferredJvmType);
}
use of org.eclipse.xtend.core.xtend.XtendField in project xtext-xtend by eclipse.
the class ErrorTest method testErrorModel_011.
@Test
public void testErrorModel_011() throws Exception {
StringConcatenation _builder = new StringConcatenation();
_builder.append("annotation { ");
_builder.newLine();
_builder.append("\t");
_builder.append("val inferred = \'bar\'");
_builder.newLine();
_builder.append("}");
_builder.newLine();
final XtendFile file = this.processWithoutException(_builder);
final XtendTypeDeclaration annotation = IterableExtensions.<XtendTypeDeclaration>last(file.getXtendTypes());
XtendMember _head = IterableExtensions.<XtendMember>head(annotation.getMembers());
final XtendField field = ((XtendField) _head);
final XExpression initializer = field.getInitialValue();
final IResolvedTypes resolvedTypes = this.typeResolver.resolveTypes(initializer);
Assert.assertNotNull(resolvedTypes.getActualType(initializer));
}
use of org.eclipse.xtend.core.xtend.XtendField in project xtext-xtend by eclipse.
the class ErrorTest method testErrorModel_012.
@Test
public void testErrorModel_012() throws Exception {
StringConcatenation _builder = new StringConcatenation();
_builder.append("class Y {");
_builder.newLine();
_builder.append(" ");
_builder.append("static def <T> IExpectationSetters<T> expect(T value) {");
_builder.newLine();
_builder.append(" ");
_builder.append("}");
_builder.newLine();
_builder.append(" ");
_builder.append("HeaderAccess<?> unboundedMockHeaderAccess");
_builder.newLine();
_builder.append(" ");
_builder.append("def test() {");
_builder.newLine();
_builder.append(" ");
_builder.append("val Object header = unboundedMockHeaderAccess.header");
_builder.newLine();
_builder.append(" ");
_builder.append("val IExpectationSettersObject> exp1 = expect(header)");
_builder.newLine();
_builder.append(" ");
_builder.append("val IExpectationSetters<Object> exp2 = expect(unboundedMockHeaderAccess.getHeader())");
_builder.newLine();
_builder.append(" ");
_builder.append("}");
_builder.newLine();
_builder.append("}");
_builder.newLine();
_builder.append("interface HeaderAccess<T> {");
_builder.newLine();
_builder.append(" ");
_builder.append("def T getHeader();");
_builder.newLine();
_builder.append("}");
_builder.newLine();
_builder.append("interface IExpectationSetters<T> {}");
_builder.newLine();
final XtendFile file = this.processWithoutException(_builder);
final XtendTypeDeclaration y = IterableExtensions.<XtendTypeDeclaration>head(file.getXtendTypes());
XtendMember _get = y.getMembers().get(3);
final XtendField exp1 = ((XtendField) _get);
final XExpression initializer = exp1.getInitialValue();
final IResolvedTypes resolvedTypes = this.typeResolver.resolveTypes(initializer);
Assert.assertNotNull(resolvedTypes.getActualType(initializer));
}
use of org.eclipse.xtend.core.xtend.XtendField in project xtext-xtend by eclipse.
the class CustomClassesTest method testFieldInAnnotationDefaults.
@Test
public void testFieldInAnnotationDefaults() {
try {
StringConcatenation _builder = new StringConcatenation();
_builder.append("annotation Foo { int foo }");
XtendMember _get = this.annotationType(_builder.toString()).getMembers().get(0);
final XtendField field = ((XtendField) _get);
Assert.assertTrue(field.isFinal());
Assert.assertTrue(field.isStatic());
Assert.assertEquals(JvmVisibility.PUBLIC, field.getVisibility());
} catch (Throwable _e) {
throw Exceptions.sneakyThrow(_e);
}
}
Aggregations