mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-07 15:56:00 +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;
|
StartPos:=CurPos.EndPos;
|
||||||
end;
|
end;
|
||||||
else
|
else
|
||||||
StartPos:=Node.StartPos;
|
if StartPos<1 then
|
||||||
|
StartPos:=Node.StartPos;
|
||||||
end;
|
end;
|
||||||
Node:=Node.Next;
|
Node:=Node.Next;
|
||||||
end;
|
end;
|
||||||
@ -1425,9 +1426,22 @@ var
|
|||||||
|
|
||||||
function IsIdentifierUsed(StartPos: integer): boolean;
|
function IsIdentifierUsed(StartPos: integer): boolean;
|
||||||
begin
|
begin
|
||||||
|
if CompareIdentifiers(PChar(GetIdentifier(@Tool.Src[StartPos])),'TComponent')=0 then
|
||||||
|
DebugLn(['IsIdentifierUsed ',GetIdentifier(@Tool.Src[StartPos])]);
|
||||||
Result:=Identifiers.Find(@Tool.Src[StartPos])<>nil;
|
Result:=Identifiers.Find(@Tool.Src[StartPos])<>nil;
|
||||||
end;
|
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
|
var
|
||||||
Node: TCodeTreeNode;
|
Node: TCodeTreeNode;
|
||||||
begin
|
begin
|
||||||
@ -1437,6 +1451,8 @@ var
|
|||||||
case Node.Desc of
|
case Node.Desc of
|
||||||
ctnEnumIdentifier:
|
ctnEnumIdentifier:
|
||||||
if IsIdentifierUsed(Node.StartPos) then exit;
|
if IsIdentifierUsed(Node.StartPos) then exit;
|
||||||
|
ctnVarDefinition,ctnConstDefinition,ctnTypeDefinition:
|
||||||
|
if IsNodeVisible(Node) and IsIdentifierUsed(Node.StartPos) then exit;
|
||||||
end;
|
end;
|
||||||
Node:=Node.Next;
|
Node:=Node.Next;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user