はじめまして!!
助けて頂きたいのですが、
コード補完で出てくる
「プロパティー」「function」「型」をmemoに抜き出す方法は有るでしょうか?
もし、ありましたら教えて頂けますと助かります。
よろしくおねがいいたします。
Delphi7以上ならIOTACodeInsightManagerでSymbolListを取得すれば
良いと思います。以下は手抜きですが、だいたいこんな感じだと思います。
パッケージを作ってインストールすれば、ショートカットCtrl+Bで起動します。
unit TestUnit;
interface
uses
ToolsAPI, Classes;
type
TSampleBufferList = class(TNotifierObject, IOTAKeyboardBinding)
private
procedure BufferListProc(const Context: IOTAKeyContext; KeyCode: TShortCut;
var BindingResult: TKeyBindingResult);
public
function GetBindingType: TBindingType;
function GetDisplayName: string;
function GetName: string;
procedure BindKeyboard(const BindingServices: IOTAKeyBindingServices);
end;
procedure Register;
procedure UnRegister;
implementation
uses
Menus, Dialogs, SysUtils;
var
BindNo: integer;
procedure Register;
begin
BindNo := (BorlandIDEServices as IOTAKeyBoardServices).AddKeyboardBinding(TSampleBufferList.Create);
end;
procedure UnRegister;
begin
(BorlandIDEServices as IOTAKeyBoardServices).RemoveKeyboardBinding(BindNo);
end;
{ TSampleBufferList }
procedure TSampleBufferList.BindKeyboard(
const BindingServices: IOTAKeyBindingServices);
begin
BindingServices.AddKeyBinding([ShortCut(Ord('B'), [ssCtrl])],
BufferListProc, nil);
end;
procedure TSampleBufferList.BufferListProc(const Context: IOTAKeyContext;
KeyCode: TShortCut; var BindingResult: TKeyBindingResult);
var
CodeInsightServices: IOTACodeInsightServices;
CodeInsightManager: IOTACodeInsightManager;
SymbolList: IOTACodeInsightSymbolList;
UserInput: string;
Allow: boolean;
i: integer;
begin
if Supports(BorlandIDEServices, IOTACodeInsightServices, CodeInsightServices) then
begin
if CodeInsightServices.CodeInsightManagerCount > 0 then
CodeInsightManager := CodeInsightServices.CodeInsightManager[(CodeInsightServices.CodeInsightManagerCount -1)];
if not (CodeInsightManager = nil) then
begin
CodeInsightServices.SetQueryContext(Context.EditBuffer.TopView, CodeInsightManager);
Allow := True;
CodeInsightManager.AllowCodeInsight(Allow, #0);
if not Allow then
exit;
UserInput := '';
if not CodeInsightManager.InvokeCodeCompletion(itManual, UserInput) then
exit;
CodeInsightManager.GetSymbolList(SymbolList);
if SymbolList = nil then
exit;
for i := 0 to 10 do
showMessage(SymbolList.SymbolText[i]);
end;
end;
BindingResult := krHandled;
end;
function TSampleBufferList.GetBindingType: TBindingType;
begin
Result := btPartial;
end;
function TSampleBufferList.GetDisplayName: string;
begin
Result := 'テスト';
end;
function TSampleBufferList.GetName: string;
begin
Result := 'Test.BufferList';
end;
initialization
finalization
UnRegister;
end.
詳しくはOpenToolsAPIのヘルプをご覧ください。
GExpertsのGX_KibitzCompユニットも参考になりそうです。
CodeInsightServices.SetQueryContext(nil, nil);
を忘れてました。
処理の最後に(for文のshowMessageの下に)追加してください。