Class XtextBmLinkProvider

java.lang.Object
com._1c.g5.v8.dt.bm.xtext.XtextBmLinkProvider
All Implemented Interfaces:
IBmExternalUriResolver
Direct Known Subclasses:
BslBmLinkProvider

public abstract class XtextBmLinkProvider extends Object implements IBmExternalUriResolver
Special IBmLinkProvider for xtext resources
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected String
     
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    Constructor
  • Method Summary

    Modifier and Type
    Method
    Description
    protected org.eclipse.emf.ecore.resource.Resource
    checkResourceInResourceSet(org.eclipse.emf.common.util.URI uri, org.eclipse.emf.ecore.resource.Resource loadedResource)
    Additional checking for resource - is it contained in resource set or not
    void
    Performs any pending maintenance operations needed by the cache.
    void
    Clearing all containing resources
    protected com.google.common.cache.Cache<org.eclipse.emf.common.util.URI,org.eclipse.emf.ecore.resource.Resource>
    Creates special Cache for caching link provider resources, with eviction.
    protected org.eclipse.emf.ecore.resource.Resource
    createResource(org.eclipse.emf.ecore.resource.ResourceSet resourceSet, org.eclipse.emf.common.util.URI uriTrim)
    Creates resource by uri
    protected abstract boolean
    fileExist(org.eclipse.emf.common.util.URI uriTrim)
    Checks that file for reading content of the resource exist
    protected int
    getCacheEntryWeight(org.eclipse.emf.common.util.URI uri, org.eclipse.emf.ecore.resource.Resource resource)
    Calculates the cache entry weight.
    org.eclipse.emf.ecore.EObject
    getObject(org.eclipse.emf.common.util.URI uri)
    Resolves the specified URI.
    protected org.eclipse.core.resources.IProject
    getProject(org.eclipse.emf.common.util.URI uri)
    Gets project by URI.
    org.eclipse.emf.ecore.resource.Resource
    getResource(org.eclipse.emf.common.util.URI uri)
    Ask link providers to obtain resource matched with specified URI.
    protected void
    initResource(org.eclipse.emf.ecore.resource.Resource newResource)
    Initialize resource
    boolean
    Designates that resources being returned by this resolver remain as-is (with original resource set and so on) and not being copied to the session.
    boolean
    isResourceLoaded(org.eclipse.emf.common.util.URI uri)
    Checks that resource with uri was loaded earlier
    protected org.eclipse.emf.ecore.resource.Resource
    loadResource(org.eclipse.emf.common.util.URI uriTrim)
    Load resource by the URI.
    protected abstract boolean
    needCacheResource(org.eclipse.emf.common.util.URI uri)
    Checks that resource creating by this file need to be cached
    protected void
    onRemoval(com.google.common.cache.RemovalNotification<org.eclipse.emf.common.util.URI,org.eclipse.emf.ecore.resource.Resource> notification)
    Event of the cache when the entry has removed.
    void
    remove(org.eclipse.emf.common.util.URI uri)
    Remove caching resource by uri
    void
    Reset caches of a resolver if applicable
    boolean
    supports(org.eclipse.emf.common.util.URI uri)
    Checks if the specified URI is supported.
    protected String
    toResourceFileName(org.eclipse.emf.common.util.URI uriTrim)
    Converts uri to valid path to the file of resouce
    void
    update(org.eclipse.emf.ecore.resource.Resource resource)
    Updates caching resource

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • XtextBmLinkProvider

      public XtextBmLinkProvider()
      Constructor
  • Method Details

    • clear

      public void clear()
      Clearing all containing resources
    • cleanUp

      public void cleanUp()
      Performs any pending maintenance operations needed by the cache. Exactly which activities are performed -- if any -- is implementation-dependent.
    • remove

      public void remove(org.eclipse.emf.common.util.URI uri)
      Remove caching resource by uri
      Parameters:
      uri - URI of the removing resource, can't be null
    • update

      public void update(org.eclipse.emf.ecore.resource.Resource resource)
      Updates caching resource
      Parameters:
      resource - new resource for caching, can't be null
    • getResource

      public org.eclipse.emf.ecore.resource.Resource getResource(org.eclipse.emf.common.util.URI uri)
      Description copied from interface: IBmExternalUriResolver
      Ask link providers to obtain resource matched with specified URI. Used to provider resources for system types.
      Specified by:
      getResource in interface IBmExternalUriResolver
      Parameters:
      uri - The resource URI. May not be null
      Returns:
      the loaded resource if found, otherwise null.
    • isPassthrough

      public boolean isPassthrough()
      Description copied from interface: IBmExternalUriResolver
      Designates that resources being returned by this resolver remain as-is (with original resource set and so on) and not being copied to the session. This approach can be used by complex resource providers requiring specific support from original resource sets (like Xtext).
      BM could use such link providers for seamless URI resolution to external resources that shouldn't be cached out in the BM resource set.
      Specified by:
      isPassthrough in interface IBmExternalUriResolver
      Returns:
      true if this resolver works in the passthrough mode; false otherwise.
    • isResourceLoaded

      public boolean isResourceLoaded(org.eclipse.emf.common.util.URI uri)
      Checks that resource with uri was loaded earlier
      Parameters:
      uri - checking resource uri, can't be null
      Returns:
      true if resource was loaded earlier, false otherwise
    • supports

      public boolean supports(org.eclipse.emf.common.util.URI uri)
      Description copied from interface: IBmExternalUriResolver
      Checks if the specified URI is supported.
      Specified by:
      supports in interface IBmExternalUriResolver
      Parameters:
      uri - The URI to run the check against. May not be null.
      Returns:
      true if the URI is supported by this resolver, otherwise false.
    • getObject

      public org.eclipse.emf.ecore.EObject getObject(org.eclipse.emf.common.util.URI uri)
      Description copied from interface: IBmExternalUriResolver
      Resolves the specified URI.
      Specified by:
      getObject in interface IBmExternalUriResolver
      Parameters:
      uri - The URI. May not be null.
      Returns:
      the object identified by the specified URI if found, otherwise null.
    • resetCaches

      public void resetCaches()
      Description copied from interface: IBmExternalUriResolver
      Reset caches of a resolver if applicable
      Specified by:
      resetCaches in interface IBmExternalUriResolver
    • getProject

      protected org.eclipse.core.resources.IProject getProject(org.eclipse.emf.common.util.URI uri)
      Gets project by URI. See IResourceLookup.getProject(URI)
      Parameters:
      uri - the object URI, cannot be null
      Returns:
      the project which contains object with provided URI or null if object is out of any project
    • checkResourceInResourceSet

      protected org.eclipse.emf.ecore.resource.Resource checkResourceInResourceSet(org.eclipse.emf.common.util.URI uri, org.eclipse.emf.ecore.resource.Resource loadedResource)
      Additional checking for resource - is it contained in resource set or not
      Parameters:
      uri - uri of the checking resource, can't be null
      loadedResource - loaded resource, can't be null
      Returns:
      new loaded resource if needed or loadedResouce, never null
    • loadResource

      protected org.eclipse.emf.ecore.resource.Resource loadResource(org.eclipse.emf.common.util.URI uriTrim)
      Load resource by the URI.
      Parameters:
      uriTrim - the uri trimmed of fragment, cannot be null.
      Returns:
      the resource loaded resource
    • createResource

      protected org.eclipse.emf.ecore.resource.Resource createResource(org.eclipse.emf.ecore.resource.ResourceSet resourceSet, org.eclipse.emf.common.util.URI uriTrim)
      Creates resource by uri
      Parameters:
      resourceSet - ResourceSet for creating resource, can't be null
      uriTrim - uri of the resource, can't be null
      Returns:
      creating resource, never null
    • fileExist

      protected abstract boolean fileExist(org.eclipse.emf.common.util.URI uriTrim)
      Checks that file for reading content of the resource exist
      Parameters:
      uriTrim - uri of the reading resource, can't be null
      Returns:
      true if file for reading content of the resource exist, false otherwise
    • initResource

      protected void initResource(org.eclipse.emf.ecore.resource.Resource newResource)
      Initialize resource
      Parameters:
      newResource - initializing resource, can't be null
    • createCache

      protected com.google.common.cache.Cache<org.eclipse.emf.common.util.URI,org.eclipse.emf.ecore.resource.Resource> createCache()
      Creates special Cache for caching link provider resources, with eviction. Default configuration uses eviction: Max cache weight limit, 15 minutes expiration after access and entry weight calculation.
      Returns:
      special Cache for caching link provider resources, never null
    • getCacheEntryWeight

      protected int getCacheEntryWeight(org.eclipse.emf.common.util.URI uri, org.eclipse.emf.ecore.resource.Resource resource)
      Calculates the cache entry weight.
      Parameters:
      uri - the URI of resource, cannot be null.
      resource - the loaded resource, cannot be null.
      Returns:
      the cache entry weight, When the weight of an entry is zero it will not be considered for size-based eviction(though it still may be evicted by other means).
      See Also:
      • CacheBuilder.weigher(com.google.common.cache.Weigher)
    • needCacheResource

      protected abstract boolean needCacheResource(org.eclipse.emf.common.util.URI uri)
      Checks that resource creating by this file need to be cached
      Parameters:
      file - IFile corresponding to the creating link provider resources, can't be null
      Returns:
      true if resource should be cached, false otherwise
    • toResourceFileName

      protected String toResourceFileName(org.eclipse.emf.common.util.URI uriTrim)
      Converts uri to valid path to the file of resouce
      Parameters:
      uriTrim - uri of the resource, can't be null
      Returns:
      valid path to the file of resouce, never null
    • onRemoval

      protected void onRemoval(com.google.common.cache.RemovalNotification<org.eclipse.emf.common.util.URI,org.eclipse.emf.ecore.resource.Resource> notification)
      Event of the cache when the entry has removed.
      Parameters:
      notification - the notification of removal, cannot be null.