8 definitionToSourceLocationMap
= dict()
12 with io
.open("workdir/loplugin.virtualdown.log", "rb", buffering
=1024*1024) as txt
:
14 tokens
= line
.strip().split("\t")
15 if tokens
[0] == "definition:":
16 fullMethodName
= tokens
[1]
17 sourceLocation
= tokens
[2]
18 definitionSet
.add(fullMethodName
)
19 definitionToSourceLocationMap
[fullMethodName
] = sourceLocation
20 elif tokens
[0] == "call:":
21 fullMethodName
= tokens
[1]
22 callSet
.add(fullMethodName
)
24 print( "unknown line: " + line
)
26 unnecessaryVirtualSet
= set()
28 for clazz
in (definitionSet
- callSet
):
29 # if clazz.startswith("canvas::"): continue
30 # if clazz == "basegfx::unotools::UnoPolyPolygon::void-modifying()const": continue
31 # ignore external code
32 if definitionToSourceLocationMap
[clazz
].startswith("external/"): continue
34 unnecessaryVirtualSet
.add((clazz
,definitionToSourceLocationMap
[clazz
] ))
37 # sort the results using a "natural order" so sequences like [item1,item2,item10] sort nicely
38 def natural_sort_key(s
, _nsre
=re
.compile('([0-9]+)')):
39 return [int(text
) if text
.isdigit() else text
.lower()
40 for text
in re
.split(_nsre
, s
)]
42 # sort results by name and line number
43 tmp1list
= sorted(unnecessaryVirtualSet
, key
=lambda v
: natural_sort_key(v
[1]))
45 with
open("compilerplugins/clang/virtualdown.results", "wt") as f
:
47 f
.write( t
[1] + "\n" )
48 f
.write( " " + t
[0] + "\n" )
49 # add an empty line at the end to make it easier for the removevirtuals plugin to mmap() the output file