implemented find declaration of OI property popupmenu item

git-svn-id: trunk@8917 -
This commit is contained in:
mattias 2006-03-11 02:17:02 +00:00
parent f540eb7d8f
commit c202035638
6 changed files with 52 additions and 5 deletions

View File

@ -4013,10 +4013,17 @@ end;
function TFindDeclarationTool.JumpToNode(ANode: TCodeTreeNode;
var NewPos: TCodeXYPosition; var NewTopLine: integer;
IgnoreJumpCentered: boolean): boolean;
var
JumpPos: LongInt;
begin
Result:=false;
if (ANode=nil) or (ANode.StartPos<1) then exit;
Result:=JumpToCleanPos(ANode.StartPos,ANode.StartPos,ANode.EndPos,
JumpPos:=ANode.StartPos;
if ANode.Desc=ctnProperty then begin
MoveCursorToPropName(ANode);
JumpPos:=CurPos.StartPos;
end;
Result:=JumpToCleanPos(JumpPos,JumpPos,ANode.EndPos,
NewPos,NewTopLine,IgnoreJumpCentered);
end;

View File

@ -70,7 +70,8 @@ procedure SaveOIFavouriteProperties(Favourites: TOIFavouriteProperties);
function GetOIFavouriteConfigFilename: string;
function FindDeclarationOfOIProperty(AnInspector: TObjectInspector;
Row: TOIPropertyGridRow; out Code: TCodeBuffer; out Caret: TPoint): Boolean;
Row: TOIPropertyGridRow; out Code: TCodeBuffer; out Caret: TPoint;
out NewTopLine: integer): Boolean;
implementation
@ -190,13 +191,14 @@ begin
end;
function FindDeclarationOfOIProperty(AnInspector: TObjectInspector;
Row: TOIPropertyGridRow; out Code: TCodeBuffer; out Caret: TPoint): Boolean;
Row: TOIPropertyGridRow; out Code: TCodeBuffer; out Caret: TPoint;
out NewTopLine: integer): Boolean;
var
PropPath: String;
LookupRoot: TPersistent;
AFile: TLazProjectFile;
NewCode: TCodeBuffer;
NewX, NewY, NewTopLine: integer;
NewX, NewY: integer;
begin
Result:=false;
Code:=nil;

View File

@ -624,12 +624,15 @@ var
Code: TCodeBuffer;
Caret: TPoint;
ErrMsg: string;
NewTopLine: integer;
begin
DebugLn('THelpManager.ShowHelpForObjectInspector ',dbgsName(Sender));
if Sender=nil then Sender:=ObjectInspector1;
if Sender is TObjectInspector then begin
AnInspector:=TObjectInspector(Sender);
if FindDeclarationOfOIProperty(AnInspector,nil,Code,Caret) then begin
if FindDeclarationOfOIProperty(AnInspector,nil,Code,Caret,NewTopLine) then
begin
if NewTopLine=0 then ;
ShowHelpForSourcePosition(Code.Filename,Caret,ErrMsg);
end;
end;

View File

