本文整理汇总了Java中org.eclipse.emf.codegen.ecore.genmodel.GenPackage类的典型用法代码示例。如果您正苦于以下问题:Java GenPackage类的具体用法?Java GenPackage怎么用?Java GenPackage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GenPackage类属于org.eclipse.emf.codegen.ecore.genmodel包,在下文中一共展示了GenPackage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadReferencedGenModels
import org.eclipse.emf.codegen.ecore.genmodel.GenPackage; //导入依赖的package包/类
/**
* Use {@link GenModelAccess#getGenPackage(EPackage)}
*/
@Deprecated
protected List<GenPackage> loadReferencedGenModels(ResourceSet rs) {
List<GenPackage> result = Lists.newArrayList();
if (getReferencedGenModels() != null) {
for (String uri : getReferencedGenModels().split(",")) {
try {
Resource resource = rs.getResource(URI.createURI(uri.trim()), true);
GenModel genmodel = (GenModel) resource.getContents().get(0);
EList<GenPackage> genPackages = genmodel.getGenPackages();
for (GenPackage genPackage : genPackages) {
genPackage.getEcorePackage().getEClassifiers();
result.add(genPackage);
}
} catch (Exception e) {
log.error("Couldn't find genmodel for uri '" + uri + "'");
throw new WrappedException(e);
}
}
}
return result;
}
示例2: findEPackagesInGenPackages
import org.eclipse.emf.codegen.ecore.genmodel.GenPackage; //导入依赖的package包/类
private Map<String, EPackage> findEPackagesInGenPackages(Set<String> packageNsURIs, ResourceSet resourceSet) {
Map<String, EPackage> result = Maps.newHashMap();
for(String nsURI: packageNsURIs) {
Resource resource = GenModelAccess.getGenModelResource(null, nsURI, resourceSet);
if (resource != null) {
for(EObject content: resource.getContents()) {
if (content instanceof GenModel) {
GenModel loadedGenModel = (GenModel) content;
GenPackage genPackage = findGenPackageByNsURI(loadedGenModel, nsURI);
result.put(nsURI, genPackage.getEcorePackage());
break;
}
}
}
}
return result;
}
示例3: getGenPackagesForPackages
import org.eclipse.emf.codegen.ecore.genmodel.GenPackage; //导入依赖的package包/类
/**
* @since 2.0
*/
protected List<GenPackage> getGenPackagesForPackages(GenModel existingGenModel, Collection<EPackage> packs) {
List<GenPackage> result = Lists.newArrayList();
for (EPackage pkg : packs) {
boolean found = false;
for (GenPackage gp : existingGenModel.getGenPackages())
if (gp.getEcorePackage() != null && gp.getEcorePackage().getNsURI() != null
&& gp.getEcorePackage().getNsURI().equals(pkg.getNsURI()))
found = true;
if (!found)
result.add(GenModelAccess.getGenPackage(pkg, existingGenModel.eResource().getResourceSet()));
}
Collections.sort(result, new Comparator<GenPackage>() {
@Override
public int compare(GenPackage o1, GenPackage o2) {
return EcoreUtil.getURI(o1).toString().compareTo(EcoreUtil.getURI(o2).toString());
}
});
return result;
}
示例4: getSaveAndReconcileGenModel
import org.eclipse.emf.codegen.ecore.genmodel.GenPackage; //导入依赖的package包/类
/**
* @since 2.0
*/
protected GenModel getSaveAndReconcileGenModel(ResourceSet rs, Grammar grammar, XpandExecutionContext ctx,
List<EPackage> packs) throws ConfigurationException {
GenModel genModel = getGenModel(rs, grammar, ctx, packs);
genModel.initialize(packs);
for (GenPackage genPackage : genModel.getGenPackages()) {
genPackage.setBasePackage(getBasePackage(grammar));
if (isSuppressLoadInitialization()) {
genPackage.setLoadInitialization(false);
}
if (getFileExtensions() != null && packs.contains(genPackage.getEcorePackage())) {
genPackage.setFileExtensions(getFileExtensions());
}
}
Set<EPackage> referencedEPackages = getReferencedEPackages(packs);
List<GenPackage> usedGenPackages = getGenPackagesForPackages(genModel, referencedEPackages);
reconcileMissingGenPackagesInUsedModels(usedGenPackages);
genModel.getUsedGenPackages().addAll(usedGenPackages);
try {
saveResource(genModel.eResource());
} catch (IOException e) {
throw new WrappedException(e);
}
new GenModelHelper().registerGenModel(genModel);
return genModel;
}
示例5: getGuiceBindingsRt
import org.eclipse.emf.codegen.ecore.genmodel.GenPackage; //导入依赖的package包/类
/**
* @since 2.11
*/
@Override
public Set<Binding> getGuiceBindingsRt(Grammar grammar) {
if (isBindEPackageAndEFactory()) {
BindFactory bindFactory = new BindFactory();
// Register generated EPackage and EFactory instances in the runtime module
for (EPackage pkg: getGeneratedEPackages(grammar)) {
GenPackage genPkg = GenModelUtil2.getGenPackage(pkg, grammar.eResource().getResourceSet());
bindFactory
.addTypeToInstance(genPkg.getQualifiedPackageInterfaceName(), genPkg.getQualifiedPackageInterfaceName()+".eINSTANCE")
.addTypeToInstance(genPkg.getQualifiedFactoryInterfaceName(), genPkg.getQualifiedFactoryInterfaceName()+".eINSTANCE");
}
return bindFactory.getBindings();
} else {
return Collections.emptySet();
}
}
示例6: getGenPackage
import org.eclipse.emf.codegen.ecore.genmodel.GenPackage; //导入依赖的package包/类
public static GenPackage getGenPackage(EPackage pkg, ResourceSet resourceSet) {
String nsURI = pkg.getNsURI();
String location = null;
if (pkg.eResource() != null && pkg.eResource().getURI() != null)
location = pkg.eResource().getURI().toString();
Resource genModelResource = getGenModelResource(location, nsURI, resourceSet);
if (genModelResource != null) {
for (EObject model : genModelResource.getContents()) {
if (model instanceof GenModel) {
GenPackage genPkg = ((GenModel) model).findGenPackage(pkg);
if (genPkg != null) {
genPkg.getEcorePackage().getEClassifiers();
return genPkg;
}
}
}
throw new RuntimeException("No GenPackage for NsURI " + nsURI + " found in " + genModelResource.getURI());
}
throw new RuntimeException("No GenPackage for NsURI " + nsURI + ".");
}
示例7: getQualifiedName
import org.eclipse.emf.codegen.ecore.genmodel.GenPackage; //导入依赖的package包/类
private static TypeReference.QualifiedClassName getQualifiedName(final EPackage epackage, final ResourceSet resourceSet) {
TypeReference.QualifiedClassName _xblockexpression = null;
{
final GenPackage genPackage = GenModelUtil2.getGenPackage(epackage, resourceSet);
String _xifexpression = null;
boolean _isSuppressEMFMetaData = genPackage.getGenModel().isSuppressEMFMetaData();
if (_isSuppressEMFMetaData) {
_xifexpression = genPackage.getQualifiedPackageClassName();
} else {
_xifexpression = genPackage.getReflectionPackageName();
}
final String packageName = _xifexpression;
String _packageInterfaceName = genPackage.getPackageInterfaceName();
_xblockexpression = new TypeReference.QualifiedClassName(packageName, _packageInterfaceName);
}
return _xblockexpression;
}
示例8: findEPackagesInGenPackages
import org.eclipse.emf.codegen.ecore.genmodel.GenPackage; //导入依赖的package包/类
private Map<String, EPackage> findEPackagesInGenPackages(final Collection<String> packageNsURIs, final ResourceSet resourceSet) {
final HashMap<String, EPackage> result = CollectionLiterals.<String, EPackage>newHashMap();
for (final String nsURI : packageNsURIs) {
{
final Resource resource = GenModelUtil2.getGenModelResource(null, nsURI, resourceSet);
if ((resource != null)) {
final GenModel loadedGenModel = IterableExtensions.<GenModel>head(Iterables.<GenModel>filter(resource.getContents(), GenModel.class));
if ((loadedGenModel != null)) {
final GenPackage genPackage = this.findGenPackageByNsURI(loadedGenModel, nsURI);
result.put(nsURI, genPackage.getEcorePackage());
}
}
}
}
return result;
}
示例9: getSaveAndReconcileGenModel
import org.eclipse.emf.codegen.ecore.genmodel.GenPackage; //导入依赖的package包/类
protected GenModel getSaveAndReconcileGenModel(final Grammar grammar, final List<EPackage> packs, final ResourceSet rs) {
final GenModel genModel = this.getGenModel(rs, grammar);
genModel.initialize(packs);
EList<GenPackage> _genPackages = genModel.getGenPackages();
for (final GenPackage genPackage : _genPackages) {
{
genPackage.setBasePackage(this.getBasePackage(grammar));
if (this.suppressLoadInitialization) {
genPackage.setLoadInitialization(false);
}
if (((!this.getLanguage().getFileExtensions().isEmpty()) && packs.contains(genPackage.getEcorePackage()))) {
genPackage.setFileExtensions(IterableExtensions.join(this.getLanguage().getFileExtensions(), ","));
}
}
}
final Set<EPackage> referencedEPackages = this.getReferencedEPackages(packs);
final List<GenPackage> usedGenPackages = this.getGenPackagesForPackages(genModel, referencedEPackages);
this.reconcileMissingGenPackagesInUsedModels(usedGenPackages);
genModel.getUsedGenPackages().addAll(usedGenPackages);
this.saveResource(genModel.eResource());
new GenModelHelper().registerGenModel(genModel);
return genModel;
}
示例10: getGenPackagesForPackages
import org.eclipse.emf.codegen.ecore.genmodel.GenPackage; //导入依赖的package包/类
protected List<GenPackage> getGenPackagesForPackages(final GenModel existingGenModel, final Collection<EPackage> packs) {
final ArrayList<GenPackage> result = CollectionLiterals.<GenPackage>newArrayList();
for (final EPackage pkg : packs) {
final Function1<GenPackage, Boolean> _function = (GenPackage it) -> {
EPackage _ecorePackage = it.getEcorePackage();
String _nsURI = null;
if (_ecorePackage!=null) {
_nsURI=_ecorePackage.getNsURI();
}
String _nsURI_1 = pkg.getNsURI();
return Boolean.valueOf(Objects.equal(_nsURI, _nsURI_1));
};
boolean _exists = IterableExtensions.<GenPackage>exists(existingGenModel.getGenPackages(), _function);
boolean _not = (!_exists);
if (_not) {
result.add(GenModelUtil2.getGenPackage(pkg, existingGenModel.eResource().getResourceSet()));
}
}
final Comparator<GenPackage> _function_1 = (GenPackage o1, GenPackage o2) -> {
return EcoreUtil.getURI(o1).toString().compareTo(EcoreUtil.getURI(o2).toString());
};
Collections.<GenPackage>sort(result, _function_1);
return result;
}
示例11: getGenClassifier
import org.eclipse.emf.codegen.ecore.genmodel.GenPackage; //导入依赖的package包/类
public static GenClassifier getGenClassifier(final EClassifier cls, final ResourceSet resourceSet) {
final GenPackage genPackage = GenModelUtil2.getGenPackage(cls.getEPackage(), resourceSet);
EList<GenClassifier> _genClassifiers = genPackage.getGenClassifiers();
for (final GenClassifier genCls : _genClassifiers) {
String _name = cls.getName();
String _name_1 = genCls.getEcoreClassifier().getName();
boolean _equals = Objects.equal(_name, _name_1);
if (_equals) {
return genCls;
}
}
StringConcatenation _builder = new StringConcatenation();
_builder.append("No GenClassifier named \'");
String _name_2 = cls.getName();
_builder.append(_name_2);
_builder.append("\' found in GenModel ");
URI _uRI = genPackage.eResource().getURI();
_builder.append(_uRI);
throw new RuntimeException(_builder.toString());
}
示例12: getQualifiedPackageInterfaceName
import org.eclipse.emf.codegen.ecore.genmodel.GenPackage; //导入依赖的package包/类
/**
* Returns the qualified package interface name for the given epackage (model).
*
* @param ePackage
* the model
* @return the package interface name
*/
public static String getQualifiedPackageInterfaceName(final EPackage ePackage) {
if (ePackage.getClass() == EPackageImpl.class) {
// EPackage loaded from ecore model
GenPackage genPackage = findGenPackage(ePackage);
if (genPackage != null) {
return genPackage.getQualifiedPackageInterfaceName();
}
} else {
// EPackage loaded from Java
Class<?>[] interfaces = ePackage.getClass().getInterfaces();
if (interfaces != null && interfaces.length > 0) {
return interfaces[0].getName();
}
}
return null;
}
示例13: preInvoke
import org.eclipse.emf.codegen.ecore.genmodel.GenPackage; //导入依赖的package包/类
/**
* Registers the given source-paths in the generator.
*/
@Override
public void preInvoke() {
ResourceSet resSet = new ResourceSetImpl();
Resource resource = resSet.getResource(URI.createURI(genModel), true);
for (EObject obj : resource.getContents()) {
if (obj instanceof GenModel) {
GenModel model = (GenModel) obj;
addSourcePathForPlugin(model.getModelPluginID());
for (GenPackage usedPackage : model.getUsedGenPackages()) {
addSourcePathForPlugin(usedPackage.getGenModel().getModelPluginID());
}
}
}
LOGGER.info("Registered source path to discover custom classes: " + Joiner.on(", ").join(this.srcPaths));
}
示例14: createGenModel
import org.eclipse.emf.codegen.ecore.genmodel.GenPackage; //导入依赖的package包/类
public static void createGenModel(final EPackage rootPackage, final IPath ecorePath, final IResource genmodelResource) {
GenModel genModel = GenModelFactory.eINSTANCE.createGenModel();
genModel.setComplianceLevel(GenJDKLevel.JDK60_LITERAL);
genModel.setModelDirectory(ecorePath.removeLastSegments(1).toString());
genModel.getForeignModel().add(ecorePath.lastSegment());
genModel.setModelName(rootPackage.getName());
genModel.setRootExtendsInterface("");
genModel.initialize(Collections.singleton(rootPackage));
GenPackage genPackage = (GenPackage) genModel.getGenPackages().get(0);
genPackage.setPrefix("");
try {
URI genModelURI = URI.createURI(genmodelResource.getLocationURI().toString());
final XMIResourceImpl genModelResource = new XMIResourceImpl(genModelURI);
genModelResource.getContents().add(genModel);
genModelResource.save(Collections.EMPTY_MAP);
} catch (IOException e) {
e.printStackTrace();
}
}
示例15: handleOriginalGenModel
import org.eclipse.emf.codegen.ecore.genmodel.GenPackage; //导入依赖的package包/类
@Override
protected void handleOriginalGenModel() throws DiagnosticException {
URI genModelURI = getOriginalGenModel().eResource().getURI();
StringBuilder text = new StringBuilder();
getOriginalGenModel().getForeignModel().stream()
.filter(value -> value.endsWith(".ecore") || value.endsWith(".emof"))
.forEach(value -> text.append(makeAbsolute(URI.createURI(value), genModelURI).toString()).append(' '));
if (text.length() == 0) {
List<URI> locations = new UniqueEList<>();
for (GenPackage genPackage : getOriginalGenModel().getGenPackages()) {
URI ecoreURI = genPackage.getEcorePackage().eResource().getURI();
if (locations.add(ecoreURI)) {
text.append(makeAbsolute(URI.createURI(ecoreURI.toString()), genModelURI).toString()).append(' ');
}
}
}
setModelLocation(text.toString().trim());
}