mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-06 16:58:25 +02:00
codetools: searching top most type section
git-svn-id: trunk@29356 -
This commit is contained in:
parent
9d8f487e25
commit
e2de6ffbef
@ -4820,7 +4820,7 @@ begin
|
|||||||
ClassProcs:=nil;
|
ClassProcs:=nil;
|
||||||
try
|
try
|
||||||
// gather body nodes
|
// gather body nodes
|
||||||
TypeSectionNode:=CodeCompleteClassNode.GetNodeOfType(ctnTypeSection);
|
TypeSectionNode:=CodeCompleteClassNode.GetTopMostNodeOfType(ctnTypeSection);
|
||||||
ProcBodyNodes:=GatherProcNodes(TypeSectionNode,
|
ProcBodyNodes:=GatherProcNodes(TypeSectionNode,
|
||||||
[phpInUpperCase,phpIgnoreForwards,phpOnlyWithClassname],
|
[phpInUpperCase,phpIgnoreForwards,phpOnlyWithClassname],
|
||||||
ExtractClassName(CodeCompleteClassNode,true));
|
ExtractClassName(CodeCompleteClassNode,true));
|
||||||
@ -6415,7 +6415,7 @@ var
|
|||||||
|
|
||||||
procedure GatherExistingClassProcBodies;
|
procedure GatherExistingClassProcBodies;
|
||||||
begin
|
begin
|
||||||
TypeSectionNode:=CodeCompleteClassNode.GetNodeOfType(ctnTypeSection);
|
TypeSectionNode:=CodeCompleteClassNode.GetTopMostNodeOfType(ctnTypeSection);
|
||||||
ClassProcs:=nil;
|
ClassProcs:=nil;
|
||||||
ProcBodyNodes:=GatherProcNodes(TypeSectionNode,
|
ProcBodyNodes:=GatherProcNodes(TypeSectionNode,
|
||||||
[phpInUpperCase,phpIgnoreForwards,phpOnlyWithClassname],
|
[phpInUpperCase,phpIgnoreForwards,phpOnlyWithClassname],
|
||||||
@ -6616,10 +6616,7 @@ var
|
|||||||
StartSearchProc:=ImplementationNode.FirstChild;
|
StartSearchProc:=ImplementationNode.FirstChild;
|
||||||
end else begin
|
end else begin
|
||||||
// class is not in interface section
|
// class is not in interface section
|
||||||
StartSearchProc:=CodeCompleteClassNode;
|
StartSearchProc:=CodeCompleteClassNode.GetTopMostNodeOfType(ctnTypeSection);
|
||||||
while (StartSearchProc.Parent<>nil)
|
|
||||||
and (StartSearchProc.Desc<>ctnTypeSection) do
|
|
||||||
StartSearchProc:=StartSearchProc.Parent;
|
|
||||||
end;
|
end;
|
||||||
case ASourceChangeCache.BeautifyCodeOptions.ForwardProcBodyInsertPolicy of
|
case ASourceChangeCache.BeautifyCodeOptions.ForwardProcBodyInsertPolicy of
|
||||||
fpipInFrontOfMethods:
|
fpipInFrontOfMethods:
|
||||||
@ -6913,7 +6910,6 @@ var
|
|||||||
OldCodePos: TCodePosition;
|
OldCodePos: TCodePosition;
|
||||||
CursorNode: TCodeTreeNode;
|
CursorNode: TCodeTreeNode;
|
||||||
CurClassName: String;
|
CurClassName: String;
|
||||||
ANode: TCodeTreeNode;
|
|
||||||
ProcNode: TCodeTreeNode;
|
ProcNode: TCodeTreeNode;
|
||||||
begin
|
begin
|
||||||
Result:=false;
|
Result:=false;
|
||||||
@ -6941,22 +6937,12 @@ begin
|
|||||||
CursorNode:=FindDeepestNodeAtPos(CleanPos,true);
|
CursorNode:=FindDeepestNodeAtPos(CleanPos,true);
|
||||||
// due to insertions in front of the class, the cursor position could
|
// due to insertions in front of the class, the cursor position could
|
||||||
// have changed
|
// have changed
|
||||||
while (CursorNode<>nil) do begin
|
if CursorNode<>nil then
|
||||||
if (CursorNode.Desc=ctnTypeSection)
|
CursorNode:=CursorNode.GetTopMostNodeOfType(ctnTypeSection);
|
||||||
or ((CursorNode.Parent<>nil) and (CursorNode.Parent.Desc=ctnTypeSection))
|
|
||||||
then break;
|
|
||||||
CursorNode:=CursorNode.Parent;
|
|
||||||
end;
|
|
||||||
FCodeCompleteClassNode:=FindClassNode(CursorNode,CurClassName,true,false);
|
FCodeCompleteClassNode:=FindClassNode(CursorNode,CurClassName,true,false);
|
||||||
if CodeCompleteClassNode=nil then
|
if CodeCompleteClassNode=nil then
|
||||||
RaiseException('oops, I lost your class');
|
RaiseException('oops, I lost your class');
|
||||||
ANode:=CodeCompleteClassNode.GetNodeOfTypes(
|
ProcNode:=FindProcNode(CursorNode,FJumpToProcName,
|
||||||
[ctnTypeDefinition,ctnGenericType]);
|
|
||||||
if ANode=nil then
|
|
||||||
RaiseException(ctsClassNodeWithoutParentNode);
|
|
||||||
if (ANode.Parent<>nil) and (ANode.Parent.Desc=ctnTypeSection) then
|
|
||||||
ANode:=ANode.Parent;
|
|
||||||
ProcNode:=FindProcNode(ANode,FJumpToProcName,
|
|
||||||
[phpInUpperCase,phpIgnoreForwards]);
|
[phpInUpperCase,phpIgnoreForwards]);
|
||||||
if ProcNode=nil then
|
if ProcNode=nil then
|
||||||
RaiseException(ctsNewProcBodyNotFound);
|
RaiseException(ctsNewProcBodyNotFound);
|
||||||
|
@ -563,10 +563,7 @@ begin
|
|||||||
DebugLn('TMethodJumpingCodeTool.FindJumpPoint 4F ');
|
DebugLn('TMethodJumpingCodeTool.FindJumpPoint 4F ');
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
// gather method bodies
|
// gather method bodies
|
||||||
TypeSectionNode:=ClassNode.Parent;
|
TypeSectionNode:=ClassNode.GetTopMostNodeOfType(ctnTypeSection);
|
||||||
if (TypeSectionNode<>nil) and (TypeSectionNode.Parent<>nil)
|
|
||||||
and (TypeSectionNode.Parent.Desc=ctnTypeSection) then
|
|
||||||
TypeSectionNode:=TypeSectionNode.Parent;
|
|
||||||
SearchForNodes:=GatherProcNodes(TypeSectionNode,
|
SearchForNodes:=GatherProcNodes(TypeSectionNode,
|
||||||
[phpInUpperCase,phpIgnoreForwards,phpOnlyWithClassname],
|
[phpInUpperCase,phpIgnoreForwards,phpOnlyWithClassname],
|
||||||
ExtractClassName(ClassNode,true));
|
ExtractClassName(ClassNode,true));
|
||||||
|
@ -654,7 +654,7 @@ begin
|
|||||||
if ClassNode<>nil then begin
|
if ClassNode<>nil then begin
|
||||||
//debugln('TPascalReaderTool.FindCorrespondingProcNode Class');
|
//debugln('TPascalReaderTool.FindCorrespondingProcNode Class');
|
||||||
// in a class definition -> search method body
|
// in a class definition -> search method body
|
||||||
StartNode:=ClassNode.GetNodeOfType(ctnTypeSection)
|
StartNode:=ClassNode.GetTopMostNodeOfType(ctnTypeSection)
|
||||||
end else if NodeIsMethodBody(ProcNode) then begin
|
end else if NodeIsMethodBody(ProcNode) then begin
|
||||||
//debugln('TPascalReaderTool.FindCorrespondingProcNode Method ',ExtractClassNameOfProcNode(ProcNode));
|
//debugln('TPascalReaderTool.FindCorrespondingProcNode Method ',ExtractClassNameOfProcNode(ProcNode));
|
||||||
// in a method body -> search in class
|
// in a method body -> search in class
|
||||||
@ -1863,6 +1863,7 @@ end;
|
|||||||
|
|
||||||
function TPascalReaderTool.NodeIsIdentifierInInterface(Node: TCodeTreeNode
|
function TPascalReaderTool.NodeIsIdentifierInInterface(Node: TCodeTreeNode
|
||||||
): boolean;
|
): boolean;
|
||||||
|
// true if identifier is visible from other units (without prefixing)
|
||||||
begin
|
begin
|
||||||
case Node.Desc of
|
case Node.Desc of
|
||||||
ctnEnumIdentifier:
|
ctnEnumIdentifier:
|
||||||
|
Loading…
Reference in New Issue
Block a user