Class LineToSourceSectionMap
- All Implemented Interfaces:
Probe.ProbeListener
LineLocation (a line number in a specific piece of Source code) to
a collection of SourceSections that exist on that line. This class assumes that all nodes
are instrumented as it uses the Probe.ProbeListener interface to determine the source sections
that exist in the file.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddSourceSectionToLine(LineLocation line, SourceSection sourceSection) Adds a source section to the given line.voidendASTProbing(Source source) Notifies that the application of all registeredASTProbers to a newly constructed AST has completed.Returns a collection ofSourceSections at the givenLineLocation, an empty list if none.getSourceSectionsAtLineNumber(int lineNumber) Convenience method to get source sections according to a int line number.voidnewProbeInserted(Probe probe) Notifies that aProbehas been newly attached to an AST viaProbeNode.Instrumentable.probe().voidprobeTaggedAs(Probe probe, SyntaxTag tag, Object tagValue) Notifies that aSyntaxTaghas been newly added to the set of tags associated with aProbeviaProbe.tagAs(SyntaxTag, Object).voidstartASTProbing(Source source) Notifies that all registeredASTProbers are about to be applied to a newly constructed AST.
-
Constructor Details
-
LineToSourceSectionMap
public LineToSourceSectionMap()
-
-
Method Details
-
startASTProbing
Description copied from interface:Probe.ProbeListenerNotifies that all registeredASTProbers are about to be applied to a newly constructed AST.- Specified by:
startASTProbingin interfaceProbe.ProbeListener- Parameters:
source- source code from which the AST was constructed
-
newProbeInserted
Description copied from interface:Probe.ProbeListenerNotifies that aProbehas been newly attached to an AST viaProbeNode.Instrumentable.probe().There can be no more than one
Probeat a node; this notification will only be delivered the first time probe() is called at a particular AST node. There will also be no notification when the AST to which the Probe is attached is cloned.- Specified by:
newProbeInsertedin interfaceProbe.ProbeListener
-
probeTaggedAs
Description copied from interface:Probe.ProbeListenerNotifies that aSyntaxTaghas been newly added to the set of tags associated with aProbeviaProbe.tagAs(SyntaxTag, Object).The tags at a
Probeare a set; this notification will only be delivered the first time a particular tag is added at aProbe.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:
probeTaggedAsin interfaceProbe.ProbeListener- Parameters:
probe- where a tag has been addedtag- 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
Description copied from interface:Probe.ProbeListenerNotifies that the application of all registeredASTProbers to a newly constructed AST has completed.- Specified by:
endASTProbingin interfaceProbe.ProbeListener- Parameters:
source- source code from which the AST was constructed
-
addSourceSectionToLine
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- TheLineLocationto attach the source section to.sourceSection- TheSourceSectionto attach for that line location.
-
getSourceSectionsAtLine
Returns a collection ofSourceSections at the givenLineLocation, an empty list if none.- Parameters:
line- The line to check.- Returns:
- the source sections at the given line.
-
getSourceSectionsAtLineNumber
Convenience method to get source sections according to a int line number. Returns a collection ofSourceSections 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.
-