blob: ef0aa727d8815159bac96b7bfa9961528eed965c [file] [log] [blame]
/**
* Copyright (c) 2011, 2015 - Lunifera GmbH (Gross Enzersdorf, Austria), Loetz GmbH&Co.KG (69115 Heidelberg, Germany)
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Florian Pirchner - Initial implementation
*/
package org.eclipse.osbp.dsl.datatype.xtext.jvmmodel
import com.google.inject.Inject
import org.eclipse.osbp.dsl.semantic.common.types.LEnum
import org.eclipse.osbp.dsl.semantic.common.types.LTypedPackage
import org.eclipse.xtext.naming.IQualifiedNameProvider
import org.eclipse.xtext.xbase.jvmmodel.AbstractModelInferrer
import org.eclipse.xtext.xbase.jvmmodel.IJvmDeclaredTypeAcceptor
import org.eclipse.xtext.xbase.jvmmodel.JvmTypesBuilder
/**
* <p>Infers a JVM model from the source model.</p>
*
* <p>The JVM model should contain all elements that would appear in the Java code
* which is generated from the source model. Other models link against the JVM model rather than the source model.</p>
*/
class DatatypeGrammarJvmModelInferrer extends AbstractModelInferrer {
@Inject extension IQualifiedNameProvider
@Inject extension JvmTypesBuilder;
def dispatch void infer(LEnum enumX, IJvmDeclaredTypeAcceptor acceptor, boolean isPreIndexingPhase) {
val type = enumX.toEnumerationType(enumX.fullyQualifiedName.toString, null)
acceptor.accept(type, [
fileHeader = (enumX.eContainer as LTypedPackage).documentation
documentation = enumX.documentation
for (f : enumX.literals) {
documentation = f.documentation
members += f.toEnumerationLiteral(f.name)
}
])
}
}