org.eclipse.emf.ecore.EModelElement Java Examples

The following examples show how to use org.eclipse.emf.ecore.EModelElement. 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 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 #2
Source File: NoDocumentationXcoreEcoreBuilder.java    From n4js with 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();

	// removes annotation from container
	inferredAnnotations.ifPresent(a -> eModelElement.getEAnnotations().remove(a));
}
 
Example #3
Source File: SarlDocumentationProvider.java    From sarl with Apache License 2.0 6 votes vote down vote up
public String getDocumentation(EObject o) {
	// Get the documentation from the Xtext grammar hidden nodes.
	String text = super.getDocumentation(o);
	if (text == null) {
		// Get the grammar from the Ecore model element.
		if (o instanceof EModelElement) {
			text = EcoreUtil.getDocumentation((EModelElement) o);
		}
		if (text == null) {
			// Get the grammar from the code builder extension.
			DocumentationAdapter adapter = (DocumentationAdapter) EcoreUtil.getAdapter(
					o.eAdapters(), DocumentationAdapter.class);
			if (adapter != null) {
				return adapter.getDocumentation();
			}
		}
	}
	return text;
}
 
Example #4
Source File: MetamodelImpl.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 *
 * @generated NOT
 */
@Override
public EModelElement getElement(String name) {
	final EPackage p = getEPackage(name);
	if (p != null) {
		return p;
	}
	final EClassifier c = getEClassifier(name);
	if (c != null) {
		return c;
	}
	final EStructuralFeature f = getEFeature(name);
	if (f != null) {
		return f;
	}
	return null;
}
 
Example #5
Source File: MetamodelImpl.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 *
 * @generated NOT
 */
@SuppressWarnings("unchecked")
@Override
public <V> EList<V> getInverse(EModelElement metamodelElement, EReference reference) {
	return new UniqueEList<V>((List) EcoreUtils.getInverse(
		metamodelElement, reference, getEPackages()));
}
 
Example #6
Source File: EcorePerPlatformPluginAdapterFactory.java    From xtext-core with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public Adapter caseEModelElement(EModelElement object) {
	return createEModelElementAdapter();
}
 
Example #7
Source File: GenModelUtil2.java    From dsl-devkit with Eclipse Public License 1.0 3 votes vote down vote up
/**
 * Returns the genmodel for the given model element.
 *
 * @param eModelElement
 *          the model element
 * @return the genmodel
 */
public static GenModel findGenModel(final EModelElement eModelElement) {
  ResourceSet resourceSet = eModelElement.eResource() != null && eModelElement.eResource().getResourceSet() != null
      ? eModelElement.eResource().getResourceSet()
      : new ResourceSetImpl();
  return findGenModel(eModelElement, resourceSet);
}
 
Example #8
Source File: EcorePerPlatformPluginSwitch.java    From xtext-core with Eclipse Public License 2.0 2 votes vote down vote up
/**
 * Returns the result of interpreting the object as an instance of '<em>EModel Element</em>'.
 * <!-- begin-user-doc -->
 * This implementation returns null;
 * returning a non-null result will terminate the switch.
 * <!-- end-user-doc -->
 * @param object the target of the switch.
 * @return the result of interpreting the object as an instance of '<em>EModel Element</em>'.
 * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject)
 * @generated
 */
public T caseEModelElement(EModelElement object) {
	return null;
}
 
Example #9
Source File: CheckGenModelUtil.java    From dsl-devkit with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Returns the genmodel for the given model element.
 *
 * @param eModelElement
 *          the model element
 * @return the genmodel
 */
public static GenModel findGenModel(final EModelElement eModelElement) {
  return findGenModel(eModelElement, eModelElement.eResource() != null ? eModelElement.eResource().getResourceSet() : new ResourceSetImpl());
}
 
Example #10
Source File: Metamodel.java    From bonita-studio with GNU General Public License v2.0 2 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * <!-- begin-model-doc -->
 * Delete an instance from the model, including all the contained instances
 * <!-- end-model-doc -->
 *
 * @model metamodelElementRequired="true"
 * @generated
 */
void delete(EModelElement metamodelElement);
 
Example #11
Source File: Metamodel.java    From bonita-studio with GNU General Public License v2.0 2 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * <!-- begin-model-doc -->
 * Get the inverse value of the reference
 * <!-- end-model-doc -->
 *
 * @model metamodelElementRequired="true" referenceRequired="true"
 * @generated
 */
<V> EList<V> getInverse(EModelElement metamodelElement, EReference reference);
 
Example #12
Source File: Metamodel.java    From bonita-studio with GNU General Public License v2.0 2 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * <!-- begin-model-doc -->
 * Resolve a metamodel element by its fully qualified name
 * <!-- end-model-doc -->
 *
 * @model nameRequired="true"
 * @generated
 */
EModelElement getElement(String name);
 
Example #13
Source File: MetamodelImpl.java    From bonita-studio with GNU General Public License v2.0 2 votes vote down vote up
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 *
 * @generated NOT
 */
@Override
public void delete(EModelElement metamodelElement) {
	EcoreUtil.delete(metamodelElement);
}