/* * [CountParms.java] * * Summary: Count number of parms in code for a given method to verify signature changes. * * Copyright: (c) 2016-2017 Roedy Green, Canadian Mind Products, http://mindprod.com * * Licence: This software may be copied and used freely for any purpose but military. * http://mindprod.com/contact/nonmil.html * * Requires: JDK 1.8+ * * Created with: JetBrains IntelliJ IDEA IDE http://www.jetbrains.com/idea/ * * Version History: * 1.0 2016-03-19 initial version */ package com.mindprod.repair; import com.mindprod.commandline.CommandLine; import com.mindprod.filter.AllButSVNDirectoriesFilter; import com.mindprod.filter.ExtensionListFilter; import com.mindprod.hunkio.HunkIO; import java.io.File; import java.io.IOException; import static java.lang.System.*; /** * Count number of parms in code for a given method to verify signature changes. * * @author Roedy Green, Canadian Mind Products * @version 1.0 2016-03-19 initial version * @since 2008 */ public class CountParms { private static final int FIRST_COPYRIGHT_YEAR = 2016; /** * undisplayed copyright notice */ @SuppressWarnings( { "UnusedDeclaration" } ) private static final String EMBEDDED_COPYRIGHT = "Copyright: (c) 2016-2017 Roedy Green, Canadian Mind Products, http://mindprod.com"; @SuppressWarnings( { "UnusedDeclaration" } ) private static final String RELEASE_DATE = "2016-03-19"; /** * embedded version string. */ @SuppressWarnings( { "UnusedDeclaration" } ) private static final String VERSION_STRING = "1.0"; private static void scan( File fileBeingProcessed, String method ) throws IOException { final String big = HunkIO.readEntireFile( fileBeingProcessed ); int start = 0; int whereFound = 0; final int end = big.length(); method += '('; while ( ( whereFound = big.indexOf( method, start ) ) >= 0 ) { int comma = 0; innerloop: for ( int i = whereFound; i < end; i++ ) { final char c = big.charAt( i ); switch ( c ) { case ',': comma++; break; case ';': start = i + 1; break innerloop; default: break; } } // number of parms found out.println( ( comma + 1 ) + " " + fileBeingProcessed.toString() ); } // end while } /** * @param args name of method to look for */ public static void main( String[] args ) { // get files to process java command line. out.println( "Gathering html files to scan for calls..." ); CommandLine wantedFiles = new CommandLine( new String[] { "-s", "-q", "E:/intellij/mp/j8/src/com/mindprod/" }, new AllButSVNDirectoriesFilter(), new ExtensionListFilter( "java" ) ); if ( args.length != 1 ) { err.println( "CountParms: missing name of method on command line" ); System.exit( 2 ); } final String method = args[ 0 ]; for ( File fileBeingProcessed : wantedFiles ) { try { scan( fileBeingProcessed, method ); } catch ( IOException e ) { e.printStackTrace( err ); err.println(); } } // end for to process each file out.println( "done" ); } }