-
Notifications
You must be signed in to change notification settings - Fork 188
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DEV2-4340 - inline chat interaction added #1406
Changes from 7 commits
82f9fa3
fc79ee4
a6a4c62
76a675b
edf176a
7ab8393
cff1aaf
4361407
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* eslint-disable class-methods-use-this */ | ||
import { | ||
CodeAction, | ||
CodeActionContext, | ||
CodeActionKind, | ||
ExtensionContext, | ||
Range, | ||
TextDocument, | ||
languages, | ||
CodeActionProvider, | ||
} from "vscode"; | ||
import { languagesFilter } from "./const"; | ||
|
||
export function registerChatActionProvider(context: ExtensionContext) { | ||
context.subscriptions.push( | ||
languages.registerCodeActionsProvider( | ||
languagesFilter, | ||
new ChatActionProvider(), | ||
{ | ||
providedCodeActionKinds: [ | ||
CodeActionKind.RefactorRewrite, | ||
CodeActionKind.QuickFix, | ||
], | ||
} | ||
) | ||
); | ||
} | ||
|
||
class ChatActionProvider implements CodeActionProvider { | ||
provideCodeActions( | ||
document: TextDocument, | ||
range: Range, | ||
codeActionContext: CodeActionContext & { | ||
triggerKind: number; | ||
} | ||
): CodeAction[] { | ||
if (codeActionContext.triggerKind !== 1) { | ||
return []; | ||
} | ||
const resultActions: CodeAction[] = []; | ||
|
||
if (codeActionContext.diagnostics[0]?.range) { | ||
const fixAction = new CodeAction( | ||
"Fix with Tabnine", | ||
CodeActionKind.QuickFix | ||
); | ||
|
||
fixAction.command = { | ||
title: fixAction.title, | ||
command: "tabnine.chat.commands.fix-code", | ||
}; | ||
resultActions.push(fixAction); | ||
} | ||
const refactor = new CodeAction( | ||
"Ask Tabnine", | ||
CodeActionKind.RefactorRewrite | ||
); | ||
|
||
refactor.command = { | ||
title: refactor.title, | ||
command: "tabnine.chat.commands.inline.action", | ||
}; | ||
resultActions.push(refactor); | ||
return resultActions; | ||
} | ||
} |
This file was deleted.
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,73 @@ | ||||||
type SCOPE = "block" | "selection" | "none"; | ||||||
export type Action = "test" | "fix" | "explain" | "document" | "workspace"; | ||||||
export type Intent = | ||||||
| "/generate-test-for-code" | ||||||
| "/fix-code" | ||||||
| "/explain-code" | ||||||
| "/document-code" | ||||||
| "/workspace"; | ||||||
|
||||||
enum LensOrder { | ||||||
test = 1, | ||||||
fix = 2, | ||||||
explain = 3, | ||||||
document = 4, | ||||||
} | ||||||
|
||||||
export type Command = { | ||||||
label: string; | ||||||
text: Action; | ||||||
intent: Intent; | ||||||
description: string; | ||||||
scope: SCOPE[]; | ||||||
multistep: boolean; | ||||||
lensOrder?: LensOrder | undefined; | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
}; | ||||||
|
||||||
export const COMANDS: Command[] = [ | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what about splitting it to
|
||||||
{ | ||||||
label: "$(feedback) explain", | ||||||
text: "explain", | ||||||
intent: "/explain-code", | ||||||
description: "Explain the selected code", | ||||||
scope: ["selection", "block"], | ||||||
multistep: false, | ||||||
lensOrder: LensOrder.explain, | ||||||
}, | ||||||
{ | ||||||
label: "$(beaker) test", | ||||||
text: "test", | ||||||
intent: "/generate-test-for-code", | ||||||
description: "Write tests for the selected code", | ||||||
scope: ["block"], | ||||||
multistep: false, | ||||||
lensOrder: LensOrder.test, | ||||||
}, | ||||||
{ | ||||||
label: "$(checklist) document", | ||||||
text: "document", | ||||||
intent: "/document-code", | ||||||
description: "Add documentation for the selected code", | ||||||
scope: ["block"], | ||||||
multistep: false, | ||||||
lensOrder: LensOrder.document, | ||||||
}, | ||||||
{ | ||||||
label: "$(symbol-property) fix", | ||||||
text: "fix", | ||||||
intent: "/fix-code", | ||||||
description: "Find errors in the selected code and fix them", | ||||||
scope: ["block"], | ||||||
multistep: false, | ||||||
lensOrder: LensOrder.fix, | ||||||
}, | ||||||
{ | ||||||
label: "$(search) workspace", | ||||||
text: "workspace", | ||||||
intent: "/workspace", | ||||||
description: | ||||||
"Ask a question related to any code within your current workspace", | ||||||
scope: ["none"], | ||||||
multistep: true, | ||||||
}, | ||||||
]; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
export const languagesFilter = [ | ||
{ language: "javascript" }, | ||
{ pattern: "**/*[!d].ts", scheme: "file" }, | ||
{ language: "javascriptreact" }, | ||
{ language: "typescriptreact" }, | ||
{ language: "python" }, | ||
{ language: "ruby" }, | ||
{ language: "go" }, | ||
{ language: "rust" }, | ||
{ language: "swift" }, | ||
{ language: "java" }, | ||
{ language: "c" }, | ||
{ language: "cpp" }, | ||
{ language: "csharp" }, | ||
{ language: "php" }, | ||
]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
is this a known type in vscode sdk? I don't see its usage