mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-14 10:59:14 +02:00
codetools: code completion: enumeration of settype
git-svn-id: trunk@22432 -
This commit is contained in:
parent
fd0f2898d5
commit
2375a8fcaf
@ -58,7 +58,7 @@ interface
|
|||||||
{ $DEFINE ShowTriedParentContexts}
|
{ $DEFINE ShowTriedParentContexts}
|
||||||
{ $DEFINE ShowTriedIdentifiers}
|
{ $DEFINE ShowTriedIdentifiers}
|
||||||
{ $DEFINE ShowTriedUnits}
|
{ $DEFINE ShowTriedUnits}
|
||||||
{ $DEFINE ShowExprEval}
|
{$DEFINE ShowExprEval}
|
||||||
{ $DEFINE ShowFoundIdentifier}
|
{ $DEFINE ShowFoundIdentifier}
|
||||||
{ $DEFINE ShowInterfaceCache}
|
{ $DEFINE ShowInterfaceCache}
|
||||||
{ $DEFINE ShowNodeCache}
|
{ $DEFINE ShowNodeCache}
|
||||||
@ -659,6 +659,8 @@ type
|
|||||||
function FindOperatorEnumerator(Node: TCodeTreeNode;
|
function FindOperatorEnumerator(Node: TCodeTreeNode;
|
||||||
ExprType: TExpressionType; Need: TFindOperatorEnumerator;
|
ExprType: TExpressionType; Need: TFindOperatorEnumerator;
|
||||||
out ResultExprType: TExpressionType): boolean;
|
out ResultExprType: TExpressionType): boolean;
|
||||||
|
function FindEnumerationTypeOfSetType(SetTypeNode: TCodeTreeNode;
|
||||||
|
out Context: TFindContext): boolean;
|
||||||
function CheckOperatorEnumerator(Params: TFindDeclarationParams;
|
function CheckOperatorEnumerator(Params: TFindDeclarationParams;
|
||||||
const FoundContext: TFindContext): TIdentifierFoundResult;
|
const FoundContext: TFindContext): TIdentifierFoundResult;
|
||||||
function CheckModifierEnumeratorCurrent(Params: TFindDeclarationParams;
|
function CheckModifierEnumeratorCurrent(Params: TFindDeclarationParams;
|
||||||
@ -8898,7 +8900,16 @@ begin
|
|||||||
then
|
then
|
||||||
RaiseTermHasNoIterator;
|
RaiseTermHasNoIterator;
|
||||||
Result:=FindExprTypeAsString(ExprType,TermPos.StartPos,Params);
|
Result:=FindExprTypeAsString(ExprType,TermPos.StartPos,Params);
|
||||||
end
|
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;
|
||||||
|
end;
|
||||||
else
|
else
|
||||||
RaiseTermHasNoIterator;
|
RaiseTermHasNoIterator;
|
||||||
end;
|
end;
|
||||||
@ -9148,6 +9159,44 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TFindDeclarationTool.FindEnumerationTypeOfSetType(
|
||||||
|
SetTypeNode: TCodeTreeNode; out Context: TFindContext): boolean;
|
||||||
|
var
|
||||||
|
Params: TFindDeclarationParams;
|
||||||
|
p: LongInt;
|
||||||
|
begin
|
||||||
|
Result:=false;
|
||||||
|
if (SetTypeNode=nil) or (SetTypeNode.Desc<>ctnSetType) then exit;
|
||||||
|
MoveCursorToNodeStart(SetTypeNode);
|
||||||
|
ReadNextAtom; // set
|
||||||
|
ReadNextAtom; // of
|
||||||
|
ReadNextAtom;
|
||||||
|
if not IsIdentStartChar[Src[CurPos.StartPos]] then
|
||||||
|
// set of ()
|
||||||
|
exit;
|
||||||
|
Params:=TFindDeclarationParams.Create;
|
||||||
|
try
|
||||||
|
Params.Flags:=fdfDefaultForExpressions;
|
||||||
|
Params.ContextNode:=SetTypeNode;
|
||||||
|
p:=CurPos.StartPos;
|
||||||
|
Params.SetIdentifier(Self,@Src[p],nil);
|
||||||
|
if not FindIdentifierInContext(Params) then exit;
|
||||||
|
if (Params.NewNode=nil)
|
||||||
|
or (Params.NewNode.Desc<>ctnTypeDefinition)
|
||||||
|
or (Params.NewNode.FirstChild=nil)
|
||||||
|
or (Params.NewNode.FirstChild.Desc<>ctnEnumerationType) then begin
|
||||||
|
MoveCursorToCleanPos(p);
|
||||||
|
ReadNextAtom;
|
||||||
|
RaiseStringExpectedButAtomFound('enumeration type');
|
||||||
|
end;
|
||||||
|
Context.Tool:=Params.NewCodeTool;
|
||||||
|
Context.Node:=Params.NewNode;
|
||||||
|
Result:=true;
|
||||||
|
finally
|
||||||
|
Params.Free;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function TFindDeclarationTool.CheckOperatorEnumerator(
|
function TFindDeclarationTool.CheckOperatorEnumerator(
|
||||||
Params: TFindDeclarationParams; const FoundContext: TFindContext
|
Params: TFindDeclarationParams; const FoundContext: TFindContext
|
||||||
): TIdentifierFoundResult;
|
): TIdentifierFoundResult;
|
||||||
|
Loading…
Reference in New Issue
Block a user