Loading de.ugoe.cs.swe.T3Q/src/de/ugoe/cs/swe/T3Q/T3Q.java +30 −2 Original line number Diff line number Diff line Loading @@ -42,6 +42,7 @@ public class T3Q { private ArrayList<String> inputPaths = new ArrayList<String>(); private String destinationPath = null; private boolean generateNewConfiguration = false; private boolean generateLocalDependencies = false; private final Stopwatch stopwatch = Stopwatch.createUnstarted(); // private boolean formattingEnabled = false; Loading Loading @@ -104,9 +105,15 @@ public class T3Q { } LoggingInterface logger = new LoggingInterface(activeProfile.getLoggingConfiguration()); logger.setMaximumLogLevel(logLevel); TTCN3ResourceProvider resourceProvider = new TTCN3ResourceProvider(inputPaths, logger, activeProfile); resourceProvider.loadResources(); //TODO: check if it has to be exclusive if (!this.isGenerateLocalDependencies()) { resourceProvider.analyzeResources(); } else { resourceProvider.analyzeDependencies(); } if (activeProfile.isGenerateXMI()) resourceProvider.createXMI(); Loading Loading @@ -196,6 +203,9 @@ public class T3Q { if (commandLine.hasOption("output-path")) { this.setDestinationPath(commandLine.getOptionValue("output-path")); } if (commandLine.hasOption("local-dependencies")) { this.setGenerateLocalDependencies(true); } return commandLine.getArgs(); } Loading @@ -211,8 +221,18 @@ public class T3Q { configTools.loadConfig(getConfigurationFilename()); activeProfile = (QualityCheckProfile) configTools.selectProfile(specifiedProfile); if (this.getDestinationPath() == null) { if (this.isGenerateLocalDependencies()) { setDestinationPath(T3Q.activeProfile.getDependencyOutputPath()); } else { setDestinationPath(T3Q.activeProfile.getPathFormattedOutputPath()); } } else { if (this.isGenerateLocalDependencies()) { T3Q.activeProfile.setDependencyOutputPath(this.getDestinationPath()); } else { T3Q.activeProfile.setPathFormattedOutputPath(this.getDestinationPath()); } } } } catch (InstantiationException e) { throw new TerminationException("ERROR: Instantiation problems encountered while loading configuration profile. " Loading Loading @@ -394,4 +414,12 @@ public class T3Q { return 0; } } public boolean isGenerateLocalDependencies() { return generateLocalDependencies; } public void setGenerateLocalDependencies(boolean generateLocalDependencies) { this.generateLocalDependencies = generateLocalDependencies; } } de.ugoe.cs.swe.T3Q/src/de/ugoe/cs/swe/T3Q/TTCN3ResourceProvider.java +68 −0 Original line number Diff line number Diff line package de.ugoe.cs.swe.T3Q; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.PrintStream; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; Loading Loading @@ -177,6 +180,71 @@ public class TTCN3ResourceProvider { + MiscTools.msToString(watchAnalyzing.elapsed(TimeUnit.MILLISECONDS)) + " minutes." + '\n'); } public void analyzeDependencies() { Stopwatch watchAnalyzing = Stopwatch.createStarted(); ExecutorService pool = Executors.newFixedThreadPool(cores); // Check if resource is a ignored one and if so, do not analyze it. Pattern pattern = Pattern.compile(activeProfile.getIgnoredResourceRegExp()); Matcher matcher = null; ArrayList<DependencyAnalyzer> analyzer = new ArrayList<DependencyAnalyzer>(); for (int i = 0; i < TTCN3GlobalScopeProvider.RESOURCES.size(); i++) { Resource resource = TTCN3GlobalScopeProvider.RESOURCES.get(i); matcher = pattern.matcher(resource.getURI().toFileString()); if(!matcher.matches()) { analyzer.add(new DependencyAnalyzer(TTCN3GlobalScopeProvider.RESOURCES.get(i), logger)); } } try { List<Future<TTCN3Dependency>> output = pool.invokeAll(analyzer); pool.shutdown(); System.out.print('\n'); for (Future<TTCN3Dependency> f : output) { TTCN3Dependency o = f.get(); System.out.println("Dependency analysis output of " + o.getResource().getURI().lastSegment()); for (String d : o.getMessages()) { printOutput(o.getResource(), d); } } String xmlpath = "dependencies.xml"; File parent = new File(this.activeProfile.getDependencyOutputPath()); parent.mkdirs(); xmlpath = parent.getAbsolutePath()+File.separator+xmlpath; FileOutputStream file; try { file = new FileOutputStream(xmlpath); PrintStream stream = new PrintStream(file); stream.print("<?xml-stylesheet type=\"text/xsl\" href=\"../dependencies.xsl\"?>\n<dependencies>\n"); //TODO: check if it is faster to do this all at once for (Future<TTCN3Dependency> f : output) { for (String d : f.get().getOutput()) { stream.print(d); } } stream.print("</dependencies>"); stream.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } } catch (InterruptedException | ExecutionException e) { // TODO Auto-generated catch block e.printStackTrace(); } watchAnalyzing.stop(); System.out.println("Test suite analyzed in " + MiscTools.msToString(watchAnalyzing.elapsed(TimeUnit.MILLISECONDS)) + " minutes." + '\n'); } private void printOutput(Resource resource, String message) { System.out.println(message); } private void printOutput(Resource resource, FeatureBasedDiagnostic featureDiagnostic) { switch (featureDiagnostic.getSeverity()) { Loading Loading
de.ugoe.cs.swe.T3Q/src/de/ugoe/cs/swe/T3Q/T3Q.java +30 −2 Original line number Diff line number Diff line Loading @@ -42,6 +42,7 @@ public class T3Q { private ArrayList<String> inputPaths = new ArrayList<String>(); private String destinationPath = null; private boolean generateNewConfiguration = false; private boolean generateLocalDependencies = false; private final Stopwatch stopwatch = Stopwatch.createUnstarted(); // private boolean formattingEnabled = false; Loading Loading @@ -104,9 +105,15 @@ public class T3Q { } LoggingInterface logger = new LoggingInterface(activeProfile.getLoggingConfiguration()); logger.setMaximumLogLevel(logLevel); TTCN3ResourceProvider resourceProvider = new TTCN3ResourceProvider(inputPaths, logger, activeProfile); resourceProvider.loadResources(); //TODO: check if it has to be exclusive if (!this.isGenerateLocalDependencies()) { resourceProvider.analyzeResources(); } else { resourceProvider.analyzeDependencies(); } if (activeProfile.isGenerateXMI()) resourceProvider.createXMI(); Loading Loading @@ -196,6 +203,9 @@ public class T3Q { if (commandLine.hasOption("output-path")) { this.setDestinationPath(commandLine.getOptionValue("output-path")); } if (commandLine.hasOption("local-dependencies")) { this.setGenerateLocalDependencies(true); } return commandLine.getArgs(); } Loading @@ -211,8 +221,18 @@ public class T3Q { configTools.loadConfig(getConfigurationFilename()); activeProfile = (QualityCheckProfile) configTools.selectProfile(specifiedProfile); if (this.getDestinationPath() == null) { if (this.isGenerateLocalDependencies()) { setDestinationPath(T3Q.activeProfile.getDependencyOutputPath()); } else { setDestinationPath(T3Q.activeProfile.getPathFormattedOutputPath()); } } else { if (this.isGenerateLocalDependencies()) { T3Q.activeProfile.setDependencyOutputPath(this.getDestinationPath()); } else { T3Q.activeProfile.setPathFormattedOutputPath(this.getDestinationPath()); } } } } catch (InstantiationException e) { throw new TerminationException("ERROR: Instantiation problems encountered while loading configuration profile. " Loading Loading @@ -394,4 +414,12 @@ public class T3Q { return 0; } } public boolean isGenerateLocalDependencies() { return generateLocalDependencies; } public void setGenerateLocalDependencies(boolean generateLocalDependencies) { this.generateLocalDependencies = generateLocalDependencies; } }
de.ugoe.cs.swe.T3Q/src/de/ugoe/cs/swe/T3Q/TTCN3ResourceProvider.java +68 −0 Original line number Diff line number Diff line package de.ugoe.cs.swe.T3Q; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.PrintStream; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; Loading Loading @@ -177,6 +180,71 @@ public class TTCN3ResourceProvider { + MiscTools.msToString(watchAnalyzing.elapsed(TimeUnit.MILLISECONDS)) + " minutes." + '\n'); } public void analyzeDependencies() { Stopwatch watchAnalyzing = Stopwatch.createStarted(); ExecutorService pool = Executors.newFixedThreadPool(cores); // Check if resource is a ignored one and if so, do not analyze it. Pattern pattern = Pattern.compile(activeProfile.getIgnoredResourceRegExp()); Matcher matcher = null; ArrayList<DependencyAnalyzer> analyzer = new ArrayList<DependencyAnalyzer>(); for (int i = 0; i < TTCN3GlobalScopeProvider.RESOURCES.size(); i++) { Resource resource = TTCN3GlobalScopeProvider.RESOURCES.get(i); matcher = pattern.matcher(resource.getURI().toFileString()); if(!matcher.matches()) { analyzer.add(new DependencyAnalyzer(TTCN3GlobalScopeProvider.RESOURCES.get(i), logger)); } } try { List<Future<TTCN3Dependency>> output = pool.invokeAll(analyzer); pool.shutdown(); System.out.print('\n'); for (Future<TTCN3Dependency> f : output) { TTCN3Dependency o = f.get(); System.out.println("Dependency analysis output of " + o.getResource().getURI().lastSegment()); for (String d : o.getMessages()) { printOutput(o.getResource(), d); } } String xmlpath = "dependencies.xml"; File parent = new File(this.activeProfile.getDependencyOutputPath()); parent.mkdirs(); xmlpath = parent.getAbsolutePath()+File.separator+xmlpath; FileOutputStream file; try { file = new FileOutputStream(xmlpath); PrintStream stream = new PrintStream(file); stream.print("<?xml-stylesheet type=\"text/xsl\" href=\"../dependencies.xsl\"?>\n<dependencies>\n"); //TODO: check if it is faster to do this all at once for (Future<TTCN3Dependency> f : output) { for (String d : f.get().getOutput()) { stream.print(d); } } stream.print("</dependencies>"); stream.close(); } catch (FileNotFoundException e) { e.printStackTrace(); } } catch (InterruptedException | ExecutionException e) { // TODO Auto-generated catch block e.printStackTrace(); } watchAnalyzing.stop(); System.out.println("Test suite analyzed in " + MiscTools.msToString(watchAnalyzing.elapsed(TimeUnit.MILLISECONDS)) + " minutes." + '\n'); } private void printOutput(Resource resource, String message) { System.out.println(message); } private void printOutput(Resource resource, FeatureBasedDiagnostic featureDiagnostic) { switch (featureDiagnostic.getSeverity()) { Loading