ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Donald <dona...@apache.org>
Subject Re: [Patch] The covreport task does not remove classes not in the ref erence classpath
Date Sat, 15 Sep 2001 04:01:07 GMT
Hi,

could you resend patch as an attachment rather than inline as it gets messed 
up while passing through mail clients ;)

On Sat, 15 Sep 2001 04:34, Garrick Olson wrote:
> The documentation states classes will be removed from the coverage report
> if they are not in the reference classpath.  This patch makes it so.
>
> 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();
>
>
>
> Confidential Information. This email is for intended recipient only.

-- 
Cheers,

Pete

*---------------------------------------------------------*
| Contrary to popular belief, UNIX is user-friendly. It   |
| just happens to be selective on who it makes friendship |
| with.                                                   |
|                       - Richard Cook                    |
*---------------------------------------------------------*

Mime
View raw message