@@ -5,33 +5,19 @@ import * as path from 'path';
55
66import * as vscode from 'vscode' ;
77
8- // eslint-disable-next-line import/order
98import Config from './config' ;
109import GlobalConfig from '../../globalConfig' ;
1110import { fullToRelativePath , getRootDir } from '../../utils' ;
1211
1312const { execFile } = require ( 'child_process' ) ;
1413
15- // Interface for parsing Kani's output and storing as an object
16- interface CoverageEntry {
17- filePath : string ;
18- lineNumber : number ;
19- coverageStatus : string ;
20- }
21-
2214// Interface for storing the coverage status for each line of a document.
2315export interface CoverageLines {
2416 full : vscode . Range [ ] ;
2517 partial : vscode . Range [ ] ;
2618 none : vscode . Range [ ] ;
2719}
2820
29- enum CoverageStatus {
30- Full = 'FULL' ,
31- Partial = 'PARTIAL' ,
32- None = 'NONE' ,
33- }
34-
3521const warningMessage = `Source-based coverage is an unstable feature.` ;
3622
3723// Callback function for the coverage code lens action
@@ -44,9 +30,6 @@ export async function runCodeCoverageAction(
4430
4531 vscode . window . showWarningMessage ( warningMessage ) ;
4632
47- const activeEditor = vscode . window . activeTextEditor ;
48- const currentFileUri = activeEditor ?. document . uri . fsPath ;
49-
5033 // Run this command: cargo kani --coverage -Z source-coverage --harness verify_success
5134 // to generate the source coverage output
5235 const playbackCommand : string = `${ kaniBinaryPath } --coverage -Z source-coverage --harness ${ functionName } ` ;
@@ -56,7 +39,6 @@ export async function runCodeCoverageAction(
5639
5740 // Convert the array of (file, line, status) objects into Map<file <line, status>>
5841 // since we need to cache this globally
59- // const coverageGlobalMap = parseCoverageFormatted(coverageOutputArray);
6042 globalConfig . setCoverage ( coverageGlobalMap ) ;
6143 renderer . renderInterface ( vscode . window . visibleTextEditors , coverageGlobalMap ) ;
6244 }
@@ -186,60 +168,10 @@ async function parseKaniCoverageOutput(stdout: string): Promise<any | undefined>
186168 terminal . show ( ) ;
187169 }
188170
189- // const coverage = parseCoverageData(coverageResultsArray);
190171 // No command found from Kani
191172 return coverageMap ;
192173}
193174
194- // Parse `CoverageEntry` objects and convert it into CoverageMap or a map<file_path, map<line_number, status>>.
195- // We store this map as the global cache since it allows easy sorting and retrieval by file name, needed by VS Code.
196- function parseCoverageFormatted ( entries : CoverageEntry [ ] ) : Map < string , Map < number , string > > {
197- const nestedMap : Map < string , Map < number , string > > = new Map ( ) ;
198-
199- for ( const entry of entries ) {
200- const { filePath, lineNumber, coverageStatus } = entry ;
201-
202- // Check if the outer map already has an entry for the filePath
203- let innerMap = nestedMap . get ( filePath ) ;
204-
205- // If not, create a new inner map and set it in the outer map
206- if ( ! innerMap ) {
207- innerMap = new Map < number , CoverageStatus > ( ) ;
208- nestedMap . set ( filePath , innerMap ) ;
209- }
210-
211- // Set the coverageStatus in the inner map for the lineNumber
212- innerMap . set ( lineNumber , coverageStatus ) ;
213- }
214-
215- return nestedMap ;
216- }
217-
218- // Convert coverage Kani's output into CoverageEntry objects
219- function parseCoverageData ( data : string [ ] ) : CoverageEntry [ ] {
220- const coverageEntries : CoverageEntry [ ] = [ ] ;
221-
222- for ( const entry of data ) {
223- const parts = entry . split ( ', ' ) ;
224-
225- if ( parts . length === 3 ) {
226- const [ filePath , lineNumberStr , coverageStatus ] = parts ;
227- if ( filePath . includes ( 'Complete - ' ) ) {
228- return coverageEntries ;
229- }
230- const lineNumber = parseInt ( lineNumberStr . trim ( ) , 10 ) ;
231-
232- coverageEntries . push ( {
233- filePath,
234- lineNumber,
235- coverageStatus,
236- } ) ;
237- }
238- }
239-
240- return coverageEntries ;
241- }
242-
243175// Class representing the Renderer that handles rendering coverage highlights in the editor.
244176export class CoverageRenderer {
245177 private configStore : Config ;
@@ -272,7 +204,6 @@ export class CoverageRenderer {
272204 // Fetch the coverage data for a file from the coverageMap.
273205 const relativePath = fullToRelativePath ( editor . document . fileName ) ;
274206 const fileMap = coverageMap . get ( relativePath ) ! ;
275- // const coverageLines = this.createCoverage(editor.document, fileMap);
276207
277208 const coverageLines = this . convertMapToLines ( fileMap ) ;
278209 this . renderHighlight ( editor , coverageLines ) ;
0 commit comments