8 definitionToSourceLocationMap
= dict()
12 with io
.open("loplugin.unnecessaryvirtual.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] == "overriding:":
21 fullMethodName
= tokens
[1]
22 overridingSet
.add(fullMethodName
)
24 unnecessaryVirtualSet
= set()
26 for clazz
in (definitionSet
- overridingSet
):
27 # windows-specific stuff
28 if clazz
.startswith("canvas::"): continue
29 if clazz
.startswith("psp::PrinterInfoManager"): continue
30 if clazz
.startswith("DdeTopic::"): continue
31 if clazz
== "basegfx::unotools::UnoPolyPolygon::void-modifying()const": continue
32 if clazz
== "SalLayout::_Bool-IsKashidaPosValid(int,)const": continue
33 if clazz
== "SalLayout::void-DisableGlyphInjection(_Bool,)": continue
35 if clazz
== "X11SalFrame::void-updateGraphics(_Bool,)": continue
37 if clazz
== "SalFrame::void-SetRepresentedURL(const class rtl::OUString &,)": continue
38 if clazz
== "SalMenu::_Bool-AddMenuBarButton(const struct SalMenuButtonItem &,)": continue
39 if clazz
== "SalMenu::class Rectangle-GetMenuBarButtonRectPixel(sal_uInt16,class SalFrame *,)": continue
40 if clazz
== "SalMenu::void-RemoveMenuBarButton(sal_uInt16,)": continue
41 if clazz
== "SalLayout::_Bool-DrawTextSpecial(class SalGraphics &,sal_uInt32,)const": continue
43 if clazz
== "GtkSalDisplay::int-CaptureMouse(class SalFrame *,)": continue
45 if clazz
.startswith("apitest::"): continue
46 # ignore external code
47 if definitionToSourceLocationMap
[clazz
].startswith("external/"): continue
49 unnecessaryVirtualSet
.add((clazz
,definitionToSourceLocationMap
[clazz
] ))
52 # sort the results using a "natural order" so sequences like [item1,item2,item10] sort nicely
53 def natural_sort_key(s
, _nsre
=re
.compile('([0-9]+)')):
54 return [int(text
) if text
.isdigit() else text
.lower()
55 for text
in re
.split(_nsre
, s
)]
57 # sort results by name and line number
58 tmp1list
= sorted(unnecessaryVirtualSet
, key
=lambda v
: natural_sort_key(v
[1]))
60 with
open("loplugin.unnecessaryvirtual.report", "wt") as f
:
62 f
.write( t
[1] + "\n" )
63 f
.write( " " + t
[0] + "\n" )
64 # add an empty line at the end to make it easier for the removevirtuals plugin to mmap() the output file