use of org.eclipse.xtend.core.xtend.XtendEnum in project xtext-xtend by eclipse.
the class JavaConverterTest method testEnumCase.
@Test
public void testEnumCase() throws Exception {
XtendEnum enum_ = this.toValidXtendEnum("public enum MyEnum { NEW,OLD }");
XtendMember _get = enum_.getMembers().get(0);
Assert.assertEquals(JvmVisibility.PUBLIC, ((XtendEnumLiteral) _get).getVisibility());
XtendMember _get_1 = enum_.getMembers().get(1);
Assert.assertEquals(JvmVisibility.PUBLIC, ((XtendEnumLiteral) _get_1).getVisibility());
}
use of org.eclipse.xtend.core.xtend.XtendEnum in project xtext-xtend by eclipse.
the class CompilationUnitImpl method toXtendTypeDeclaration.
public XtendTypeDeclarationImpl<? extends XtendTypeDeclaration> toXtendTypeDeclaration(final XtendTypeDeclaration delegate) {
final Function1<XtendTypeDeclaration, XtendTypeDeclarationImpl<? extends XtendTypeDeclaration>> _function = (XtendTypeDeclaration it) -> {
XtendTypeDeclarationImpl<? extends XtendTypeDeclaration> _switchResult = null;
boolean _matched = false;
if (delegate instanceof XtendClass) {
_matched = true;
XtendClassDeclarationImpl _xtendClassDeclarationImpl = new XtendClassDeclarationImpl();
final Procedure1<XtendClassDeclarationImpl> _function_1 = (XtendClassDeclarationImpl it_1) -> {
it_1.setDelegate(((XtendClass) delegate));
it_1.setCompilationUnit(this);
};
_switchResult = ObjectExtensions.<XtendClassDeclarationImpl>operator_doubleArrow(_xtendClassDeclarationImpl, _function_1);
}
if (!_matched) {
if (delegate instanceof XtendInterface) {
_matched = true;
XtendInterfaceDeclarationImpl _xtendInterfaceDeclarationImpl = new XtendInterfaceDeclarationImpl();
final Procedure1<XtendInterfaceDeclarationImpl> _function_1 = (XtendInterfaceDeclarationImpl it_1) -> {
it_1.setDelegate(((XtendInterface) delegate));
it_1.setCompilationUnit(this);
};
_switchResult = ObjectExtensions.<XtendInterfaceDeclarationImpl>operator_doubleArrow(_xtendInterfaceDeclarationImpl, _function_1);
}
}
if (!_matched) {
if (delegate instanceof XtendAnnotationType) {
_matched = true;
XtendAnnotationTypeDeclarationImpl _xtendAnnotationTypeDeclarationImpl = new XtendAnnotationTypeDeclarationImpl();
final Procedure1<XtendAnnotationTypeDeclarationImpl> _function_1 = (XtendAnnotationTypeDeclarationImpl it_1) -> {
it_1.setDelegate(((XtendAnnotationType) delegate));
it_1.setCompilationUnit(this);
};
_switchResult = ObjectExtensions.<XtendAnnotationTypeDeclarationImpl>operator_doubleArrow(_xtendAnnotationTypeDeclarationImpl, _function_1);
}
}
if (!_matched) {
if (delegate instanceof XtendEnum) {
_matched = true;
XtendEnumerationDeclarationImpl _xtendEnumerationDeclarationImpl = new XtendEnumerationDeclarationImpl();
final Procedure1<XtendEnumerationDeclarationImpl> _function_1 = (XtendEnumerationDeclarationImpl it_1) -> {
it_1.setDelegate(((XtendEnum) delegate));
it_1.setCompilationUnit(this);
};
_switchResult = ObjectExtensions.<XtendEnumerationDeclarationImpl>operator_doubleArrow(_xtendEnumerationDeclarationImpl, _function_1);
}
}
return _switchResult;
};
return this.<XtendTypeDeclaration, XtendTypeDeclarationImpl<? extends XtendTypeDeclaration>>getOrCreate(delegate, _function);
}
use of org.eclipse.xtend.core.xtend.XtendEnum in project xtext-xtend by eclipse.
the class InferredJvmModelTest method test_bug475337.
@Test
public void test_bug475337() throws Exception {
Resource content = file("enum Foo { bar, ,baz }", false, false).eResource();
XtendEnum xtendEnumType = (XtendEnum) ((XtendFile) content.getContents().get(0)).getXtendTypes().get(0);
assertEquals(3, xtendEnumType.getMembers().size());
assertNull(((XtendEnumLiteral) xtendEnumType.getMembers().get(1)).getName());
// check jvm model
JvmEnumerationType enumType = (JvmEnumerationType) content.getContents().get(1);
assertEquals(2, enumType.getLiterals().size());
assertEquals("bar", enumType.getLiterals().get(0).getSimpleName());
assertEquals("baz", enumType.getLiterals().get(1).getSimpleName());
}
Aggregations