Search in sources :

Example 6 with EPackage

use of org.eclipse.emf.ecore.EPackage in project xtext-core by eclipse.

the class FragmentFakingEcoreResource method getURIFragment.

public String getURIFragment(final EClassifier classifier) {
    EPackage _eSuperPackage = classifier.getEPackage().getESuperPackage();
    boolean _tripleNotEquals = (_eSuperPackage != null);
    if (_tripleNotEquals) {
        final StringBuilder result = new StringBuilder(60);
        this.calculateURIFragment(classifier.getEPackage(), result, CollectionLiterals.<EPackage>newHashSet());
        result.append(classifier.getName());
        return result.toString();
    }
    return null;
}
Also used : EPackage(org.eclipse.emf.ecore.EPackage)

Example 7 with EPackage

use of org.eclipse.emf.ecore.EPackage in project xtext-core by eclipse.

the class Ecore2XtextExtensions method subClasses.

public static Iterable<EClass> subClasses(final EClass it) {
    Iterable<EClass> _xifexpression = null;
    EPackage _ePackage = it.getEPackage();
    boolean _tripleEquals = (_ePackage == null);
    if (_tripleEquals) {
        _xifexpression = CollectionLiterals.<EClass>emptyList();
    } else {
        final Function1<EClass, Boolean> _function = (EClass c) -> {
            return Boolean.valueOf(c.getEAllSuperTypes().contains(it));
        };
        _xifexpression = IterableExtensions.<EClass>filter(Iterables.<EClass>filter(it.getEPackage().getEClassifiers(), EClass.class), _function);
    }
    return _xifexpression;
}
Also used : EClass(org.eclipse.emf.ecore.EClass) EPackage(org.eclipse.emf.ecore.EPackage)

Example 8 with EPackage

use of org.eclipse.emf.ecore.EPackage in project ifml2php by Dipiert.

the class Controller method registerPackages.

/**
 * This can be used to update the resource set's package registry with all needed EPackages.
 *
 * @param resourceSet
 *            The resource set which registry has to be updated.
 * @generated NOT
 */
@Override
public void registerPackages(ResourceSet resourceSet) {
    super.registerPackages(resourceSet);
    URI uri = URI.createFileURI("../edu.ifml2php.pim.ifml.gen.lycmm/models/metamodels/Metamodel.ecore");
    Resource resource = resourceSet.getResource(uri, true);
    EPackage PHPMVC = (EPackage) resource.getContents().get(0);
    List<EPackage> subPackages = PHPMVC.getESubpackages();
    for (EPackage subPack : subPackages) {
        EPackage.Registry.INSTANCE.put(subPack.getNsURI(), subPack);
    }
/*
         * If you want to change the content of this method, do NOT forget to change the "@generated"
         * tag in the Javadoc of this method to "@generated NOT". Without this new tag, any compilation
         * of the Acceleo module with the main template that has caused the creation of this class will
         * revert your modifications.
         */
/*
         * If you need additional package registrations, you can register them here. The following line
         * (in comment) is an example of the package registration for UML.
         * 
         * You can use the method  "isInWorkspace(Class c)" to check if the package that you are about to
         * register is in the workspace.
         * 
         * To register a package properly, please follow the following conventions:
         *
         * If the package is located in another plug-in, already installed in Eclipse. The following content should
         * have been generated at the beginning of this method. Do not register the package using this mechanism if
         * the metamodel is located in the workspace.
         *  
         * if (!isInWorkspace(UMLPackage.class)) {
         *     // The normal package registration if your metamodel is in a plugin.
         *     resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
         * }
         * 
         * If the package is located in another project in your workspace, the plugin containing the package has not
         * been register by EMF and Acceleo should register it automatically. If you want to use the generator in
         * stand alone, the regular registration (seen a couple lines before) is needed.
         * 
         * To learn more about Package Registration, have a look at the Acceleo documentation (Help -> Help Contents).
         */
}
Also used : Resource(org.eclipse.emf.ecore.resource.Resource) URI(org.eclipse.emf.common.util.URI) EPackage(org.eclipse.emf.ecore.EPackage)

