Class AbstractTraceRegion
- java.lang.Object
-
- org.eclipse.xtext.generator.trace.AbstractTraceRegion
-
- Direct Known Subclasses:
AbstractStatefulTraceRegion
public abstract class AbstractTraceRegion extends java.lang.Object
Abstract base class for trace regions. Implements theequals(Object)
andhashCode()
contract and delegates some functionality to the parent.
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractTraceRegion(AbstractTraceRegion parent)
Creates a new trace region and adds it to the parent if a parent was given.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected java.util.Map<SourceRelativeURI,java.util.List<org.eclipse.xtext.util.Pair<ILocationData,AbstractTraceRegion>>>
collectMatchingLocations(SourceRelativeURI expectedAssociatedPath)
LocationData
createLocationData(AbstractTraceRegion region, SourceRelativeURI myPath)
boolean
equals(java.lang.Object obj)
Compares the specified object with this region for equality.java.lang.String
getAnnotatedString(java.lang.String input)
abstract java.util.List<ILocationData>
getAssociatedLocations()
SourceRelativeURI
getAssociatedSrcRelativePath()
protected java.util.List<org.eclipse.xtext.util.Pair<ILocationData,AbstractTraceRegion>>
getCollectingList(SourceRelativeURI associatedPath, SourceRelativeURI expectedAssociatedPath, java.util.Map<SourceRelativeURI,java.util.List<org.eclipse.xtext.util.Pair<ILocationData,AbstractTraceRegion>>> listsPerURI)
ILocationData
getMergedAssociatedLocation()
Returns the merged location of all associated locations if they belong to the same resource.abstract int
getMyEndLineNumber()
abstract int
getMyLength()
abstract int
getMyLineNumber()
abstract int
getMyOffset()
org.eclipse.xtext.util.ITextRegionWithLineInformation
getMyRegion()
java.util.List<AbstractTraceRegion>
getNestedRegions()
Returns the nested trace regions.AbstractTraceRegion
getParent()
AbstractTraceRegion
getRoot()
protected java.util.List<AbstractTraceRegion>
getWritableNestedRegions()
int
hashCode()
Returns the hash code value for this region.protected void
inplaceSortByOffset(java.util.List<org.eclipse.xtext.util.Pair<ILocationData,AbstractTraceRegion>> locations)
java.util.Map<SourceRelativeURI,java.util.List<AbstractTraceRegion>>
invertAll(SourceRelativeURI myPath)
java.util.List<AbstractTraceRegion>
invertFor(SourceRelativeURI expectedAssociatedPath, SourceRelativeURI myPath)
protected boolean
isConsistentWithParent()
abstract boolean
isUseForDebugging()
java.util.Iterator<AbstractTraceRegion>
leafIterator()
Returns an iterator that will only offer leaf trace regions.static AbstractTraceRegion
mergedFrom(java.util.List<AbstractTraceRegion> regions)
protected void
setAsChildIn(AbstractTraceRegion parent)
void
setParent(AbstractTraceRegion parent)
Sets the parent (if any) and maintains thenested regions
of the parent.protected java.util.List<AbstractTraceRegion>
toInvertedTraceRegions(java.util.List<org.eclipse.xtext.util.Pair<ILocationData,AbstractTraceRegion>> locations, SourceRelativeURI myPath)
Produces trees from a sorted list of locations.java.lang.String
toString()
org.eclipse.emf.common.util.TreeIterator<AbstractTraceRegion>
treeIterator()
-
-
-
Constructor Detail
-
AbstractTraceRegion
protected AbstractTraceRegion(AbstractTraceRegion parent)
Creates a new trace region and adds it to the parent if a parent was given.
-
-
Method Detail
-
isConsistentWithParent
protected boolean isConsistentWithParent()
-
setParent
public void setParent(AbstractTraceRegion parent)
Sets the parent (if any) and maintains thenested regions
of the parent.- Parameters:
parent
- the parent ornull
if none.- See Also:
setAsChildIn(AbstractTraceRegion)
-
setAsChildIn
protected void setAsChildIn(AbstractTraceRegion parent)
-
getNestedRegions
public final java.util.List<AbstractTraceRegion> getNestedRegions()
Returns the nested trace regions. The list does not necessarily contain all the regions that will be returned by theleafIterator()
.- Returns:
- the list of directly nested regions.
-
getWritableNestedRegions
protected final java.util.List<AbstractTraceRegion> getWritableNestedRegions()
-
invertFor
public java.util.List<AbstractTraceRegion> invertFor(SourceRelativeURI expectedAssociatedPath, SourceRelativeURI myPath)
-
invertAll
public java.util.Map<SourceRelativeURI,java.util.List<AbstractTraceRegion>> invertAll(SourceRelativeURI myPath)
-
collectMatchingLocations
protected java.util.Map<SourceRelativeURI,java.util.List<org.eclipse.xtext.util.Pair<ILocationData,AbstractTraceRegion>>> collectMatchingLocations(SourceRelativeURI expectedAssociatedPath)
-
getCollectingList
protected java.util.List<org.eclipse.xtext.util.Pair<ILocationData,AbstractTraceRegion>> getCollectingList(SourceRelativeURI associatedPath, SourceRelativeURI expectedAssociatedPath, java.util.Map<SourceRelativeURI,java.util.List<org.eclipse.xtext.util.Pair<ILocationData,AbstractTraceRegion>>> listsPerURI)
-
treeIterator
public org.eclipse.emf.common.util.TreeIterator<AbstractTraceRegion> treeIterator()
-
inplaceSortByOffset
protected void inplaceSortByOffset(java.util.List<org.eclipse.xtext.util.Pair<ILocationData,AbstractTraceRegion>> locations)
-
toInvertedTraceRegions
protected java.util.List<AbstractTraceRegion> toInvertedTraceRegions(java.util.List<org.eclipse.xtext.util.Pair<ILocationData,AbstractTraceRegion>> locations, SourceRelativeURI myPath)
Produces trees from a sorted list of locations. If the locations overlap, they'll be splitted automatically to fulfill the contract of invariant of trace regions.
-
mergedFrom
public static AbstractTraceRegion mergedFrom(java.util.List<AbstractTraceRegion> regions)
-
createLocationData
public LocationData createLocationData(AbstractTraceRegion region, SourceRelativeURI myPath)
-
leafIterator
public final java.util.Iterator<AbstractTraceRegion> leafIterator()
Returns an iterator that will only offer leaf trace regions. If the nested regions have gaps, these will be filled with parent data. If this region is a leaf, a singleton iterator will be returned.- Returns:
- an unmodifiable iterator for all leafs. Never
null
.
-
getMyLength
public abstract int getMyLength()
-
getMyOffset
public abstract int getMyOffset()
-
getMyLineNumber
public abstract int getMyLineNumber()
-
getMyEndLineNumber
public abstract int getMyEndLineNumber()
-
getMyRegion
public org.eclipse.xtext.util.ITextRegionWithLineInformation getMyRegion()
-
getAssociatedLocations
public abstract java.util.List<ILocationData> getAssociatedLocations()
-
getMergedAssociatedLocation
public ILocationData getMergedAssociatedLocation()
Returns the merged location of all associated locations if they belong to the same resource. Otherwisenull
is returned.
-
getAssociatedSrcRelativePath
public SourceRelativeURI getAssociatedSrcRelativePath()
-
getParent
public AbstractTraceRegion getParent()
-
getRoot
public AbstractTraceRegion getRoot()
-
getAnnotatedString
public java.lang.String getAnnotatedString(java.lang.String input)
-
isUseForDebugging
public abstract boolean isUseForDebugging()
-
hashCode
public int hashCode()
Returns the hash code value for this region. The hash code of a trace regionr
is defined to be:r.getMyOffset() ^ r.getMyLength() ^ r.getAssociatedOffset() ^ r.getAssociatedLength() ^ (r.getParent() == null ? 0 : r.getParent().hashCode())
This ensures that r1.equals(r2) implies that r1.hashCode()==r2.hashCode() for any twoAbstractTraceRegion
r1 and r2, as required by the general contract of Object.hashCode.- Overrides:
hashCode
in classjava.lang.Object
- Returns:
- the hash code value for this trace region
- See Also:
Object.hashCode()
,Object.equals(Object)
,equals(Object)
-
equals
public boolean equals(java.lang.Object obj)
Compares the specified object with this region for equality. Returnstrue
if the given object is also anAbstractTraceRegion
and the two regions represent the same data. More formally, two regionsr1
andr2
are considered to be equal if(r1.getMyOffset() == r2.getMyOffset()) && (r1.getMyLength() == r2.getMyLength()) && (r1.getAssociatedOffset() == r2.getAssociatedOffset()) && (r1.getAssociatedLength() == r2.getAssociatedLength()) && (r1.getParent() == null ? r2.getParent() == null : r1.getParent().equals(r2.getParent()))
This ensures that theequals(Object)
method works properly across different implementations of theAbstractTraceRegion
interface.- Overrides:
equals
in classjava.lang.Object
- Parameters:
obj
- object to be compared for equality with this trace region- Returns:
- true if the specified object is equal to this trace region
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-