Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Cleanup / Loading imported models: when "importURI" does have an effect? #380

@goto40

Description

@goto40

Until now (textx 3.0), we have the ImportURI scope provider base class which allows to use the special attribute "importURI" to load imported models: e.g., see this example.

Specializations of ImportURI (scope providers allowing to import models):

How does the base class ImportURI work:

  • when loading a model, prior to reference resolution, all imported models are loaded. This happens in model.py by checking if the scope provider ìs a ModelLoader instance: here and here.
  • The ImportURI has a specific way to detect imports. It scans the model for attributes named importURI to load models (this could be implemented in a different way, e.g., by using other attributes, but we do not do this any unittest).
  • The ImportURI has a specific way to load models. They are stored in some special `_tx"-atttributes of the model (or the metamodel). This "special way" of loading models is used by our multi model scope providers or tool functions (see, e.g, http://textx.github.io/textX/3.0/scoping/#included-model-retrieval) but could be implemented differently.

I would like to start a discussion if we should narrow the possibilities to load models into the model (here and here.):

  • instead to call all ModelLoader scope provider separately (which redundantly tries to load and reload all imported models if more than one such scope provider is registered)
  • we could just once find all importURIattributes (fixed logic) and load all imported models (like we do it now in the ImportURI scope provider).
  • All scope providers have then to be analyzed if they should lookup cross-model references by default or always (e.g. +m in RREL strings or the FQN-scope provider).

This a BIC in any case! We should carefully think about it some time... But I think, if done correctly, this BIC should have no (or nearly no) impact for "normal users".

I am looking forward to discuss this topic with the users of textx! We can also move it to the discussion section, but since I expect some actions following this discussion I started it as issue... @igordejanovic feel free to move this issue...

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions