org.eclipse.emf.ecore.EcorePackage Java Examples

The following examples show how to use org.eclipse.emf.ecore.EcorePackage. 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 Project: xtext-core   Author: eclipse   File: DeclarativeValidatorTest.java    License: Eclipse Public License 2.0 6 votes vote down vote up
@Test public void testErrorWithSource() {
	AbstractDeclarativeValidator test = new AbstractDeclarativeValidator() {
		@Check
		public void foo(Object x) {
			error(
					"Error Message", 
					EcorePackage.eINSTANCE.getEAnnotation(), 
					EcorePackage.Literals.ENAMED_ELEMENT__NAME,
					ValidationMessageAcceptor.INSIGNIFICANT_INDEX);
		}
	};
	BasicDiagnostic chain = new BasicDiagnostic();
	test.validate(EcorePackage.eINSTANCE.getEClass(), chain, Collections.emptyMap());
	assertEquals(1, chain.getChildren().size());

	Diagnostic diag = chain.getChildren().get(0);
	assertEquals("Error Message", diag.getMessage());
	assertEquals(EcorePackage.eINSTANCE.getEAnnotation().toString(), diag.getSource());
	assertEquals(Diagnostic.ERROR, diag.getSeverity());
}
 
Example #2
Source Project: xtext-core   Author: eclipse   File: LocalUniqueNameContext.java    License: Eclipse Public License 2.0 6 votes vote down vote up
@Override
public Iterable<IEObjectDescription> getExportedObjects(EClass type, QualifiedName name, boolean ignoreCase) {
	Preconditions.checkArgument(!ignoreCase);
	Object result = index.get(name.getFirstSegment());
	if (result == null) {
		return Collections.emptyList();
	}
	if (result instanceof IEObjectDescription) {
		if (EcoreUtil2.isAssignableFrom(type, ((IEObjectDescription) result).getEClass())) {
			return Collections.singletonList((IEObjectDescription)result);
		}
		return Collections.emptyList();
	}
	@SuppressWarnings("unchecked")
	List<IEObjectDescription> casted = (List<IEObjectDescription>) result;
	if (type == EcorePackage.Literals.EOBJECT) {
		return casted;
	}
	return FluentIterable.from(casted).filter(it -> EcoreUtil2.isAssignableFrom(type, it.getEClass()));
}
 
Example #3
Source Project: xtext-core   Author: eclipse   File: EClassInfoTest.java    License: Eclipse Public License 2.0 6 votes vote down vote up
@Test public void testContainsCompatibleFeature_01() throws Exception {
	EcorePackage pack = EcorePackage.eINSTANCE;
	EClass eClass = pack.getEClass();
	EClassInfo objectUnderTest = new EClassifierInfo.EClassInfo(eClass, false, Collections.<String>emptySet(), null);
	assertEquals(true,objectUnderTest.containsCompatibleFeature("name", false, true, pack.getEString(), new StringBuilder()));
	assertEquals(false,objectUnderTest.containsCompatibleFeature("name", true, true, pack.getEString(), new StringBuilder()));
	assertEquals(false,objectUnderTest.containsCompatibleFeature("name", true, true, pack.getEAnnotation(), new StringBuilder()));
	assertEquals(false,objectUnderTest.containsCompatibleFeature("name", true, true, pack.getEShort(), new StringBuilder()));
	assertEquals(false,objectUnderTest.containsCompatibleFeature("names", false, true, pack.getEString(), new StringBuilder()));
	
	assertEquals(true,objectUnderTest.containsCompatibleFeature("eStructuralFeatures", true, true, pack.getEAttribute(), new StringBuilder()));
	assertEquals(true,objectUnderTest.containsCompatibleFeature("eStructuralFeatures", true, true, pack.getEReference(), new StringBuilder()));
	assertEquals(true,objectUnderTest.containsCompatibleFeature("eStructuralFeatures", true, true, pack.getEStructuralFeature(), new StringBuilder()));
	assertEquals(false,objectUnderTest.containsCompatibleFeature("eStructuralFeatures", false, true, pack.getEStructuralFeature(), new StringBuilder()));
	assertEquals(false,objectUnderTest.containsCompatibleFeature("eStructuralFeatures", true, true, pack.getEAnnotation(), new StringBuilder()));
}
 
Example #4
Source Project: n4js   Author: eclipse   File: NoDocumentationInferenceXcoreEcoreBuilder.java    License: Eclipse Public License 1.0 6 votes vote down vote up
@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 #5
Source Project: n4js   Author: eclipse   File: DomPackageImpl.java    License: Eclipse Public License 1.0 6 votes vote down vote up
/**
 * Creates, registers, and initializes the <b>Package</b> for this model, and for any others upon which it depends.
 *
 * <p>This method is used to initialize {@link DomPackage#eINSTANCE} when that field is accessed.
 * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @see #eNS_URI
 * @see #createPackageContents()
 * @see #initializePackageContents()
 * @generated
 */
