mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-22 07:19:31 +02:00
Jedi code format: adds an extra space lines at sections end. Issue #40539
This commit is contained in:
parent
df428e215f
commit
77f9fb9cd0
@ -123,7 +123,7 @@ function ProcedureHasBody(const pt: TParseTreeNode): boolean;
|
||||
function FirstSolidChild(const pt: TParseTreeNode): TParseTreeNode;
|
||||
|
||||
function InFilesUses(const pt: TParseTreeNode): boolean;
|
||||
|
||||
function NextTokenIsCommentInNewLine(const pt:TSourceToken):boolean;
|
||||
|
||||
function Root(const pt: TParseTreeNode): TParseTreeNode;
|
||||
|
||||
@ -910,4 +910,15 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function NextTokenIsCommentInNewLine(const pt:TSourceToken):boolean;
|
||||
var
|
||||
lcNext:TSourceToken;
|
||||
begin
|
||||
result:=false;
|
||||
lcNext:=pt.NextTokenWithExclusions([ttWhiteSpace,ttReturn]);
|
||||
if (lcNext<>nil) and (lcNext.TokenType=ttComment) {and (lcNext.CommentStyle=eCompilerDirective)} then
|
||||
result:=true;
|
||||
end;
|
||||
|
||||
|
||||
end.
|
||||
|
@ -128,14 +128,29 @@ begin
|
||||
Result := True;
|
||||
end;
|
||||
|
||||
function HasEmptyLineAfterComment(const pt: TSourceToken): Boolean;
|
||||
function HasEmptyLineOrDirectiveAfterComments(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;
|
||||
while (pnext<>nil) and (pnext.TokenType=ttReturn) do
|
||||
begin
|
||||
pnext:= pnext.NextTokenWithExclusions([ttWhiteSpace]);
|
||||
if pnext<>nil then
|
||||
begin
|
||||
if pnext.TokenType=ttReturn then
|
||||
Exit(true);
|
||||
if pnext.TokenType=ttComment then
|
||||
begin
|
||||
if pnext.CommentStyle=eCompilerDirective then
|
||||
Exit(true);
|
||||
pnext:=pnext.NextTokenWithExclusions([ttWhiteSpace]); //End of current line
|
||||
end
|
||||
else
|
||||
Exit(false);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
function IsIndented(const pt: TSourceToken): Boolean;
|
||||
@ -684,7 +699,7 @@ begin
|
||||
and (pt.NextSolidTokenType in ProcedureWords)
|
||||
and ( not pt.HasParentNode(ObjectBodies + [nRecordType]))
|
||||
//not followed by a blank line.
|
||||
and not HasEmptyLineAfterComment(pt) then
|
||||
and not HasEmptyLineOrDirectiveAfterComments(pt) then
|
||||
begin
|
||||
Result:=0;
|
||||
if FormattingSettings.Indent.IndentLibraryProcs then
|
||||
|
@ -190,6 +190,9 @@ begin
|
||||
if (pt.TokenType = ttSemiColon) and (pt.NextTokenTypeWithExclusions([ttWhiteSpace]) = ttComment) then
|
||||
Exit(False);
|
||||
|
||||
if (pt.TokenType = ttSemiColon) and NextTokenIsCommentInNewLine(pt) then
|
||||
Exit(False);
|
||||
|
||||
lcPt := pt;
|
||||
if (pt.TokenType = ttComment) and (pt.PriorTokenTypeWithExclusions([ttWhiteSpace])=ttSemiColon) then
|
||||
lcPt:= pt.PriorTokenWithExclusions([ttWhiteSpace]); // use the ';' token before the comment for tests.
|
||||
|
Loading…
Reference in New Issue
Block a user