CodeTools: don't break one-liner class definitions like "private const". Issue 39514

This commit is contained in:
Ondrej Pokorny 2021-12-13 17:46:46 +01:00
parent fdd5721318
commit 1dac8b96e8

View File

@ -7732,8 +7732,12 @@ begin
if CodeCompleteClassNode.Desc in AllClassObjects then
begin
ClassSectionNode:=CodeCompleteClassNode.FirstChild;
while (ClassSectionNode<>nil)
and (ClassSectionNode.Desc<>ClassSectionNodeType[Visibility]) do
while (ClassSectionNode<>nil) and (
(ClassSectionNode.Desc<>ClassSectionNodeType[Visibility])
// do not break one-liner double definitions like "private const" (const is a child node for the private section)
or ((ClassSectionNode.FirstChild<>nil)
and (ClassSectionNode.FirstChild.StartPos=ClassSectionNode.StartPos+Length(NodeDescriptionAsString(ClassSectionNode.Desc))+1))
) do
ClassSectionNode:=ClassSectionNode.NextBrother;
end else begin
ClassSectionNode:=CodeCompleteClassNode;
@ -7999,8 +8003,12 @@ var
SectionNode:=SectionNode.PriorBrother;
end else
SectionNode:=CodeCompleteClassNode.LastChild;
while (SectionNode<>nil)
and (SectionNode.Desc<>ClassSectionNodeType[Visibility]) do
while (SectionNode<>nil) and (
(SectionNode.Desc<>ClassSectionNodeType[Visibility])
// do not break one-liner double definitions like "private const" (const is a child node for the private section)
or ((SectionNode.FirstChild<>nil)
and (SectionNode.FirstChild.StartPos=SectionNode.StartPos+Length(NodeDescriptionAsString(SectionNode.Desc))+1))
) do
SectionNode:=SectionNode.PriorBrother;
if (SectionNode<>nil) then begin
//DebugLn(['AddClassSection section exists for ',NodeDescriptionAsString(ClassSectionNodeType[Visibility])]);