Class AbstractTrace

  • All Implemented Interfaces:
    ITrace

    public abstract class AbstractTrace
    extends java.lang.Object
    implements ITrace
    • Constructor Detail

      • AbstractTrace

        public AbstractTrace()
    • Method Detail

      • hasTraceData

        public boolean hasTraceData()
        Description copied from interface: ITrace
        Returns true if the trace is not empty and can provide at leat one location.
        Specified by:
        hasTraceData in interface ITrace
      • setTraceToSource

        public void setTraceToSource​(boolean isTraceToSource)
      • isTraceToSource

        public boolean isTraceToSource()
      • isTraceToTarget

        public boolean isTraceToTarget()
      • setTraceRegionProvider

        public void setTraceRegionProvider​(ITraceRegionProvider traceRegionProvider)
      • getBestAssociatedLocation

        public ILocationInResource getBestAssociatedLocation​(org.eclipse.xtext.util.ITextRegion region)
        Description copied from interface: ITrace
        Returns the best associated location that matches the given region. 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, null is returned.
        If no location data is available, returns null.
        Specified by:
        getBestAssociatedLocation in interface ITrace
        Parameters:
        region - the region in the current resource. May not be null.
        Returns:
        the best associated location or null if none.
      • createLocationInResource

        protected ILocationInResource createLocationInResource​(org.eclipse.xtext.util.ITextRegionWithLineInformation region,
                                                               SourceRelativeURI srcRelativePath)
      • createLocationInResourceFor

        protected ILocationInResource createLocationInResourceFor​(ILocationData location,
                                                                  AbstractTraceRegion traceRegion)
        Creates a new location for a target resource that matches the given location.
        Parameters:
        location - the location
        Returns:
        the location in resource, null detecting a path fails.
      • 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 given region encloses the offset.
        Parameters:
        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.
        Returns:
        true if the given region encloses the offset.
      • encloses

        public boolean encloses​(int regionOffset,
                                int regionLength,
                                int offset,
                                boolean includeRegionEnd)
        Calculate whether the given region encloses 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: ITrace
        Returns all associated locations that match the given region.
        Specified by:
        getAllAssociatedLocations in interface ITrace
        Parameters:
        localRegion - the region in the current resource. May not be null.
        Returns:
        all associated locations. Never null.
      • getBestAssociatedLocation

        public ILocationInResource getBestAssociatedLocation​(org.eclipse.xtext.util.ITextRegion localRegion,
                                                             AbsoluteURI uri)
        Description copied from interface: ITrace
        Returns the best 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:
        • The merged region of all matching locations in the targetResource is returned.
        If no location data is available or the localRegion does not yield a location in absoluteTargetResource, returns null.
        Specified by:
        getBestAssociatedLocation in interface ITrace
        Parameters:
        localRegion - the region in the current resource. May not be null.
        uri - the expected target resource. May not be null.
        Returns:
        the best associated location or null if none.
      • getAllAssociatedLocations

        public java.lang.Iterable<? extends ILocationInResource> getAllAssociatedLocations​(org.eclipse.xtext.util.ITextRegion localRegion,
                                                                                           AbsoluteURI uri)
        Description copied from interface: ITrace
        Returns all individual locations that match the given localRegion for the expected absoluteTargetResource.
        Specified by:
        getAllAssociatedLocations in interface ITrace
        Parameters:
        localRegion - the region in the current resource. May not be null.
        uri - the expected target resource. May not be null.
        Returns:
        all associated locations. Never null.
      • getAllAssociatedLocations

        public java.lang.Iterable<? extends ILocationInResource> getAllAssociatedLocations​(AbsoluteURI uri)
        Description copied from interface: ITrace
        Returns all known locations that were produced from the associated resource in the given absoluteTargetResource.
        Specified by:
        getAllAssociatedLocations in interface ITrace
        Parameters:
        uri - the expected target resource. May not be null.
        Returns:
        all locations. Never null.
      • getLocalLanguage

        public LanguageInfo getLocalLanguage()
        Description copied from interface: ITrace
        Returns the language that is associated with the local resource. May be null if the artifact does not have an associated Xtext language, e.g. for html or java files.
        Specified by:
        getLocalLanguage in interface ITrace
        Returns:
        the language that is associated with the local resource. May be null.
      • getLocalURI

        public abstract AbsoluteURI getLocalURI()
        Description copied from interface: ITrace
        Returns the absolute URI of the local resource. Never null.
        Specified by:
        getLocalURI in interface ITrace
        Returns:
        the absolute URI of the local resource. Never null.
      • getSrcRelativeLocalURI

        public SourceRelativeURI getSrcRelativeLocalURI()
        Description copied from interface: ITrace
        Returns the relative URI of the local resource. Never 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.
        Specified by:
        getSrcRelativeLocalURI in interface ITrace
        Returns:
        the relative URI of the local resource. Never null.
      • getLocalProjectConfig

        public abstract IProjectConfig getLocalProjectConfig()
        Description copied from interface: ITrace
        Returns the local project. Never null.
        Specified by:
        getLocalProjectConfig in interface ITrace
        Returns:
        the local project. Never null.
      • getAllTraceRegions

        protected java.lang.Iterable<AbstractTraceRegion> getAllTraceRegions​(org.eclipse.xtext.util.ITextRegion localRegion)
      • 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
      • getService

        protected <T> T getService​(AbstractURIWrapper uri,
                                   java.lang.Class<T> type)
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object