Class VisibleDepsSearchScope

  • All Implemented Interfaces:
    SearchScope

    public class VisibleDepsSearchScope
    extends BaseScope
    SearchScope implementation that uses 'visible' module dependencies to build a scope.

    Since this class deals with SModule and SModel, appropriate model access (at least read) is expected from the caller.

    Note, this class is stateful and doesn't track changes to initial modules, though there's no obligation it's a snapshot either. At the moment, set of modules is fixed at init time, while set of models is dynamic. This is not given, implementation may change at any moment. Likely, we will cache everything at init time (depending on observed performance).

    {@implNote The reason I don't want to keep scope instance along with an AbstractModule is that there's little value in caching these scopes. We need to invalidate them in bulk on any module change anyway. Most usage scenarios obtain scope instance, perform some activities and abandon it afterwards, therefore stateful instance if perfectly fine.
    Since:
    2018.2
    • Constructor Detail

      • VisibleDepsSearchScope

        public VisibleDepsSearchScope​(@Nullable
                                      SRepository repository,
                                      @NotNull
                                      SModule module)
        Parameters:
        repository - repository to look up dependencies (dependant modules and accessory models of used languages) in. If null, scope consists of a module itself only.
        module - source of dependencies to scan
    • Method Detail

      • resolve

        public SModule resolve​(@NotNull
                               SModuleReference reference)
        Description copied from interface: SearchScope
        Finder use this method to go from module reference to SModule object, Find Usages client may use this method to limit what's visible/accessible to a Finder. shall always resolve references to modules from SearchScope.getModules()
        Specified by:
        resolve in interface SearchScope
        Overrides:
        resolve in class BaseScope
        Parameters:
        reference - module to look up in the scope
        Returns:
        module instance, or null if there's no such module in the scope
      • resolve

        public SModel resolve​(@NotNull
                              SModelReference reference)
        Description copied from interface: SearchScope
        Finder use this method to go from model reference to SModel object, Find Usages client may use this method to limit what's visible/accessible to a Finder. Generally, finder use this method to resolve references to search values shall always resolve references to models from SearchScope.getModels()
        Specified by:
        resolve in interface SearchScope
        Overrides:
        resolve in class BaseScope
        Parameters:
        reference - model to look up in the scope
        Returns:
        model instance, or null if model with specified reference is not visible in the scope