public static DomPackage init() {
	if (isInited) return (DomPackage)EPackage.Registry.INSTANCE.getEPackage(DomPackage.eNS_URI);

	// Obtain or create and register package
	Object registeredDomPackage = EPackage.Registry.INSTANCE.get(eNS_URI);
	DomPackageImpl theDomPackage = registeredDomPackage instanceof DomPackageImpl ? (DomPackageImpl)registeredDomPackage : new DomPackageImpl();

	isInited = true;

	// Initialize simple dependencies
	EcorePackage.eINSTANCE.eClass();

	// Create package meta-data objects
	theDomPackage.createPackageContents();

	// Initialize created meta-data
	theDomPackage.initializePackageContents();

	// Mark meta-data to indicate it can't be changed
	theDomPackage.freeze();

	// Update the registry and return the package
	EPackage.Registry.INSTANCE.put(DomPackage.eNS_URI, theDomPackage);
	return theDomPackage;
}
 
Example #6
Source Project: BIMserver   Author: opensourceBIM   File: Scaler.java    License: GNU Affero General Public License v3.0 6 votes vote down vote up
@SuppressWarnings({ "rawtypes", "unchecked" })
private void setDoubleAsStringValues(IdEObject idEObject) {
	for (EAttribute eAttribute : idEObject.eClass().getEAllAttributes()) {
		if (eAttribute.getEType() == EcorePackage.eINSTANCE.getEDouble()) {
			EStructuralFeature asStringFeature = idEObject.eClass().getEStructuralFeature(eAttribute.getName() + "AsString");
			if (asStringFeature != null) {
				if (eAttribute.isMany()) {
					List list = (List) idEObject.eGet(eAttribute);
					List listAsString = (List) idEObject.eGet(asStringFeature);
					for (int i = 0; i < list.size(); i++) {
						listAsString.set(i, "" + list.get(i));
					}
				} else {
					idEObject.eSet(asStringFeature, "" + idEObject.eGet(eAttribute));
				}
			}
		}
	}
}
 
Example #7
Source Project: xtext-core   Author: eclipse   File: ResourceSetBasedResourceDescriptionsTest.java    License: Eclipse Public License 2.0 6 votes vote down vote up
@Test public void testDataBasedResourceSetBasedResourceDescriptions() throws Exception {
	ResourceDescriptionsData data = new ResourceDescriptionsData(new ArrayList<IResourceDescription>());
	ResourceDescriptionsData.ResourceSetAdapter.installResourceDescriptionsData(resourceSet, data);
	resDescs.setContext(resourceSet);
	
	Resource resource = createResource();
	QualifiedName name = QualifiedName.create("SomeName");
	createNamedElement(name, EcorePackage.Literals.ECLASS, resource);
	// still empty
	assertFalse(resDescs.getAllResourceDescriptions().iterator().hasNext());
	assertTrue(resDescs.isEmpty());
	assertFalse(resDescs.getExportedObjectsByType(EcorePackage.Literals.ECLASS).iterator().hasNext());
	assertFalse(resDescs.getExportedObjects(EcorePackage.Literals.ECLASS,name, false).iterator().hasNext());
	assertFalse(resDescs.getExportedObjects().iterator().hasNext());
	
	// add resource description to data
	IResourceDescription description = resourceDescriptionManager.getResourceDescription(resource);
	data.addDescription(description.getURI(), description);
	// now contained
	assertSame(description, resDescs.getAllResourceDescriptions().iterator().next());
	assertFalse(resDescs.isEmpty());
	assertTrue(resDescs.getExportedObjectsByType(EcorePackage.Literals.ECLASS).iterator().hasNext());
	assertTrue(resDescs.getExportedObjects(EcorePackage.Literals.ECLASS,name, false).iterator().hasNext());
	assertFalse(resDescs.getExportedObjects(EcorePackage.Literals.EATTRIBUTE,name, false).iterator().hasNext());
	assertTrue(resDescs.getExportedObjects().iterator().hasNext());
}
 
Example #8
Source Project: xtext-core   Author: eclipse   File: XtextPackageImpl.java    License: Eclipse Public License 2.0 6 votes vote down vote up
/**
 * Creates, registers, and initializes the <b>Package</b> for this model, and for any others upon which it depends.
 * 
 * <p>This method is used to initialize {@link XtextPackage#eINSTANCE} when that field is accessed.
 * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @see #eNS_URI
 * @see #createPackageContents()
 * @see #initializePackageContents()
 * @generated
 */
public static XtextPackage init() {
	if (isInited) return (XtextPackage)EPackage.Registry.INSTANCE.getEPackage(XtextPackage.eNS_URI);

	// Obtain or create and register package
	XtextPackageImpl theXtextPackage = (XtextPackageImpl)(EPackage.Registry.INSTANCE.get(eNS_URI) instanceof XtextPackageImpl ? EPackage.Registry.INSTANCE.get(eNS_URI) : new XtextPackageImpl());

	isInited = true;

	// Initialize simple dependencies
	EcorePackage.eINSTANCE.eClass();

	// Create package meta-data objects
	theXtextPackage.createPackageContents();

	// Initialize created meta-data
	theXtextPackage.initializePackageContents();

	// Mark meta-data to indicate it can't be changed
	theXtextPackage.freeze();

 
	// Update the registry and return the package
	EPackage.Registry.INSTANCE.put(XtextPackage.eNS_URI, theXtextPackage);
	return theXtextPackage;
}
 
Example #9
Source Project: xtext-core   Author: eclipse   File: MetamodelTest.java    License: Eclipse Public License 2.0 6 votes vote down vote up
@Test public void testDerivedModel() {
	EPackage pack = DatatypeRulesTestLanguagePackage.eINSTANCE;
	EClass model = (EClass) pack.getEClassifier("Model");
	assertNotNull(model);
	EStructuralFeature feature = model.getEStructuralFeature("id");
	assertNotNull(feature);
	assertEquals(EcorePackage.Literals.ESTRING, feature.getEType());
	feature = model.getEStructuralFeature("value");
	assertNotNull(feature);
	assertEquals(EcorePackage.Literals.EBIG_DECIMAL, feature.getEType());
	feature = model.getEStructuralFeature("vector");
	assertNotNull(feature);
	assertEquals(EcorePackage.Literals.ESTRING, feature.getEType());
	feature = model.getEStructuralFeature("dots");
	assertNotNull(feature);
	assertEquals(EcorePackage.Literals.ESTRING, feature.getEType());
}
 
Example #10
Source Project: xtext-core   Author: eclipse   File: DeclarativeValidatorTest.java    License: Eclipse Public License 2.0 6 votes vote down vote up
@Test public void testWarningWithSource() {
	AbstractDeclarativeValidator test = new AbstractDeclarativeValidator() {
		@Check
		public void foo(Object x) {
			warning(
					"Error Message", 
					EcorePackage.eINSTANCE.getEAnnotation(), 
					EcorePackage.Literals.ENAMED_ELEMENT__NAME,
					ValidationMessageAcceptor.INSIGNIFICANT_INDEX);
		}
	};
	BasicDiagnostic chain = new BasicDiagnostic();
	test.validate(EcorePackage.eINSTANCE.getEClass(), chain, Collections.emptyMap());
	assertEquals(1, chain.getChildren().size());

	Diagnostic diag = chain.getChildren().get(0);
	assertEquals("Error Message", diag.getMessage());
	assertEquals(EcorePackage.eINSTANCE.getEAnnotation().toString(), diag.getSource());
	assertEquals(Diagnostic.WARNING, diag.getSeverity());
}
 
Example #11
Source Project: eip-designer   Author: lbroudoux   File: FilterPropertiesEditionComponent.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 * @see org.eclipse.emf.eef.runtime.impl.components.StandardPropertiesEditionComponent#updatePart(org.eclipse.emf.common.notify.Notification)
 */
public void updatePart(Notification msg) {
	super.updatePart(msg);
	if (editingPart.isVisible()) {
		FilterPropertiesEditionPart basePart = (FilterPropertiesEditionPart)editingPart;
		if (EipPackage.eINSTANCE.getEndpoint_Name().equals(msg.getFeature()) && msg.getNotifier().equals(semanticObject) && basePart != null && isAccessible(EipViewsRepository.Filter.Properties.name)) {
			if (msg.getNewValue() != null) {
				basePart.setName(EcoreUtil.convertToString(EcorePackage.Literals.ESTRING, msg.getNewValue()));
			} else {
				basePart.setName("");
			}
		}
		if (EipPackage.eINSTANCE.getEndpoint_ToChannels().equals(msg.getFeature())  && isAccessible(EipViewsRepository.Filter.Properties.toChannels))
			basePart.updateToChannels();
		if (EipPackage.eINSTANCE.getEndpoint_FromChannels().equals(msg.getFeature())  && isAccessible(EipViewsRepository.Filter.Properties.fromChannels))
			basePart.updateFromChannels();
		if (EipPackage.eINSTANCE.getFilter_Expression().equals(msg.getFeature()) && msg.getNotifier().equals(semanticObject) && basePart != null && isAccessible(EipViewsRepository.Filter.Properties.expression)) {
			if (msg.getNewValue() != null) {
				basePart.setExpression(EcoreUtil.convertToString(EcorePackage.Literals.ESTRING, msg.getNewValue()));
			} else {
				basePart.setExpression("");
			}
		}
		
	}
}
 
