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(r
"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
:
39 # check to see if the SID is used programmatically
41 a
= subprocess
.Popen("git grep -wn " + sidName
, stdout
=subprocess
.PIPE
, shell
=True)
42 with a
.stdout
as txt2
:
44 foundLines
= foundLines
+ line2
45 if foundLines
.find("ExecuteList") != -1:
47 if foundLines
.find("GetDispatcher()->Execute") != -1:
49 if foundLines
.find("ExecuteScenarioSlot") != -1:
51 # TODO not sure about this, but let's tackle the easy ones first
52 if foundLines
.find("Invalidate(") != -1:
55 # dump any lines that contain the SID, so we can eyeball the results
56 print("remove: " + commandName
)
58 print("----------------------------------------------------------------------------")