mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-06 04:26:17 +02:00
codetools: finding unused units
git-svn-id: trunk@19287 -
This commit is contained in:
parent
9a76510f83
commit
fe3b0c86d2
@ -1414,7 +1414,8 @@ var
|
||||
StartPos:=CurPos.EndPos;
|
||||
end;
|
||||
else
|
||||
StartPos:=Node.StartPos;
|
||||
if StartPos<1 then
|
||||
StartPos:=Node.StartPos;
|
||||
end;
|
||||
Node:=Node.Next;
|
||||
end;
|
||||
@ -1425,9 +1426,22 @@ var
|
||||
|
||||
function IsIdentifierUsed(StartPos: integer): boolean;
|
||||
begin
|
||||
if CompareIdentifiers(PChar(GetIdentifier(@Tool.Src[StartPos])),'TComponent')=0 then
|
||||
DebugLn(['IsIdentifierUsed ',GetIdentifier(@Tool.Src[StartPos])]);
|
||||
Result:=Identifiers.Find(@Tool.Src[StartPos])<>nil;
|
||||
end;
|
||||
|
||||
function IsNodeVisible(Node: TCodeTreeNode): boolean;
|
||||
begin
|
||||
if (Node.Parent=nil)
|
||||
or (Node.Parent.Desc=ctnInterface)
|
||||
or (Node.Parent.Parent=nil)
|
||||
or (Node.Parent.Parent.Desc=ctnInterface) then
|
||||
Result:=true
|
||||
else
|
||||
Result:=false;
|
||||
end;
|
||||
|
||||
var
|
||||
Node: TCodeTreeNode;
|
||||
begin
|
||||
@ -1437,6 +1451,8 @@ var
|
||||
case Node.Desc of
|
||||
ctnEnumIdentifier:
|
||||
if IsIdentifierUsed(Node.StartPos) then exit;
|
||||
ctnVarDefinition,ctnConstDefinition,ctnTypeDefinition:
|
||||
if IsNodeVisible(Node) and IsIdentifierUsed(Node.StartPos) then exit;
|
||||
end;
|
||||
Node:=Node.Next;
|
||||
end;
|
||||
|
Loading…
Reference in New Issue
Block a user