Example #12
Source Project: xtext-extras   Author: eclipse   File: EcoreResourceDescriptionManagerTest.java    License: Eclipse Public License 2.0 6 votes vote down vote up
@Test public void testPerformance() throws Exception {
		GenericResourceDescriptionManager manager = getEmfResourceDescriptionsManager();
		Collection<String> uris = ImmutableList.copyOf(EPackage.Registry.INSTANCE.keySet());
		for(String uri: uris) {
			EPackage pack = EPackage.Registry.INSTANCE.getEPackage(uri);
			IResourceDescription description = manager.getResourceDescription(pack.eResource());
			assertNotNull(description);
			for(int i = 0; i < 10; i++) {
				Iterator<EObject> iter = EcoreUtil.getAllProperContents(pack, true);
				while(iter.hasNext()) {
					EObject next = iter.next();
					if (next instanceof ENamedElement) {
						String name = ((ENamedElement) next).getName();
//						Iterable<IEObjectDescription> objects = 
						description.getExportedObjects(EcorePackage.Literals.EOBJECT, QualifiedName.create(name), false);
//						assertFalse(name + " - " + uri + " - " + next, Iterables.isEmpty(objects));
					}
				}
			}
		}
	}
 
Example #13
Source Project: eip-designer   Author: lbroudoux   File: ChannelPropertiesEditionComponent.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * {@inheritDoc}
 * @see org.eclipse.emf.eef.runtime.impl.components.StandardPropertiesEditionComponent#updatePart(org.eclipse.emf.common.notify.Notification)
 */
public void updatePart(Notification msg) {
	super.updatePart(msg);
	if (editingPart.isVisible()) {
		ChannelPropertiesEditionPart basePart = (ChannelPropertiesEditionPart)editingPart;
		if (EipPackage.eINSTANCE.getChannel_ToEndpoint().equals(msg.getFeature()) && basePart != null && isAccessible(EipViewsRepository.Channel.Properties.toEndpoint))
			basePart.setToEndpoint((EObject)msg.getNewValue());
		if (EipPackage.eINSTANCE.getChannel_FromEndpoint().equals(msg.getFeature()) && basePart != null && isAccessible(EipViewsRepository.Channel.Properties.fromEndpoint))
			basePart.setFromEndpoint((EObject)msg.getNewValue());
		if (EipPackage.eINSTANCE.getChannel_Name().equals(msg.getFeature()) && msg.getNotifier().equals(semanticObject) && basePart != null && isAccessible(EipViewsRepository.Channel.Properties.name)) {
			if (msg.getNewValue() != null) {
				basePart.setName(EcoreUtil.convertToString(EcorePackage.Literals.ESTRING, msg.getNewValue()));
			} else {
				basePart.setName("");
			}
		}
		if (EipPackage.eINSTANCE.getChannel_Guaranteed().equals(msg.getFeature()) && msg.getNotifier().equals(semanticObject) && basePart != null && isAccessible(EipViewsRepository.Channel.Properties.guaranteed))
			basePart.setGuaranteed((Boolean)msg.getNewValue());
		
		
	}
}
 
Example #14
Source Project: ADT_Frontend   Author: abapGit   File: DocumentRootImpl.java    License: MIT License 5 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public EMap<String, String> getXMLNSPrefixMap() {
	if (xMLNSPrefixMap == null) {
		xMLNSPrefixMap = new EcoreEMap<String,String>(EcorePackage.Literals.ESTRING_TO_STRING_MAP_ENTRY, EStringToStringMapEntryImpl.class, this, IAbapgitstagingPackage.DOCUMENT_ROOT__XMLNS_PREFIX_MAP);
	}
	return xMLNSPrefixMap;
}
 
