org.eclipse.emf.codegen.ecore.genmodel.GenModelPackage Java Examples
The following examples show how to use
org.eclipse.emf.codegen.ecore.genmodel.GenModelPackage.
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: NoDocumentationInferenceXcoreEcoreBuilder.java From n4js with Eclipse Public License 1.0 | 6 votes |
@Override protected void handleAnnotations(XModelElement xModelElement, EModelElement eModelElement) { super.handleAnnotations(xModelElement, eModelElement); // the following special handling only applies to EPackages if (!(eModelElement instanceof EPackage)) { return; } // obtain annotation that was created based on the automatic inference of copyright headers Optional<EAnnotation> inferredAnnotations = eModelElement.getEAnnotations().stream() .filter(a -> a.getSource().equals(GenModelPackage.eNS_URI)) // find annotation that is added automatically by inferring copyright header .filter(a -> a.getDetails().containsKey("documentation") && a.getDetails().size() == 1) .findFirst(); // delete @Ecore annotation as it is not present in an incremental build Optional<EAnnotation> ecoreAnnotation = eModelElement.getEAnnotations().stream() .filter(a -> a.getSource().equals(EcorePackage.eNS_URI)) .findFirst(); // removes annotation from container inferredAnnotations.ifPresent(a -> eModelElement.getEAnnotations().remove(a)); ecoreAnnotation.ifPresent(a -> eModelElement.getEAnnotations().remove(a)); }
Example #2
Source File: NoDocumentationXcoreEcoreBuilder.java From n4js with Eclipse Public License 1.0 | 6 votes |
@Override protected void handleAnnotations(XModelElement xModelElement, EModelElement eModelElement) { super.handleAnnotations(xModelElement, eModelElement); // the following special handling only applies to EPackages if (!(eModelElement instanceof EPackage)) { return; } // obtain annotation that was created based on the automatic inference of copyright headers Optional<EAnnotation> inferredAnnotations = eModelElement.getEAnnotations().stream() .filter(a -> a.getSource().equals(GenModelPackage.eNS_URI)) // find annotation that is added automatically by inferring copyright header .filter(a -> a.getDetails().containsKey("documentation") && a.getDetails().size() == 1) .findFirst(); // removes annotation from container inferredAnnotations.ifPresent(a -> eModelElement.getEAnnotations().remove(a)); }
Example #3
Source File: AbstractPortableURIsTest.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
@Before public void setUp() throws Exception { globalStateMemento = GlobalRegistries.makeCopyOfGlobalState(); EPackage.Registry.INSTANCE.put(XMLTypePackage.eNS_URI, XMLTypePackage.eINSTANCE); resourceSet = new XtextResourceSet(); resourceSet.getPackageRegistry().put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE); resourceSet.getPackageRegistry().put(GenModelPackage.eNS_URI, GenModelPackage.eINSTANCE); resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("genmodel", new EcoreResourceFactoryImpl()); resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl()); resourceSet.getURIConverter().getURIMap().put(URI.createPlatformPluginURI("org.eclipse.xtext/", false), URI.createURI("classpath:/")); resourceSet.getURIConverter().getURIMap().put(URI.createPlatformPluginURI("org.eclipse.xtext.xbase/", false), URI.createURI("classpath:/")); resourceSet.getURIConverter().getURIMap().put(URI.createPlatformPluginURI("org.eclipse.xtext.common.types/", false), URI.createURI("classpath:/")); resourceSet.getURIConverter().getURIMap().put(URI.createPlatformResourceURI("org.eclipse.emf.ecore/", false), URI.createURI("classpath:/")); resourceSet.getURIConverter().getURIMap().put(URI.createPlatformResourceURI("org.eclipse.xtext.xbase/", false), URI.createURI("classpath:/")); resourceSet.getURIConverter().getURIMap().put(URI.createPlatformResourceURI("org.eclipse.xtext.common.types/", false), URI.createURI("classpath:/")); resourceSet.getLoadOptions().put(XMLResource.OPTION_URI_HANDLER, this); resourceSet.setClasspathURIContext(getClasspathURIContext()); }
Example #4
Source File: AbstractPortableURIsTest.java From xtext-extras with Eclipse Public License 2.0 | 5 votes |
@Before public void setUp() throws Exception { globalStateMemento = GlobalRegistries.makeCopyOfGlobalState(); EPackage.Registry.INSTANCE.put(XMLTypePackage.eNS_URI, XMLTypePackage.eINSTANCE); resourceSet = new XtextResourceSet(); resourceSet.getPackageRegistry().put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE); resourceSet.getPackageRegistry().put(GenModelPackage.eNS_URI, GenModelPackage.eINSTANCE); resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("genmodel", new EcoreResourceFactoryImpl()); resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl()); resourceSet.getURIConverter().getURIMap().put(URI.createPlatformPluginURI("org.eclipse.xtext/", false), URI.createURI("classpath:/")); resourceSet.getURIConverter().getURIMap().put(URI.createPlatformResourceURI("org.eclipse.emf.ecore/", false), URI.createURI("classpath:/")); resourceSet.getLoadOptions().put(XMLResource.OPTION_URI_HANDLER, this); }
Example #5
Source File: EMFGeneratorFragment2.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override public void initialize(final Injector injector) { super.initialize(injector); boolean _containsKey = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().containsKey("genmodel"); boolean _not = (!_containsKey); if (_not) { Map<String, Object> _extensionToFactoryMap = Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap(); EcoreResourceFactoryImpl _ecoreResourceFactoryImpl = new EcoreResourceFactoryImpl(); _extensionToFactoryMap.put("genmodel", _ecoreResourceFactoryImpl); } GenModelPackage.eINSTANCE.getGenAnnotation(); }
Example #6
Source File: AbstractPortableURIsTest.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Before public void setUp() throws Exception { globalStateMemento = GlobalRegistries.makeCopyOfGlobalState(); EPackage.Registry.INSTANCE.put(XMLTypePackage.eNS_URI, XMLTypePackage.eINSTANCE); resourceSet = new XtextResourceSet(); resourceSet.getPackageRegistry().put(EcorePackage.eNS_URI, EcorePackage.eINSTANCE); resourceSet.getPackageRegistry().put(GenModelPackage.eNS_URI, GenModelPackage.eINSTANCE); resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("genmodel", new EcoreResourceFactoryImpl()); resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put("ecore", new EcoreResourceFactoryImpl()); resourceSet.getURIConverter().getURIMap().put(URI.createPlatformPluginURI("org.eclipse.xtext/", false), URI.createURI("classpath:/")); resourceSet.getURIConverter().getURIMap().put(URI.createPlatformResourceURI("org.eclipse.emf.ecore/", false), URI.createURI("classpath:/")); resourceSet.getLoadOptions().put(XMLResource.OPTION_URI_HANDLER, this); resourceSet.setClasspathURIContext(getClasspathURIContext()); }
Example #7
Source File: DataObjectGenerator.java From BIMserver with GNU Affero General Public License v3.0 | 5 votes |
public VirtualFile generate(VirtualFile basedir) throws DatabaseException { GenModel genModel = GenModelFactory.eINSTANCE.createGenModel(); genModel.setRuntimeVersion(GenRuntimeVersion.EMF25); genModel.setComplianceLevel(GenJDKLevel.JDK60_LITERAL); genModel.setFeatureDelegation(GenDelegationKind.REFLECTIVE_LITERAL); genModel.setRootExtendsClass("org.bimserver.emf.IdEObjectImpl"); genModel.setRootExtendsInterface("org.bimserver.emf.IdEObject"); genModel.setSuppressContainment(true); genModel.setCodeFormatting(true); genModel.setCopyrightText(StringUtils.readFromFile(new File("copyright.txt"))); genModel.setCanGenerate(true); genModel.setModelDirectory("test"); genModel.setModelName("model name"); genModel.setForceOverwrite(true); genModel.setSuppressNotification(false); genModel.setContainmentProxies(false); genModel.setBinaryCompatibleReflectiveMethods(false); genModel.setPublicConstructors(false); genModel.setMinimalReflectiveMethods(true); // More code, but faster genModel.setUpdateClasspath(false); genModel.initialize(schema.getEPackages()); GeneratorAdapterFactory.Descriptor.Registry.INSTANCE.addDescriptor(GenModelPackage.eNS_URI, GenModelGeneratorAdapterFactory.DESCRIPTOR); Generator generator = new Generator(); generator.setInput(genModel); generator.generate(genModel, GenBaseGeneratorAdapter.MODEL_PROJECT_TYPE, new BasicMonitor.Printing(System.out)); // List<GenPackage> genPackages = createGenPackages(genModel, basedir); // generatePackages(genModel, genPackages, basedir); return basedir; }
Example #8
Source File: EMFGeneratorFragment2.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
protected void doGenerate(final GenModel genModel) { final Generator generator = new Generator() { @Override public JControlModel getJControlModel() { if ((this.jControlModel == null)) { JControlModel _jControlModel = new JControlModel(); this.jControlModel = _jControlModel; this.jControlModel.initialize(null, this.options.mergeRulesURI); } return this.jControlModel; } }; GeneratorAdapterFactory.Descriptor.Registry _adapterFactoryDescriptorRegistry = generator.getAdapterFactoryDescriptorRegistry(); String _lineDelimiter = this.codeConfig.getLineDelimiter(); CvsIdFilteringGeneratorAdapterFactoryDescriptor _cvsIdFilteringGeneratorAdapterFactoryDescriptor = new CvsIdFilteringGeneratorAdapterFactoryDescriptor(_lineDelimiter); _adapterFactoryDescriptorRegistry.addDescriptor(GenModelPackage.eNS_URI, _cvsIdFilteringGeneratorAdapterFactoryDescriptor); genModel.setCanGenerate(true); generator.setInput(genModel); BasicMonitor _basicMonitor = new BasicMonitor(); final Diagnostic diagnostic = generator.generate(genModel, GenBaseGeneratorAdapter.MODEL_PROJECT_TYPE, _basicMonitor); int _severity = diagnostic.getSeverity(); boolean _notEquals = (_severity != Diagnostic.OK); if (_notEquals) { EMFGeneratorFragment2.LOG.warn(diagnostic); } if (this.generateEdit) { BasicMonitor _basicMonitor_1 = new BasicMonitor(); final Diagnostic editDiag = generator.generate(genModel, GenBaseGeneratorAdapter.EDIT_PROJECT_TYPE, _basicMonitor_1); int _severity_1 = editDiag.getSeverity(); boolean _notEquals_1 = (_severity_1 != Diagnostic.OK); if (_notEquals_1) { EMFGeneratorFragment2.LOG.warn(editDiag); } } if (this.generateEditor) { BasicMonitor _basicMonitor_2 = new BasicMonitor(); final Diagnostic editorDiag = generator.generate(genModel, GenBaseGeneratorAdapter.EDITOR_PROJECT_TYPE, _basicMonitor_2); int _severity_2 = editorDiag.getSeverity(); boolean _notEquals_2 = (_severity_2 != Diagnostic.OK); if (_notEquals_2) { EMFGeneratorFragment2.LOG.warn(editorDiag); } } }
Example #9
Source File: CustomClassEcoreGeneratorFragment.java From dsl-devkit with Eclipse Public License 1.0 | 4 votes |
@Override protected void doGenerate(final GenModel genModel) { if (LOGGER.isInfoEnabled()) { LOGGER.info("generating EMF code for " + genModel.eResource().getURI()); //$NON-NLS-1$ } Generator generator = new Generator() { @Override public JControlModel getJControlModel() { return new JControlModel() { @Override public boolean canMerge() { return false; } }; } }; genModel.setNonNLSMarkers(generateNonNLSMarkers); generator.getAdapterFactoryDescriptorRegistry().addDescriptor(GenModelPackage.eNS_URI, new GeneratorAdapterDescriptor(loggedTypeMappings, getTypeMapper())); generator.setInput(genModel); Diagnostic diagnostic = generator.generate(genModel, GenBaseGeneratorAdapter.MODEL_PROJECT_TYPE, new BasicMonitor()); if (diagnostic.getSeverity() != Diagnostic.OK) { LOGGER.info(diagnostic); } if (isGenerateEdit()) { Diagnostic editDiag = generator.generate(genModel, GenBaseGeneratorAdapter.EDIT_PROJECT_TYPE, new BasicMonitor()); if (editDiag.getSeverity() != Diagnostic.OK) { LOGGER.info(editDiag); } } if (isGenerateEditor()) { Diagnostic editorDiag = generator.generate(genModel, GenBaseGeneratorAdapter.EDITOR_PROJECT_TYPE, new BasicMonitor()); if (editorDiag.getSeverity() != Diagnostic.OK) { LOGGER.info(editorDiag); } } }
Example #10
Source File: TestsStandaloneSetup.java From joynr with Apache License 2.0 | 4 votes |
@Override public Injector createInjectorAndDoEMFRegistration() { EPackage.Registry.INSTANCE.put(GenModelPackage.eNS_URI, GenModelPackage.eINSTANCE); return super.createInjectorAndDoEMFRegistration(); }