diff --git a/src/tabnineChatWidget/extensionCommands/codeLens/ChatCodeLensProvider.ts b/src/tabnineChatWidget/extensionCommands/codeLens/ChatCodeLensProvider.ts index a9de2df4bf..8cf7808609 100644 --- a/src/tabnineChatWidget/extensionCommands/codeLens/ChatCodeLensProvider.ts +++ b/src/tabnineChatWidget/extensionCommands/codeLens/ChatCodeLensProvider.ts @@ -1,14 +1,6 @@ -import { - CodeLens, - CodeLensProvider, - commands, - DocumentSymbol, - Location, - SymbolInformation, - SymbolKind, - TextDocument, -} from "vscode"; +import { CodeLens, CodeLensProvider, Location, TextDocument } from "vscode"; import { fireEvent } from "../../../binary/requests/requests"; +import { getFuctionsSymbols } from "../getFuctionsSymbols"; const CODE_LENS_ACTIONS = [ ["test", "generate-test-for-code"], @@ -16,8 +8,6 @@ const CODE_LENS_ACTIONS = [ ["explain", "explain-code"], ]; -const VALID_SYMBOLS = [SymbolKind.Function, SymbolKind.Method]; - const MAX_LINES = 2500; export default class ChatCodeLensProvider implements CodeLensProvider { @@ -28,31 +18,18 @@ export default class ChatCodeLensProvider implements CodeLensProvider { if (document.lineCount > MAX_LINES) { return []; } - const documnetSymbols = await commands.executeCommand< - (SymbolInformation & DocumentSymbol)[] - >("vscode.executeDocumentSymbolProvider", document.uri); + + const documnetSymbols = await getFuctionsSymbols(document); + if (!documnetSymbols?.length) { return []; } const lenses: CodeLens[] = []; - documnetSymbols - ?.filter((fn) => VALID_SYMBOLS.includes(fn.kind)) - .forEach(({ location }) => - lenses.push(...toIntentLens(location), toAskLens(location)) - ); - - documnetSymbols - ?.filter((symbol) => symbol.kind === SymbolKind.Class) - .forEach((classSymbol) => { - classSymbol.children - .filter((child) => VALID_SYMBOLS.includes(child.kind)) - .forEach((method) => { - const { location } = (method as unknown) as SymbolInformation; - lenses.push(...toIntentLens(location), toAskLens(location)); - }); - }); + documnetSymbols.forEach(({ location }) => { + lenses.push(...toIntentLens(location), toAskLens(location)); + }); void fireEvent({ name: "chat-lens-label-rendered", diff --git a/src/tabnineChatWidget/extensionCommands/slashCommands.ts b/src/tabnineChatWidget/extensionCommands/slashCommands.ts index 891ef12363..7b5ac05c5a 100644 --- a/src/tabnineChatWidget/extensionCommands/slashCommands.ts +++ b/src/tabnineChatWidget/extensionCommands/slashCommands.ts @@ -5,23 +5,29 @@ export type SlashCommand = { }; export const SLASH_COMANDS: SlashCommand[] = [ { - label: "explain", + label: "$(feedback) explain", intent: "/explain-code", description: "Explain the selected code", }, { - label: "test", + label: "$(beaker) test", intent: "/generate-test-for-code", description: "Write tests for the selected code", }, { - label: "document", + label: "$(checklist) document", intent: "/document-code", description: "Add documentation for the selected code", }, { - label: "fix", + label: "$(symbol-property) fix", intent: "/fix-code", description: "Find errors in the selected code and fix them", }, + { + label: "$(search) workspace", + intent: "/workspace", + description: + "Ask a question related to any code within your current workspace", + }, ]; diff --git a/src/tabnineChatWidget/tabnineChatWidgetWebview.ts b/src/tabnineChatWidget/tabnineChatWidgetWebview.ts index d2a7c47f80..cb72bccec7 100644 --- a/src/tabnineChatWidget/tabnineChatWidgetWebview.ts +++ b/src/tabnineChatWidget/tabnineChatWidgetWebview.ts @@ -101,6 +101,6 @@ function registerWebview(context: ExtensionContext, serverUrl?: string): void { }) ); context.subscriptions.push(registerChatCommnmads(chatProvider)); - registerChatActionProvider(context, chatProvider); + registerChatActionProvider(context); registerChatCodeLens(context, chatProvider); }