org.eclipse.emf.mwe.utils.GenModelHelper Java Examples

The following examples show how to use org.eclipse.emf.mwe.utils.GenModelHelper. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: EcoreGeneratorFragment.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * @since 2.0
 */
@Deprecated
protected void registerReferencedGenModels() {
	try {
		if (getReferencedGenModels() != null && getReferencedGenModels().length() > 0) {
			ResourceSet rs = new XtextResourceSet();
			GenModelHelper gmh = new GenModelHelper();
			for (String uriStr : getReferencedGenModels().split(",")) {
				URI uri = URI.createURI(uriStr.trim());
				gmh.registerGenModel(rs, uri);
			}
		}
	} catch (ConfigurationException ce) {
		throw ce;
	} catch (Exception e) {
		log.error(e, e);
	}
}
 
Example #2
Source File: EMFGeneratorFragment.java    From xtext-extras with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * @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;
}
 
Example #3
Source File: EMFGeneratorFragment2.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
private void registerUsedGenModel(final URIConverter converter, final Grammar grammar) {
  final URI genModelUri = this.getGenModelUri(grammar);
  boolean _exists = converter.exists(genModelUri, null);
  if (_exists) {
    try {
      GenModelHelper _genModelHelper = new GenModelHelper();
      XtextResourceSet _xtextResourceSet = new XtextResourceSet();
      _genModelHelper.registerGenModel(_xtextResourceSet, genModelUri);
    } catch (final Throwable _t) {
      if (_t instanceof Exception) {
        final Exception e = (Exception)_t;
        EMFGeneratorFragment2.LOG.error("Failed to register GenModel", e);
      } else {
        throw Exceptions.sneakyThrow(_t);
      }
    }
  }
}
 
Example #4
Source File: EMFGeneratorFragment2.java    From xtext-core with Eclipse Public License 2.0 6 votes vote down vote up
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;
}
 
Example #5
Source File: EMFGeneratorFragment.java    From xtext-extras with Eclipse Public License 2.0 5 votes vote down vote up
private void registerUsedGenModel(URIConverter converter) {
	if (genModel == null)
		return;
	URI genModelUri = URI.createURI(genModel);
	genModelUri = toPlatformResourceURI(genModelUri);
	if (converter.exists(genModelUri, null)) {
		try {
			new GenModelHelper().registerGenModel(new XtextResourceSet(), genModelUri);
		} catch (ConfigurationException ce) {
			throw ce;
		} catch (Exception e) {
			log.error(e, e);
		}
	}
}
 
Example #6
Source File: StandaloneSetup.java    From dsl-devkit with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Registers the given files in the gen model.
 *
 * @param fileNames
 *          the comma separated file names
 */
public void setRegisterGenModelFiles(final String fileNames) {
  GenModelHelper helper = createGenModelHelper();
  for (URI uri : splitCommaSeparatedString(fileNames)) {
    helper.registerGenModel(resourceSet, uri);
  }
}
 
Example #7
Source File: XtextGeneratorResourceSetInitializer.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
private void register(final GenModel genModel) {
  new GenModelHelper().registerGenModel(genModel);
}
 
Example #8
Source File: StandaloneSetup.java    From dsl-devkit with Eclipse Public License 1.0 4 votes vote down vote up
@Override
protected GenModelHelper createGenModelHelper() {
  return new DependencyAwareGenModelHelper();
}
 
Example #9
Source File: LazyStandaloneSetup.java    From openhab-core with Eclipse Public License 2.0 4 votes vote down vote up
private GenModelHelper createGenModelHelper() {
    return new GenModelHelper();
}
 
Example #10
Source File: LazyStandaloneSetup.java    From smarthome with Eclipse Public License 2.0 4 votes vote down vote up
private GenModelHelper createGenModelHelper() {
    return new GenModelHelper();
}