@ -345,6 +345,7 @@ type
Shift: TShiftState);
procedure OIOnAddToFavourites(Sender: TObject);
procedure OIOnRemoveFromFavourites(Sender: TObject);
procedure OIOnFindDeclarationOfProperty(Sender: TObject);
procedure OnPropHookGetMethods(TypeData: PTypeData; Proc:TGetStringProc);
function OnPropHookMethodExists(const AMethodName: ShortString;
TypeData: PTypeData;
@ -1237,6 +1238,22 @@ begin
ShowAddRemoveFavouriteDialog(ObjectInspector1,false);
end;
procedure TMainIDE.OIOnFindDeclarationOfProperty(Sender: TObject);
var
AnInspector: TObjectInspector;
Code: TCodeBuffer;
Caret: TPoint;
NewTopLine: integer;
begin
if not BeginCodeTools then exit;
if Sender=nil then Sender:=ObjectInspector1;
if Sender is TObjectInspector then begin
AnInspector:=TObjectInspector(Sender);
if FindDeclarationOfOIProperty(AnInspector,nil,Code,Caret,NewTopLine) then
DoOpenFileAndJumpToPos(Code.Filename,Caret,NewTopLine,-1,[]);
end;
end;
procedure TMainIDE.OnPropHookGetMethods(TypeData:PTypeData;
Proc:TGetStringProc);
var ActiveSrcEdit: TSourceEditor;
@ -1450,6 +1467,8 @@ begin
ObjectInspector1.Favourites:=LoadOIFavouriteProperties;
ObjectInspector1.OnAddToFavourites:=@OIOnAddToFavourites;
ObjectInspector1.OnRemoveFromFavourites:=@OIOnRemoveFromFavourites;
ObjectInspector1.FindDeclarationPopupmenuItem.Visible:=true;
ObjectInspector1.OnFindDeclarationOfProperty:=@OIOnFindDeclarationOfProperty;
ObjectInspector1.BorderStyle:=bsSizeToolWin;
IDECmdScopeObjctInspectorOnly.AddWindowClass(TObjectInspector);

View File

@ -538,6 +538,7 @@ type
AddToFavoritesPopupMenuItem: TMenuItem;
RemoveFromFavoritesPopupMenuItem: TMenuItem;
UndoPropertyPopupMenuItem: TMenuItem;
FindDeclarationPopupmenuItem: TMenuItem;
CutPopupmenuItem: TMenuItem;
CopyPopupmenuItem: TMenuItem;
PastePopupmenuItem: TMenuItem;
@ -555,6 +556,7 @@ type
procedure OnAddToFavoritesPopupmenuItemClick(Sender: TObject);
procedure OnRemoveFromFavoritesPopupmenuItemClick(Sender: TObject);
procedure OnUndoPopupmenuItemClick(Sender: TObject);
procedure OnFindDeclarationPopupmenuItemClick(Sender: TObject);
procedure OnCutPopupmenuItemClick(Sender: TObject);
procedure OnCopyPopupmenuItemClick(Sender: TObject);
procedure OnPastePopupmenuItemClick(Sender: TObject);
@ -566,6 +568,7 @@ type
private
FFavourites: TOIFavouriteProperties;
FOnAddToFavourites: TNotifyEvent;
FOnFindDeclarationOfProperty: TNotifyEvent;
FOnOIKeyDown: TKeyEvent;
FOnRemainingKeyUp: TKeyEvent;
FOnRemoveFromFavourites: TNotifyEvent;
@ -652,6 +655,8 @@ type
property OnRemoveFromFavourites: TNotifyEvent read FOnRemoveFromFavourites
write FOnRemoveFromFavourites;
property OnOIKeyDown: TKeyEvent read FOnOIKeyDown write FOnOIKeyDown;
property OnFindDeclarationOfProperty: TNotifyEvent
read FOnFindDeclarationOfProperty write FOnFindDeclarationOfProperty;
end;
const
@ -3008,6 +3013,9 @@ begin
AddPopupMenuItem(UndoPropertyPopupMenuItem,nil,'UndoPropertyPopupMenuItem',
oisUndo,'Set property value to last valid value',
@OnUndoPopupmenuItemClick,false,true,true);
AddPopupMenuItem(FindDeclarationPopupmenuItem,nil,'FindDeclarationPopupmenuItem',
oisFinddeclaration,'Jump to declaration of property',
@OnFindDeclarationPopupmenuItemClick,false,true,false);
AddSeparatorMenuItem(nil,'OptionsSeparatorMenuItem',true);
AddPopupMenuItem(CutPopupMenuItem,nil,'CutPopupMenuItem',
oisCut,'Cut selected item',
@ -3429,6 +3437,13 @@ begin
CurGrid.CurrentEditValue:=CurRow.Editor.GetVisualValue;
end;
procedure TObjectInspector.OnFindDeclarationPopupmenuItemClick(Sender: TObject
);
begin
if Assigned(OnFindDeclarationOfProperty) then
OnFindDeclarationOfProperty(Self);
end;
procedure TObjectInspector.OnCutPopupmenuItemClick(Sender: TObject);
var
ADesigner: TIDesigner;

View File

@ -51,6 +51,7 @@ resourcestring
oisAddToFavorites = 'Add to Favorites';
oisRemoveFromFavorites = 'Remove from Favorites';
oisUndo = 'Undo';
oisFinddeclaration = 'Jump to declaration';
oisCut = 'Cut';
oisCopy = 'Copy';
oisPaste = 'Paste';