Example 9 with EPackage

use of org.eclipse.emf.ecore.EPackage in project ifml2php by Dipiert.

the class Model method registerPackages.

/**
 * This can be used to update the resource set's package registry with all needed EPackages.
 *
 * @param resourceSet
 *            The resource set which registry has to be updated.
 * @generated NOT
 */
@Override
public void registerPackages(ResourceSet resourceSet) {
    super.registerPackages(resourceSet);
    URI uri = URI.createFileURI("../edu.ifml2php.pim.ifml.gen.lycmm/models/metamodels/Metamodel.ecore");
    Resource resource = resourceSet.getResource(uri, true);
    EPackage PHPMVC = (EPackage) resource.getContents().get(0);
    List<EPackage> subPackages = PHPMVC.getESubpackages();
    for (EPackage subPack : subPackages) {
        EPackage.Registry.INSTANCE.put(subPack.getNsURI(), subPack);
    }
/*
         * If you want to change the content of this method, do NOT forget to change the "@generated"
         * tag in the Javadoc of this method to "@generated NOT". Without this new tag, any compilation
         * of the Acceleo module with the main template that has caused the creation of this class will
         * revert your modifications.
         */
/*
         * If you need additional package registrations, you can register them here. The following line
         * (in comment) is an example of the package registration for UML.
         * 
         * You can use the method  "isInWorkspace(Class c)" to check if the package that you are about to
         * register is in the workspace.
         * 
         * To register a package properly, please follow the following conventions:
         *
         * If the package is located in another plug-in, already installed in Eclipse. The following content should
         * have been generated at the beginning of this method. Do not register the package using this mechanism if
         * the metamodel is located in the workspace.
         *  
         * if (!isInWorkspace(UMLPackage.class)) {
         *     // The normal package registration if your metamodel is in a plugin.
         *     resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
         * }
         * 
         * If the package is located in another project in your workspace, the plugin containing the package has not
         * been register by EMF and Acceleo should register it automatically. If you want to use the generator in
         * stand alone, the regular registration (seen a couple lines before) is needed.
         * 
         * To learn more about Package Registration, have a look at the Acceleo documentation (Help -> Help Contents).
         */
}
Also used : Resource(org.eclipse.emf.ecore.resource.Resource) URI(org.eclipse.emf.common.util.URI) EPackage(org.eclipse.emf.ecore.EPackage)

Example 10 with EPackage

use of org.eclipse.emf.ecore.EPackage in project ifml2php by Dipiert.

the class Application method registerPackages.

/**
 * This can be used to update the resource set's package registry with all needed EPackages.
 *
 * @param resourceSet
 *            The resource set which registry has to be updated.
 * @generated NOT
 */
