codetools: fixed search in hidden used units

git-svn-id: trunk@36978 -
This commit is contained in:
mattias 2012-04-22 20:15:40 +00:00
parent ad932b2c33
commit 11216625db

View File

@ -2885,23 +2885,17 @@ var
end; end;
end; end;
function SearchDefault: boolean;
begin
Result:=false;
if (not (fdfIgnoreUsedUnits in Params.Flags))
and FindIdentifierInHiddenUsedUnits(Params) then begin
Result:=CheckResult(true,false);
end;
end;
function SearchInSourceName: boolean; function SearchInSourceName: boolean;
// returns: true if ok to exit // returns: true if ok to exit
// false if search should continue // false if search should continue
var
SrcNode: TCodeTreeNode;
begin begin
Result:=false; Result:=false;
MoveCursorToNodeStart(ContextNode); SrcNode:=Tree.Root;
MoveCursorToNodeStart(SrcNode);
ReadNextAtom; // read keyword ReadNextAtom; // read keyword
if (ContextNode.Desc=ctnProgram) and (not UpAtomIs('PROGRAM')) then exit; if (SrcNode.Desc=ctnProgram) and (not UpAtomIs('PROGRAM')) then exit;
ReadNextAtom; // read name ReadNextAtom; // read name
if (fdfCollect in Params.Flags) if (fdfCollect in Params.Flags)
or CompareSrcIdentifiers(CurPos.StartPos,Params.Identifier) then or CompareSrcIdentifiers(CurPos.StartPos,Params.Identifier) then
@ -2910,13 +2904,24 @@ var
{$IFDEF ShowTriedIdentifiers} {$IFDEF ShowTriedIdentifiers}
DebugLn(' Source Name Identifier found="',GetIdentifier(Params.Identifier),'"'); DebugLn(' Source Name Identifier found="',GetIdentifier(Params.Identifier),'"');
{$ENDIF} {$ENDIF}
Params.SetResult(Self,ContextNode,CurPos.StartPos); Params.SetResult(Self,SrcNode,CurPos.StartPos);
Result:=CheckResult(true,true); Result:=CheckResult(true,true);
if not (fdfCollect in Params.Flags) then if not (fdfCollect in Params.Flags) then
exit; exit;
end; end;
end; end;
function SearchDefault: boolean;
begin
Result:=false;
if SearchInSourceName then
exit(true);
if (not (fdfIgnoreUsedUnits in Params.Flags))
and FindIdentifierInHiddenUsedUnits(Params) then begin
Result:=CheckResult(true,false);
end;
end;
function SearchInProperty: boolean; function SearchInProperty: boolean;
// returns: true if ok to exit // returns: true if ok to exit
// false if search should continue // false if search should continue
@ -2987,8 +2992,7 @@ var
// after search in the generic, search in the generic parameter names // after search in the generic, search in the generic parameter names
if SearchInGenericParams(ContextNode.Parent) then begin if SearchInGenericParams(ContextNode.Parent) then begin
FindIdentifierInContext:=true; FindIdentifierInContext:=true;
Result:=false; exit(false);
exit;
end; end;
end; end;
@ -3004,8 +3008,7 @@ var
Params.Flags:=OldParamFlags; Params.Flags:=OldParamFlags;
if Result then begin if Result then begin
FindIdentifierInContext:=true; FindIdentifierInContext:=true;
Result:=false; exit(false);
exit;
end; end;
end; end;
@ -3013,7 +3016,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;
break; exit(false);
end; end;
if ((not (fdfSearchForward in Params.Flags)) if ((not (fdfSearchForward in Params.Flags))
@ -3198,6 +3201,7 @@ begin
ctnTypeSection, ctnVarSection, ctnConstSection, ctnResStrSection, ctnTypeSection, ctnVarSection, ctnConstSection, ctnResStrSection,
ctnLabelSection, ctnPropertySection, ctnLabelSection, ctnPropertySection,
ctnInterface, ctnImplementation, ctnInterface, ctnImplementation,
ctnProgram, ctnLibrary,
ctnClassPublic, ctnClassPrivate, ctnClassProtected, ctnClassPublished, ctnClassPublic, ctnClassPrivate, ctnClassProtected, ctnClassPublished,
ctnClassClassVar, ctnClassClassVar,
ctnClass, ctnClassInterface, ctnDispinterface, ctnObject, ctnClass, ctnClassInterface, ctnDispinterface, ctnObject,
@ -3246,15 +3250,6 @@ begin
ContextNode:=ContextNode.FirstChild; // the ctnParameterList ContextNode:=ContextNode.FirstChild; // the ctnParameterList
end; end;
ctnProgram, ctnLibrary:
begin
if SearchInSourceName then exit;
MoveContextNodeToChildren;
end;
ctnUnit, ctnPackage:
if SearchInSourceName then exit;
ctnProperty: ctnProperty:
if SearchInProperty then exit; if SearchInProperty then exit;
@ -3297,15 +3292,15 @@ begin
DebugLn('[TFindDeclarationTool.FindIdentifierInContext] IgnoreCurContext '); DebugLn('[TFindDeclarationTool.FindIdentifierInContext] IgnoreCurContext ');
{$ENDIF} {$ENDIF}
end; end;
if LastContextNode=Tree.Root then begin
if SearchDefault then exit;
end;
if LastContextNode=ContextNode then begin if LastContextNode=ContextNode then begin
// same context -> search in prior context // no special context switch => search next node
if not LeavingContextIsPermitted then break; if not LeavingContextIsPermitted then break;
if not SearchNextNode then exit; if not SearchNextNode then exit;
end; end;
until ContextNode=nil; until ContextNode=nil;
if LastSearchedNode=Tree.Root then begin
if SearchDefault then exit;
end;
{except {except
// unexpected exception // unexpected exception
@ -6092,7 +6087,6 @@ begin
if not BuildInterfaceIdentifierCache(true) then exit(false); if not BuildInterfaceIdentifierCache(true) then exit(false);
if (AskingTool<>Self) and (AskingTool<>nil) then if (AskingTool<>Self) and (AskingTool<>nil) then
AskingTool.AddToolDependency(Self); AskingTool.AddToolDependency(Self);
// search identifier in cache // search identifier in cache
if fdfCollect in Params.Flags then begin if fdfCollect in Params.Flags then begin
AVLNode:=FInterfaceIdentifierCache.Items.FindLowest; AVLNode:=FInterfaceIdentifierCache.Items.FindLowest;