mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2026-02-25 04:48:16 +01:00
Jedi code format: fix parser error when there are more than one attribute.
(cherry picked from commit 140875c982)
This commit is contained in:
parent
aca4f26ee0
commit
e4d0ae656e
@ -273,7 +273,7 @@ type
|
||||
function IdentifierNext(const peStrictness: TIdentifierStrictness): boolean;
|
||||
function ArrayConstantNext: boolean;
|
||||
function SubrangeTypeNext: boolean;
|
||||
function TypePastAttribute: boolean;
|
||||
function TypePastAttributes: boolean;
|
||||
procedure RecogniseGenericConstraints;
|
||||
procedure RecogniseGenericConstraint;
|
||||
procedure RecogniseHeritageList;
|
||||
@ -1145,7 +1145,7 @@ begin
|
||||
|
||||
{ In Delphi.Net, the type can be preceeded by an attribute in '[ ]' }
|
||||
lc := fcTokenList.FirstSolidToken;
|
||||
while (lc <> nil) and ((lc.WordType in IdentifierTypes) or TypePastAttribute) do
|
||||
while (lc <> nil) and ((lc.WordType in IdentifierTypes) or TypePastAttributes) do
|
||||
begin
|
||||
{ Can be an empty nested type section
|
||||
TFoo=class
|
||||
@ -1177,8 +1177,8 @@ begin
|
||||
PopNode;
|
||||
end;
|
||||
|
||||
// is there an attribute followed by a type name?
|
||||
function TBuildParseTree.TypePastAttribute: boolean;
|
||||
// are there attribute(s) followed by a type name?
|
||||
function TBuildParseTree.TypePastAttributes: boolean;
|
||||
var
|
||||
lc: TSourceToken;
|
||||
i: integer;
|
||||
@ -1194,35 +1194,23 @@ var
|
||||
|
||||
begin
|
||||
i := fcTokenList.CurrentTokenIndex;
|
||||
|
||||
lc := fcTokenList.SourceTokens[i];
|
||||
AdvanceToSolid;
|
||||
|
||||
if (lc = nil) or (lc.TokenType <> ttOpenSquareBracket) then
|
||||
begin
|
||||
Result := False;
|
||||
exit;
|
||||
end;
|
||||
|
||||
while (lc <> nil) and (lc.TokenType <> ttCloseSquareBracket) do
|
||||
begin
|
||||
inc(i);
|
||||
repeat
|
||||
lc := fcTokenList.SourceTokens[i];
|
||||
end;
|
||||
|
||||
inc(i);
|
||||
lc := fcTokenList.SourceTokens[i];
|
||||
|
||||
if lc = nil then
|
||||
begin
|
||||
Result := False;
|
||||
exit;
|
||||
end;
|
||||
|
||||
AdvanceToSolid;
|
||||
|
||||
AdvanceToSolid;
|
||||
if (lc = nil) or (lc.TokenType <> ttOpenSquareBracket) then
|
||||
Exit(False);
|
||||
while (lc <> nil) and (lc.TokenType <> ttCloseSquareBracket) do
|
||||
begin
|
||||
Inc(i);
|
||||
lc := fcTokenList.SourceTokens[i];
|
||||
end;
|
||||
Inc(i);
|
||||
lc := fcTokenList.SourceTokens[i];
|
||||
if lc = nil then
|
||||
Exit(False);
|
||||
AdvanceToSolid;
|
||||
until (lc = nil) or (lc.TokenType <> ttOpenSquareBracket);
|
||||
Result := (lc <> nil) and (lc.WordType in IdentifierTypes);
|
||||
|
||||
end;
|
||||
|
||||
procedure TBuildParseTree.RecogniseTypeHelper;
|
||||
|
||||
@ -212,7 +212,11 @@ begin
|
||||
if (pt.TokenType = ttOpenSquareBracket) and
|
||||
pt.HasParentNode(nTypeDecl, 2) and
|
||||
(not pt.HasParentNode([nClassType, nRecordType])) then
|
||||
begin
|
||||
if (pt.PriorSolidTokenType = ttCloseSquareBracket) and pt.PriorSolidToken.HasParentNode(nAttribute) then
|
||||
exit(False); // don't duplicate return if there are more than one attribute
|
||||
exit(True);
|
||||
end;
|
||||
|
||||
end;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user