Example #15
Source Project: xtext-core   Author: eclipse   File: IndentLangPackageImpl.java    License: Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Creates, registers, and initializes the <b>Package</b> for this model, and for any others upon which it depends.
 *
 * <p>This method is used to initialize {@link IndentLangPackage#eINSTANCE} when that field is accessed.
 * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @see #eNS_URI
 * @see #createPackageContents()
 * @see #initializePackageContents()
 * @generated
 */
public static IndentLangPackage init()
{
  if (isInited) return (IndentLangPackage)EPackage.Registry.INSTANCE.getEPackage(IndentLangPackage.eNS_URI);

  // Obtain or create and register package
  Object registeredIndentLangPackage = EPackage.Registry.INSTANCE.get(eNS_URI);
  IndentLangPackageImpl theIndentLangPackage = registeredIndentLangPackage instanceof IndentLangPackageImpl ? (IndentLangPackageImpl)registeredIndentLangPackage : new IndentLangPackageImpl();

  isInited = true;

  // Initialize simple dependencies
  EcorePackage.eINSTANCE.eClass();

  // Create package meta-data objects
  theIndentLangPackage.createPackageContents();

  // Initialize created meta-data
  theIndentLangPackage.initializePackageContents();

  // Mark meta-data to indicate it can't be changed
  theIndentLangPackage.freeze();

  // Update the registry and return the package
  EPackage.Registry.INSTANCE.put(IndentLangPackage.eNS_URI, theIndentLangPackage);
  return theIndentLangPackage;
}
 
Example #16
Source Project: n4js   Author: eclipse   File: BuilderUtil.java    License: Eclipse Public License 1.0 5 votes vote down vote up
/***/
public static boolean indexContainsElement(final String fileUri, final String eObjectName) {
	IResourceDescriptions descriptions = getBuilderState();
	URI uri = URI.createURI("platform:/resource" + fileUri);
	IResourceDescription description = descriptions.getResourceDescription(uri);
	if (description != null) {
		return description
				.getExportedObjects(EcorePackage.Literals.EOBJECT, QualifiedName.create(eObjectName), false)
				.iterator().hasNext();
	}
	return false;
}
 
Example #17
Source Project: bonita-studio   Author: bonitasoft   File: GroupImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
    * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
    * @generated
    */
@Override
public EMap<String, String> getHtmlAttributes() {
       if (htmlAttributes == null) {
           htmlAttributes = new EcoreEMap<String,String>(EcorePackage.Literals.ESTRING_TO_STRING_MAP_ENTRY, EStringToStringMapEntryImpl.class, this, FormPackage.GROUP__HTML_ATTRIBUTES);
       }
       return htmlAttributes;
   }
 
Example #18
Source Project: xtext-core   Author: eclipse   File: DefaultResourceDescriptionDeltaTest.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@Test public void testHasChanges_MultipleEObjects() throws Exception {
	TestResDesc resourceDesc = new TestResDesc();
	resourceDesc.imported.add(FOO);
	resourceDesc.exported.add(EObjectDescription.create(BAR, EcorePackage.Literals.EANNOTATION, Collections.singletonMap("foo", "bar")));
	resourceDesc.exported.add(EObjectDescription.create(FOO, EcorePackage.Literals.EANNOTATION, Collections.singletonMap("foo", "bar")));
	
	TestResDesc resourceDesc2 = new TestResDesc();
	resourceDesc2.imported.add(FOO);
	resourceDesc2.exported.add(EObjectDescription.create(BAR, EcorePackage.Literals.EANNOTATION, Collections.singletonMap("foo", "bar")));
	resourceDesc2.exported.add(EObjectDescription.create(FOO, EcorePackage.Literals.EANNOTATION, Collections.singletonMap("foo", "bar")));
	
	assertFalse(new DefaultResourceDescriptionDelta(resourceDesc, resourceDesc2).haveEObjectDescriptionsChanged());
}
 
Example #19
Source Project: xtext-core   Author: eclipse   File: FragmentTestLanguagePackageImpl.java    License: Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Creates, registers, and initializes the <b>Package</b> for this model, and for any others upon which it depends.
 *
 * <p>This method is used to initialize {@link FragmentTestLanguagePackage#eINSTANCE} when that field is accessed.
 * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @see #eNS_URI
 * @see #createPackageContents()
 * @see #initializePackageContents()
 * @generated
 */
public static FragmentTestLanguagePackage init()
{
  if (isInited) return (FragmentTestLanguagePackage)EPackage.Registry.INSTANCE.getEPackage(FragmentTestLanguagePackage.eNS_URI);

  // Obtain or create and register package
  Object registeredFragmentTestLanguagePackage = EPackage.Registry.INSTANCE.get(eNS_URI);
  FragmentTestLanguagePackageImpl theFragmentTestLanguagePackage = registeredFragmentTestLanguagePackage instanceof FragmentTestLanguagePackageImpl ? (FragmentTestLanguagePackageImpl)registeredFragmentTestLanguagePackage : new FragmentTestLanguagePackageImpl();

  isInited = true;

  // Initialize simple dependencies
  EcorePackage.eINSTANCE.eClass();

  // Create package meta-data objects
  theFragmentTestLanguagePackage.createPackageContents();

  // Initialize created meta-data
  theFragmentTestLanguagePackage.initializePackageContents();

  // Mark meta-data to indicate it can't be changed
  theFragmentTestLanguagePackage.freeze();

  // Update the registry and return the package
  EPackage.Registry.INSTANCE.put(FragmentTestLanguagePackage.eNS_URI, theFragmentTestLanguagePackage);
  return theFragmentTestLanguagePackage;
}
 
Example #20
Source Project: BIMserver   Author: opensourceBIM   File: Step0010.java    License: GNU Affero General Public License v3.0 5 votes vote down vote up
@Override
public void migrate(Schema schema, DatabaseSession databaseSession) {
	EClass projectSmall = schema.getEClass("store", "ProjectSmall");
	EEnum objectState = schema.getEEnum("store", "ObjectState");
	schema.createEAttribute(projectSmall, "state", objectState, Multiplicity.SINGLE);
	schema.createEAttribute(projectSmall, "nrRevisions", EcorePackage.eINSTANCE.getEInt(), Multiplicity.SINGLE);
	schema.createEAttribute(projectSmall, "nrSubProjects", EcorePackage.eINSTANCE.getEInt(), Multiplicity.SINGLE);
	schema.createEAttribute(projectSmall, "hasCheckinRights", EcorePackage.eINSTANCE.getEBoolean(), Multiplicity.SINGLE);
}
 
Example #21
Source Project: xtext-core   Author: eclipse   File: EMFGeneratorFragment2.java    License: Eclipse Public License 2.0 5 votes vote down vote up
protected Set<EPackage> getReferencedEPackages(final List<EPackage> packs) {
  final HashSet<EPackage> result = CollectionLiterals.<EPackage>newHashSet();
  for (final EPackage pkg : packs) {
    {
      final TreeIterator<EObject> iterator = pkg.eAllContents();
      while (iterator.hasNext()) {
        {
          final EObject obj = iterator.next();
          EList<EObject> _eCrossReferences = obj.eCrossReferences();
          for (final EObject crossRef : _eCrossReferences) {
            boolean _eIsProxy = crossRef.eIsProxy();
            if (_eIsProxy) {
              URI _eProxyURI = ((InternalEObject) crossRef).eProxyURI();
              String _plus = ("Proxy \'" + _eProxyURI);
              String _plus_1 = (_plus + "\' could not be resolved");
              EMFGeneratorFragment2.LOG.error(_plus_1);
            } else {
              final EPackage p = EcoreUtil2.<EPackage>getContainerOfType(crossRef, EPackage.class);
              if ((p != null)) {
                result.add(p);
              }
            }
          }
        }
      }
    }
  }
  result.removeAll(packs);
  result.remove(EcorePackage.eINSTANCE);
  result.remove(XMLTypePackage.eINSTANCE);
  result.remove(XMLNamespacePackage.eINSTANCE);
  return result;
}
 
Example #22
Source Project: xtext-core   Author: eclipse   File: ImportScopeTest.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@Test public void testAllAliasedElements_05() throws Exception {
	final IEObjectDescription desc1 = new EObjectDescription(QualifiedName.create("com","foo"), EcorePackage.Literals.EANNOTATION, null);
	final IEObjectDescription desc2 = new EObjectDescription(QualifiedName.create("com","bar"), EcorePackage.Literals.EANNOTATION, null);
	final IEObjectDescription desc3 = new EObjectDescription(QualifiedName.create("de","foo"), EcorePackage.Literals.EATTRIBUTE, null);
	final ArrayList<IEObjectDescription> newArrayList = newArrayList(desc1,desc2,desc3);
	ImportNormalizer n1 = new ImportNormalizer(QualifiedName.create("COM"), true, true);
	ImportNormalizer n2 = new ImportNormalizer(QualifiedName.create("DE"), true, true);
	TestableImportScope scope = new TestableImportScope(newArrayList(n1,n2), IScope.NULLSCOPE, null, EcorePackage.Literals.EOBJECT, true);
	Iterable<IEObjectDescription> elements = scope.getAliasedElements(newArrayList);
	assertEquals(1,size(elements));
	assertSame(desc2,((AliasedEObjectDescription)elements.iterator().next()).getAliasedEObjectDescription());
}
 
Example #23
Source Project: xtext-core   Author: eclipse   File: Formattertestlanguage2PackageImpl.java    License: Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Creates, registers, and initializes the <b>Package</b> for this model, and for any others upon which it depends.
 *
 * <p>This method is used to initialize {@link Formattertestlanguage2Package#eINSTANCE} when that field is accessed.
 * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @see #eNS_URI
 * @see #createPackageContents()
 * @see #initializePackageContents()
 * @generated
 */
public static Formattertestlanguage2Package init()
{
  if (isInited) return (Formattertestlanguage2Package)EPackage.Registry.INSTANCE.getEPackage(Formattertestlanguage2Package.eNS_URI);

  // Obtain or create and register package
  Object registeredFormattertestlanguage2Package = EPackage.Registry.INSTANCE.get(eNS_URI);
  Formattertestlanguage2PackageImpl theFormattertestlanguage2Package = registeredFormattertestlanguage2Package instanceof Formattertestlanguage2PackageImpl ? (Formattertestlanguage2PackageImpl)registeredFormattertestlanguage2Package : new Formattertestlanguage2PackageImpl();

  isInited = true;

  // Initialize simple dependencies
  EcorePackage.eINSTANCE.eClass();

  // Create package meta-data objects
  theFormattertestlanguage2Package.createPackageContents();

  // Initialize created meta-data
  theFormattertestlanguage2Package.initializePackageContents();

  // Mark meta-data to indicate it can't be changed
  theFormattertestlanguage2Package.freeze();

  // Update the registry and return the package
  EPackage.Registry.INSTANCE.put(Formattertestlanguage2Package.eNS_URI, theFormattertestlanguage2Package);
  return theFormattertestlanguage2Package;
}
 
Example #24
Source Project: xtext-core   Author: eclipse   File: TestLangPackageImpl.java    License: Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Creates, registers, and initializes the <b>Package</b> for this model, and for any others upon which it depends.
 *
 * <p>This method is used to initialize {@link TestLangPackage#eINSTANCE} when that field is accessed.
 * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @see #eNS_URI
 * @see #createPackageContents()
 * @see #initializePackageContents()
 * @generated
 */
public static TestLangPackage init()
{
  if (isInited) return (TestLangPackage)EPackage.Registry.INSTANCE.getEPackage(TestLangPackage.eNS_URI);

  // Obtain or create and register package
  Object registeredTestLangPackage = EPackage.Registry.INSTANCE.get(eNS_URI);
  TestLangPackageImpl theTestLangPackage = registeredTestLangPackage instanceof TestLangPackageImpl ? (TestLangPackageImpl)registeredTestLangPackage : new TestLangPackageImpl();

  isInited = true;

  // Initialize simple dependencies
  EcorePackage.eINSTANCE.eClass();

  // Create package meta-data objects
  theTestLangPackage.createPackageContents();

  // Initialize created meta-data
  theTestLangPackage.initializePackageContents();

  // Mark meta-data to indicate it can't be changed
  theTestLangPackage.freeze();

  // Update the registry and return the package
  EPackage.Registry.INSTANCE.put(TestLangPackage.eNS_URI, theTestLangPackage);
  return theTestLangPackage;
}
 
Example #25
Source Project: xtext-core   Author: eclipse   File: EcorePerPlatformResourcePackageImpl.java    License: Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Complete the initialization of the package and its meta-model.  This
 * method is guarded to have no affect on any invocation but its first.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void initializePackageContents() {
	if (isInitialized) return;
	isInitialized = true;

	// Initialize package
	setName(eNAME);
	setNsPrefix(eNS_PREFIX);
	setNsURI(eNS_URI);

	// Obtain other dependent packages
	EcorePackage theEcorePackage = (EcorePackage)EPackage.Registry.INSTANCE.getEPackage(EcorePackage.eNS_URI);
	EcorePerNsURIPackage theEcorePerNsURIPackage = (EcorePerNsURIPackage)EPackage.Registry.INSTANCE.getEPackage(EcorePerNsURIPackage.eNS_URI);
	EcorePerPlatformPluginPackage theEcorePerPlatformPluginPackage = (EcorePerPlatformPluginPackage)EPackage.Registry.INSTANCE.getEPackage(EcorePerPlatformPluginPackage.eNS_URI);

	// Create type parameters

	// Set bounds for type parameters

	// Add supertypes to classes
	extendsResourceEObjectEClass.getESuperTypes().add(theEcorePackage.getEObject());

	// Initialize classes and features; add operations and parameters
	initEClass(extendsResourceEObjectEClass, ExtendsResourceEObject.class, "ExtendsResourceEObject", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
	initEAttribute(getExtendsResourceEObject_Name(), theEcorePackage.getEString(), "name", null, 0, 1, ExtendsResourceEObject.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
	initEReference(getExtendsResourceEObject_EObjectReference1(), theEcorePackage.getEObject(), null, "eObjectReference1", null, 0, 1, ExtendsResourceEObject.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
	initEReference(getExtendsResourceEObject_EObjectReference2(), theEcorePerNsURIPackage.getExtendsNsURIEObject(), null, "eObjectReference2", null, 0, 1, ExtendsResourceEObject.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
	initEReference(getExtendsResourceEObject_EObjectReference3(), theEcorePerPlatformPluginPackage.getExtendsPluginEObject(), null, "eObjectReference3", null, 0, 1, ExtendsResourceEObject.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
	initEReference(getExtendsResourceEObject_EObjectReference4(), this.getExtendsResourceEObject(), null, "eObjectReference4", null, 0, 1, ExtendsResourceEObject.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
	initEReference(getExtendsResourceEObject_EObjectContainment(), theEcorePackage.getEObject(), null, "eObjectContainment", null, 0, -1, ExtendsResourceEObject.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);

	// Create resource
	createResource(eNS_URI);
}
 
Example #26
Source Project: xtext-core   Author: eclipse   File: ImportScopeTest.java    License: Eclipse Public License 2.0 5 votes vote down vote up
@Test public void testDuplicatesNotVisible_01_IgnoreCase() throws Exception {
	final IEObjectDescription desc1 = new EObjectDescription(QualifiedName.create("com","foo"), EcorePackage.Literals.EANNOTATION, null);
	final IEObjectDescription desc2 = new EObjectDescription(QualifiedName.create("de","Foo"), EcorePackage.Literals.EATTRIBUTE, null);
	SimpleScope outer = new SimpleScope(newArrayList(desc1,desc2), true);
	ImportNormalizer n1 = new ImportNormalizer(QualifiedName.create("com"), true, true);
	ImportNormalizer n2 = new ImportNormalizer(QualifiedName.create("de"), true, true);
	TestableImportScope scope = new TestableImportScope(newArrayList(n1,n2), outer, new ScopeBasedSelectable(outer), EcorePackage.Literals.EOBJECT, true);
	
	Iterator<IEObjectDescription> iterator = scope.getAllElements().iterator();
	assertSame(desc1,iterator.next());
	assertSame(desc2,iterator.next());
	assertFalse(iterator.hasNext());
}
 
Example #27
Source Project: xtext-core   Author: eclipse   File: Bug302128PackageImpl.java    License: Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Complete the initialization of the package and its meta-model.  This
 * method is guarded to have no affect on any invocation but its first.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void initializePackageContents()
{
  if (isInitialized) return;
  isInitialized = true;

  // Initialize package
  setName(eNAME);
  setNsPrefix(eNS_PREFIX);
  setNsURI(eNS_URI);

  // Obtain other dependent packages
  EcorePackage theEcorePackage = (EcorePackage)EPackage.Registry.INSTANCE.getEPackage(EcorePackage.eNS_URI);

  // Create type parameters

  // Set bounds for type parameters

  // Add supertypes to classes

  // Initialize classes and features; add operations and parameters
  initEClass(modelEClass, Model.class, "Model", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
  initEReference(getModel_Elements(), this.getElement(), null, "elements", null, 0, -1, Model.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, IS_COMPOSITE, !IS_RESOLVE_PROXIES, !IS_UNSETTABLE, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);

  initEClass(elementEClass, Element.class, "Element", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS);
  initEAttribute(getElement_Name(), theEcorePackage.getEString(), "name", null, 0, 1, Element.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);
  initEAttribute(getElement_Value(), theEcorePackage.getEString(), "value", null, 0, 1, Element.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED);

  // Create resource
  createResource(eNS_URI);
}
 
Example #28
Source Project: bonita-studio   Author: bonitasoft   File: DocumentRootImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * <!-- begin-user-doc -->
    * <!-- end-user-doc -->
 * @generated
 */
   @Override
   public EMap<String, String> getXMLNSPrefixMap() {
	if (xMLNSPrefixMap == null) {
		xMLNSPrefixMap = new EcoreEMap<String,String>(EcorePackage.Literals.ESTRING_TO_STRING_MAP_ENTRY, EStringToStringMapEntryImpl.class, this, ConnectorDefinitionPackage.DOCUMENT_ROOT__XMLNS_PREFIX_MAP);
	}
	return xMLNSPrefixMap;
}
 
Example #29
Source Project: bonita-studio   Author: bonitasoft   File: ImageWidgetImpl.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
    * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
    * @generated
    */
@Override
public EMap<String, String> getHtmlAttributes() {
       if (htmlAttributes == null) {
           htmlAttributes = new EcoreEMap<String,String>(EcorePackage.Literals.ESTRING_TO_STRING_MAP_ENTRY, EStringToStringMapEntryImpl.class, this, FormPackage.IMAGE_WIDGET__HTML_ATTRIBUTES);
       }
       return htmlAttributes;
   }
 
Example #30
Source Project: xtext-core   Author: eclipse   File: Bug301935TestPackageImpl.java    License: Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Creates, registers, and initializes the <b>Package</b> for this model, and for any others upon which it depends.
 *
 * <p>This method is used to initialize {@link Bug301935TestPackage#eINSTANCE} when that field is accessed.
 * Clients should not invoke it directly. Instead, they should simply access that field to obtain the package.
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @see #eNS_URI
 * @see #createPackageContents()
 * @see #initializePackageContents()
 * @generated
 */
public static Bug301935TestPackage init()
{
  if (isInited) return (Bug301935TestPackage)EPackage.Registry.INSTANCE.getEPackage(Bug301935TestPackage.eNS_URI);

  // Obtain or create and register package
  Object registeredBug301935TestPackage = EPackage.Registry.INSTANCE.get(eNS_URI);
  Bug301935TestPackageImpl theBug301935TestPackage = registeredBug301935TestPackage instanceof Bug301935TestPackageImpl ? (Bug301935TestPackageImpl)registeredBug301935TestPackage : new Bug301935TestPackageImpl();

  isInited = true;

  // Initialize simple dependencies
  EcorePackage.eINSTANCE.eClass();

  // Create package meta-data objects
  theBug301935TestPackage.createPackageContents();

  // Initialize created meta-data
  theBug301935TestPackage.initializePackageContents();

  // Mark meta-data to indicate it can't be changed
  theBug301935TestPackage.freeze();

  // Update the registry and return the package
  EPackage.Registry.INSTANCE.put(Bug301935TestPackage.eNS_URI, theBug301935TestPackage);
  return theBug301935TestPackage;
}