mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 23:39:40 +02:00
codetools: identifier completion collecting forward class definitions, bug #13101
git-svn-id: trunk@18542 -
This commit is contained in:
parent
90e58cc971
commit
feaa627c17
@ -189,6 +189,7 @@ type
|
|||||||
function Count: integer;
|
function Count: integer;
|
||||||
function GetFilteredCount: integer;
|
function GetFilteredCount: integer;
|
||||||
function HasIdentifier(Identifier: PChar; const ParamList: string): boolean;
|
function HasIdentifier(Identifier: PChar; const ParamList: string): boolean;
|
||||||
|
function FindIdentifier(Identifier: PChar; const ParamList: string): TIdentifierListItem;
|
||||||
function FindCreatedIdentifier(const Ident: string): integer;
|
function FindCreatedIdentifier(const Ident: string): integer;
|
||||||
function CreateIdentifier(const Ident: string): PChar;
|
function CreateIdentifier(const Ident: string): PChar;
|
||||||
function StartUpAtomInFrontIs(const s: string): boolean;
|
function StartUpAtomInFrontIs(const s: string): boolean;
|
||||||
@ -654,11 +655,25 @@ function TIdentifierList.HasIdentifier(Identifier: PChar;
|
|||||||
const ParamList: string): boolean;
|
const ParamList: string): boolean;
|
||||||
begin
|
begin
|
||||||
FIdentSearchItem.Identifier:=Identifier;
|
FIdentSearchItem.Identifier:=Identifier;
|
||||||
FIdentSearchItem.ParamList:='';
|
FIdentSearchItem.ParamList:=ParamList;
|
||||||
Result:=FIdentView.FindKey(FIdentSearchItem,
|
Result:=FIdentView.FindKey(FIdentSearchItem,
|
||||||
@CompareIdentListSearchWithItems)<>nil;
|
@CompareIdentListSearchWithItems)<>nil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TIdentifierList.FindIdentifier(Identifier: PChar;
|
||||||
|
const ParamList: string): TIdentifierListItem;
|
||||||
|
var
|
||||||
|
AVLNode: TAVLTreeNode;
|
||||||
|
begin
|
||||||
|
FIdentSearchItem.Identifier:=Identifier;
|
||||||
|
FIdentSearchItem.ParamList:=ParamList;
|
||||||
|
AVLNode:=FIdentView.FindKey(FIdentSearchItem,@CompareIdentListSearchWithItems);
|
||||||
|
if AVLNode<>nil then
|
||||||
|
Result:=TIdentifierListItem(AVLNode.Data)
|
||||||
|
else
|
||||||
|
Result:=nil;
|
||||||
|
end;
|
||||||
|
|
||||||
function TIdentifierList.FindCreatedIdentifier(const Ident: string): integer;
|
function TIdentifierList.FindCreatedIdentifier(const Ident: string): integer;
|
||||||
begin
|
begin
|
||||||
if Ident<>'' then begin
|
if Ident<>'' then begin
|
||||||
@ -871,19 +886,23 @@ begin
|
|||||||
|
|
||||||
ctnTypeDefinition,ctnGenericType:
|
ctnTypeDefinition,ctnGenericType:
|
||||||
begin
|
begin
|
||||||
Node:=FoundContext.Tool.FindTypeNodeOfDefinition(FoundContext.Node);
|
Node:=FoundContext.Node.FirstChild;
|
||||||
if (Node<>nil)
|
|
||||||
and (Node.Desc in [ctnClass,ctnClassInterface])
|
|
||||||
and ((ctnsForwardDeclaration and Node.SubDesc)>0)
|
|
||||||
then
|
|
||||||
// skip forward definition
|
|
||||||
exit;
|
|
||||||
if FoundContext.Node.Desc=ctnTypeDefinition then
|
if FoundContext.Node.Desc=ctnTypeDefinition then
|
||||||
Ident:=@FoundContext.Tool.Src[FoundContext.Node.StartPos]
|
Ident:=@FoundContext.Tool.Src[FoundContext.Node.StartPos]
|
||||||
else begin
|
else begin
|
||||||
// generic
|
// generic
|
||||||
if FoundContext.Node.FirstChild=nil then exit;
|
if Node=nil then exit;
|
||||||
Ident:=@FoundContext.Tool.Src[FoundContext.Node.FirstChild.StartPos];
|
Ident:=@FoundContext.Tool.Src[Node.StartPos];
|
||||||
|
end;
|
||||||
|
if (Node<>nil)
|
||||||
|
and (Node.Desc in [ctnClass,ctnClassInterface])
|
||||||
|
and ((ctnsForwardDeclaration and Node.SubDesc)>0)
|
||||||
|
then begin
|
||||||
|
// forward definition of a class
|
||||||
|
if CurrentIdentifierList.FindIdentifier(Ident,'')<>nil then begin
|
||||||
|
// the real class is already in the list => skip forward
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user