@Override
public void registerPackages(ResourceSet resourceSet) {
    super.registerPackages(resourceSet);
    /*if (!isInWorkspace(IFML.Core.CorePackage.class)) {
            resourceSet.getPackageRegistry().put(IFML.Core.CorePackage.eINSTANCE.getNsURI(), IFML.Core.CorePackage.eINSTANCE);
        }/*
        File file = new File("/home/dam/Escritorio/ws/preprod.acceleo.ifml2OurMM/src/acceleo/generacionClaseApplication/main/acceleo/ifml2OurMM/Metamodel.ecore");
        EObject obj;
        try {
            obj = ModelUtils.load(file, resourceSet);
            resourceSet.getPackageRegistry().put("http://www.application.org", obj); 
         } catch (IOException e) {
             e.printStackTrace();
         }*/
    /*Por cambios en la plataforma de Eclipse en la versión Luna, la estrategia de usar Acceleo plug-in como launcher
        no funciona. La alternativa es usar Java como launcher, como aplicación stand alone. Para estos casos EMF no descubrirá
        ni registrará los paquetes disponibles y por ello debe hacer esto manualmente*/
    // URI uri = URI.createFileURI("/home/dam/Escritorio/ws/edu.ifml2php.psm.lycmm.gen.laravel/src/Metamodel.ecore");
    URI uri = URI.createFileURI("../edu.ifml2php.pim.ifml.gen.lycmm/models/metamodels/Metamodel.ecore");
    Resource resource = resourceSet.getResource(uri, true);
    EPackage PHPMVC = (EPackage) resource.getContents().get(0);
    List<EPackage> subPackages = PHPMVC.getESubpackages();
    for (EPackage subPack : subPackages) {
        EPackage.Registry.INSTANCE.put(subPack.getNsURI(), subPack);
    }
/*if (!isInWorkspace(org.eclipse.uml2.uml.UMLPackage.class)) {
            resourceSet.getPackageRegistry().put(org.eclipse.uml2.uml.UMLPackage.eINSTANCE.getNsURI(), org.eclipse.uml2.uml.UMLPackage.eINSTANCE);
        }*/
/*
         * If you want to change the content of this method, do NOT forget to change the "@generated"
         * tag in the Javadoc of this method to "@generated NOT". Without this new tag, any compilation
         * of the Acceleo module with the main template that has caused the creation of this class will
         * revert your modifications.
         */
/*
         * If you need additional package registrations, you can register them here. The following line
         * (in comment) is an example of the package registration for UML.
         * 
         * You can use the method  "isInWorkspace(Class c)" to check if the package that you are about to
         * register is in the workspace.
         * 
         * To register a package properly, please follow the following conventions:
         *
         * If the package is located in another plug-in, already installed in Eclipse. The following content should
         * have been generated at the beginning of this method. Do not register the package using this mechanism if
         * the metamodel is located in the workspace.
         *  
         * if (!isInWorkspace(UMLPackage.class)) {
         *     // The normal package registration if your metamodel is in a plugin.
         *     resourceSet.getPackageRegistry().put(UMLPackage.eNS_URI, UMLPackage.eINSTANCE);
         * }
         * 
         * If the package is located in another project in your workspace, the plugin containing the package has not
         * been register by EMF and Acceleo should register it automatically. If you want to use the generator in
         * stand alone, the regular registration (seen a couple lines before) is needed.
         * 
         * To learn more about Package Registration, have a look at the Acceleo documentation (Help -> Help Contents).
         */
}
Also used : Resource(org.eclipse.emf.ecore.resource.Resource) URI(org.eclipse.emf.common.util.URI) EPackage(org.eclipse.emf.ecore.EPackage)

Aggregations

EPackage (org.eclipse.emf.ecore.EPackage)424 ParserRule (org.eclipse.xtext.ParserRule)201 Action (org.eclipse.xtext.Action)196 Parameter (org.eclipse.xtext.Parameter)196 Test (org.junit.Test)101 EClass (org.eclipse.emf.ecore.EClass)85 Resource (org.eclipse.emf.ecore.resource.Resource)50 EObject (org.eclipse.emf.ecore.EObject)39 EClassifier (org.eclipse.emf.ecore.EClassifier)32 URI (org.eclipse.emf.common.util.URI)30 ResourceSet (org.eclipse.emf.ecore.resource.ResourceSet)23 Grammar (org.eclipse.xtext.Grammar)22 ResourceSetImpl (org.eclipse.emf.ecore.resource.impl.ResourceSetImpl)16 EStructuralFeature (org.eclipse.emf.ecore.EStructuralFeature)15 GenPackage (org.eclipse.emf.codegen.ecore.genmodel.GenPackage)14 AbstractMetamodelDeclaration (org.eclipse.xtext.AbstractMetamodelDeclaration)14 XtextResource (org.eclipse.xtext.resource.XtextResource)14 EEnum (org.eclipse.emf.ecore.EEnum)13 EReference (org.eclipse.emf.ecore.EReference)12 IOException (java.io.IOException)11