mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-04 18:20:34 +02:00
codetools: find declaration: search in type of constant/variable
git-svn-id: trunk@29415 -
This commit is contained in:
parent
503ab21004
commit
6495ad0a79
@ -6007,15 +6007,39 @@ function TFindDeclarationTool.FindIdentifierInTypeOfConstant(
|
||||
}
|
||||
var
|
||||
TypeNode: TCodeTreeNode;
|
||||
ExprType: TExpressionType;
|
||||
TypeParams: TFindDeclarationParams;
|
||||
OldInput: TFindDeclarationInput;
|
||||
begin
|
||||
Result:=false;
|
||||
//debugln(['TFindDeclarationTool.FindIdentifierInTypeOfConstant ',VarConstNode.DescAsString]);
|
||||
TypeNode:=VarConstNode.FirstChild;
|
||||
if TypeNode=nil then exit;
|
||||
if TypeNode.Desc=ctnIdentifier then begin
|
||||
debugln(['TFindDeclarationTool.FindIdentifierInTypeOfConstant ']);
|
||||
//ExprType:=FindExpressionTypeOfTerm(TypeNode.StartPos,-1,Params);
|
||||
|
||||
// resolve type
|
||||
//debugln(['TFindDeclarationTool.FindIdentifierInTypeOfConstant ']);
|
||||
TypeParams:=TFindDeclarationParams.Create;
|
||||
try
|
||||
TypeParams.ContextNode:=TypeNode;
|
||||
TypeParams.SetIdentifier(Self,nil,nil);
|
||||
TypeParams.Flags:=fdfDefaultForExpressions+[fdfIgnoreCurContextNode];
|
||||
ExprType:=FindExpressionTypeOfTerm(TypeNode.StartPos,-1,TypeParams,false);
|
||||
//debugln(['TFindDeclarationTool.FindIdentifierInTypeOfConstant ExprType=',ExprTypeToString(ExprType)]);
|
||||
finally
|
||||
TypeParams.Free;
|
||||
end;
|
||||
if ExprType.Desc=xtContext then begin
|
||||
if ExprType.Context.Node.Parent=nil then exit;
|
||||
if not (ExprType.Context.Node.Parent.Desc in [ctnTypeDefinition,ctnGenericType])
|
||||
then
|
||||
exit;
|
||||
// search identifier in type
|
||||
Params.Save(OldInput);
|
||||
Params.ContextNode:=ExprType.Context.Node;
|
||||
Params.Flags:=Params.Flags-[fdfIgnoreCurContextNode,fdfSearchInParentNodes];
|
||||
Result:=ExprType.Context.Tool.FindIdentifierInContext(Params);
|
||||
Params.Load(OldInput,true);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@ -1357,7 +1357,7 @@ begin
|
||||
Result:=nil;
|
||||
exit;
|
||||
end;
|
||||
if Result.Desc=ctnConstDefinition then exit(nil);
|
||||
if Result.Desc<>ctnVarDefinition then exit(nil);
|
||||
Result:=Result.NextBrother;
|
||||
end;
|
||||
end;
|
||||
@ -1506,6 +1506,7 @@ end;
|
||||
|
||||
function TPascalReaderTool.FindClassNode(CursorNode: TCodeTreeNode
|
||||
): TCodeTreeNode;
|
||||
// find class node of a node in a procedure (declaration or body)
|
||||
begin
|
||||
while CursorNode<>nil do begin
|
||||
if CursorNode.Desc in AllClassObjects then begin
|
||||
|
Loading…
Reference in New Issue
Block a user