org.eclipse.viatra.query.tooling.core.generator.genmodel

## Class GenModelMetamodelProviderService

- java.lang.Object
- - org.eclipse.viatra.query.patternlanguage.emf.scoping.BaseMetamodelProviderService
  - - org.eclipse.viatra.query.tooling.core.generator.genmodel.GenModelMetamodelProviderService

- All Implemented Interfaces:
    IMetamodelProvider, IMetamodelProviderInstance, IVQGenmodelProvider

      public class GenModelMetamodelProviderService
      extends BaseMetamodelProviderService
      implements IVQGenmodelProvider, IMetamodelProviderInstance

- - ### Field Summary

    - ### Fields inherited from class org.eclipse.viatra.query.patternlanguage.emf.scoping.BaseMetamodelProviderService

      `logger, qualifiedNameConverter`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `GenModelMetamodelProviderService()`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected java.lang.String` | `doGetQualifiedClassName(org.eclipse.emf.ecore.EClassifier classifier, org.eclipse.emf.ecore.EObject context)`
    `org.eclipse.emf.codegen.ecore.genmodel.GenPackage` | `findGenPackage(org.eclipse.emf.ecore.EObject ctx, org.eclipse.emf.ecore.EPackage ePackage)` Tries to find the EMF `GenPackage` for a selected `EPackage`.
    `org.eclipse.emf.codegen.ecore.genmodel.GenPackage` | `findGenPackage(org.eclipse.emf.ecore.EObject ctx, java.lang.String packageNsUri)` Tries to find the EMF `GenPackage` for a selected `EPackage`.
    `org.eclipse.emf.codegen.ecore.genmodel.GenPackage` | `findGenPackage(org.eclipse.emf.ecore.resource.ResourceSet set, org.eclipse.emf.ecore.EPackage ePackage)` Tries to find the EMF `GenPackage` for a selected `EPackage`.
    `org.eclipse.emf.codegen.ecore.genmodel.GenPackage` | `findGenPackage(org.eclipse.emf.ecore.resource.ResourceSet set, java.lang.String packageNsUri)` Tries to find the EMF `GenPackage` for a selected `EPackage`.
    `java.util.Collection<org.eclipse.emf.ecore.EPackage>` | `getAllMetamodelObjects(org.eclipse.core.resources.IProject project)` Collects all EPackage objects available from a selected project, including the ones from the EPackage Registry.
    `org.eclipse.xtext.scoping.IScope` | `getAllMetamodelObjects(org.eclipse.xtext.scoping.IScope delegateScope, org.eclipse.emf.ecore.EObject ctx)` Returns a set of all available EPackages wrapped into `IEObjectDescription` for the use of scoping.
    `ViatraQueryGeneratorModel` | `getGeneratorModel(org.eclipse.emf.ecore.EObject pattern)` Gets the generator model for a selected VIATRA query-related context object (e.g.
    `ViatraQueryGeneratorModel` | `getGeneratorModel(org.eclipse.core.resources.IProject project)`
    `ViatraQueryGeneratorModel` | `getGeneratorModel(org.eclipse.core.resources.IProject project, org.eclipse.emf.ecore.resource.ResourceSet set)` Gets the generator model for a selected Viatra Query project.
    `ViatraQueryGeneratorModel` | `getGeneratorModel(org.eclipse.emf.ecore.resource.ResourceSet set)`
    `org.eclipse.core.resources.IFile` | `getGeneratorModelFile(org.eclipse.core.resources.IProject project)`
    `org.eclipse.core.runtime.IPath` | `getGeneratorModelPath(org.eclipse.core.resources.IProject project)` Calculates the path of the generator model from a selected project.
    `java.lang.String` | `getIdentifier()` Get a textual identifier for the metamodel provider instance
    `java.lang.String` | `getModelPluginId(org.eclipse.emf.ecore.EPackage ePackage, org.eclipse.emf.ecore.resource.ResourceSet set)` Returns the identifier of the plugin that contains the generated model code.
    `int` | `getPriority()` A default priority for the provider instance; a lower number means a higher priority.
    `protected java.util.Collection<java.lang.String>` | `getProvidedMetamodels()`
    `ViatraQueryGeneratorModel` | `initializeGeneratorModel(org.eclipse.core.resources.IProject project, org.eclipse.emf.ecore.resource.ResourceSet set)` Initializes and returns the VIATRA Query generator model for the selected project.
    `boolean` | `isGeneratedCodeAvailable(org.eclipse.emf.ecore.EPackage ePackage, org.eclipse.emf.ecore.resource.ResourceSet set)` Returns true if the generated code is available for the given EPackage, the code uses the given resource set as context.
    `boolean` | `isGeneratorModelDefined(org.eclipse.core.resources.IProject project)`
    `org.eclipse.emf.ecore.EPackage` | `loadEPackage(java.lang.String packageUri, org.eclipse.emf.ecore.resource.ResourceSet set)` Loads an EMF package from the nsURI or resource URI of the model, and uses the resource set given as the second parameter.
    `void` | `saveGeneratorModel(org.eclipse.core.resources.IProject project, ViatraQueryGeneratorModel generatorModel)` Saves the changes to the generator model instance in the selected project.

    - ### Methods inherited from class org.eclipse.viatra.query.patternlanguage.emf.scoping.BaseMetamodelProviderService

      `getGenmodelRegistry, getModelPluginId, getQualifiedClassName`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.eclipse.viatra.query.patternlanguage.emf.scoping.IMetamodelProvider

      `getQualifiedClassName`

- - ### Constructor Detail

    - #### GenModelMetamodelProviderService

          public GenModelMetamodelProviderService()

  - ### Method Detail

    - #### getIdentifier

          public java.lang.String getIdentifier()

      Description copied from interface: `IMetamodelProviderInstance`
      Get a textual identifier for the metamodel provider instance
      Specified by:
        `getIdentifier` in interface `IMetamodelProviderInstance`
      Returns:
        a non-null textual identifier; should be unique over all possible implementations

    - #### getPriority

          public int getPriority()

      Description copied from interface: `IMetamodelProviderInstance`
      A default priority for the provider instance; a lower number means a higher priority. The priority may be overriden through `CompoundMetamodelProviderService`.
      Specified by:
        `getPriority` in interface `IMetamodelProviderInstance`
      Returns:
        a non-negative priority number

    - #### getAllMetamodelObjects

          public org.eclipse.xtext.scoping.IScope getAllMetamodelObjects(org.eclipse.xtext.scoping.IScope delegateScope,
                                                                         org.eclipse.emf.ecore.EObject ctx)

      Description copied from interface: `IMetamodelProvider`
      Returns a set of all available EPackages wrapped into `IEObjectDescription` for the use of scoping. It uses the `IEObjectDescription`s from the delegate scope provider too, this way the `EPackage`s from the XText index will be available too.
      Specified by:
        `getAllMetamodelObjects` in interface `IMetamodelProvider`
      Overrides:
        `getAllMetamodelObjects` in class `BaseMetamodelProviderService`
      Parameters:
        `delegateScope` - the delegate scope
        `ctx` - the context object for the scoping

    - #### getAllMetamodelObjects

          public java.util.Collection<org.eclipse.emf.ecore.EPackage> getAllMetamodelObjects(org.eclipse.core.resources.IProject project)
                                                                                      throws org.eclipse.core.runtime.CoreException

      Description copied from interface: `IVQGenmodelProvider`
      Collects all EPackage objects available from a selected project, including the ones from the EPackage Registry. If the project features an vqgen files, the packages referenced there are also included.
      Specified by:
        `getAllMetamodelObjects` in interface `IVQGenmodelProvider`
      Returns:
        a non-null collection of packages
      Throws:
        `org.eclipse.core.runtime.CoreException`

    - #### loadEPackage

          public org.eclipse.emf.ecore.EPackage loadEPackage(java.lang.String packageUri,
                                                             org.eclipse.emf.ecore.resource.ResourceSet set)

      Description copied from interface: `IMetamodelProvider`
      Loads an EMF package from the nsURI or resource URI of the model, and uses the resource set given as the second parameter.
      Specified by:
        `loadEPackage` in interface `IMetamodelProvider`
      Returns:
        the loaded EMF EPackage

    - #### isGeneratedCodeAvailable

          public boolean isGeneratedCodeAvailable(org.eclipse.emf.ecore.EPackage ePackage,
                                                  org.eclipse.emf.ecore.resource.ResourceSet set)

      Description copied from interface: `IMetamodelProvider`
      Returns true if the generated code is available for the given EPackage, the code uses the given resource set as context.
      Specified by:
        `isGeneratedCodeAvailable` in interface `IMetamodelProvider`
      Overrides:
        `isGeneratedCodeAvailable` in class `BaseMetamodelProviderService`
      Parameters:
        `ePackage` - for which the availability of generated code is checked
        `set` - used for context in the checking
      Returns:
        true, if the generated code for the EPackage is available

    - #### getModelPluginId

          public java.lang.String getModelPluginId(org.eclipse.emf.ecore.EPackage ePackage,
                                                   org.eclipse.emf.ecore.resource.ResourceSet set)

      Description copied from interface: `IMetamodelProvider`
      Returns the identifier of the plugin that contains the generated model code.
      Specified by:
        `getModelPluginId` in interface `IMetamodelProvider`
      Overrides:
        `getModelPluginId` in class `BaseMetamodelProviderService`
      Parameters:
        `ePackage` - for which the model plugin ID is requested
        `set` - used for context in the searching
      Returns:
        the model plugin ID or null if it cannot be found

    - #### getGeneratorModel

          public ViatraQueryGeneratorModel getGeneratorModel(org.eclipse.emf.ecore.EObject pattern)

      Description copied from interface: `IVQGenmodelProvider`
      Gets the generator model for a selected VIATRA query-related context object (e.g. a `Pattern`). If the project of the pattern has no generator model specified, this method returns an empty generator model. The genmodel will be placed into the `ResourceSet` of the Pattern object.
      Specified by:
        `getGeneratorModel` in interface `IVQGenmodelProvider`
      Returns:
        the loaded generator model

    - #### getGeneratorModel

          public ViatraQueryGeneratorModel getGeneratorModel(org.eclipse.core.resources.IProject project)

    - #### getGeneratorModel

          public ViatraQueryGeneratorModel getGeneratorModel(org.eclipse.emf.ecore.resource.ResourceSet set)

    - #### getGeneratorModel

          public ViatraQueryGeneratorModel getGeneratorModel(org.eclipse.core.resources.IProject project,
                                                             org.eclipse.emf.ecore.resource.ResourceSet set)

      Description copied from interface: `IVQGenmodelProvider`
      Gets the generator model for a selected Viatra Query project. If the project has no generator model specified, this method returns an empty generator model. The genmodel will be placed into the specified resource set
      Specified by:
        `getGeneratorModel` in interface `IVQGenmodelProvider`
      Returns:
        the loaded generator model

    - #### saveGeneratorModel

          public void saveGeneratorModel(org.eclipse.core.resources.IProject project,
                                         ViatraQueryGeneratorModel generatorModel)
                                  throws java.io.IOException

      Description copied from interface: `IVQGenmodelProvider`
      Saves the changes to the generator model instance in the selected project. The provider assumes that the genmodel was instantiated by using the `IVQGenmodelProvider.getGeneratorModel(EObject)` or the `IVQGenmodelProvider.getGeneratorModel(IProject, ResourceSet)` methods.
      Specified by:
        `saveGeneratorModel` in interface `IVQGenmodelProvider`
      Throws:
        `java.io.IOException`

    - #### findGenPackage

          public org.eclipse.emf.codegen.ecore.genmodel.GenPackage findGenPackage(org.eclipse.emf.ecore.EObject ctx,
                                                                                  org.eclipse.emf.ecore.EPackage ePackage)

      Description copied from interface: `IVQGenmodelProvider`
      Tries to find the EMF `GenPackage` for a selected `EPackage`. The context object is used for determining the actual project.
      Specified by:
        `findGenPackage` in interface `IVQGenmodelProvider`
      Returns:
        the corresponding `GenPackage` for the selected `EPackage`

    - #### findGenPackage

          public org.eclipse.emf.codegen.ecore.genmodel.GenPackage findGenPackage(org.eclipse.emf.ecore.EObject ctx,
                                                                                  java.lang.String packageNsUri)

      Description copied from interface: `IVQGenmodelProvider`
      Tries to find the EMF `GenPackage` for a selected `EPackage`. The context object is used for determining the actual project.
      Specified by:
        `findGenPackage` in interface `IVQGenmodelProvider`
      Returns:
        the corresponding `GenPackage` for the selected `EPackage`

    - #### findGenPackage

          public org.eclipse.emf.codegen.ecore.genmodel.GenPackage findGenPackage(org.eclipse.emf.ecore.resource.ResourceSet set,
                                                                                  org.eclipse.emf.ecore.EPackage ePackage)

      Description copied from interface: `IVQGenmodelProvider`
      Tries to find the EMF `GenPackage` for a selected `EPackage`. The resource set is expected to be the one Xtext assigns for a Java project.
      Specified by:
        `findGenPackage` in interface `IVQGenmodelProvider`
      Returns:
        the corresponding `GenPackage` for the selected `EPackage`

    - #### findGenPackage

          public org.eclipse.emf.codegen.ecore.genmodel.GenPackage findGenPackage(org.eclipse.emf.ecore.resource.ResourceSet set,
                                                                                  java.lang.String packageNsUri)

      Description copied from interface: `IVQGenmodelProvider`
      Tries to find the EMF `GenPackage` for a selected `EPackage`. The resource set is expected to be the one Xtext assigns for a Java project.
      Specified by:
        `findGenPackage` in interface `IVQGenmodelProvider`
      Returns:
        the corresponding `GenPackage` for the selected `EPackage`

    - #### isGeneratorModelDefined

          public boolean isGeneratorModelDefined(org.eclipse.core.resources.IProject project)

    - #### getGeneratorModelFile

          public org.eclipse.core.resources.IFile getGeneratorModelFile(org.eclipse.core.resources.IProject project)

    - #### getGeneratorModelPath

          public org.eclipse.core.runtime.IPath getGeneratorModelPath(org.eclipse.core.resources.IProject project)

      Description copied from interface: `IVQGenmodelProvider`
      Calculates the path of the generator model from a selected project. If the project has no generator model defined, the method still returns the path where to look for the generator model.
      Specified by:
        `getGeneratorModelPath` in interface `IVQGenmodelProvider`
      Returns:
        a non-empty path for the generator model. It is possible that no resource exists at this path.

    - #### initializeGeneratorModel

          public ViatraQueryGeneratorModel initializeGeneratorModel(org.eclipse.core.resources.IProject project,
                                                                    org.eclipse.emf.ecore.resource.ResourceSet set)

      Initializes and returns the VIATRA Query generator model for the selected project. If the model is already initialized, it returns the existing model.

    - #### getProvidedMetamodels

          protected java.util.Collection<java.lang.String> getProvidedMetamodels()

      Specified by:
        `getProvidedMetamodels` in class `BaseMetamodelProviderService`

    - #### doGetQualifiedClassName

          protected java.lang.String doGetQualifiedClassName(org.eclipse.emf.ecore.EClassifier classifier,
                                                             org.eclipse.emf.ecore.EObject context)

      Specified by:
        `doGetQualifiedClassName` in class `BaseMetamodelProviderService`