Class LineToSourceSectionMap

    • Constructor Detail

      • LineToSourceSectionMap

        public LineToSourceSectionMap()
    • Method Detail

      • startASTProbing

        public void startASTProbing​(Source source)
        Description copied from interface: Probe.ProbeListener
        Notifies that all registered ASTProbers are about to be applied to a newly constructed AST.
        Specified by:
        startASTProbing in interface Probe.ProbeListener
        Parameters:
        source - source code from which the AST was constructed
      • probeTaggedAs

        public void probeTaggedAs​(Probe probe,
                                  SyntaxTag tag,
                                  java.lang.Object tagValue)
        Description copied from interface: Probe.ProbeListener
        Notifies that a SyntaxTag has been newly added to the set of tags associated with a Probe via Probe.tagAs(SyntaxTag, Object).

        The tags at a Probe are a set; this notification will only be delivered the first time a particular tag is added at a Probe.

        An optional value supplied with tagAs(SyntaxTag, Object) is reported to all listeners, but not stored. As a consequence, the optional value will have no effect at all if the tag had already been added.

        Specified by:
        probeTaggedAs in interface Probe.ProbeListener
        Parameters:
        probe - where a tag has been added
        tag - the tag that has been newly added (subsequent additions of the tag are unreported).
        tagValue - an optional value associated with the tag for the purposes of reporting.
      • endASTProbing

        public void endASTProbing​(Source source)
        Description copied from interface: Probe.ProbeListener
        Notifies that the application of all registered ASTProbers to a newly constructed AST has completed.
        Specified by:
        endASTProbing in interface Probe.ProbeListener
        Parameters:
        source - source code from which the AST was constructed
      • addSourceSectionToLine

        protected void addSourceSectionToLine​(LineLocation line,
                                              SourceSection sourceSection)
        Adds a source section to the given line.

        If the line already exists in the internal lineToSourceSectionsMap, this source section will be added to the existing collection. If no line already exists in the internal map, then a new key is added along with a new collection containing the source section.

        This class does not check if a source section has already been added to a line.

        Parameters:
        line - The LineLocation to attach the source section to.
        sourceSection - The SourceSection to attach for that line location.
      • getSourceSectionsAtLine

        public java.util.Collection<SourceSection> getSourceSectionsAtLine​(LineLocation line)
        Returns a collection of SourceSections at the given LineLocation, an empty list if none.
        Parameters:
        line - The line to check.
        Returns:
        the source sections at the given line.
      • getSourceSectionsAtLineNumber

        public java.util.Collection<SourceSection> getSourceSectionsAtLineNumber​(int lineNumber)
        Convenience method to get source sections according to a int line number. Returns a collection of SourceSections at the given line number. If there are no source sections at that line, an empty list is returned.
        Parameters:
        lineNumber - The line number to check.
        Returns:
        A collection of source sections at the given line.