Package net.sf.jcontracts.dependencyanalyzer

Examples of net.sf.jcontracts.dependencyanalyzer.DependencyAnalyzer


            if (targets.isEmpty())
            {
                throw new RuntimeException(
                        "Java Contract Suite: error list of source files is empty or no matches for pattern(s), no files to process!");
            }
            DependencyAnalyzer da = new DependencyAnalyzer();
            Graph dependencyGraph = null;
            log.info("parsing input files to determine dependencies.");
            long start = System.currentTimeMillis();
            MultipleCompilationUnitState multipleCompilationUnitState = new MultipleCompilationUnitState();
            try
            {
                for (int targetIndex = 0; targetIndex < targets.size(); targetIndex++)
                {
                    String filename = ((Target) targets.elementAt(targetIndex)).getName();
                    try
                    {
                        Reader is = new FileReader(filename);
                        try
                        {
                            BufferedReader bufferedIs = new BufferedReader(is);
                            try
                            {
                                recent_file = filename;
                                if (++number_of_files % 50 == 0 && number_of_files > 0)
                                {
                                    log.info(" (" + number_of_files + " files parsed)");
                                }
                                net.sf.jcontracts.codeparser.Parser parser = new net.sf.jcontracts.codeparser.Parser(
                                        bufferedIs, filename, multipleCompilationUnitState);
                                MetaclassFactory metaclassFactory = new MetaclassFactory(filename);
                                parser.setMetaclassFactory(metaclassFactory);
                                Vector v = parser.getUsedTypes();
                                da.process(v);
                            }
                            finally
                            {
                                bufferedIs.close();
                            }
                        }
                        finally
                        {
                            is.close();
                        }
                    }
                    catch (FileNotFoundException _ex)
                    {
                        throw new RuntimeException("Java Contract Suite: error file " + filename + " not found!", _ex);
                    }
                }

                long end = System.currentTimeMillis();
                log.info("Analyzed " + targets.size() + " files in " + (end - start) / 1000D + " s.");
            }
            catch (Exception e)
            {
                log.error("parsing problem while looking at " + recent_file);
                throw e;
            }
            if (multipleCompilationUnitState.hasUnresolvedNames())
            {
                String unresolvedNames = multipleCompilationUnitState.getUnresolvedNamesAsString();
                log.error("could not resolve the following type names:\n" + unresolvedNames);
                throw new RuntimeException("could not resolve the following type names:\n" + unresolvedNames);
            }
            dependencyGraph = da.getGraph();
            log.info("found " + dependencyGraph.getSize() + " relavant types referenced in the " + targets.size()
                    + " files.");
            AllOption allOption = null;
            for (int i = 0; i < options.size(); i++)
            {
View Full Code Here

TOP

Related Classes of net.sf.jcontracts.dependencyanalyzer.DependencyAnalyzer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.