@@ -29,6 +29,9 @@ export async function getAutoModelUsages({
2929
3030 const cancellationTokenSource = new CancellationTokenSource ( ) ;
3131
32+ // This will re-run the query that was already run when opening the data extensions editor. This
33+ // might be unnecessary, but this makes it really easy to get the path to the BQRS file which we
34+ // need to interpret the results.
3235 const queryResult = await runQuery ( {
3336 cliServer,
3437 queryRunner,
@@ -52,6 +55,9 @@ export async function getAutoModelUsages({
5255 message : "Retrieving source location prefix" ,
5356 } ) ;
5457
58+ // CodeQL needs to have access to the database to be able to retrieve the
59+ // snippets from it. The source location prefix is used to determine the
60+ // base path of the database.
5561 const sourceLocationPrefix = await databaseItem . getSourceLocationPrefix (
5662 cliServer ,
5763 ) ;
@@ -70,9 +76,17 @@ export async function getAutoModelUsages({
7076 message : "Interpreting results" ,
7177 } ) ;
7278
79+ // Convert the results to SARIF so that Codeql will retrieve the snippets
80+ // from the datababe. This means we don't need to do that in the extension
81+ // and everything is handled by the CodeQL CLI.
7382 const sarif = await interpretResultsSarif (
7483 cliServer ,
7584 {
85+ // To interpret the results we need to provide metadata about the query. We could do this using
86+ // `resolveMetadata` but that would be an extra call to the CodeQL CLI server and would require
87+ // us to know the path to the query on the filesystem. Since we know what the metadata should
88+ // look like and the only metadata that the CodeQL CLI requires is an ID and the kind, we can
89+ // simply use constants here.
7690 kind : "problem" ,
7791 id : "usage" ,
7892 } ,
@@ -100,6 +114,7 @@ export async function getAutoModelUsages({
100114 throw new Error ( "No results" ) ;
101115 }
102116
117+ // This will group the snippets by the method signature.
103118 for ( const result of results ) {
104119 const signature = result . message . text ;
105120
0 commit comments