Jedi code format: add support for record alignment directive.

This commit is contained in:
DomingoGP 2024-01-19 21:39:10 +01:00
parent afae7dfa87
commit 839c4e8307
7 changed files with 27 additions and 1 deletions

View File

@ -2186,6 +2186,11 @@ begin
begin
RecogniseRecordBody;
Recognise(ttEnd);
if fcTokenList.FirstSolidTokenType = ttAlign then
begin
Recognise(ttAlign);
RecogniseConstantExpression;
end;
end;
RecogniseHintDirectives;

View File

@ -155,6 +155,7 @@ type
{ reserved words that are directives }
ttAbsolute,
ttAlign,
ttExternal,
ttPascal,
ttSafecall,
@ -681,6 +682,7 @@ begin
AddKeyword('package', wtReservedWordDirective, ttPackage);
AddKeyword('contains', wtReservedWordDirective, ttContains);
AddKeyword('requires', wtReservedWordDirective, ttRequires);
AddKeyword('align', wtReservedWordDirective, ttAlign);
{ reseved words that are directives }
AddKeyword('absolute', wtReservedWordDirective, ttAbsolute);

View File

@ -91,6 +91,10 @@ begin
if pt.HasParentNode(nAsm) then
exit;
{ after record ... end align XX; }
if (pt.TokenType = ttAlign) and pt.HasParentNode(nRecordType, 1) then
exit(True);
lcSetReturns := FormattingSettings.Returns;
Assert(lcSetReturns <> nil);

View File

@ -71,6 +71,10 @@ begin
if pt.TokenType=ttReference then
exit(true);
{ after record ... end align XX; }
if (pt.TokenType = ttAlign) and pt.HasParentNode(nRecordType, 1) then
exit(true);
// referencce to procedure/function
if (pt.TokenType in [ttFunction,ttProcedure]) and (pt.PriorSolidTokenType=ttTo) then
exit(true);

View File

@ -316,7 +316,10 @@ begin
if (lcNext <> nil) and (lcNext.TokenType = ttElse) then
Result := (FormattingSettings.Returns.EndElseStyle = eAlways)
else
Result := True;
begin
{ after record ... end align XX; }
Result := not ((lcNext <> nil) and (lcNext.TokenType = ttAlign) and lcNext.HasParentNode(nRecordType, 1));
end;
exit;
end;

View File

@ -78,6 +78,10 @@ begin
Result := False;
{ after record ... end align XX; }
if (pt.TokenType = ttAlign) and pt.HasParentNode(nRecordType, 1) then
exit(True);
if (pt.TokenType in operators) and pt.HasParentNode(nIdentifier,1) then //operator orverloading identifier;
Exit(False);

View File

@ -78,6 +78,10 @@ begin
if pt = nil then
exit;
{ after record ... end align XX; }
if (pt.TokenType = ttAlign) and pt.HasParentNode(nRecordType, 1) then
exit(True);
if pt.HasParentNode(nGeneric, 1) then
exit;