Interface IDependentModelProvider


  • public interface IDependentModelProvider
    The service allows to load dependent model from source text feature of some object and can hold model mapped to parent object and feature. This prevents to load dependent model multiple times for each purpose of callers.

    Dependent model means that the content (text) of model stores NOT into separate file, but in some text feature of other object. As Example, DCS file contains some objects with text features of Query and Expression languages, which root objects should load into a separate resource.

    Parent object and feature means object that actually contains text which will be parsed with Xtext into some new model in separate resource. As example, StringLiteral object in module and it's "lines" feature is parent for Query Language root object (QuerySchema) which will be parsed from "lines". Dependent model sometimes need to be related to the source object where you get the text of it. As example, DCS Expression language bases it's context of schema fields and it might be validated that used expression parts are existing fields.



    WARNING!
    • This dependent model should be use as read-only model, otherwise the link to parent will be removed and dependent resource will be or might be unloaded.
    • If source text feature or source object has changed the link to dependent model will be removed and dependent resource will be unloaded.
    • It is better to create a wrapper service for specific model to hide from callers unrelated logic of basePath computation and provide strong types. See com._1c.g5.v8.dt.ql.dcs.resource.IDependentQuerySchemaProvider as example.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      <T extends org.eclipse.emf.ecore.EObject>
      T
      getDependentModel​(org.eclipse.emf.ecore.EObject source, org.eclipse.emf.ecore.EStructuralFeature textFeature, org.eclipse.core.runtime.IPath basePath, BiFunction<org.eclipse.emf.ecore.EObject,​org.eclipse.emf.ecore.EStructuralFeature,​String> textProvider, org.eclipse.xtext.util.CancelIndicator cancelIndicator)
      Gets the dependent model by the source object and it's text feature provided.
      <T extends org.eclipse.emf.ecore.EObject>
      T
      getDependentModel​(org.eclipse.emf.ecore.EObject source, org.eclipse.emf.ecore.EStructuralFeature textFeature, org.eclipse.core.runtime.IPath basePath, org.eclipse.xtext.util.CancelIndicator cancelIndicator)
      Gets the dependent model by the source object and it's text feature.
      org.eclipse.emf.ecore.EObject getParent​(org.eclipse.emf.ecore.EObject dependent)
      Gets the parent object of the dependent model object.
      org.eclipse.emf.ecore.EStructuralFeature getParentFeature​(org.eclipse.emf.ecore.EObject dependent)
      Gets the parent containing text feature of the dependent model object.
      void unload​(org.eclipse.emf.ecore.EObject root)
      Explicitly unload dependent model object from resource and remove linkage to the parent object.
    • Method Detail

      • getDependentModel

        <T extends org.eclipse.emf.ecore.EObject> T getDependentModel​(org.eclipse.emf.ecore.EObject source,
                                                                      org.eclipse.emf.ecore.EStructuralFeature textFeature,
                                                                      org.eclipse.core.runtime.IPath basePath,
                                                                      org.eclipse.xtext.util.CancelIndicator cancelIndicator)
        Gets the dependent model by the source object and it's text feature.
        Type Parameters:
        T - the generic type of dependent model root object
        Parameters:
        source - the source object, cannot be null.
        textFeature - the text feature of the source object, cannot be null.
        basePath - the base project relative path with file extension of dependent resource, cannot be null.
        cancelIndicator - the cancel indicator, cannot be null.
        Returns:
        the dependent model, may return null if cannot load .
      • getDependentModel

        <T extends org.eclipse.emf.ecore.EObject> T getDependentModel​(org.eclipse.emf.ecore.EObject source,
                                                                      org.eclipse.emf.ecore.EStructuralFeature textFeature,
                                                                      org.eclipse.core.runtime.IPath basePath,
                                                                      BiFunction<org.eclipse.emf.ecore.EObject,​org.eclipse.emf.ecore.EStructuralFeature,​String> textProvider,
                                                                      org.eclipse.xtext.util.CancelIndicator cancelIndicator)
        Gets the dependent model by the source object and it's text feature provided.
        Type Parameters:
        T - the generic type of dependent model root object
        Parameters:
        source - the source object, cannot be null.
        textFeature - the text feature of the source object, cannot be null.
        basePath - the base project relative path with file extension of dependent resource, cannot be null.
        textProvider - the text provider of the dependent model, cannot be null.
        cancelIndicator - the cancel indicator, cannot be null.
        Returns:
        the dependent model, may be null.
      • getParent

        org.eclipse.emf.ecore.EObject getParent​(org.eclipse.emf.ecore.EObject dependent)
        Gets the parent object of the dependent model object.
        Parameters:
        dependent - the dependent model object, cannot be null.
        Returns:
        the parent object of dependent model, may return null if the model is not linked to it's parent.
      • getParentFeature

        org.eclipse.emf.ecore.EStructuralFeature getParentFeature​(org.eclipse.emf.ecore.EObject dependent)
        Gets the parent containing text feature of the dependent model object.
        Parameters:
        dependent - the dependent model object, cannot be null.
        Returns:
        the parent text feature, may return null if the model is not linked to it's parent.
      • unload

        void unload​(org.eclipse.emf.ecore.EObject root)
        Explicitly unload dependent model object from resource and remove linkage to the parent object.
        Parameters:
        root - the root of dependent model, cannot be null.