mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 20:01:45 +02:00
Jedi code format: dont't ident comments before procedures at the end of sections. Issue #40533.
This commit is contained in:
parent
f453aa8a45
commit
8035014eaf
@ -128,6 +128,16 @@ begin
|
|||||||
Result := True;
|
Result := True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function HasEmptyLineAfterComment(const pt: TSourceToken): Boolean;
|
||||||
|
var
|
||||||
|
pnext: TSourceToken;
|
||||||
|
begin
|
||||||
|
result:=false;
|
||||||
|
pnext:=pt.NextTokenWithExclusions([ttWhiteSpace]); //End of current line
|
||||||
|
if (pnext<>nil) and (pnext.TokenType=ttReturn) then
|
||||||
|
result:= pnext.NextTokenTypeWithExclusions([ttWhiteSpace])=ttReturn;
|
||||||
|
end;
|
||||||
|
|
||||||
function IsIndented(const pt: TSourceToken): Boolean;
|
function IsIndented(const pt: TSourceToken): Boolean;
|
||||||
begin
|
begin
|
||||||
Result := IsFirstSolidTokenOnLine(pt);
|
Result := IsFirstSolidTokenOnLine(pt);
|
||||||
@ -669,6 +679,21 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
// last comments in var, const,... sections belongs to the next procedure/function.
|
||||||
|
if (pt.TokenType=ttComment) and pt.HasParentNode([nTypeSection,nVarSection,nConstSection,nUses])
|
||||||
|
and (pt.NextSolidTokenType in ProcedureWords)
|
||||||
|
and ( not pt.HasParentNode(ObjectBodies + [nRecordType]))
|
||||||
|
//not followed by a blank line.
|
||||||
|
and not HasEmptyLineAfterComment(pt) then
|
||||||
|
begin
|
||||||
|
Result:=0;
|
||||||
|
if FormattingSettings.Indent.IndentLibraryProcs then
|
||||||
|
begin
|
||||||
|
if pt.HasParentNode([nLibrary, nProgram]) and (liIndentCount >= 1) then
|
||||||
|
Result:=1;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
constructor TIndenter.Create;
|
constructor TIndenter.Create;
|
||||||
|
Loading…
Reference in New Issue
Block a user