mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 09:56:12 +02:00
codetools: var completion of for-var-in-genericarray, from Pascal Riekenberg, issue #37076
git-svn-id: trunk@63160 -
This commit is contained in:
parent
9083125eb6
commit
c64cd287c5
@ -844,7 +844,8 @@ type
|
|||||||
function FindEnumerationTypeOfSetType(SetTypeNode: TCodeTreeNode;
|
function FindEnumerationTypeOfSetType(SetTypeNode: TCodeTreeNode;
|
||||||
out Context: TFindContext): boolean;
|
out Context: TFindContext): boolean;
|
||||||
function FindElementTypeOfArrayType(ArrayNode: TCodeTreeNode;
|
function FindElementTypeOfArrayType(ArrayNode: TCodeTreeNode;
|
||||||
out ExprType: TExpressionType; AliasType: PFindContext): boolean;
|
out ExprType: TExpressionType; AliasType: PFindContext;
|
||||||
|
ParentParams: TFindDeclarationParams = nil): boolean;
|
||||||
function CheckOperatorEnumerator(Params: TFindDeclarationParams;
|
function CheckOperatorEnumerator(Params: TFindDeclarationParams;
|
||||||
const FoundContext: TFindContext): TIdentifierFoundResult;
|
const FoundContext: TFindContext): TIdentifierFoundResult;
|
||||||
function CheckModifierEnumeratorCurrent({%H-}Params: TFindDeclarationParams;
|
function CheckModifierEnumeratorCurrent({%H-}Params: TFindDeclarationParams;
|
||||||
@ -12734,7 +12735,7 @@ function TFindDeclarationTool.FindForInTypeAsString(TermPos: TAtomPosition;
|
|||||||
begin
|
begin
|
||||||
AliasType:=CleanFindContext;
|
AliasType:=CleanFindContext;
|
||||||
if SubExprType.Context.Tool.FindElementTypeOfArrayType(
|
if SubExprType.Context.Tool.FindElementTypeOfArrayType(
|
||||||
SubExprType.Context.Node,ExprType,@AliasType)
|
SubExprType.Context.Node,ExprType,@AliasType,Params)
|
||||||
then begin
|
then begin
|
||||||
Result:=FindExprTypeAsString(ExprType,TermPos.StartPos,@AliasType);
|
Result:=FindExprTypeAsString(ExprType,TermPos.StartPos,@AliasType);
|
||||||
end;
|
end;
|
||||||
@ -13131,7 +13132,7 @@ end;
|
|||||||
|
|
||||||
function TFindDeclarationTool.FindElementTypeOfArrayType(
|
function TFindDeclarationTool.FindElementTypeOfArrayType(
|
||||||
ArrayNode: TCodeTreeNode; out ExprType: TExpressionType;
|
ArrayNode: TCodeTreeNode; out ExprType: TExpressionType;
|
||||||
AliasType: PFindContext): boolean;
|
AliasType: PFindContext; ParentParams: TFindDeclarationParams): boolean;
|
||||||
var
|
var
|
||||||
Params: TFindDeclarationParams;
|
Params: TFindDeclarationParams;
|
||||||
p: LongInt;
|
p: LongInt;
|
||||||
@ -13142,27 +13143,36 @@ begin
|
|||||||
if (ArrayNode=nil) then exit;
|
if (ArrayNode=nil) then exit;
|
||||||
if (ArrayNode.Desc<>ctnOpenArrayType) and (ArrayNode.Desc<>ctnRangedArrayType)
|
if (ArrayNode.Desc<>ctnOpenArrayType) and (ArrayNode.Desc<>ctnRangedArrayType)
|
||||||
then exit;
|
then exit;
|
||||||
MoveCursorToNodeStart(ArrayNode);
|
if (ArrayNode.Parent <> nil)
|
||||||
ReadNextAtom; // array
|
and (ArrayNode.Parent.Desc = ctnGenericType)
|
||||||
if not UpAtomIs('ARRAY') then exit;
|
and (ParentParams <> nil) then begin
|
||||||
ReadNextAtom; // of
|
ExprType.Desc := xtContext;
|
||||||
if CurPos.Flag=cafEdgedBracketOpen then begin
|
ExprType.Context.Node := ParentParams.GenParamValueMappings.SpecializeParamsNode.FirstChild;
|
||||||
ReadTilBracketClose(true);
|
ExprType.Context.Tool := ParentParams.GenParamValueMappings.SpecializeParamsTool;
|
||||||
ReadNextAtom;
|
|
||||||
end;
|
|
||||||
if not UpAtomIs('OF') then exit;
|
|
||||||
ReadNextAtom;
|
|
||||||
if not AtomIsIdentifier then exit;
|
|
||||||
Params:=TFindDeclarationParams.Create;
|
|
||||||
try
|
|
||||||
Params.Flags:=fdfDefaultForExpressions;
|
|
||||||
Params.ContextNode:=ArrayNode;
|
|
||||||
p:=CurPos.StartPos;
|
|
||||||
Params.SetIdentifier(Self,@Src[p],nil);
|
|
||||||
ExprType:=FindExpressionResultType(Params,p,-1,AliasType);
|
|
||||||
Result:=true;
|
Result:=true;
|
||||||
finally
|
end else begin
|
||||||
Params.Free;
|
MoveCursorToNodeStart(ArrayNode);
|
||||||
|
ReadNextAtom; // array
|
||||||
|
if not UpAtomIs('ARRAY') then exit;
|
||||||
|
ReadNextAtom; // of
|
||||||
|
if CurPos.Flag=cafEdgedBracketOpen then begin
|
||||||
|
ReadTilBracketClose(true);
|
||||||
|
ReadNextAtom;
|
||||||
|
end;
|
||||||
|
if not UpAtomIs('OF') then exit;
|
||||||
|
ReadNextAtom;
|
||||||
|
if not AtomIsIdentifier then exit;
|
||||||
|
Params:=TFindDeclarationParams.Create;
|
||||||
|
try
|
||||||
|
Params.Flags:=fdfDefaultForExpressions;
|
||||||
|
Params.ContextNode:=ArrayNode;
|
||||||
|
p:=CurPos.StartPos;
|
||||||
|
Params.SetIdentifier(Self,@Src[p],nil);
|
||||||
|
ExprType:=FindExpressionResultType(Params,p,-1,AliasType);
|
||||||
|
Result:=true;
|
||||||
|
finally
|
||||||
|
Params.Free;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -111,6 +111,8 @@ type
|
|||||||
TOL3 = TOL2;
|
TOL3 = TOL2;
|
||||||
TOL4 = class(TOL2);
|
TOL4 = class(TOL2);
|
||||||
|
|
||||||
|
generic TArray<T> = array of T;
|
||||||
|
|
||||||
var
|
var
|
||||||
OL_P1_1: TOL_P1_1;
|
OL_P1_1: TOL_P1_1;
|
||||||
OL_P1_2: TOL_P1_2;
|
OL_P1_2: TOL_P1_2;
|
||||||
@ -124,6 +126,7 @@ var
|
|||||||
OL2: TOL2;
|
OL2: TOL2;
|
||||||
OL3: TOL3;
|
OL3: TOL3;
|
||||||
OL4: TOL4;
|
OL4: TOL4;
|
||||||
|
A: specialize TArray<TObj>;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
for o_p1_1{guesstype:TObj} in OL_P1_1 do ;
|
for o_p1_1{guesstype:TObj} in OL_P1_1 do ;
|
||||||
@ -138,6 +141,7 @@ begin
|
|||||||
for o2{guesstype:TObj} in OL2 do ;
|
for o2{guesstype:TObj} in OL2 do ;
|
||||||
for o3{guesstype:TObj} in OL3 do ;
|
for o3{guesstype:TObj} in OL3 do ;
|
||||||
for o4{guesstype:TObj} in OL4 do ;
|
for o4{guesstype:TObj} in OL4 do ;
|
||||||
|
for i{guesstype:TObj} in A do;
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user