mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-09 02:36:07 +02:00
codetools: fixed find declaration
git-svn-id: trunk@36982 -
This commit is contained in:
parent
9d8803bbcc
commit
e055f6003b
@ -2517,7 +2517,6 @@ var
|
|||||||
LastContextNode, StartContextNode, FirstSearchedNode, LastSearchedNode,
|
LastContextNode, StartContextNode, FirstSearchedNode, LastSearchedNode,
|
||||||
ContextNode: TCodeTreeNode;
|
ContextNode: TCodeTreeNode;
|
||||||
IsForward: boolean;
|
IsForward: boolean;
|
||||||
OldParamFlags: TFindDeclarationFlags;
|
|
||||||
IdentifierFoundResult: TIdentifierFoundResult;
|
IdentifierFoundResult: TIdentifierFoundResult;
|
||||||
LastNodeCache: TCodeTreeNodeCache;
|
LastNodeCache: TCodeTreeNodeCache;
|
||||||
LastCacheEntry: PCodeTreeNodeCacheEntry;
|
LastCacheEntry: PCodeTreeNodeCacheEntry;
|
||||||
@ -2614,6 +2613,10 @@ var
|
|||||||
if fdfCollect in Params.Flags then
|
if fdfCollect in Params.Flags then
|
||||||
raise Exception.Create('fdfCollect must never return true');
|
raise Exception.Create('fdfCollect must never return true');
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
{$IFDEF ShowFoundIdentifier}
|
||||||
|
debugln(['CacheResult FOUND ',GetIdentifier(Params.Identifier)]);
|
||||||
|
Params.WriteDebugReport;
|
||||||
|
{$ENDIF}
|
||||||
if (FirstSearchedNode=nil) then exit;
|
if (FirstSearchedNode=nil) then exit;
|
||||||
if ([fdfDoNotCache,fdfCollect,fdfExtractOperand]*Params.Flags<>[]) then exit;
|
if ([fdfDoNotCache,fdfCollect,fdfExtractOperand]*Params.Flags<>[]) then exit;
|
||||||
if ([fodDoNotCache]*Params.NewFlags<>[]) then exit;
|
if ([fodDoNotCache]*Params.NewFlags<>[]) then exit;
|
||||||
@ -2668,6 +2671,11 @@ var
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
if NewResult then begin
|
if NewResult then begin
|
||||||
// identifier found
|
// identifier found
|
||||||
|
{$IFDEF ShowFoundIdentifier}
|
||||||
|
debugln(['CheckResult FOUND ',GetIdentifier(Params.Identifier)]);
|
||||||
|
Params.WriteDebugReport;
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
if fdfExtractOperand in Params.Flags then
|
if fdfExtractOperand in Params.Flags then
|
||||||
case Params.NewNode.Desc of
|
case Params.NewNode.Desc of
|
||||||
ctnVarDefinition, ctnConstDefinition:
|
ctnVarDefinition, ctnConstDefinition:
|
||||||
@ -2731,7 +2739,7 @@ var
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
Params.SetResult(Params.FoundProc^.Context.Tool,
|
Params.SetResult(Params.FoundProc^.Context.Tool,
|
||||||
Params.FoundProc^.Context.Node);
|
Params.FoundProc^.Context.Node);
|
||||||
{$IFDEF ShowProcSearch}
|
{$IF defined(ShowProcSearch) or defined(ShowFoundIdentifier)}
|
||||||
DebugLn('[TFindDeclarationTool.FindIdentifierInContext] PROC Search ended with only one proc (normal when searching every used unit):');
|
DebugLn('[TFindDeclarationTool.FindIdentifierInContext] PROC Search ended with only one proc (normal when searching every used unit):');
|
||||||
Params.WriteDebugReport;
|
Params.WriteDebugReport;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
@ -2986,6 +2994,11 @@ var
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function SearchNextNode: boolean;
|
function SearchNextNode: boolean;
|
||||||
|
const
|
||||||
|
AbortNoCacheResult = false;
|
||||||
|
Proceed = true;
|
||||||
|
var
|
||||||
|
OldInput: TFindDeclarationInput;
|
||||||
begin
|
begin
|
||||||
repeat
|
repeat
|
||||||
// search for prior node
|
// search for prior node
|
||||||
@ -3003,7 +3016,7 @@ var
|
|||||||
if fdfCollect in Params.Flags then
|
if fdfCollect in Params.Flags then
|
||||||
raise Exception.Create('fdfCollect must never return true');
|
raise Exception.Create('fdfCollect must never return true');
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
exit(false);
|
exit(AbortNoCacheResult);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -3012,18 +3025,17 @@ var
|
|||||||
// after searching in a class definition, search in its ancestors
|
// after searching in a class definition, search in its ancestors
|
||||||
|
|
||||||
// ToDo: check for cycles in ancestors
|
// ToDo: check for cycles in ancestors
|
||||||
|
Params.Save(OldInput);
|
||||||
OldParamFlags:=Params.Flags;
|
|
||||||
Exclude(Params.Flags,fdfExceptionOnNotFound);
|
Exclude(Params.Flags,fdfExceptionOnNotFound);
|
||||||
Result:=FindIdentifierInAncestors(ContextNode,Params);
|
Result:=FindIdentifierInAncestors(ContextNode,Params);
|
||||||
Params.Flags:=OldParamFlags;
|
Params.Load(OldInput,true);
|
||||||
if Result then begin
|
if Result then begin
|
||||||
FindIdentifierInContext:=true;
|
FindIdentifierInContext:=true;
|
||||||
{$IFDEF ShowCollect}
|
{$IFDEF ShowCollect}
|
||||||
if fdfCollect in Params.Flags then
|
if fdfCollect in Params.Flags then
|
||||||
raise Exception.Create('fdfCollect must never return true');
|
raise Exception.Create('fdfCollect must never return true');
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
exit(false);
|
exit(AbortNoCacheResult);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -3031,7 +3043,7 @@ var
|
|||||||
and (not (fdfSearchInParentNodes in Params.Flags)) then begin
|
and (not (fdfSearchInParentNodes in Params.Flags)) then begin
|
||||||
// startcontext completed => not searching in parents or ancestors
|
// startcontext completed => not searching in parents or ancestors
|
||||||
ContextNode:=nil;
|
ContextNode:=nil;
|
||||||
exit(false);
|
exit(Proceed);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if ((not (fdfSearchForward in Params.Flags))
|
if ((not (fdfSearchForward in Params.Flags))
|
||||||
@ -3134,7 +3146,7 @@ var
|
|||||||
if fdfCollect in Params.Flags then
|
if fdfCollect in Params.Flags then
|
||||||
raise Exception.Create('fdfCollect must never return true');
|
raise Exception.Create('fdfCollect must never return true');
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
exit(false);
|
exit(AbortNoCacheResult);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -3146,7 +3158,7 @@ var
|
|||||||
break;
|
break;
|
||||||
end;
|
end;
|
||||||
until false;
|
until false;
|
||||||
Result:=true;
|
Result:=Proceed;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
@ -8290,7 +8302,7 @@ begin
|
|||||||
DebugLn('[TFindDeclarationTool.CheckSrcIdentifier]',
|
DebugLn('[TFindDeclarationTool.CheckSrcIdentifier]',
|
||||||
' Ident=',GetIdentifier(Params.Identifier),
|
' Ident=',GetIdentifier(Params.Identifier),
|
||||||
' FoundContext=',FoundContext.Node.DescAsString,
|
' FoundContext=',FoundContext.Node.DescAsString,
|
||||||
' Flags=[',FindDeclarationFlagsAsString(Params.Flags),']'
|
' Flags=[',dbgs(Params.Flags),']'
|
||||||
);
|
);
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
if FoundContext.Node.Desc=ctnProcedure then begin
|
if FoundContext.Node.Desc=ctnProcedure then begin
|
||||||
@ -10834,12 +10846,13 @@ begin
|
|||||||
else
|
else
|
||||||
DebugLn(' NewNode=nil');
|
DebugLn(' NewNode=nil');
|
||||||
DebugLn(' NewCleanPos=',dbgs(NewCleanPos));
|
DebugLn(' NewCleanPos=',dbgs(NewCleanPos));
|
||||||
if NewCodeTool<>nil then
|
if NewCodeTool<>nil then begin
|
||||||
DebugLn(' NewCodeTool=',NewCodeTool.MainFilename)
|
DebugLn(' NewCodeTool=',NewCodeTool.MainFilename,' at ',NewCodeTool.CleanPosToStr(NewCleanPos,false))
|
||||||
else
|
end else begin
|
||||||
DebugLn(' NewCodeTool=nil');
|
DebugLn([' NewCodeTool=nil NewCleanPos=',NewCleanPos]);
|
||||||
|
end;
|
||||||
if NewPos.Code<>nil then
|
if NewPos.Code<>nil then
|
||||||
DebugLn(' NewPos=',NewPos.Code.Filename,' x=',dbgs(NewPos.X),' y=',dbgs(NewPos.Y),' topline=',dbgs(NewTopLine))
|
DebugLn([' NewPos=',NewPos.Code.Filename,' x=',NewPos.X,' y=',NewPos.Y,' topline=',NewTopLine])
|
||||||
else
|
else
|
||||||
DebugLn(' NewPos=nil');
|
DebugLn(' NewPos=nil');
|
||||||
DebugLn(' NewFlags=',dbgs(NewFlags));
|
DebugLn(' NewFlags=',dbgs(NewFlags));
|
||||||
|
@ -1607,8 +1607,10 @@ begin
|
|||||||
ctnInitialization:
|
ctnInitialization:
|
||||||
if (NodeBehind=nil)
|
if (NodeBehind=nil)
|
||||||
or (NodeBehind.Desc in [ctnInitialization,ctnFinalization,ctnEndPoint,ctnBeginBlock])
|
or (NodeBehind.Desc in [ctnInitialization,ctnFinalization,ctnEndPoint,ctnBeginBlock])
|
||||||
then
|
then begin
|
||||||
Add('finalization');
|
Add('finalization');
|
||||||
|
Add('begin');
|
||||||
|
end;
|
||||||
|
|
||||||
ctnProcedure:
|
ctnProcedure:
|
||||||
begin
|
begin
|
||||||
@ -1654,6 +1656,18 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
ctnTypeSection,ctnVarSection,ctnConstSection,ctnLabelSection,ctnResStrSection:
|
||||||
|
if (Node.FirstChild<>nil)
|
||||||
|
and (Node.FirstChild.StartPos<CleanPos)
|
||||||
|
then begin
|
||||||
|
Add('type');
|
||||||
|
Add('const');
|
||||||
|
Add('var');
|
||||||
|
Add('procedure');
|
||||||
|
Add('function');
|
||||||
|
Add('property');
|
||||||
|
end;
|
||||||
|
|
||||||
ctnProperty:
|
ctnProperty:
|
||||||
CheckProperty(Node);
|
CheckProperty(Node);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user