mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-11 19:16:16 +02:00
extended codetools for method jumping in generic classes
git-svn-id: trunk@8368 -
This commit is contained in:
parent
52ebb7d2a7
commit
10bbedf011
@ -32,17 +32,17 @@ var
|
||||
NewCode: TCodeBuffer;
|
||||
NewX, NewY, NewTopLine: integer;
|
||||
RevertableJump: boolean;
|
||||
Tool: TCustomCodeTool;
|
||||
//Tool: TCustomCodeTool;
|
||||
begin
|
||||
ExpandedFilename:=ExpandFileName('tgeneric2.pp');
|
||||
CodeBuf:=CodeToolBoss.LoadFile(ExpandedFilename,true,false);
|
||||
if CodeToolBoss.JumpToMethod(CodeBuf,10,8,NewCode,NewX,NewY,NewTopLine,
|
||||
if CodeToolBoss.JumpToMethod(CodeBuf,3,15,NewCode,NewX,NewY,NewTopLine,
|
||||
RevertableJump)
|
||||
then
|
||||
writeln(NewCode.Filename,' ',NewX,',',NewY,' TopLine=',NewTopLine,' RevertableJump=',RevertableJump)
|
||||
else
|
||||
writeln('Method body not found.');
|
||||
Tool:=CodeToolBoss.FindCodeToolForSource(CodeBuf);
|
||||
Tool.WriteDebugTreeReport;
|
||||
//Tool:=CodeToolBoss.FindCodeToolForSource(CodeBuf);
|
||||
//Tool.WriteDebugTreeReport;
|
||||
end.
|
||||
|
||||
|
@ -271,9 +271,10 @@ const
|
||||
ProcNode: TCodeTreeNode;
|
||||
begin
|
||||
Result:=false;
|
||||
if SearchForProcNode=nil then exit;
|
||||
SearchedProcHead:=ExtractProcHead(SearchForProcNode,SearchForProcAttr);
|
||||
{$IFDEF CTDEBUG}
|
||||
DebugLn('TMethodJumpingCodeTool.FindJumpPoint.FindBestProcNode Searching ',dbgs(ProcNode<>nil),' "',SearchedProcHead,'"');
|
||||
DebugLn('TMethodJumpingCodeTool.FindJumpPoint.FindBestProcNode Searching ',SearchForProcNode.DescAsString,' "',SearchedProcHead,'" ',ProcHeadAttributesToStr(SearchForProcAttr));
|
||||
{$ENDIF}
|
||||
if SearchedProcHead='' then exit;
|
||||
ProcNode:=FindProcNode(StartNode,SearchedProcHead,SearchInProcAttr);
|
||||
@ -353,10 +354,7 @@ begin
|
||||
DebugLn('TMethodJumpingCodeTool.FindJumpPoint E ',dbgs(CleanCursorPos),', |',copy(Src,CleanCursorPos,8));
|
||||
{$ENDIF}
|
||||
BuildSubTreeForClass(ClassNode);
|
||||
TypeSectionNode:=ClassNode.Parent;
|
||||
if (TypeSectionNode<>nil) and (TypeSectionNode.Parent<>nil)
|
||||
and (TypeSectionNode.Parent.Desc=ctnTypeSection) then
|
||||
TypeSectionNode:=TypeSectionNode.Parent;
|
||||
TypeSectionNode:=ClassNode.GetNodeOfType(ctnTypeSection);
|
||||
// search the method node under the cursor
|
||||
CursorNode:=FindDeepestNodeAtPos(CleanCursorPos,true).
|
||||
GetNodeOfType(ctnProcedure);
|
||||
|
@ -326,7 +326,7 @@ end;
|
||||
function TPascalReaderTool.ExtractProcHead(ProcNode: TCodeTreeNode;
|
||||
Attr: TProcHeadAttributes): string;
|
||||
var
|
||||
GrandPaNode: TCodeTreeNode;
|
||||
TypeDefNode: TCodeTreeNode;
|
||||
TheClassName, s: string;
|
||||
HasClassName, IsProcType: boolean;
|
||||
IsProcedure: Boolean;
|
||||
@ -344,13 +344,17 @@ begin
|
||||
exit;
|
||||
IsProcType:=(ProcNode.Desc=ctnProcedureType);
|
||||
if (phpAddClassname in Attr) then begin
|
||||
GrandPaNode:=ProcNode.Parent;
|
||||
if GrandPaNode=nil then exit;
|
||||
GrandPaNode:=GrandPaNode.Parent;
|
||||
if (GrandPaNode=nil) or (GrandPaNode.Desc<>ctnClass) then exit;
|
||||
GrandPaNode:=GrandPaNode.Parent;
|
||||
if GrandPaNode.Desc<>ctnTypeDefinition then exit;
|
||||
MoveCursorToCleanPos(GrandPaNode.StartPos);
|
||||
TypeDefNode:=ProcNode.Parent;
|
||||
if TypeDefNode=nil then exit;
|
||||
TypeDefNode:=TypeDefNode.Parent;
|
||||
if (TypeDefNode=nil) or (TypeDefNode.Desc<>ctnClass) then exit;
|
||||
TypeDefNode:=TypeDefNode.Parent;
|
||||
if TypeDefNode.Desc=ctnGenericType then begin
|
||||
TypeDefNode:=TypeDefNode.Parent;
|
||||
if TypeDefNode=nil then exit;
|
||||
end;
|
||||
if TypeDefNode.Desc<>ctnTypeDefinition then exit;
|
||||
MoveCursorToCleanPos(TypeDefNode.StartPos);
|
||||
ReadNextAtom;
|
||||
if not AtomIsIdentifier(false) then exit;
|
||||
TheClassName:=GetAtom;
|
||||
@ -365,7 +369,6 @@ begin
|
||||
ExtractNextAtom((phpWithStart in Attr)
|
||||
and not (phpWithoutClassKeyword in Attr),Attr);
|
||||
IsProcedure:=UpAtomIs('PROCEDURE');
|
||||
IsProcedure:=UpAtomIs('PROCEDURE');
|
||||
IsFunction:=(not IsProcedure) and UpAtomIs('FUNCTION');
|
||||
IsOperator:=(not IsProcedure) and (not IsFunction) and UpAtomIs('OPERATOR');
|
||||
if IsProcedure or IsFunction or IsOperator
|
||||
@ -1056,6 +1059,8 @@ begin
|
||||
if Result<>nil then exit;
|
||||
end else if ANode.Desc=ctnTypeDefinition then begin
|
||||
CurClassNode:=ANode.FirstChild;
|
||||
if (CurClassNode<>nil) and (CurClassNode.Desc=ctnGenericType) then
|
||||
CurClassNode:=CurClassNode.FirstChild;
|
||||
if (CurClassNode<>nil) and (CurClassNode.Desc=ctnClass) then begin
|
||||
if (not (IgnoreForwards
|
||||
and ((CurClassNode.SubDesc and ctnsForwardDeclaration)>0)))
|
||||
|
Loading…
Reference in New Issue
Block a user