diff --git a/components/codetools/codecompletiontool.pas b/components/codetools/codecompletiontool.pas index 12b90b8d27..44e0e7c58d 100644 --- a/components/codetools/codecompletiontool.pas +++ b/components/codetools/codecompletiontool.pas @@ -4820,7 +4820,7 @@ begin ClassProcs:=nil; try // gather body nodes - TypeSectionNode:=CodeCompleteClassNode.GetNodeOfType(ctnTypeSection); + TypeSectionNode:=CodeCompleteClassNode.GetTopMostNodeOfType(ctnTypeSection); ProcBodyNodes:=GatherProcNodes(TypeSectionNode, [phpInUpperCase,phpIgnoreForwards,phpOnlyWithClassname], ExtractClassName(CodeCompleteClassNode,true)); @@ -6415,7 +6415,7 @@ var procedure GatherExistingClassProcBodies; begin - TypeSectionNode:=CodeCompleteClassNode.GetNodeOfType(ctnTypeSection); + TypeSectionNode:=CodeCompleteClassNode.GetTopMostNodeOfType(ctnTypeSection); ClassProcs:=nil; ProcBodyNodes:=GatherProcNodes(TypeSectionNode, [phpInUpperCase,phpIgnoreForwards,phpOnlyWithClassname], @@ -6616,10 +6616,7 @@ var StartSearchProc:=ImplementationNode.FirstChild; end else begin // class is not in interface section - StartSearchProc:=CodeCompleteClassNode; - while (StartSearchProc.Parent<>nil) - and (StartSearchProc.Desc<>ctnTypeSection) do - StartSearchProc:=StartSearchProc.Parent; + StartSearchProc:=CodeCompleteClassNode.GetTopMostNodeOfType(ctnTypeSection); end; case ASourceChangeCache.BeautifyCodeOptions.ForwardProcBodyInsertPolicy of fpipInFrontOfMethods: @@ -6913,7 +6910,6 @@ var OldCodePos: TCodePosition; CursorNode: TCodeTreeNode; CurClassName: String; - ANode: TCodeTreeNode; ProcNode: TCodeTreeNode; begin Result:=false; @@ -6941,22 +6937,12 @@ begin CursorNode:=FindDeepestNodeAtPos(CleanPos,true); // due to insertions in front of the class, the cursor position could // have changed - while (CursorNode<>nil) do begin - if (CursorNode.Desc=ctnTypeSection) - or ((CursorNode.Parent<>nil) and (CursorNode.Parent.Desc=ctnTypeSection)) - then break; - CursorNode:=CursorNode.Parent; - end; + if CursorNode<>nil then + CursorNode:=CursorNode.GetTopMostNodeOfType(ctnTypeSection); FCodeCompleteClassNode:=FindClassNode(CursorNode,CurClassName,true,false); if CodeCompleteClassNode=nil then RaiseException('oops, I lost your class'); - ANode:=CodeCompleteClassNode.GetNodeOfTypes( - [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, + ProcNode:=FindProcNode(CursorNode,FJumpToProcName, [phpInUpperCase,phpIgnoreForwards]); if ProcNode=nil then RaiseException(ctsNewProcBodyNotFound); diff --git a/components/codetools/methodjumptool.pas b/components/codetools/methodjumptool.pas index dbfb01962e..81483e23ff 100644 --- a/components/codetools/methodjumptool.pas +++ b/components/codetools/methodjumptool.pas @@ -563,10 +563,7 @@ begin DebugLn('TMethodJumpingCodeTool.FindJumpPoint 4F '); {$ENDIF} // gather method bodies - TypeSectionNode:=ClassNode.Parent; - if (TypeSectionNode<>nil) and (TypeSectionNode.Parent<>nil) - and (TypeSectionNode.Parent.Desc=ctnTypeSection) then - TypeSectionNode:=TypeSectionNode.Parent; + TypeSectionNode:=ClassNode.GetTopMostNodeOfType(ctnTypeSection); SearchForNodes:=GatherProcNodes(TypeSectionNode, [phpInUpperCase,phpIgnoreForwards,phpOnlyWithClassname], ExtractClassName(ClassNode,true)); diff --git a/components/codetools/pascalreadertool.pas b/components/codetools/pascalreadertool.pas index 8679f65369..04784cb2f2 100644 --- a/components/codetools/pascalreadertool.pas +++ b/components/codetools/pascalreadertool.pas @@ -654,7 +654,7 @@ begin if ClassNode<>nil then begin //debugln('TPascalReaderTool.FindCorrespondingProcNode Class'); // in a class definition -> search method body - StartNode:=ClassNode.GetNodeOfType(ctnTypeSection) + StartNode:=ClassNode.GetTopMostNodeOfType(ctnTypeSection) end else if NodeIsMethodBody(ProcNode) then begin //debugln('TPascalReaderTool.FindCorrespondingProcNode Method ',ExtractClassNameOfProcNode(ProcNode)); // in a method body -> search in class @@ -1863,6 +1863,7 @@ end; function TPascalReaderTool.NodeIsIdentifierInInterface(Node: TCodeTreeNode ): boolean; +// true if identifier is visible from other units (without prefixing) begin case Node.Desc of ctnEnumIdentifier: