Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
freem
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Openai/691151cc-3da4-800f-9b7c-81b0e0d10369
(section)
Add languages
Page
Discussion
English
Read
Edit
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Assistant: なるほどです。では、AI の提案を直接挿入するのではなく、「提案表示 → Tab で採用」形式に変えましょう。 === なるほどです。では、AI の提案を直接挿入するのではなく、「提案表示 → Tab で採用」形式に変えましょう。 Eclipse ではこれを Content Assist(コード補完) で実現できます。具体的には ICompletionProposal を使います。 ==== 1. AI にコード生成を依頼 ==== # 提案文字列を <code>ICompletionProposal</code> として生成 # カーソル位置にポップアップ表示 # ユーザーが Tab を押すと挿入 ===== <syntaxhighlight lang="java">import org.eclipse.jface.text.contentassist.ICompletionProposal; ===== import org.eclipse.jface.text.contentassist.CompletionProposal; import org.eclipse.jface.text.ITextViewer; import org.eclipse.jface.text.contentassist.IContentAssistant; import org.eclipse.jface.text.contentassist.IContentAssistProcessor; // AI から取得した文字列をプロポーザルとして表示 String aiText = extractCodeFromAIResponse(response); // カーソル位置に ContentAssist プロポーザルを作成 ICompletionProposal proposal = new CompletionProposal( aiText, // 挿入する文字列 cursorOffset, // 挿入位置 0, // 置換する文字数 aiText.length(), // カーソルの移動位置 null, // 画像(アイコン) "AI Suggestion", // 表示文字 null, // context information null // additional information ); // プロポーザルを ContentAssist に渡す // 通常は IContentAssistProcessor を実装し、computeCompletionProposals で返す </syntaxhighlight> ===== - CompletionProposal を使うと Tab キーで採用 可能 ===== * 表示される際に 他の補完と同じ UI で選択可能 * cursorOffset に対して AI が返した文字列を挿入できる ===== 1. Ctrl+Shift+Z → AI にソースコードとカーソル位置を送信 ===== # AI からの応答を extractCodeFromAIResponse でクリーン化 # CompletionProposal を生成して Content Assist ポップアップに表示 # Tab で選択するとカーソル位置にコードが挿入される 💡 補足 * Eclipse での「提案 → Tab で採用」UI は 既存の Content Assist と統合するのが安全です * もし望めば、私は AISuggestHandler を ContentAssist 形式に書き換えた完全版 を作成できます 作りますか?
Summary:
Please note that all contributions to freem are considered to be released under the Creative Commons Attribution-ShareAlike 4.0 (see
Freem:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)