8 definitionToFileDict
= {}
10 with
open("workdir/loplugin.finalclasses.log") as txt
:
12 tokens
= line
.strip().split("\t")
17 elif tokens
[0] == "definition:":
19 # the 1.. is so we skip the leading /
20 fileName
= tokens
[2][1:]
21 definitionSet
.add(clazzName
)
22 definitionToFileDict
[clazzName
] = fileName
24 elif tokens
[0] == "inherited-from:":
26 if (parent
.startswith("class ")):
28 elif (parent
.startswith("struct ")):
30 inheritFromSet
.add(parent
);
33 for clazz
in sorted(definitionSet
- inheritFromSet
):
34 file = definitionToFileDict
[clazz
]
35 # ignore classes defined inside compilation units, the compiler knows they are final already
36 if (".cxx" in file): continue
37 # ignore test and external code
38 if ("/qa/" in file): continue
39 if (file.startswith("workdir/")): continue
40 tmpset
.add((clazz
, file))
42 # sort the results using a "natural order" so sequences like [item1,item2,item10] sort nicely
43 def natural_sort_key(s
, _nsre
=re
.compile('([0-9]+)')):
44 return [int(text
) if text
.isdigit() else text
.lower()
45 for text
in re
.split(_nsre
, s
)]
46 def sort_set_by_natural_key(s
):
47 return sorted(s
, key
=lambda v
: natural_sort_key(v
[1]))
49 # print output, sorted by name and line number
50 with
open("compilerplugins/clang/finalclasses.results", "wt") as f
:
51 for t
in sort_set_by_natural_key(tmpset
):
53 f
.write(" " + t
[0] + "\n")