Class LineToProbesMap
- java.lang.Object
-
- com.oracle.truffle.api.instrument.impl.LineToProbesMap
-
- All Implemented Interfaces:
Probe.ProbeListener
public class LineToProbesMap extends java.lang.Object implements Probe.ProbeListener
A mapping fromLineLocation(a line number in a specific piece ofSourcecode) to a collection ofProbes whose associatedSourceSectionstarts on that line.
-
-
Constructor Summary
Constructors Constructor Description LineToProbesMap()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddProbeToLine(LineLocation line, Probe probe)Records creation of a probe whose associated source starts on the given line.voidendASTProbing(Source source)Notifies that the application of all registeredASTProbers to a newly constructed AST has completed.ProbefindLineProbe(LineLocation lineLocation)Returns theProbe, if any, associated with source that starts on a specified line; if there are more than one, return the one with the first starting character location.voidforget(Source source)java.util.Collection<Probe>getProbesAtLine(LineLocation line)Returns a collection ofProbes whose associated source begins at the givenLineLocation, an empty list if none.java.util.Collection<Probe>getProbesAtLineNumber(int lineNumber)Convenience method to get probes 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, java.lang.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.
-
-
-
Method Detail
-
startASTProbing
public void startASTProbing(Source source)
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
public void newProbeInserted(Probe probe)
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
public void probeTaggedAs(Probe probe, SyntaxTag tag, java.lang.Object tagValue)
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
public void endASTProbing(Source source)
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
-
findLineProbe
public Probe findLineProbe(LineLocation lineLocation)
Returns theProbe, if any, associated with source that starts on a specified line; if there are more than one, return the one with the first starting character location.
-
addProbeToLine
protected void addProbeToLine(LineLocation line, Probe probe)
Records creation of a probe whose associated source starts on the given line.If the line already exists in the internal
lineToProbesMap, this probe 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 probe.This class requires that each added line/probe pair hasn't been previously added. However, attaching the same probe to a new line location is allowed.
- Parameters:
line- TheLineLocationto attach the probe to.probe- TheProbeto attach for that line location.
-
getProbesAtLine
public java.util.Collection<Probe> getProbesAtLine(LineLocation line)
Returns a collection ofProbes whose associated source begins at the givenLineLocation, an empty list if none.- Parameters:
line- The line to check.- Returns:
- A collection of probes at the given line.
-
getProbesAtLineNumber
public java.util.Collection<Probe> getProbesAtLineNumber(int lineNumber)
Convenience method to get probes according to a int line number. Returns a collection ofProbes at the given line number, an empty list if none.- Parameters:
lineNumber- The line number to check.- Returns:
- A collection of probes at the given line.
-
forget
public void forget(Source source)
-
-