Class AbstractTraceRegion
- java.lang.Object
-
- org.eclipse.xtext.generator.trace.AbstractTraceRegion
-
- Direct Known Subclasses:
AbstractStatefulTraceRegion
public abstract class AbstractTraceRegion extends java.lang.ObjectAbstract base class for trace regions. Implements theequals(Object)andhashCode()contract and delegates some functionality to the parent.
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractTraceRegion(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)LocationDatacreateLocationData(AbstractTraceRegion region, SourceRelativeURI myPath)booleanequals(java.lang.Object obj)Compares the specified object with this region for equality.java.lang.StringgetAnnotatedString(java.lang.String input)abstract java.util.List<ILocationData>getAssociatedLocations()SourceRelativeURIgetAssociatedSrcRelativePath()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)ILocationDatagetMergedAssociatedLocation()Returns the merged location of all associated locations if they belong to the same resource.abstract intgetMyEndLineNumber()abstract intgetMyLength()abstract intgetMyLineNumber()abstract intgetMyOffset()org.eclipse.xtext.util.ITextRegionWithLineInformationgetMyRegion()java.util.List<AbstractTraceRegion>getNestedRegions()Returns the nested trace regions.AbstractTraceRegiongetParent()AbstractTraceRegiongetRoot()protected java.util.List<AbstractTraceRegion>getWritableNestedRegions()inthashCode()Returns the hash code value for this region.protected voidinplaceSortByOffset(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 booleanisConsistentWithParent()abstract booleanisUseForDebugging()java.util.Iterator<AbstractTraceRegion>leafIterator()Returns an iterator that will only offer leaf trace regions.static AbstractTraceRegionmergedFrom(java.util.List<AbstractTraceRegion> regions)protected voidsetAsChildIn(AbstractTraceRegion parent)voidsetParent(AbstractTraceRegion parent)Sets the parent (if any) and maintains thenested regionsof 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.StringtoString()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 regionsof the parent.- Parameters:
parent- the parent ornullif 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. Otherwisenullis 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 regionris 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 twoAbstractTraceRegionr1 and r2, as required by the general contract of Object.hashCode.- Overrides:
hashCodein 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. Returnstrueif the given object is also anAbstractTraceRegionand the two regions represent the same data. More formally, two regionsr1andr2are 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 theAbstractTraceRegioninterface.- Overrides:
equalsin 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:
toStringin classjava.lang.Object
-
-