@@ -14,6 +14,9 @@ import { DatabaseItem } from "../../databases/local-databases";
1414import { relative } from "path" ;
1515import { CodeQLCliServer } from "../../codeql-cli/cli" ;
1616import { INITIAL_HIDE_MODELED_METHODS_VALUE } from "../shared/hide-modeled-methods" ;
17+ import { getModelingStatus } from "../shared/modeling-status" ;
18+ import { assertNever } from "../../common/helpers-pure" ;
19+ import { ModeledMethod } from "../modeled-method" ;
1720
1821export class MethodsUsageDataProvider
1922 extends DisposableObject
@@ -23,6 +26,8 @@ export class MethodsUsageDataProvider
2326 private databaseItem : DatabaseItem | undefined = undefined ;
2427 private sourceLocationPrefix : string | undefined = undefined ;
2528 private hideModeledMethods : boolean = INITIAL_HIDE_MODELED_METHODS_VALUE ;
29+ private modeledMethods : Record < string , ModeledMethod > = { } ;
30+ private modifiedMethodSignatures : Set < string > = new Set ( ) ;
2631
2732 private readonly onDidChangeTreeDataEmitter = this . push (
2833 new EventEmitter < void > ( ) ,
@@ -47,17 +52,23 @@ export class MethodsUsageDataProvider
4752 methods : Method [ ] ,
4853 databaseItem : DatabaseItem ,
4954 hideModeledMethods : boolean ,
55+ modeledMethods : Record < string , ModeledMethod > ,
56+ modifiedMethodSignatures : Set < string > ,
5057 ) : Promise < void > {
5158 if (
5259 this . methods !== methods ||
5360 this . databaseItem !== databaseItem ||
54- this . hideModeledMethods !== hideModeledMethods
61+ this . hideModeledMethods !== hideModeledMethods ||
62+ this . modeledMethods !== modeledMethods ||
63+ this . modifiedMethodSignatures !== modifiedMethodSignatures
5564 ) {
5665 this . methods = methods ;
5766 this . databaseItem = databaseItem ;
5867 this . sourceLocationPrefix =
5968 await this . databaseItem . getSourceLocationPrefix ( this . cliServer ) ;
6069 this . hideModeledMethods = hideModeledMethods ;
70+ this . modeledMethods = modeledMethods ;
71+ this . modifiedMethodSignatures = modifiedMethodSignatures ;
6172
6273 this . onDidChangeTreeDataEmitter . fire ( ) ;
6374 }
@@ -68,7 +79,7 @@ export class MethodsUsageDataProvider
6879 return {
6980 label : `${ item . packageName } .${ item . typeName } .${ item . methodName } ${ item . methodParameters } ` ,
7081 collapsibleState : TreeItemCollapsibleState . Collapsed ,
71- iconPath : new ThemeIcon ( "symbol-method" ) ,
82+ iconPath : this . getModelingStatusIcon ( item ) ,
7283 } ;
7384 } else {
7485 const method = this . getParent ( item ) ;
@@ -83,11 +94,30 @@ export class MethodsUsageDataProvider
8394 command : "codeQLModelEditor.jumpToUsageLocation" ,
8495 arguments : [ method , item , this . databaseItem ] ,
8596 } ,
86- iconPath : new ThemeIcon ( "error" , new ThemeColor ( "errorForeground" ) ) ,
8797 } ;
8898 }
8999 }
90100
101+ private getModelingStatusIcon ( method : Method ) : ThemeIcon {
102+ const modeledMethod = this . modeledMethods [ method . signature ] ;
103+ const modifiedMethod = this . modifiedMethodSignatures . has ( method . signature ) ;
104+
105+ const status = getModelingStatus ( modeledMethod , modifiedMethod ) ;
106+ switch ( status ) {
107+ case "unmodeled" :
108+ return new ThemeIcon ( "error" , new ThemeColor ( "errorForeground" ) ) ;
109+ case "unsaved" :
110+ return new ThemeIcon ( "pass" , new ThemeColor ( "testing.iconPassed" ) ) ;
111+ case "saved" :
112+ return new ThemeIcon (
113+ "pass-filled" ,
114+ new ThemeColor ( "testing.iconPassed" ) ,
115+ ) ;
116+ default :
117+ assertNever ( status ) ;
118+ }
119+ }
120+
91121 private relativePathWithinDatabase ( uri : string ) : string {
92122 const parsedUri = Uri . parse ( uri ) ;
93123 if ( this . sourceLocationPrefix ) {
0 commit comments