public abstract class AbstractTrace extends java.lang.Object implements ITrace
Modifier and Type | Class and Description |
---|---|
protected static class |
AbstractTrace.TraceAccess |
protected class |
AbstractTrace.TraceRegionsByURI |
Constructor and Description |
---|
AbstractTrace() |
Modifier and Type | Method and Description |
---|---|
protected ILocationInResource |
createLocationInResource(ITextRegionWithLineInformation region,
SourceRelativeURI srcRelativePath) |
protected ILocationInResource |
createLocationInResourceFor(ILocationData location,
AbstractTraceRegion traceRegion)
Creates a new location for a target resource that matches the given
location . |
protected AbstractTraceRegion |
doGetRootTraceRegion() |
boolean |
encloses(AbstractTraceRegion region,
int offset,
boolean includeRegionEnd)
Calculate whether the given
region encloses the offset. |
boolean |
encloses(int regionOffset,
int regionLength,
int offset,
boolean includeRegionEnd)
Calculate whether the given
region encloses the offset. |
protected LanguageInfo |
findLanguage(AbstractURIWrapper uri) |
protected AbstractTraceRegion |
findParentByURI(AbstractTraceRegion region,
AbsoluteURI uri,
IProjectConfig project) |
protected AbstractTraceRegion |
findTraceRegionAt(int offset,
boolean includeRegionEnd) |
AbstractTraceRegion |
findTraceRegionAtLeftOffset(int offset) |
AbstractTraceRegion |
findTraceRegionAtRightOffset(int offset) |
java.lang.Iterable<? extends ILocationInResource> |
getAllAssociatedLocations()
Returns all known associated
locations . |
java.lang.Iterable<? extends ILocationInResource> |
getAllAssociatedLocations(AbsoluteURI uri)
Returns all known
locations that were produced from the associated resource in the
given absoluteTargetResource . |
java.lang.Iterable<? extends ILocationInResource> |
getAllAssociatedLocations(ITextRegion localRegion)
Returns all associated
locations that match the given region . |
java.lang.Iterable<? extends ILocationInResource> |
getAllAssociatedLocations(ITextRegion localRegion,
AbsoluteURI uri)
Returns all individual
locations that match the given localRegion
for the expected absoluteTargetResource . |
protected java.lang.Iterable<AbstractTraceRegion> |
getAllTraceRegions() |
protected java.lang.Iterable<AbstractTraceRegion> |
getAllTraceRegions(ITextRegion localRegion) |
ILocationInResource |
getBestAssociatedLocation(ITextRegion region)
Returns the best associated
location that matches the given region . |
ILocationInResource |
getBestAssociatedLocation(ITextRegion localRegion,
AbsoluteURI uri)
|
protected abstract java.io.InputStream |
getContents(SourceRelativeURI uri) |
protected abstract java.io.Reader |
getContentsAsText(SourceRelativeURI uri) |
protected abstract java.io.Reader |
getLocalContentsAsText() |
LanguageInfo |
getLocalLanguage()
Returns the language that is associated with the local resource.
|
abstract IProjectConfig |
getLocalProjectConfig()
Returns the local project.
|
abstract AbsoluteURI |
getLocalURI()
Returns the absolute URI of the local resource.
|
protected ILocationInResource |
getMergedLocationInResource(AbstractTraceRegion region) |
AbstractTraceRegion |
getRootTraceRegion()
Returns the root trace region where
AbstractStatefulTraceRegion.getMyOffset() and
AbstractStatefulTraceRegion.getMyLength() return the information for the
resource that this ITrace is associated with. |
protected <T> T |
getService(AbstractURIWrapper uri,
java.lang.Class<T> type) |
SourceRelativeURI |
getSrcRelativeLocalURI()
Returns the relative URI of the local resource.
|
protected ITraceRegionProvider |
getTraceRegionProvider() |
boolean |
hasTraceData()
Returns true if the trace is not empty and can provide at leat one location.
|
protected boolean |
isAssociatedWith(AbstractTraceRegion region,
AbsoluteURI uri,
IProjectConfig project) |
boolean |
isTraceToSource() |
boolean |
isTraceToTarget() |
protected ILocationInResource |
mergeRegions(AbstractTraceRegion left,
AbstractTraceRegion right) |
protected AbsoluteURI |
resolvePath(SourceRelativeURI path) |
void |
setTraceRegionProvider(ITraceRegionProvider traceRegionProvider) |
void |
setTraceToSource(boolean isTraceToSource) |
protected java.lang.Iterable<? extends ILocationInResource> |
toLocations(java.lang.Iterable<AbstractTraceRegion> allTraceRegions) |
java.lang.String |
toString() |
public final AbstractTraceRegion getRootTraceRegion()
AbstractStatefulTraceRegion.getMyOffset()
and
AbstractStatefulTraceRegion.getMyLength()
return the information for the
resource that this ITrace
is associated with.null
if no trace data is available.public boolean hasTraceData()
ITrace
hasTraceData
in interface ITrace
public void setTraceToSource(boolean isTraceToSource)
public boolean isTraceToSource()
public boolean isTraceToTarget()
protected AbstractTraceRegion doGetRootTraceRegion()
public void setTraceRegionProvider(ITraceRegionProvider traceRegionProvider)
protected ITraceRegionProvider getTraceRegionProvider()
public ILocationInResource getBestAssociatedLocation(ITextRegion region)
ITrace
location
that matches the given region
.
If the region does not match a single location, the following strategy applies:
null
is returned.
null
.getBestAssociatedLocation
in interface ITrace
region
- the region in the current resource. May not be null
.null
if none.protected ILocationInResource mergeRegions(AbstractTraceRegion left, AbstractTraceRegion right)
protected ILocationInResource createLocationInResource(ITextRegionWithLineInformation region, SourceRelativeURI srcRelativePath)
protected ILocationInResource getMergedLocationInResource(AbstractTraceRegion region)
protected ILocationInResource createLocationInResourceFor(ILocationData location, AbstractTraceRegion traceRegion)
location
.location
- the locationnull
detecting a path fails.protected AbsoluteURI resolvePath(SourceRelativeURI path)
public AbstractTraceRegion findTraceRegionAtRightOffset(int offset)
protected AbstractTraceRegion findTraceRegionAt(int offset, boolean includeRegionEnd)
public AbstractTraceRegion findTraceRegionAtLeftOffset(int offset)
public boolean encloses(AbstractTraceRegion region, int offset, boolean includeRegionEnd)
region
encloses the offset.region
- the region to be checked. May not be null
.offset
- the offset that should be enclosed by the region.includeRegionEnd
- whether a region is enclosing the offset if it ends at that location.true if the given region encloses the offset.
public boolean encloses(int regionOffset, int regionLength, int offset, boolean includeRegionEnd)
region
encloses the offset.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.true if the given region encloses the offset.
public java.lang.Iterable<? extends ILocationInResource> getAllAssociatedLocations(ITextRegion localRegion)
ITrace
locations
that match the given region
.getAllAssociatedLocations
in interface ITrace
localRegion
- the region in the current resource. May not be null
.null
.public ILocationInResource getBestAssociatedLocation(ITextRegion localRegion, AbsoluteURI uri)
ITrace
location
that matches the given
localRegion
in the absoluteTargetResource
.
If the region does not match a single location in the target, the following strategy applies:
targetResource
is returned.
localRegion
does not yield
a location in absoluteTargetResource
, returns null
.getBestAssociatedLocation
in interface ITrace
localRegion
- the region in the current resource. May not be null
.uri
- the expected target resource. May not be null
.null
if none.protected boolean isAssociatedWith(AbstractTraceRegion region, AbsoluteURI uri, IProjectConfig project)
protected AbstractTraceRegion findParentByURI(AbstractTraceRegion region, AbsoluteURI uri, IProjectConfig project)
public java.lang.Iterable<? extends ILocationInResource> getAllAssociatedLocations(ITextRegion localRegion, AbsoluteURI uri)
ITrace
locations
that match the given localRegion
for the expected absoluteTargetResource
.getAllAssociatedLocations
in interface ITrace
localRegion
- the region in the current resource. May not be null
.uri
- the expected target resource. May not be null
.null
.public java.lang.Iterable<? extends ILocationInResource> getAllAssociatedLocations(AbsoluteURI uri)
ITrace
locations
that were produced from the associated resource in the
given absoluteTargetResource
.getAllAssociatedLocations
in interface ITrace
uri
- the expected target resource. May not be null
.null
.public LanguageInfo getLocalLanguage()
ITrace
null
if the artifact does not have an associated Xtext language, e.g. for html or java files.getLocalLanguage
in interface ITrace
null
.public abstract AbsoluteURI getLocalURI()
ITrace
null
.getLocalURI
in interface ITrace
null
.public SourceRelativeURI getSrcRelativeLocalURI()
ITrace
null
.
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.getSrcRelativeLocalURI
in interface ITrace
null
.public abstract IProjectConfig getLocalProjectConfig()
ITrace
null
.getLocalProjectConfig
in interface ITrace
null
.protected java.lang.Iterable<? extends ILocationInResource> toLocations(java.lang.Iterable<AbstractTraceRegion> allTraceRegions)
protected java.lang.Iterable<AbstractTraceRegion> getAllTraceRegions(ITextRegion localRegion)
public java.lang.Iterable<? extends ILocationInResource> getAllAssociatedLocations()
ITrace
locations
.getAllAssociatedLocations
in interface ITrace
null
.protected java.lang.Iterable<AbstractTraceRegion> getAllTraceRegions()
protected abstract java.io.InputStream getContents(SourceRelativeURI uri) throws java.io.IOException
java.io.IOException
protected abstract java.io.Reader getContentsAsText(SourceRelativeURI uri) throws java.io.IOException
java.io.IOException
protected abstract java.io.Reader getLocalContentsAsText() throws java.io.IOException
java.io.IOException
protected LanguageInfo findLanguage(AbstractURIWrapper uri)
protected <T> T getService(AbstractURIWrapper uri, java.lang.Class<T> type)
public java.lang.String toString()
toString
in class java.lang.Object