mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-12 05:36:22 +02:00
codetools: code completion: enumeration of arrays
git-svn-id: trunk@22433 -
This commit is contained in:
parent
2375a8fcaf
commit
ef97e3ee6b
@ -264,6 +264,8 @@ ResourceString
|
||||
ctsResultTypeOfFunctionGetEnumeratorNotFound = 'result type of function '
|
||||
+'GetEnumerator not found';
|
||||
ctsPropertyCurrentNotFound = 'property Current not found';
|
||||
ctsEnumerationType = 'enumeration type';
|
||||
ctsType = 'type';
|
||||
|
||||
implementation
|
||||
|
||||
|
@ -661,6 +661,8 @@ type
|
||||
out ResultExprType: TExpressionType): boolean;
|
||||
function FindEnumerationTypeOfSetType(SetTypeNode: TCodeTreeNode;
|
||||
out Context: TFindContext): boolean;
|
||||
function FindElementTypeOfArrayType(ArrayNode: TCodeTreeNode;
|
||||
out ExprType: TExpressionType): boolean;
|
||||
function CheckOperatorEnumerator(Params: TFindDeclarationParams;
|
||||
const FoundContext: TFindContext): TIdentifierFoundResult;
|
||||
function CheckModifierEnumeratorCurrent(Params: TFindDeclarationParams;
|
||||
@ -8902,13 +8904,17 @@ begin
|
||||
Result:=FindExprTypeAsString(ExprType,TermPos.StartPos,Params);
|
||||
end;
|
||||
ctnSetType:
|
||||
begin
|
||||
if TermExprType.Context.Tool.FindEnumerationTypeOfSetType(
|
||||
TermExprType.Context.Node,ExprType.Context)
|
||||
then begin
|
||||
ExprType.Desc:=xtContext;
|
||||
Result:=FindExprTypeAsString(ExprType,TermPos.StartPos,Params);
|
||||
end;
|
||||
if TermExprType.Context.Tool.FindEnumerationTypeOfSetType(
|
||||
TermExprType.Context.Node,ExprType.Context)
|
||||
then begin
|
||||
ExprType.Desc:=xtContext;
|
||||
Result:=FindExprTypeAsString(ExprType,TermPos.StartPos,Params);
|
||||
end;
|
||||
ctnRangedArrayType,ctnOpenArrayType:
|
||||
if TermExprType.Context.Tool.FindElementTypeOfArrayType(
|
||||
TermExprType.Context.Node,ExprType)
|
||||
then begin
|
||||
Result:=FindExprTypeAsString(ExprType,TermPos.StartPos,Params);
|
||||
end;
|
||||
else
|
||||
RaiseTermHasNoIterator;
|
||||
@ -9169,7 +9175,9 @@ begin
|
||||
if (SetTypeNode=nil) or (SetTypeNode.Desc<>ctnSetType) then exit;
|
||||
MoveCursorToNodeStart(SetTypeNode);
|
||||
ReadNextAtom; // set
|
||||
if not UpAtomIs('SET') then exit;
|
||||
ReadNextAtom; // of
|
||||
if not UpAtomIs('OF') then exit;
|
||||
ReadNextAtom;
|
||||
if not IsIdentStartChar[Src[CurPos.StartPos]] then
|
||||
// set of ()
|
||||
@ -9187,7 +9195,7 @@ begin
|
||||
or (Params.NewNode.FirstChild.Desc<>ctnEnumerationType) then begin
|
||||
MoveCursorToCleanPos(p);
|
||||
ReadNextAtom;
|
||||
RaiseStringExpectedButAtomFound('enumeration type');
|
||||
RaiseStringExpectedButAtomFound(ctsEnumerationType);
|
||||
end;
|
||||
Context.Tool:=Params.NewCodeTool;
|
||||
Context.Node:=Params.NewNode;
|
||||
@ -9197,6 +9205,41 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
function TFindDeclarationTool.FindElementTypeOfArrayType(
|
||||
ArrayNode: TCodeTreeNode; out ExprType: TExpressionType): boolean;
|
||||
var
|
||||
Params: TFindDeclarationParams;
|
||||
p: LongInt;
|
||||
begin
|
||||
Result:=false;
|
||||
ExprType:=CleanExpressionType;
|
||||
if (ArrayNode=nil) then exit;
|
||||
if (ArrayNode.Desc<>ctnOpenArrayType) and (ArrayNode.Desc<>ctnRangedArrayType)
|
||||
then exit;
|
||||
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(false) 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);
|
||||
Result:=true;
|
||||
finally
|
||||
Params.Free;
|
||||
end;
|
||||
end;
|
||||
|
||||
function TFindDeclarationTool.CheckOperatorEnumerator(
|
||||
Params: TFindDeclarationParams; const FoundContext: TFindContext
|
||||
): TIdentifierFoundResult;
|
||||
|
Loading…
Reference in New Issue
Block a user