Package com._1c.g5.v8.dt.bm.xtext
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
SpecialIBmLinkProvider
for xtext resources
-
-
Field Summary
Fields Modifier and Type Field Description protected String
extension
protected BmAwareResourceSetProvider
resourceSetProvider
-
Constructor Summary
Constructors Constructor Description XtextBmLinkProvider()
Constructor
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods 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 notvoid
cleanUp()
Performs any pending maintenance operations needed by the cache.void
clear()
Clearing all containing resourcesprotected com.google.common.cache.Cache<org.eclipse.emf.common.util.URI,org.eclipse.emf.ecore.resource.Resource>
createCache()
Creates specialCache
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 uriprotected abstract boolean
fileExist(org.eclipse.emf.common.util.URI uriTrim)
Checks that file for reading content of the resource existprotected 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 byURI
.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 resourceboolean
isPassthrough()
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 withuri
was loaded earlierprotected 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 thisfile
need to be cachedprotected 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 uriboolean
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 resoucevoid
update(org.eclipse.emf.ecore.resource.Resource resource)
Updates caching resource
-
-
-
Field Detail
-
extension
@Inject protected String extension
-
resourceSetProvider
@Inject protected BmAwareResourceSetProvider resourceSetProvider
-
-
Method Detail
-
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 benull
-
update
public void update(org.eclipse.emf.ecore.resource.Resource resource)
Updates caching resource- Parameters:
resource
- new resource for caching, can't benull
-
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 interfaceIBmExternalUriResolver
- Parameters:
uri
- The resource URI. May not benull
- 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 interfaceIBmExternalUriResolver
- 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 withuri
was loaded earlier- Parameters:
uri
- checking resource uri, can't benull
- 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 interfaceIBmExternalUriResolver
- Parameters:
uri
- The URI to run the check against. May not benull
.- Returns:
true
if the URI is supported by this resolver, otherwisefalse
.
-
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 interfaceIBmExternalUriResolver
- Parameters:
uri
- The URI. May not benull
.- Returns:
- the object identified by the specified URI if found, otherwise
null
.
-
getProject
protected org.eclipse.core.resources.IProject getProject(org.eclipse.emf.common.util.URI uri)
Gets project byURI
. SeeIResourceLookup.getProject(URI)
- Parameters:
uri
- the object URI, cannot benull
- 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 benull
loadedResource
- loaded resource, can't benull
- Returns:
- new loaded resource if needed or
loadedResouce
, nevernull
-
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 benull
.- 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 benull
uriTrim
- uri of the resource, can't benull
- 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 benull
- 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 benull
-
createCache
protected com.google.common.cache.Cache<org.eclipse.emf.common.util.URI,org.eclipse.emf.ecore.resource.Resource> createCache()
Creates specialCache
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, nevernull
-
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 benull
.resource
- the loaded resource, cannot benull
.- 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 thisfile
need to be cached- Parameters:
file
-IFile
corresponding to the creating link provider resources, can't benull
- 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 benull
- 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 benull
.
-
-