/** * Factory method for creating a source line annotation describing the * source line number for the instruction being visited by given visitor. * * @param classContext * the ClassContext * @param visitor * a BetterVisitor which is visiting the method * @param pc * the bytecode offset of the instruction in the method * @return the SourceLineAnnotation, or null if we do not have line number * information for the instruction */ public static SourceLineAnnotation fromVisitedInstruction(ClassContext classContext, PreorderVisitor visitor, int pc) { return fromVisitedInstructionRange(classContext, visitor, pc, pc); }
public SourceLineAnnotation getCurrentSwitchStatement(BytecodeScanningDetector detector) { if (switchOffsetStack.isEmpty()) { throw new IllegalStateException("No current switch statement"); } SwitchDetails details = switchOffsetStack.get(switchOffsetStack.size()-1); return SourceLineAnnotation.fromVisitedInstructionRange( detector.getClassContext(), detector, details.switchPC, details.switchPC + details.maxOffset-1); } public static class SwitchDetails {
/** * Factory method for creating a source line annotation describing the * source line number for the instruction being visited by given visitor. * * @param visitor * a BetterVisitor which is visiting the method * @param pc * the bytecode offset of the instruction in the method * @return the SourceLineAnnotation, or null if we do not have line number * information for the instruction */ public static SourceLineAnnotation fromVisitedInstruction(BytecodeScanningDetector visitor, int pc) { return fromVisitedInstructionRange(visitor.getClassContext(), visitor, pc, pc); }
/** * Add a source line annotation describing the source line numbers for a * range of instructions in the method being visited by the given visitor. * Note that if the method does not have line number information, then no * source line annotation will be added. * * @param classContext * the ClassContext * @param visitor * a BetterVisitor which is visiting the method * @param startPC * the bytecode offset of the start instruction in the range * @param endPC * the bytecode offset of the end instruction in the range * @return this object */ @Nonnull public BugInstance addSourceLineRange(ClassContext classContext, PreorderVisitor visitor, int startPC, int endPC) { SourceLineAnnotation sourceLineAnnotation = SourceLineAnnotation.fromVisitedInstructionRange(classContext, visitor, startPC, endPC); requireNonNull(sourceLineAnnotation); add(sourceLineAnnotation); return this; }
/** * Add a source line annotation describing the source line numbers for a * range of instructions in the method being visited by the given visitor. * Note that if the method does not have line number information, then no * source line annotation will be added. * * @param visitor * a BetterVisitor which is visiting the method * @param startPC * the bytecode offset of the start instruction in the range * @param endPC * the bytecode offset of the end instruction in the range * @return this object */ @Nonnull public BugInstance addSourceLineRange(BytecodeScanningDetector visitor, int startPC, int endPC) { SourceLineAnnotation sourceLineAnnotation = SourceLineAnnotation.fromVisitedInstructionRange(visitor.getClassContext(), visitor, startPC, endPC); requireNonNull(sourceLineAnnotation); add(sourceLineAnnotation); return this; }
end = tmp; SourceLineAnnotation sourceLineAnnotation = SourceLineAnnotation.fromVisitedInstructionRange(classContext, methodGen, sourceFile, start, end); if (sourceLineAnnotation != null) {
BufferedReader r = null; try { SourceLineAnnotation srcLine = SourceLineAnnotation.fromVisitedInstructionRange(this, lastPC, getPC()); SourceFinder sourceFinder = AnalysisContext.currentAnalysisContext().getSourceFinder(); SourceFile sourceFile = sourceFinder.findSourceFile(srcLine.getPackageName(), srcLine.getSourceFile());
continue; SourceLineAnnotation firstSourceLine = SourceLineAnnotation.fromVisitedInstructionRange(getClassContext(), this, first, endOfFirstSegment - 1); SourceLineAnnotation secondSourceLine = SourceLineAnnotation.fromVisitedInstructionRange(getClassContext(), this, second, endOfSecondSegment - 1);
if (!hasFallThruComment(lastPC + 1, getPC() - 1)) { if (!isDefaultOffset) { SourceLineAnnotation sourceLineAnnotation = SourceLineAnnotation.fromVisitedInstructionRange( getClassContext(), this, lastPC, getPC()); found.add(sourceLineAnnotation);
/** * Factory method for creating a source line annotation describing the * source line number for the instruction being visited by given visitor. * * @param classContext * the ClassContext * @param visitor * a BetterVisitor which is visiting the method * @param pc * the bytecode offset of the instruction in the method * @return the SourceLineAnnotation, or null if we do not have line number * information for the instruction */ public static SourceLineAnnotation fromVisitedInstruction(ClassContext classContext, PreorderVisitor visitor, int pc) { return fromVisitedInstructionRange(classContext, visitor, pc, pc); }
public SourceLineAnnotation getCurrentSwitchStatement(BytecodeScanningDetector detector) { if (switchOffsetStack.isEmpty()) { throw new IllegalStateException("No current switch statement"); } SwitchDetails details = switchOffsetStack.get(switchOffsetStack.size()-1); return SourceLineAnnotation.fromVisitedInstructionRange( detector.getClassContext(), detector, details.switchPC, details.switchPC + details.maxOffset-1); } public static class SwitchDetails {
/** * Factory method for creating a source line annotation describing the * source line number for the instruction being visited by given visitor. * * @param visitor * a BetterVisitor which is visiting the method * @param pc * the bytecode offset of the instruction in the method * @return the SourceLineAnnotation, or null if we do not have line number * information for the instruction */ public static SourceLineAnnotation fromVisitedInstruction(BytecodeScanningDetector visitor, int pc) { return fromVisitedInstructionRange(visitor.getClassContext(), visitor, pc, pc); }
/** * Add a source line annotation describing the source line numbers for a * range of instructions in the method being visited by the given visitor. * Note that if the method does not have line number information, then no * source line annotation will be added. * * @param classContext * the ClassContext * @param visitor * a BetterVisitor which is visiting the method * @param startPC * the bytecode offset of the start instruction in the range * @param endPC * the bytecode offset of the end instruction in the range * @return this object */ @Nonnull public BugInstance addSourceLineRange(ClassContext classContext, PreorderVisitor visitor, int startPC, int endPC) { SourceLineAnnotation sourceLineAnnotation = SourceLineAnnotation.fromVisitedInstructionRange(classContext, visitor, startPC, endPC); requireNonNull(sourceLineAnnotation); add(sourceLineAnnotation); return this; }
/** * Add a source line annotation describing the source line numbers for a * range of instructions in the method being visited by the given visitor. * Note that if the method does not have line number information, then no * source line annotation will be added. * * @param visitor * a BetterVisitor which is visiting the method * @param startPC * the bytecode offset of the start instruction in the range * @param endPC * the bytecode offset of the end instruction in the range * @return this object */ @Nonnull public BugInstance addSourceLineRange(BytecodeScanningDetector visitor, int startPC, int endPC) { SourceLineAnnotation sourceLineAnnotation = SourceLineAnnotation.fromVisitedInstructionRange(visitor.getClassContext(), visitor, startPC, endPC); requireNonNull(sourceLineAnnotation); add(sourceLineAnnotation); return this; }
end = tmp; SourceLineAnnotation sourceLineAnnotation = SourceLineAnnotation.fromVisitedInstructionRange(classContext, methodGen, sourceFile, start, end); if (sourceLineAnnotation != null) {
BufferedReader r = null; try { SourceLineAnnotation srcLine = SourceLineAnnotation.fromVisitedInstructionRange(this, lastPC, getPC()); SourceFinder sourceFinder = AnalysisContext.currentAnalysisContext().getSourceFinder(); SourceFile sourceFile = sourceFinder.findSourceFile(srcLine.getPackageName(), srcLine.getSourceFile());
continue; SourceLineAnnotation firstSourceLine = SourceLineAnnotation.fromVisitedInstructionRange(getClassContext(), this, first, endOfFirstSegment - 1); SourceLineAnnotation secondSourceLine = SourceLineAnnotation.fromVisitedInstructionRange(getClassContext(), this, second, endOfSecondSegment - 1);
if (!hasFallThruComment(lastPC + 1, getPC() - 1)) { if (!isDefaultOffset) { SourceLineAnnotation sourceLineAnnotation = SourceLineAnnotation.fromVisitedInstructionRange( getClassContext(), this, lastPC, getPC()); found.add(sourceLineAnnotation);