@@ -5,9 +5,9 @@ const PROVIDER_ID = 'chat-context-sample.jsonLineCount';
55export function activate ( context : vscode . ExtensionContext ) {
66 console . log ( 'Chat context sample extension is now active!' ) ;
77
8- // Register the chat context provider for JSON files
9- const provider : vscode . ChatContextProvider = {
10- provideChatContextForResource ( options : { resource : vscode . Uri } , token : vscode . CancellationToken ) : vscode . ProviderResult < vscode . ChatContextItem | undefined > {
8+ // Register the chat resource context provider for JSON files
9+ const provider : vscode . ChatResourceContextProvider = {
10+ provideResourceChatContext ( options : { resource : vscode . Uri } , token : vscode . CancellationToken ) : vscode . ProviderResult < vscode . ChatContextItem | undefined > {
1111 // Find the text document for this resource
1212 const document = vscode . workspace . textDocuments . find ( doc => doc . uri . toString ( ) === options . resource . toString ( ) ) ;
1313 if ( ! document ) {
@@ -18,22 +18,23 @@ export function activate(context: vscode.ExtensionContext) {
1818 const fileName = options . resource . path . split ( '/' ) . pop ( ) ?? 'unknown' ;
1919
2020 return {
21- icon : new vscode . ThemeIcon ( 'json' ) ,
21+ icon : new vscode . ThemeIcon ( 'file' ) ,
22+ resourceUri : options . resource ,
2223 label : `${ fileName } : ${ lineCount } lines` ,
2324 modelDescription : `The JSON file "${ fileName } " has ${ lineCount } lines.` ,
2425 tooltip : new vscode . MarkdownString ( `**Line count:** ${ lineCount } ` ) ,
2526 value : `File: ${ fileName } \nLine count: ${ lineCount } `
2627 } ;
2728 } ,
2829
29- resolveChatContext ( context : vscode . ChatContextItem , token : vscode . CancellationToken ) : vscode . ProviderResult < vscode . ChatContextItem > {
30+ resolveResourceChatContext ( context : vscode . ChatContextItem , token : vscode . CancellationToken ) : vscode . ProviderResult < vscode . ChatContextItem > {
3031 // Context items already have values, so just return as-is
3132 return context ;
3233 }
3334 } ;
3435
3536 // Register with a document selector for JSON files
36- const disposable = vscode . chat . registerChatContextProvider (
37+ const disposable = vscode . chat . registerChatResourceContextProvider (
3738 [ { language : 'json' } , { language : 'jsonc' } ] ,
3839 PROVIDER_ID ,
3940 provider
0 commit comments