Class AbstractTraceRegion

  • Direct Known Subclasses:
    AbstractStatefulTraceRegion

    public abstract class AbstractTraceRegion
    extends java.lang.Object
    Abstract base class for trace regions. Implements the equals(Object) and hashCode() contract and delegates some functionality to the parent.
    • 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()
      • 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 the leafIterator().
        Returns:
        the list of directly nested regions.
      • getWritableNestedRegions

        protected final java.util.List<AbstractTraceRegion> getWritableNestedRegions()
      • treeIterator

        public org.eclipse.emf.common.util.TreeIterator<AbstractTraceRegion> treeIterator()
      • 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.
      • 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. Otherwise null is returned.
      • getAssociatedSrcRelativePath

        public SourceRelativeURI getAssociatedSrcRelativePath()
      • 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 region r 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 two AbstractTraceRegion r1 and r2, as required by the general contract of Object.hashCode.
        Overrides:
        hashCode in class java.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. Returns true if the given object is also an AbstractTraceRegion and the two regions represent the same data. More formally, two regions r1 and r2 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 the equals(Object) method works properly across different implementations of the AbstractTraceRegion interface.
        Overrides:
        equals in class java.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 class java.lang.Object