diff --git a/components/jcf2/Parse/BuildParseTree.pas b/components/jcf2/Parse/BuildParseTree.pas index 959f56fc32..7371a037cd 100644 --- a/components/jcf2/Parse/BuildParseTree.pas +++ b/components/jcf2/Parse/BuildParseTree.pas @@ -1042,7 +1042,7 @@ begin begin if leFirstTokenType in (ClassVisibility+[ttStrict]) then 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; end else @@ -1123,7 +1123,7 @@ begin begin if fcTokenList.FirstSolidTokenType in (ClassVisibility + [ttStrict]) then 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; end else @@ -2458,7 +2458,7 @@ const END_VAR_SECTION: TTokenTypeSet = [ttVar, ttThreadVar, ttConst, ttLabel, ttResourceString, ttType, ttBegin, ttEnd, ttImplementation, ttInitialization, - ttProcedure, ttFunction, ttOperator, ttConstructor, ttDestructor, ttClass, ttAsm, ttGeneric]; + ttProcedure, ttFunction, ttOperator, ttConstructor, ttDestructor, ttClass, ttAsm, ttGeneric, ttCase]; var leEndVarSection: TTokenTypeSet; begin @@ -2493,6 +2493,7 @@ begin PushNode(nFunctionHeading); Recognise(ttClass); Recognise(ttOperator); + RecogniseMethodName(False); if fcTokenList.FirstSolidTokenType = ttOpenBracket then RecogniseFormalParameters; @@ -5182,6 +5183,14 @@ procedure TBuildParseTree.RecogniseMethodName(const pbClassNameCompulsory: boole var lbMore: boolean; begin + if fcTokenList.FirstSolidTokenType = ttAssign then + begin + PushNode(nIdentifier); + Recognise(ttAssign); + PopNode; + exit; + end + else if IsSymbolOperator(fcTokenList.FirstSolidToken) then begin PushNode(nIdentifier); Recognise(Operators); @@ -5209,7 +5218,10 @@ begin while lbMore do begin Recognise(ttDot); - Recognise(IdentiferTokens + Operators); + if fcTokenList.FirstSolidTokenType = ttAssign then + Recognise(ttAssign) + else + Recognise(IdentiferTokens + Operators); if fcTokenList.FirstSolidTokenType = ttLessThan then begin @@ -5932,13 +5944,13 @@ var lc: TSourceToken; begin 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 lc.TokenType:=ttEnumerator; lc.WordType:=wtReservedWord; end; 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 lc.TokenType:=ttEnumerator; lc.WordType:=wtReservedWord; diff --git a/components/jcf2/Process/Spacing/SingleSpaceAfter.pas b/components/jcf2/Process/Spacing/SingleSpaceAfter.pas index 9a9f525b4f..c1698f9bb6 100644 --- a/components/jcf2/Process/Spacing/SingleSpaceAfter.pas +++ b/components/jcf2/Process/Spacing/SingleSpaceAfter.pas @@ -67,7 +67,7 @@ const function NeedsSingleSpace(const pt, ptNext: TSourceToken): boolean; var - lcSameLineToken: TSourceToken; + lcSameLineToken,lcPrev: TSourceToken; begin Assert(pt <> nil); Assert(ptNext <> nil); @@ -120,7 +120,12 @@ begin Result := True; if (pt.TokenType in SingleSpaceAfterTokens) then + begin + lcPrev := pt.PriorSolidToken; + if (lcPrev <> nil) and (lcPrev.TokenType = ttDot) then // operaror typename.:=( ) .+= .*= + exit(false); exit(True); + end; if pt.TokenType = ttOpenBracket then if FormattingSettings.Spaces.SpaceAfterOpenBrackets then diff --git a/components/jcf2/Process/Spacing/SingleSpaceBefore.pas b/components/jcf2/Process/Spacing/SingleSpaceBefore.pas index 50ed175e96..f4ad8e0ab1 100644 --- a/components/jcf2/Process/Spacing/SingleSpaceBefore.pas +++ b/components/jcf2/Process/Spacing/SingleSpaceBefore.pas @@ -122,7 +122,12 @@ begin exit; if (pt.TokenType in AssignmentDirectives) then + begin + lcPrev := pt.PriorSolidToken; + if (lcPrev <> nil) and (lcPrev.TokenType = ttDot) then // operaror typename.:=( ) + exit(false); exit(True); + end; if IsHintDirective(pt) then exit(True);