started codecontextform

git-svn-id: trunk@8594 -
This commit is contained in:
mattias 2006-01-21 17:46:08 +00:00
parent fd01e74b09
commit 0775b5cafc
5 changed files with 106 additions and 7 deletions

View File

@ -306,6 +306,8 @@ type
var NewX, NewY, NewTopLine: integer): boolean;
// get code context
function FindCodeContext(Code: TCodeBuffer; X,Y: integer;
out CodeContexts: TCodeContextInfo): boolean;
function ExtractProcedureHeader(Code: TCodeBuffer; X,Y: integer;
Attributes: TProcHeadAttributes; var ProcHead: string): boolean;
@ -1470,6 +1472,29 @@ begin
{$ENDIF}
end;
function TCodeToolManager.FindCodeContext(Code: TCodeBuffer; X, Y: integer; out
CodeContexts: TCodeContextInfo): boolean;
var
CursorPos: TCodeXYPosition;
begin
Result:=false;
{$IFDEF CTDEBUG}
DebugLn('TCodeToolManager.FindCodeContext A ',Code.Filename,' x=',dbgs(x),' y=',dbgs(y));
{$ENDIF}
if not InitCurCodeTool(Code) then exit;
CursorPos.X:=X;
CursorPos.Y:=Y;
CursorPos.Code:=Code;
try
Result:=FCurCodeTool.FindCodeContext(CursorPos,CodeContexts);
except
on e: Exception do HandleException(e);
end;
{$IFDEF CTDEBUG}
DebugLn('TCodeToolManager.FindCodeContext END ');
{$ENDIF}
end;
function TCodeToolManager.ExtractProcedureHeader(Code: TCodeBuffer; X,
Y: integer; Attributes: TProcHeadAttributes; var ProcHead: string): boolean;
var
@ -1489,7 +1514,7 @@ begin
on e: Exception do HandleException(e);
end;
{$IFDEF CTDEBUG}
DebugLn('TCodeToolManager.GatherIdentifiers END ');
DebugLn('TCodeToolManager.ExtractProcedureHeader END ');
{$ENDIF}
end;

View File

@ -483,6 +483,23 @@ const
AllFindSmartFlags = [fsfIncludeDirective];
type
{ TCodeContextInfo }
TCodeContextInfo = class
private
FItems: PFindContext;
FCount: integer;
function GetItems(Index: integer): TFindContext;
public
constructor Create;
destructor Destroy; override;
function Count: integer;
property Items[Index: integer]: TFindContext read GetItems; default;
function Add(const FindContext: TFindContext): integer;
procedure Clear;
end;
//----------------------------------------------------------------------------
ECodeToolUnitNotFound = class(ECodeToolFileNotFound)
end;
@ -673,6 +690,8 @@ type
SkipComments: boolean; out ListOfPCodeXYPosition: TFPList): boolean;
function CleanPosIsDeclarationIdentifier(CleanPos: integer;
Node: TCodeTreeNode): boolean;
function FindCodeContext(const CursorPos: TCodeXYPosition;
out CodeContexts: TCodeContextInfo): boolean;
function JumpToNode(ANode: TCodeTreeNode;
var NewPos: TCodeXYPosition; var NewTopLine: integer;
@ -3651,6 +3670,15 @@ begin
end;
end;
function TFindDeclarationTool.FindCodeContext(const CursorPos: TCodeXYPosition;
out CodeContexts: TCodeContextInfo): boolean;
begin
DebugLn('TFindDeclarationTool.FindCodeContext ');
CodeContexts:=nil;
Result:=false;
end;
function TFindDeclarationTool.JumpToNode(ANode: TCodeTreeNode;
var NewPos: TCodeXYPosition; var NewTopLine: integer;
IgnoreJumpCentered: boolean): boolean;
@ -7615,5 +7643,42 @@ begin
end;
{ TCodeContextInfo }
function TCodeContextInfo.GetItems(Index: integer): TFindContext;
begin
Result:=FItems[Index];
end;
constructor TCodeContextInfo.Create;
begin
end;
destructor TCodeContextInfo.Destroy;
begin
Clear;
inherited Destroy;
end;
function TCodeContextInfo.Count: integer;
begin
Result:=FCount;
end;
function TCodeContextInfo.Add(const FindContext: TFindContext): integer;
begin
inc(FCount);
Result:=Count;
ReAllocMem(FItems,SizeOf(TFindContext)*FCount);
FItems[FCount-1]:=FindContext;
end;
procedure TCodeContextInfo.Clear;
begin
FCount:=0;
ReAllocMem(FItems,0);
end;
end.

View File

@ -36,8 +36,8 @@ unit CodeContextForm;
interface
uses
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs,
CodeCache, CodeToolManager, SynEdit;
Classes, SysUtils, LCLProc, LResources, Forms, Controls, Graphics, Dialogs,
CodeCache, FindDeclarationTool, CodeToolManager, SynEdit;
type
TCodeContextFrm = class(TForm)
@ -55,11 +55,20 @@ implementation
function ShowCodeContext(Code: TCodeBuffer; Editor: TSynEdit): boolean;
var
LogCaretXY: TPoint;
CodeContexts: TCodeContextInfo;
begin
Result:=false;
LogCaretXY:=Editor.LogicalCaretXY;
if not CodeToolBoss.FindCodeContext(Code,LogCaretXY,CodeContext) then
exit;
CodeContexts:=nil;
try
if not CodeToolBoss.FindCodeContext(Code,LogCaretXY.X,LogCaretXY.Y,
CodeContexts)
then
exit;
DebugLn('ShowCodeContext show ..');
finally
CodeContexts.Free;
end;
end;
initialization

View File

@ -43,7 +43,7 @@ uses
{$ENDIF}
Classes, SysUtils, Math, Controls, LCLProc, LCLType, LResources, LCLIntf,
FileUtil, Forms, Buttons, ComCtrls, Dialogs, StdCtrls, GraphType, Graphics,
TypInfo, Extctrls, Menus,
TypInfo, Extctrls, Menus, CodeContextForm,
// codetools
CodeToolManager, CodeCache, SourceLog,
// synedit

View File

@ -28,7 +28,7 @@ MAKEOPTS="-Fl/opt/gnome/lib"
if [ -n "$FPCCfg" ]; then
MAKEOPTS="$MAKEOPTS -n @$FPCCfg"
fi
make all OPT="$MAKEOPTS" USESVN2REVISIONINC=0
make bigide OPT="$MAKEOPTS" USESVN2REVISIONINC=0
make tools OPT="$MAKEOPTS"
# build gtk2 .ppu
export LCL_PLATFORM=gtk2