Skip to content

Commit

Permalink
codetools: identifier completion: list each namespace only once
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.freepascal.org/svn/lazarus/trunk@54740 4005530d-fff6-0310-9dd1-cebe43e6787f
  • Loading branch information
mattias committed Apr 26, 2017
1 parent 05d0552 commit 409f3a6
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions components/codetools/finddeclarationtool.pas
Original file line number Diff line number Diff line change
Expand Up @@ -4475,7 +4475,7 @@ function TFindDeclarationTool.FindIdentifierInContext(
var
UnitNode, ThisNamespaceNode, TargetNamespaceNode, UsesNode: TCodeTreeNode;
Level, CurLevel: Integer;
InFilename, AnUnitName: String;
InFilename, AnUnitName, FoundNames, FoundName: String;
NewCodeTool: TFindDeclarationTool;
begin
Result := False;
Expand Down Expand Up @@ -4504,6 +4504,7 @@ function TFindDeclarationTool.FindIdentifierInContext(
SourceNamespaceNode:=SourceNamespaceNode.PriorBrother;
end;

FoundNames:='';
UnitNode := UsesNode.LastChild;
while UnitNode<>nil do
begin
Expand All @@ -4525,12 +4526,15 @@ function TFindDeclarationTool.FindIdentifierInContext(
if CurLevel=Level then
begin
// namespace paths match
debugln(['SearchInNamespaces Match ',ExtractNode(TargetNamespaceNode.Parent,[])]);
//debugln(['SearchInNamespaces Match ',ExtractNode(TargetNamespaceNode.Parent,[])]);
if (TargetNamespaceNode.NextBrother<>nil) then begin
// prefix matches
if (Params.Identifier=nil)
or CompareSrcIdentifiers(TargetNamespaceNode.NextBrother.StartPos,Params.Identifier)
FoundName:='('+GetIdentifier(@Src[TargetNamespaceNode.NextBrother.StartPos])+')';
if (Pos(FoundName,FoundNames)<1)
and ((Params.Identifier=nil)
or CompareSrcIdentifiers(TargetNamespaceNode.NextBrother.StartPos,Params.Identifier))
then begin
FoundNames:=FoundNames+FoundName;
Params.SetResult(Self,TargetNamespaceNode.NextBrother);
Result:=CheckResult(true,true);
end;
Expand Down

0 comments on commit 409f3a6

Please sign in to comment.