I have attached it to this email. Sorry about that.
-----Original Message-----
From: Peter Donald [mailto:[EMAIL PROTECTED]
Sent: Friday, September 14, 2001 09:01 PM
To: [EMAIL PROTECTED]
Subject: Re: [Patch] The covreport task does not remove classes not in
the ref erence classpath
Importance: Low
Hi,
could you resend patch as an attachment rather than inline as it gets messed
up while passing through mail clients ;)
Confidential Information. This email is for intended recipient only.
Index: XMLReport.java
===================================================================
RCS file:
/home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/sitraka/XMLReport.java,v
retrieving revision 1.1
diff -u -r1.1 XMLReport.java
--- XMLReport.java 2001/07/31 08:40:12 1.1
+++ XMLReport.java 2001/09/14 18:18:23
@@ -88,6 +88,9 @@
/** parsed document */
protected Document report;
+ /** mapping of class names to <code>ClassFile</code>s from the reference
classpath. It is used to filter the JProbe report. */
+ protected Hashtable classFiles;
+
/** mapping package name / package node for faster access */
protected Hashtable pkgMap;
@@ -155,7 +158,7 @@
methodname.delete(methodname.toString().indexOf("(") ,
methodname.toString().length());
String signature = classname + "." +
methodname + "()";
if (filters.accept(signature)){
- log("keeped method:" +
signature);
+ log("kept method:" + signature);
nbmethods++;
}
else {
@@ -163,7 +166,7 @@
}
}
// if we don't keep any method, we don't keep
the class
- if (nbmethods != 0){
+ if (nbmethods != 0 &&
classFiles.containsKey(classname)){
log("Adding class '" + classname + "'");
classMap.put(classname, clazz);
nbclasses++;
@@ -186,19 +189,8 @@
/** create the whole new document */
public Document createDocument(String[] classPath) throws Exception {
- DocumentBuilder dbuilder = newBuilder();
- InputSource is = new InputSource( new FileInputStream(file) );
- if (jprobeHome != null){
- File dtdDir = new File(jprobeHome, "Dtd/snapshot.dtd");
- is.setSystemId( "file:///" + dtdDir.getAbsolutePath() );
- }
- report = dbuilder.parse( is );
- report.normalize();
-
- // create maps for faster node access
- createNodeMaps();
-
- // iterate over the classpath...
+ // Iterate over the classpath to identify reference classes
+ classFiles = new Hashtable();
ClassPathLoader cpl = new ClassPathLoader(classPath);
Enumeration enum = cpl.loaders();
while ( enum.hasMoreElements() ){
@@ -207,8 +199,28 @@
log("Processing " + classes.length + " classes in " +
fl.getFile());
// process all classes
for (int i = 0; i < classes.length; i++){
- serializeClass(classes[i]);
+ classFiles.put(classes[i].getFullName(),
classes[i]);
}
+ }
+
+ // Load the JProbe coverage XML report
+ DocumentBuilder dbuilder = newBuilder();
+ InputSource is = new InputSource( new FileInputStream(file) );
+ if (jprobeHome != null){
+ File dtdDir = new File(jprobeHome, "Dtd");
+ is.setSystemId( "file:///" + dtdDir.getAbsolutePath() +
"/");
+ }
+ report = dbuilder.parse( is );
+ report.normalize();
+
+ // create maps for faster node access (also filters out
unwanted nodes)
+ createNodeMaps();
+
+ // Make sure each class from the reference path ends up in the
report
+ Enumeration classes = classFiles.elements();
+ while ( classes.hasMoreElements() ){
+ ClassFile cf = (ClassFile) classes.nextElement();
+ serializeClass(cf);
}
// update the document with the stats
update();