1212import javax .xml .parsers .DocumentBuilder ;
1313import javax .xml .parsers .DocumentBuilderFactory ;
1414import javax .xml .parsers .ParserConfigurationException ;
15+ import javax .xml .transform .OutputKeys ;
1516import javax .xml .transform .Transformer ;
1617import javax .xml .transform .TransformerException ;
1718import javax .xml .transform .TransformerFactory ;
@@ -31,11 +32,16 @@ public ReportMissingSummaryWrapper(IMethodSummaryProvider flows) {
3132 super (flows );
3233 }
3334
34- ConcurrentHashMap <SootClass , AtomicInteger > classSummariesMissing = new ConcurrentHashMap <>();
35+ private ConcurrentHashMap <SootClass , AtomicInteger > classSummariesMissing = new ConcurrentHashMap <>();
36+ private boolean prettyPrint = false ;
37+ private boolean showAppClasses = false ;
3538
3639 @ Override
3740 protected void reportMissingMethod (SootMethod method ) {
38- count (method .getDeclaringClass (), classSummariesMissing );
41+ SootClass decl = method .getDeclaringClass ();
42+ if (!showAppClasses && decl .isApplicationClass ())
43+ return ;
44+ count (decl , classSummariesMissing );
3945 }
4046
4147 private static <T > void count (T item , Map <T , AtomicInteger > map ) {
@@ -49,6 +55,22 @@ private static <T> void count(T item, Map<T, AtomicInteger> map) {
4955 ai .incrementAndGet ();
5056 }
5157
58+ public void setPrettyPrinting (boolean prettyPrint ) {
59+ this .prettyPrint = prettyPrint ;
60+ }
61+
62+ public boolean isPrettyPrinting () {
63+ return prettyPrint ;
64+ }
65+
66+ public void setShowApplicationClasses (boolean showAppClasses ) {
67+ this .showAppClasses = showAppClasses ;
68+ }
69+
70+ public boolean isShowingApplicationClasses () {
71+ return showAppClasses ;
72+ }
73+
5274 public void writeResults (File file ) throws IOException , ParserConfigurationException , TransformerException {
5375 Map <SootClass , Integer > sortedClassSummariesMissing = sortMap (classSummariesMissing );
5476 DocumentBuilderFactory docFactory = DocumentBuilderFactory .newInstance ();
@@ -71,6 +93,11 @@ public void writeResults(File file) throws IOException, ParserConfigurationExcep
7193
7294 TransformerFactory transformerFactory = TransformerFactory .newInstance ();
7395 Transformer transformer = transformerFactory .newTransformer ();
96+
97+ if (prettyPrint ) {
98+ transformer .setOutputProperty (OutputKeys .INDENT , "yes" );
99+ transformer .setOutputProperty ("{http://xml.apache.org/xslt}indent-amount" , "4" );
100+ }
74101 DOMSource source = new DOMSource (doc );
75102 StreamResult result = new StreamResult (file );
76103
0 commit comments