3 # Find potentially unused UNO command entries in SDI files.
5 # Note that this is not foolproof, some extra checking is required because some command names might be
6 # constructed at runtime.
11 # search for entries in .sdi files that declare UNO/SID commands
12 a
= subprocess
.Popen("git grep -P '^\s*\w+Item\s+\w+\s+SID_\w+$' -- *.sdi", stdout
=subprocess
.PIPE
, shell
=True)
14 # parse out the UNO command names
20 idx2
= line
.find(" ", idx1
+ 1)
21 commandName
= line
[idx1
+1 : idx2
].strip()
22 sidName
= line
[idx2
+1:].strip()
23 commandSet
.append((commandName
,sidName
))
25 # now check to see if that UNO command is called anywhere in the codebase.
26 for pair
in commandSet
:
30 # check to see if that UNO command is called anywhere in the codebase.
31 a
= subprocess
.Popen("git grep -wFn '.uno:" + commandName
+ "'", stdout
=subprocess
.PIPE
, shell
=True)
33 with a
.stdout
as txt2
:
38 # check to see if the SID is used programmatically
40 a
= subprocess
.Popen("git grep -wn " + sidName
, stdout
=subprocess
.PIPE
, shell
=True)
41 with a
.stdout
as txt2
:
43 foundLines
= foundLines
+ line2
44 if foundLines
.find("ExecuteList") != -1: continue
45 if foundLines
.find("GetDispatcher()->Execute") != -1: continue
46 if foundLines
.find("ExecuteScenarioSlot") != -1: continue
47 # TODO not sure about this, but let's tackle the easy ones first
48 if foundLines
.find("Invalidate(") != -1: continue
50 # dump any lines that contain the SID, so we can eyeball the results
51 print("remove: " + commandName
)
53 print("----------------------------------------------------------------------------")