Class AbstractTrace
- java.lang.Object
-
- org.eclipse.xtext.generator.trace.internal.AbstractTrace
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classAbstractTrace.TraceAccessprotected classAbstractTrace.TraceRegionsByURI
-
Constructor Summary
Constructors Constructor Description AbstractTrace()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected ILocationInResourcecreateLocationInResource(org.eclipse.xtext.util.ITextRegionWithLineInformation region, SourceRelativeURI srcRelativePath)protected ILocationInResourcecreateLocationInResourceFor(ILocationData location, AbstractTraceRegion traceRegion)Creates a new location for a target resource that matches the givenlocation.protected AbstractTraceRegiondoGetRootTraceRegion()booleanencloses(int regionOffset, int regionLength, int offset, boolean includeRegionEnd)Calculate whether the givenregionencloses the offset.booleanencloses(AbstractTraceRegion region, int offset, boolean includeRegionEnd)Calculate whether the givenregionencloses the offset.protected LanguageInfofindLanguage(AbstractURIWrapper uri)protected AbstractTraceRegionfindParentByURI(AbstractTraceRegion region, AbsoluteURI uri, IProjectConfig project)protected AbstractTraceRegionfindTraceRegionAt(int offset, boolean includeRegionEnd)AbstractTraceRegionfindTraceRegionAtLeftOffset(int offset)AbstractTraceRegionfindTraceRegionAtRightOffset(int offset)java.lang.Iterable<? extends ILocationInResource>getAllAssociatedLocations()Returns all known associatedlocations.java.lang.Iterable<? extends ILocationInResource>getAllAssociatedLocations(AbsoluteURI uri)Returns all knownlocationsthat were produced from the associated resource in the givenabsoluteTargetResource.java.lang.Iterable<? extends ILocationInResource>getAllAssociatedLocations(org.eclipse.xtext.util.ITextRegion localRegion)Returns all associatedlocationsthat match the givenregion.java.lang.Iterable<? extends ILocationInResource>getAllAssociatedLocations(org.eclipse.xtext.util.ITextRegion localRegion, AbsoluteURI uri)Returns all individuallocationsthat match the givenlocalRegionfor the expectedabsoluteTargetResource.protected java.lang.Iterable<AbstractTraceRegion>getAllTraceRegions()protected java.lang.Iterable<AbstractTraceRegion>getAllTraceRegions(org.eclipse.xtext.util.ITextRegion localRegion)ILocationInResourcegetBestAssociatedLocation(org.eclipse.xtext.util.ITextRegion region)Returns the best associatedlocationthat matches the givenregion.ILocationInResourcegetBestAssociatedLocation(org.eclipse.xtext.util.ITextRegion localRegion, AbsoluteURI uri)protected abstract java.io.InputStreamgetContents(SourceRelativeURI uri)protected abstract java.io.ReadergetContentsAsText(SourceRelativeURI uri)protected abstract java.io.ReadergetLocalContentsAsText()LanguageInfogetLocalLanguage()Returns the language that is associated with the local resource.abstract IProjectConfiggetLocalProjectConfig()Returns the local project.abstract AbsoluteURIgetLocalURI()Returns the absolute URI of the local resource.protected ILocationInResourcegetMergedLocationInResource(AbstractTraceRegion region)AbstractTraceRegiongetRootTraceRegion()Returns the root trace region whereAbstractStatefulTraceRegion.getMyOffset()andAbstractStatefulTraceRegion.getMyLength()return the information for the resource that thisITraceis associated with.protected <T> TgetService(AbstractURIWrapper uri, java.lang.Class<T> type)SourceRelativeURIgetSrcRelativeLocalURI()Returns the relative URI of the local resource.protected ITraceRegionProvidergetTraceRegionProvider()booleanhasTraceData()Returns true if the trace is not empty and can provide at leat one location.protected booleanisAssociatedWith(AbstractTraceRegion region, AbsoluteURI uri, IProjectConfig project)booleanisTraceToSource()booleanisTraceToTarget()protected ILocationInResourcemergeRegions(AbstractTraceRegion left, AbstractTraceRegion right)protected AbsoluteURIresolvePath(SourceRelativeURI path)voidsetTraceRegionProvider(ITraceRegionProvider traceRegionProvider)voidsetTraceToSource(boolean isTraceToSource)protected java.lang.Iterable<? extends ILocationInResource>toLocations(java.lang.Iterable<AbstractTraceRegion> allTraceRegions)java.lang.StringtoString()
-
-
-
Method Detail
-
getRootTraceRegion
public final AbstractTraceRegion getRootTraceRegion()
Returns the root trace region whereAbstractStatefulTraceRegion.getMyOffset()andAbstractStatefulTraceRegion.getMyLength()return the information for the resource that thisITraceis associated with.- Returns:
- the root trace region. May be
nullif no trace data is available.
-
hasTraceData
public boolean hasTraceData()
Description copied from interface:ITraceReturns true if the trace is not empty and can provide at leat one location.- Specified by:
hasTraceDatain interfaceITrace
-
setTraceToSource
public void setTraceToSource(boolean isTraceToSource)
-
isTraceToSource
public boolean isTraceToSource()
-
isTraceToTarget
public boolean isTraceToTarget()
-
doGetRootTraceRegion
protected AbstractTraceRegion doGetRootTraceRegion()
-
setTraceRegionProvider
public void setTraceRegionProvider(ITraceRegionProvider traceRegionProvider)
-
getTraceRegionProvider
protected ITraceRegionProvider getTraceRegionProvider()
-
getBestAssociatedLocation
public ILocationInResource getBestAssociatedLocation(org.eclipse.xtext.util.ITextRegion region)
Description copied from interface:ITraceReturns the best associatedlocationthat matches the givenregion. If the region does not match a single location, the following strategy applies:- If the region spans multiple locations where the first and the last location belong to the same resource, the merged location is returned.
- If the region spans multiple locations that belong to different resources, the longest prefix location for a single resource is returned.
-
If the region spans multiple overlapping locations that belong to different resources,
nullis returned.
null.- Specified by:
getBestAssociatedLocationin interfaceITrace- Parameters:
region- the region in the current resource. May not benull.- Returns:
- the best associated location or
nullif none.
-
mergeRegions
protected ILocationInResource mergeRegions(AbstractTraceRegion left, AbstractTraceRegion right)
-
createLocationInResource
protected ILocationInResource createLocationInResource(org.eclipse.xtext.util.ITextRegionWithLineInformation region, SourceRelativeURI srcRelativePath)
-
getMergedLocationInResource
protected ILocationInResource getMergedLocationInResource(AbstractTraceRegion region)
-
createLocationInResourceFor
protected ILocationInResource createLocationInResourceFor(ILocationData location, AbstractTraceRegion traceRegion)
Creates a new location for a target resource that matches the givenlocation.- Parameters:
location- the location- Returns:
- the location in resource,
nulldetecting a path fails.
-
resolvePath
protected AbsoluteURI resolvePath(SourceRelativeURI path)
-
findTraceRegionAtRightOffset
public AbstractTraceRegion findTraceRegionAtRightOffset(int offset)
-
findTraceRegionAt
protected AbstractTraceRegion findTraceRegionAt(int offset, boolean includeRegionEnd)
-
findTraceRegionAtLeftOffset
public AbstractTraceRegion findTraceRegionAtLeftOffset(int offset)
-
encloses
public boolean encloses(AbstractTraceRegion region, int offset, boolean includeRegionEnd)
Calculate whether the givenregionencloses the offset.- Parameters:
region- the region to be checked. May not benull.offset- the offset that should be enclosed by the region.includeRegionEnd- whether a region is enclosing the offset if it ends at that location.- Returns:
true if the given region encloses the offset.
-
encloses
public boolean encloses(int regionOffset, int regionLength, int offset, boolean includeRegionEnd)Calculate whether the givenregionencloses the offset.- Parameters:
regionOffset- the start of the region that should be checked.regionLength- the length of the region that should be checked.offset- the offset that should be enclosed by the region.includeRegionEnd- whether a region is enclosing the offset if it ends at that location.- Returns:
true if the given region encloses the offset.- Noreference:
- This method is not intended to be referenced by clients.
- Nooverride:
- This method is not intended to be re-implemented or extended by clients.
-
getAllAssociatedLocations
public java.lang.Iterable<? extends ILocationInResource> getAllAssociatedLocations(org.eclipse.xtext.util.ITextRegion localRegion)
Description copied from interface:ITraceReturns all associatedlocationsthat match the givenregion.- Specified by:
getAllAssociatedLocationsin interfaceITrace- Parameters:
localRegion- the region in the current resource. May not benull.- Returns:
- all associated locations. Never
null.
-
getBestAssociatedLocation
public ILocationInResource getBestAssociatedLocation(org.eclipse.xtext.util.ITextRegion localRegion, AbsoluteURI uri)
Description copied from interface:ITraceReturns the bestlocationthat matches the givenlocalRegionin theabsoluteTargetResource. If the region does not match a single location in the target, the following strategy applies:-
The merged region of all matching locations in the
targetResourceis returned.
localRegiondoes not yield a location inabsoluteTargetResource, returnsnull.- Specified by:
getBestAssociatedLocationin interfaceITrace- Parameters:
localRegion- the region in the current resource. May not benull.uri- the expected target resource. May not benull.- Returns:
- the best associated location or
nullif none.
-
The merged region of all matching locations in the
-
isAssociatedWith
protected boolean isAssociatedWith(AbstractTraceRegion region, AbsoluteURI uri, IProjectConfig project)
-
findParentByURI
protected AbstractTraceRegion findParentByURI(AbstractTraceRegion region, AbsoluteURI uri, IProjectConfig project)
-
getAllAssociatedLocations
public java.lang.Iterable<? extends ILocationInResource> getAllAssociatedLocations(org.eclipse.xtext.util.ITextRegion localRegion, AbsoluteURI uri)
Description copied from interface:ITraceReturns all individuallocationsthat match the givenlocalRegionfor the expectedabsoluteTargetResource.- Specified by:
getAllAssociatedLocationsin interfaceITrace- Parameters:
localRegion- the region in the current resource. May not benull.uri- the expected target resource. May not benull.- Returns:
- all associated locations. Never
null.
-
getAllAssociatedLocations
public java.lang.Iterable<? extends ILocationInResource> getAllAssociatedLocations(AbsoluteURI uri)
Description copied from interface:ITraceReturns all knownlocationsthat were produced from the associated resource in the givenabsoluteTargetResource.- Specified by:
getAllAssociatedLocationsin interfaceITrace- Parameters:
uri- the expected target resource. May not benull.- Returns:
- all locations. Never
null.
-
getLocalLanguage
public LanguageInfo getLocalLanguage()
Description copied from interface:ITraceReturns the language that is associated with the local resource. May benullif the artifact does not have an associated Xtext language, e.g. for html or java files.- Specified by:
getLocalLanguagein interfaceITrace- Returns:
- the language that is associated with the local resource. May be
null.
-
getLocalURI
public abstract AbsoluteURI getLocalURI()
Description copied from interface:ITraceReturns the absolute URI of the local resource. Nevernull.- Specified by:
getLocalURIin interfaceITrace- Returns:
- the absolute URI of the local resource. Never
null.
-
getSrcRelativeLocalURI
public SourceRelativeURI getSrcRelativeLocalURI()
Description copied from interface:ITraceReturns the relative URI of the local resource. Nevernull. In other words: returns the URI as it would be relative to the class path after the resource was packaged. If the resource resides in a source folder of a java project, it'll return the URI relative to the source folder itself. Otherwise relative to the project root.- Specified by:
getSrcRelativeLocalURIin interfaceITrace- Returns:
- the relative URI of the local resource. Never
null.
-
getLocalProjectConfig
public abstract IProjectConfig getLocalProjectConfig()
Description copied from interface:ITraceReturns the local project. Nevernull.- Specified by:
getLocalProjectConfigin interfaceITrace- Returns:
- the local project. Never
null.
-
toLocations
protected java.lang.Iterable<? extends ILocationInResource> toLocations(java.lang.Iterable<AbstractTraceRegion> allTraceRegions)
-
getAllTraceRegions
protected java.lang.Iterable<AbstractTraceRegion> getAllTraceRegions(org.eclipse.xtext.util.ITextRegion localRegion)
-
getAllAssociatedLocations
public java.lang.Iterable<? extends ILocationInResource> getAllAssociatedLocations()
Description copied from interface:ITraceReturns all known associatedlocations.- Specified by:
getAllAssociatedLocationsin interfaceITrace- Returns:
- all associated locations. Never
null.
-
getAllTraceRegions
protected java.lang.Iterable<AbstractTraceRegion> getAllTraceRegions()
-
getContents
protected abstract java.io.InputStream getContents(SourceRelativeURI uri) throws java.io.IOException
- Throws:
java.io.IOException
-
getContentsAsText
protected abstract java.io.Reader getContentsAsText(SourceRelativeURI uri) throws java.io.IOException
- Throws:
java.io.IOException
-
getLocalContentsAsText
protected abstract java.io.Reader getLocalContentsAsText() throws java.io.IOException- Throws:
java.io.IOException
-
findLanguage
protected LanguageInfo findLanguage(AbstractURIWrapper uri)
-
getService
protected <T> T getService(AbstractURIWrapper uri, java.lang.Class<T> type)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-