All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.eclipse.xtext.purexbase.jvmmodel.PureXbaseJvmModelInferrer.xtend Maven / Gradle / Ivy

There is a newer version: 2.36.0
Show newest version
/*******************************************************************************
 * Copyright (c) 2011, 2016 itemis AG (http://www.itemis.eu) and others.
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License 2.0 which is available at
 * http://www.eclipse.org/legal/epl-2.0.
 *
 * SPDX-License-Identifier: EPL-2.0
 *******************************************************************************/
package org.eclipse.xtext.purexbase.jvmmodel

import com.google.inject.Inject
import org.eclipse.emf.ecore.resource.Resource
import org.eclipse.xtext.purexbase.pureXbase.Model
import org.eclipse.xtext.xbase.jvmmodel.AbstractModelInferrer
import org.eclipse.xtext.xbase.jvmmodel.IJvmDeclaredTypeAcceptor
import org.eclipse.xtext.xbase.jvmmodel.JvmTypesBuilder

/**
 * 

Infers a JVM model from the source model.

* *

The JVM model should contain all elements that would appear in the Java code * which is generated from the source model. * Other Xtend models link against the JVM model rather than the source model. The JVM * model elements should be associated with their source element by means of the * {@link org.eclipse.xtext.xbase.jvmmodel.IJvmModelAssociator}.

*/ class PureXbaseJvmModelInferrer extends AbstractModelInferrer { @Inject extension JvmTypesBuilder def dispatch void infer(Model m, /* @NonNull */ IJvmDeclaredTypeAcceptor acceptor, boolean prelinkingPhase) { val e = m.block acceptor.accept(e.toClass(e.eResource.name)) [ members += e.toMethod("myMethod", inferredType) [ exceptions += typeRef(Throwable) body = e ] ] } def name(Resource res) { val s = res.URI.lastSegment return s.substring(0, s.length - '.xbase'.length) } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy