1 26 27 package net.sourceforge.groboutils.codecoverage.v2.module; 28 29 30 import net.sourceforge.groboutils.codecoverage.v2.IAnalysisMetaData; 31 import net.sourceforge.groboutils.codecoverage.v2.IAnalysisModule; 32 import net.sourceforge.groboutils.codecoverage.v2.IMethodCode; 33 34 import org.apache.bcel.generic.Instruction; 35 import org.apache.bcel.generic.InstructionHandle; 36 import org.apache.bcel.generic.InvokeInstruction; 37 38 39 59 public class CallPairMeasure implements IAnalysisModule 60 { 61 64 public String getMeasureName() 65 { 66 return "Call Pair"; 67 } 68 69 72 public String getMeasureUnit() 73 { 74 return "call"; 75 } 76 77 78 82 public String getMimeEncoding() 83 { 84 return "text/plain"; 85 } 86 87 88 91 public void analyze( IMethodCode method ) 92 { 93 BytecodeLineUtil blu = new BytecodeLineUtil( method ); 94 InstructionHandle handles[] = blu.getHandles(); 95 96 for (int i = 0; i < handles.length; ++i) 98 { 99 InstructionHandle h = handles[i]; 100 Instruction instr = h.getInstruction(); 101 if (instr instanceof InvokeInstruction) 102 { 103 int lineNo = blu.getLineNumber( h ); 106 method.markInstruction( i, createMetaData( i, lineNo ) ); 107 } 108 } 109 } 110 111 112 private IAnalysisMetaData createMetaData( int bytecodePos, int lineNo ) 113 { 114 return new DefaultAnalysisMetaData( 115 "Invoke for line "+lineNo, 116 "Didn't cover invocation for line "+lineNo, 117 (byte)0 ); 118 } 119 } 120 121 | Popular Tags |