mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-24 03:29:35 +02:00
fixed finding declaration and ancestors for unit name
git-svn-id: trunk@6560 -
This commit is contained in:
parent
a66dd7eb21
commit
3ccb0f5d03
@ -469,7 +469,8 @@ type
|
|||||||
// than declarations:
|
// than declarations:
|
||||||
TFindSmartFlag = (
|
TFindSmartFlag = (
|
||||||
fsfIncludeDirective, // search for include file
|
fsfIncludeDirective, // search for include file
|
||||||
fsfFindMainDeclaration // stop if already on a declaration
|
fsfFindMainDeclaration, // stop if already on a declaration
|
||||||
|
fsfSearchSourceName // if searching for a unit name, return the source name node
|
||||||
);
|
);
|
||||||
TFindSmartFlags = set of TFindSmartFlag;
|
TFindSmartFlags = set of TFindSmartFlag;
|
||||||
|
|
||||||
@ -994,6 +995,25 @@ var CleanCursorPos: integer;
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function FindSourceName(ACode: TCodeBuffer): boolean;
|
||||||
|
var
|
||||||
|
NamePos: TAtomPosition;
|
||||||
|
begin
|
||||||
|
Result:=false;
|
||||||
|
NewTool:=nil;
|
||||||
|
NewNode:=nil;
|
||||||
|
if Assigned(FOnGetCodeToolForBuffer) then
|
||||||
|
NewTool:=FOnGetCodeToolForBuffer(Self,ACode,false);
|
||||||
|
if NewTool=nil then exit;
|
||||||
|
NewTool.BuildTree(true);
|
||||||
|
if not NewTool.GetSourceNamePos(NamePos) then exit;
|
||||||
|
NewNode:=NewTool.Tree.Root;
|
||||||
|
if not NewTool.JumpToCleanPos(NamePos.StartPos,NamePos.StartPos,
|
||||||
|
NamePos.StartPos,NewPos,NewTopLine,false)
|
||||||
|
then exit;
|
||||||
|
Result:=true;
|
||||||
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
CleanPosInFront: integer;
|
CleanPosInFront: integer;
|
||||||
CursorAtIdentifier: boolean;
|
CursorAtIdentifier: boolean;
|
||||||
@ -1058,6 +1078,8 @@ begin
|
|||||||
NewPos,NewTopLine);
|
NewPos,NewTopLine);
|
||||||
NewNode:=nil;
|
NewNode:=nil;
|
||||||
NewTool:=nil;
|
NewTool:=nil;
|
||||||
|
if fsfSearchSourceName in SearchSmartFlags then
|
||||||
|
Result:=FindSourceName(NewPos.Code);
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
DirectSearch:=false;
|
DirectSearch:=false;
|
||||||
@ -2860,13 +2882,23 @@ begin
|
|||||||
CurCursorPos:=CursorPos;
|
CurCursorPos:=CursorPos;
|
||||||
CurTool:=Self;
|
CurTool:=Self;
|
||||||
try
|
try
|
||||||
while CurTool.FindDeclaration(CurCursorPos,AllFindSmartFlags,
|
while CurTool.FindDeclaration(CurCursorPos,AllFindSmartFlags
|
||||||
|
+[fsfSearchSourceName],
|
||||||
NewTool,NewNode,NewPos,NewTopLine) do
|
NewTool,NewNode,NewPos,NewTopLine) do
|
||||||
begin
|
begin
|
||||||
if IndexOfCodePosition(@NewPos)>=0 then break;
|
if IndexOfCodePosition(@NewPos)>=0 then break;
|
||||||
AddCodePosition(NewPos);
|
AddCodePosition(NewPos);
|
||||||
CurCursorPos:=NewPos;
|
CurCursorPos:=NewPos;
|
||||||
CurTool:=NewTool;
|
CurTool:=NewTool;
|
||||||
|
{$IFDEF VerboseFindWithAncestors}
|
||||||
|
debugln('TFindDeclarationTool.FindDeclarationsAndAncestors ',
|
||||||
|
' Self="',MainFilename,'" ');
|
||||||
|
if CurCursorPos.Code<>nil then
|
||||||
|
debugln(' CurCursorPos=',CurCursorPos.Code.Filename,' ',dbgs(CurCursorPos.X),',',dbgs(CurCursorPos.Y));
|
||||||
|
if CurTool<>nil then
|
||||||
|
debugln(' CurTool=',CurTool.MainFilename);
|
||||||
|
{$ENDIF}
|
||||||
|
if (CurTool=nil) then exit;
|
||||||
end;
|
end;
|
||||||
except
|
except
|
||||||
// just stop on errors
|
// just stop on errors
|
||||||
|
Loading…
Reference in New Issue
Block a user