CppunitTest_sc_tiledrendering2: move to tiledrendering folder
[LibreOffice.git] / bin / find-unused-sid-commands.py
blob4688d54a5ccd6cdf654413e960c340c4fc545677
1 #!/usr/bin/python
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.
9 import subprocess
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
15 commandSet = list()
16 with a.stdout as txt:
17 for line in txt:
18 line = line.strip()
19 idx1 = line.find(" ")
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:
27 commandName = pair[0]
28 sidName = pair[1]
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)
32 cnt = 0
33 with a.stdout as txt2:
34 for line2 in txt2:
35 cnt = cnt + 1
36 if cnt > 0:
37 continue
39 # check to see if the SID is used programmatically
40 foundLines = ""
41 a = subprocess.Popen("git grep -wn " + sidName, stdout=subprocess.PIPE, shell=True)
42 with a.stdout as txt2:
43 for line2 in txt2:
44 foundLines = foundLines + line2
45 if foundLines.find("ExecuteList") != -1:
46 continue
47 if foundLines.find("GetDispatcher()->Execute") != -1:
48 continue
49 if foundLines.find("ExecuteScenarioSlot") != -1:
50 continue
51 # TODO not sure about this, but let's tackle the easy ones first
52 if foundLines.find("Invalidate(") != -1:
53 continue
55 # dump any lines that contain the SID, so we can eyeball the results
56 print("remove: " + commandName)
57 print(foundLines)
58 print("----------------------------------------------------------------------------")