mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-15 19:39:28 +02:00
started codecontextform
git-svn-id: trunk@8594 -
This commit is contained in:
parent
fd01e74b09
commit
0775b5cafc
@ -306,6 +306,8 @@ type
|
|||||||
var NewX, NewY, NewTopLine: integer): boolean;
|
var NewX, NewY, NewTopLine: integer): boolean;
|
||||||
|
|
||||||
// get code context
|
// get code context
|
||||||
|
function FindCodeContext(Code: TCodeBuffer; X,Y: integer;
|
||||||
|
out CodeContexts: TCodeContextInfo): boolean;
|
||||||
function ExtractProcedureHeader(Code: TCodeBuffer; X,Y: integer;
|
function ExtractProcedureHeader(Code: TCodeBuffer; X,Y: integer;
|
||||||
Attributes: TProcHeadAttributes; var ProcHead: string): boolean;
|
Attributes: TProcHeadAttributes; var ProcHead: string): boolean;
|
||||||
|
|
||||||
@ -1470,6 +1472,29 @@ begin
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
end;
|
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,
|
function TCodeToolManager.ExtractProcedureHeader(Code: TCodeBuffer; X,
|
||||||
Y: integer; Attributes: TProcHeadAttributes; var ProcHead: string): boolean;
|
Y: integer; Attributes: TProcHeadAttributes; var ProcHead: string): boolean;
|
||||||
var
|
var
|
||||||
@ -1489,7 +1514,7 @@ begin
|
|||||||
on e: Exception do HandleException(e);
|
on e: Exception do HandleException(e);
|
||||||
end;
|
end;
|
||||||
{$IFDEF CTDEBUG}
|
{$IFDEF CTDEBUG}
|
||||||
DebugLn('TCodeToolManager.GatherIdentifiers END ');
|
DebugLn('TCodeToolManager.ExtractProcedureHeader END ');
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -483,6 +483,23 @@ const
|
|||||||
AllFindSmartFlags = [fsfIncludeDirective];
|
AllFindSmartFlags = [fsfIncludeDirective];
|
||||||
|
|
||||||
type
|
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)
|
ECodeToolUnitNotFound = class(ECodeToolFileNotFound)
|
||||||
end;
|
end;
|
||||||
@ -673,6 +690,8 @@ type
|
|||||||
SkipComments: boolean; out ListOfPCodeXYPosition: TFPList): boolean;
|
SkipComments: boolean; out ListOfPCodeXYPosition: TFPList): boolean;
|
||||||
function CleanPosIsDeclarationIdentifier(CleanPos: integer;
|
function CleanPosIsDeclarationIdentifier(CleanPos: integer;
|
||||||
Node: TCodeTreeNode): boolean;
|
Node: TCodeTreeNode): boolean;
|
||||||
|
function FindCodeContext(const CursorPos: TCodeXYPosition;
|
||||||
|
out CodeContexts: TCodeContextInfo): boolean;
|
||||||
|
|
||||||
function JumpToNode(ANode: TCodeTreeNode;
|
function JumpToNode(ANode: TCodeTreeNode;
|
||||||
var NewPos: TCodeXYPosition; var NewTopLine: integer;
|
var NewPos: TCodeXYPosition; var NewTopLine: integer;
|
||||||
@ -3651,6 +3670,15 @@ begin
|
|||||||
end;
|
end;
|
||||||
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;
|
function TFindDeclarationTool.JumpToNode(ANode: TCodeTreeNode;
|
||||||
var NewPos: TCodeXYPosition; var NewTopLine: integer;
|
var NewPos: TCodeXYPosition; var NewTopLine: integer;
|
||||||
IgnoreJumpCentered: boolean): boolean;
|
IgnoreJumpCentered: boolean): boolean;
|
||||||
@ -7615,5 +7643,42 @@ begin
|
|||||||
end;
|
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.
|
end.
|
||||||
|
|
||||||
|
@ -36,8 +36,8 @@ unit CodeContextForm;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, LResources, Forms, Controls, Graphics, Dialogs,
|
Classes, SysUtils, LCLProc, LResources, Forms, Controls, Graphics, Dialogs,
|
||||||
CodeCache, CodeToolManager, SynEdit;
|
CodeCache, FindDeclarationTool, CodeToolManager, SynEdit;
|
||||||
|
|
||||||
type
|
type
|
||||||
TCodeContextFrm = class(TForm)
|
TCodeContextFrm = class(TForm)
|
||||||
@ -55,11 +55,20 @@ implementation
|
|||||||
function ShowCodeContext(Code: TCodeBuffer; Editor: TSynEdit): boolean;
|
function ShowCodeContext(Code: TCodeBuffer; Editor: TSynEdit): boolean;
|
||||||
var
|
var
|
||||||
LogCaretXY: TPoint;
|
LogCaretXY: TPoint;
|
||||||
|
CodeContexts: TCodeContextInfo;
|
||||||
begin
|
begin
|
||||||
Result:=false;
|
Result:=false;
|
||||||
LogCaretXY:=Editor.LogicalCaretXY;
|
LogCaretXY:=Editor.LogicalCaretXY;
|
||||||
if not CodeToolBoss.FindCodeContext(Code,LogCaretXY,CodeContext) then
|
CodeContexts:=nil;
|
||||||
exit;
|
try
|
||||||
|
if not CodeToolBoss.FindCodeContext(Code,LogCaretXY.X,LogCaretXY.Y,
|
||||||
|
CodeContexts)
|
||||||
|
then
|
||||||
|
exit;
|
||||||
|
DebugLn('ShowCodeContext show ..');
|
||||||
|
finally
|
||||||
|
CodeContexts.Free;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
initialization
|
initialization
|
||||||
|
@ -43,7 +43,7 @@ uses
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
Classes, SysUtils, Math, Controls, LCLProc, LCLType, LResources, LCLIntf,
|
Classes, SysUtils, Math, Controls, LCLProc, LCLType, LResources, LCLIntf,
|
||||||
FileUtil, Forms, Buttons, ComCtrls, Dialogs, StdCtrls, GraphType, Graphics,
|
FileUtil, Forms, Buttons, ComCtrls, Dialogs, StdCtrls, GraphType, Graphics,
|
||||||
TypInfo, Extctrls, Menus,
|
TypInfo, Extctrls, Menus, CodeContextForm,
|
||||||
// codetools
|
// codetools
|
||||||
CodeToolManager, CodeCache, SourceLog,
|
CodeToolManager, CodeCache, SourceLog,
|
||||||
// synedit
|
// synedit
|
||||||
|
@ -28,7 +28,7 @@ MAKEOPTS="-Fl/opt/gnome/lib"
|
|||||||
if [ -n "$FPCCfg" ]; then
|
if [ -n "$FPCCfg" ]; then
|
||||||
MAKEOPTS="$MAKEOPTS -n @$FPCCfg"
|
MAKEOPTS="$MAKEOPTS -n @$FPCCfg"
|
||||||
fi
|
fi
|
||||||
make all OPT="$MAKEOPTS" USESVN2REVISIONINC=0
|
make bigide OPT="$MAKEOPTS" USESVN2REVISIONINC=0
|
||||||
make tools OPT="$MAKEOPTS"
|
make tools OPT="$MAKEOPTS"
|
||||||
# build gtk2 .ppu
|
# build gtk2 .ppu
|
||||||
export LCL_PLATFORM=gtk2
|
export LCL_PLATFORM=gtk2
|
||||||
|
Loading…
Reference in New Issue
Block a user