Jedi Code Format: Format operator := and "case" in records. Issue #38995, patch by Domingo Galmés.

git-svn-id: trunk@65223 -
This commit is contained in:
juha 2021-06-13 10:11:55 +00:00
parent 3347fe79d8
commit 6f17bec491
3 changed files with 29 additions and 7 deletions

View File

@ -1042,7 +1042,7 @@ begin
begin begin
if leFirstTokenType in (ClassVisibility+[ttStrict]) then if leFirstTokenType in (ClassVisibility+[ttStrict]) then
break; break;
if leFirstTokenType in [ttClass,ttVar,ttThreadVar,ttConst,ttFunction,ttProcedure,ttOperator,ttConstructor,ttDestructor,ttProperty] then if leFirstTokenType in [ttClass,ttVar,ttThreadVar,ttConst,ttFunction,ttProcedure,ttOperator,ttConstructor,ttDestructor,ttProperty,ttCase] then
break; break;
end end
else else
@ -1123,7 +1123,7 @@ begin
begin begin
if fcTokenList.FirstSolidTokenType in (ClassVisibility + [ttStrict]) then if fcTokenList.FirstSolidTokenType in (ClassVisibility + [ttStrict]) then
break; break;
if fcTokenList.FirstSolidTokenType in [ttClass,ttVar,ttThreadVar, ttConst,ttFunction,ttProcedure,ttOperator,ttConstructor,ttDestructor,ttProperty] then if fcTokenList.FirstSolidTokenType in [ttClass,ttVar,ttThreadVar, ttConst,ttFunction,ttProcedure,ttOperator,ttConstructor,ttDestructor,ttProperty,ttCase] then
break; break;
end end
else else
@ -2458,7 +2458,7 @@ const
END_VAR_SECTION: TTokenTypeSet = END_VAR_SECTION: TTokenTypeSet =
[ttVar, ttThreadVar, ttConst, ttLabel, ttResourceString, ttType, [ttVar, ttThreadVar, ttConst, ttLabel, ttResourceString, ttType,
ttBegin, ttEnd, ttImplementation, ttInitialization, ttBegin, ttEnd, ttImplementation, ttInitialization,
ttProcedure, ttFunction, ttOperator, ttConstructor, ttDestructor, ttClass, ttAsm, ttGeneric]; ttProcedure, ttFunction, ttOperator, ttConstructor, ttDestructor, ttClass, ttAsm, ttGeneric, ttCase];
var var
leEndVarSection: TTokenTypeSet; leEndVarSection: TTokenTypeSet;
begin begin
@ -2493,6 +2493,7 @@ begin
PushNode(nFunctionHeading); PushNode(nFunctionHeading);
Recognise(ttClass); Recognise(ttClass);
Recognise(ttOperator); Recognise(ttOperator);
RecogniseMethodName(False); RecogniseMethodName(False);
if fcTokenList.FirstSolidTokenType = ttOpenBracket then if fcTokenList.FirstSolidTokenType = ttOpenBracket then
RecogniseFormalParameters; RecogniseFormalParameters;
@ -5182,6 +5183,14 @@ procedure TBuildParseTree.RecogniseMethodName(const pbClassNameCompulsory: boole
var var
lbMore: boolean; lbMore: boolean;
begin begin
if fcTokenList.FirstSolidTokenType = ttAssign then
begin
PushNode(nIdentifier);
Recognise(ttAssign);
PopNode;
exit;
end
else
if IsSymbolOperator(fcTokenList.FirstSolidToken) then begin if IsSymbolOperator(fcTokenList.FirstSolidToken) then begin
PushNode(nIdentifier); PushNode(nIdentifier);
Recognise(Operators); Recognise(Operators);
@ -5209,7 +5218,10 @@ begin
while lbMore do while lbMore do
begin begin
Recognise(ttDot); Recognise(ttDot);
Recognise(IdentiferTokens + Operators); if fcTokenList.FirstSolidTokenType = ttAssign then
Recognise(ttAssign)
else
Recognise(IdentiferTokens + Operators);
if fcTokenList.FirstSolidTokenType = ttLessThan then if fcTokenList.FirstSolidTokenType = ttLessThan then
begin begin
@ -5932,13 +5944,13 @@ var
lc: TSourceToken; lc: TSourceToken;
begin begin
lc := fcTokenList.FirstSolidToken; lc := fcTokenList.FirstSolidToken;
if (lc.TokenType=ttIdentifier) and (length(lc.SourceCode)=10) and (lowercase(lc.SourceCode)='enumerator') then if (lc<>nil) and (lc.TokenType=ttIdentifier) and (length(lc.SourceCode)=10) and (lowercase(lc.SourceCode)='enumerator') then
begin begin
lc.TokenType:=ttEnumerator; lc.TokenType:=ttEnumerator;
lc.WordType:=wtReservedWord; lc.WordType:=wtReservedWord;
end; end;
lc := fcTokenList.SolidToken(2); lc := fcTokenList.SolidToken(2);
if (lc.TokenType=ttIdentifier) and (length(lc.SourceCode)=10) and (lowercase(lc.SourceCode)='enumerator') then if (lc<>nil) and (lc.TokenType=ttIdentifier) and (length(lc.SourceCode)=10) and (lowercase(lc.SourceCode)='enumerator') then
begin begin
lc.TokenType:=ttEnumerator; lc.TokenType:=ttEnumerator;
lc.WordType:=wtReservedWord; lc.WordType:=wtReservedWord;

View File

@ -67,7 +67,7 @@ const
function NeedsSingleSpace(const pt, ptNext: TSourceToken): boolean; function NeedsSingleSpace(const pt, ptNext: TSourceToken): boolean;
var var
lcSameLineToken: TSourceToken; lcSameLineToken,lcPrev: TSourceToken;
begin begin
Assert(pt <> nil); Assert(pt <> nil);
Assert(ptNext <> nil); Assert(ptNext <> nil);
@ -120,7 +120,12 @@ begin
Result := True; Result := True;
if (pt.TokenType in SingleSpaceAfterTokens) then if (pt.TokenType in SingleSpaceAfterTokens) then
begin
lcPrev := pt.PriorSolidToken;
if (lcPrev <> nil) and (lcPrev.TokenType = ttDot) then // operaror typename.:=( ) .+= .*=
exit(false);
exit(True); exit(True);
end;
if pt.TokenType = ttOpenBracket then if pt.TokenType = ttOpenBracket then
if FormattingSettings.Spaces.SpaceAfterOpenBrackets then if FormattingSettings.Spaces.SpaceAfterOpenBrackets then

View File

@ -122,7 +122,12 @@ begin
exit; exit;
if (pt.TokenType in AssignmentDirectives) then if (pt.TokenType in AssignmentDirectives) then
begin
lcPrev := pt.PriorSolidToken;
if (lcPrev <> nil) and (lcPrev.TokenType = ttDot) then // operaror typename.:=( )
exit(false);
exit(True); exit(True);
end;
if IsHintDirective(pt) then if IsHintDirective(pt) then
exit(True); exit(True);