From 4255a6e4c58fd1ebce04096dc1ade74cb78b7977 Mon Sep 17 00:00:00 2001 From: Sandro Date: Wed, 16 Jun 2021 11:05:47 +0200 Subject: [PATCH 01/15] start picocli impl --- build.gradle | 5 +++ .../analysiscli/AnalysisCLI.java | 38 +++++++++++++++++++ .../analysiscli/AnalysiscliApplication.java | 12 ------ .../commands/DependencyAdaptionCommand.java | 4 -- .../LanguageStructureApplianceCommand.java | 23 +++++++++++ 5 files changed, 66 insertions(+), 16 deletions(-) create mode 100644 src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/AnalysisCLI.java delete mode 100644 src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/AnalysiscliApplication.java create mode 100644 src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/LanguageStructureApplianceCommand.java diff --git a/build.gradle b/build.gradle index f05cad9..f46a3ff 100644 --- a/build.gradle +++ b/build.gradle @@ -28,7 +28,9 @@ dependencies { implementation 'org.springframework.shell:spring-shell-standard:2.0.1.RELEASE' implementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.14.1' implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.14.1' + implementation 'fr.inria.gforge.spoon:spoon-core:9.0.0' errorprone("com.google.errorprone:error_prone_core:2.7.1") + implementation 'info.picocli:picocli:4.6.1' testImplementation 'org.springframework.boot:spring-boot-starter-test' } @@ -62,3 +64,6 @@ jar { tasks.withType(JavaCompile).configureEach { options.fork = true } +bootRun { + main = 'edu.kit.kastel.dsis.mosim.refactorlizar.analysiscli.AnalysiscliApplication' +} diff --git a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/AnalysisCLI.java b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/AnalysisCLI.java new file mode 100644 index 0000000..84d84ff --- /dev/null +++ b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/AnalysisCLI.java @@ -0,0 +1,38 @@ +package edu.kit.kastel.dsis.mosim.refactorlizar.analysiscli; + +import picocli.CommandLine; +import picocli.CommandLine.Option; +import picocli.CommandLine.Command; + +import java.util.concurrent.Callable; + +@Command( + name = "analysiscli", + mixinStandardHelpOptions = true, + version = "0.0.1", + description = "Analysis CLI" +) +public class AnalysisCLI implements Callable { + + @Option( + names = {"-l", "--language"}, + description = "Path to the language" + ) + private String language; + + @Option( + names = {"-c", "--code"}, + description = "Path to the code" + ) + private String code; + + public static void main(String[] args) { + int exitCode = new CommandLine(new AnalysisCLI()).execute(args); + System.exit(exitCode); + } + + @Override + public Integer call() throws Exception { + return null; + } +} diff --git a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/AnalysiscliApplication.java b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/AnalysiscliApplication.java deleted file mode 100644 index 44a3da1..0000000 --- a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/AnalysiscliApplication.java +++ /dev/null @@ -1,12 +0,0 @@ -package edu.kit.kastel.dsis.mosim.refactorlizar.analysiscli; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class AnalysiscliApplication { - - public static void main(String[] args) { - SpringApplication.run(AnalysiscliApplication.class, args); - } -} diff --git a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/DependencyAdaptionCommand.java b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/DependencyAdaptionCommand.java index 772813c..e9c79e7 100644 --- a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/DependencyAdaptionCommand.java +++ b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/DependencyAdaptionCommand.java @@ -13,12 +13,8 @@ import java.util.stream.Stream; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.springframework.shell.standard.ShellCommandGroup; -import org.springframework.shell.standard.ShellComponent; import org.springframework.shell.standard.ShellMethod; -@ShellComponent -@ShellCommandGroup("Language to program dependencies") public class DependencyAdaptionCommand { private static final Logger logger = LogManager.getLogger(DependencyAdaptionCommand.class); private final String DELIMITER = ";"; diff --git a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/LanguageStructureApplianceCommand.java b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/LanguageStructureApplianceCommand.java new file mode 100644 index 0000000..6fd8f32 --- /dev/null +++ b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/LanguageStructureApplianceCommand.java @@ -0,0 +1,23 @@ +package edu.kit.kastel.dsis.mosim.refactorlizar.analysiscli.commands; + +import org.springframework.shell.standard.ShellCommandGroup; +import org.springframework.shell.standard.ShellComponent; +import org.springframework.shell.standard.ShellMethod; +import spoon.Launcher; +import spoon.reflect.CtModel; +import spoon.reflect.factory.Factory; + +@ShellComponent +@ShellCommandGroup("Refactorings") +public class LanguageStructureApplianceCommand { + + @ShellMethod("applyLanguageStructureToCode") + public void applyLanguageStructureToCode(String language, String code){ + final var codeLauncher = new Launcher(); + codeLauncher.addInputResource(code); + var codeModel = codeLauncher.buildModel(); + + + + } +} From 78ed479b14a54bbfc517c86c8bdf190168ecda76 Mon Sep 17 00:00:00 2001 From: Sandro Date: Wed, 16 Jun 2021 11:23:11 +0200 Subject: [PATCH 02/15] update --- .../refactorlizar/analysiscli/AnalysisCLI.java | 18 ++++++++++++++++++ .../LanguageStructureApplianceCommand.java | 14 -------------- 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/AnalysisCLI.java b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/AnalysisCLI.java index 84d84ff..513bd2d 100644 --- a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/AnalysisCLI.java +++ b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/AnalysisCLI.java @@ -1,5 +1,13 @@ package edu.kit.kastel.dsis.mosim.refactorlizar.analysiscli; +import edu.kit.kastel.dsis.mosim.refactorlizar.analysiscli.commands.DependencyAdaptionCommand; +import edu.kit.kastel.dsis.mosim.refactorlizar.analysiscli.commands.DependencyCycleCommand; +import edu.kit.kastel.dsis.mosim.refactorlizar.analysiscli.commands.DependencyDirectionCommand; +import edu.kit.kastel.dsis.mosim.refactorlizar.analysiscli.commands.EcoreTypeExtractionCommand; +import edu.kit.kastel.dsis.mosim.refactorlizar.analysiscli.commands.FeatureScatterCommand; +import edu.kit.kastel.dsis.mosim.refactorlizar.analysiscli.commands.ImproperLayerCommand; +import edu.kit.kastel.dsis.mosim.refactorlizar.analysiscli.commands.LanguageBlobCommand; +import edu.kit.kastel.dsis.mosim.refactorlizar.analysiscli.commands.LanguageStructureApplianceCommand; import picocli.CommandLine; import picocli.CommandLine.Option; import picocli.CommandLine.Command; @@ -8,6 +16,16 @@ @Command( name = "analysiscli", + subcommands = { + DependencyAdaptionCommand.class, + DependencyCycleCommand.class, + DependencyDirectionCommand.class, + EcoreTypeExtractionCommand.class, + FeatureScatterCommand.class, + ImproperLayerCommand.class, + LanguageBlobCommand.class, + LanguageStructureApplianceCommand.class + }, mixinStandardHelpOptions = true, version = "0.0.1", description = "Analysis CLI" diff --git a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/LanguageStructureApplianceCommand.java b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/LanguageStructureApplianceCommand.java index 6fd8f32..47c56bf 100644 --- a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/LanguageStructureApplianceCommand.java +++ b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/LanguageStructureApplianceCommand.java @@ -1,23 +1,9 @@ package edu.kit.kastel.dsis.mosim.refactorlizar.analysiscli.commands; -import org.springframework.shell.standard.ShellCommandGroup; -import org.springframework.shell.standard.ShellComponent; -import org.springframework.shell.standard.ShellMethod; -import spoon.Launcher; -import spoon.reflect.CtModel; -import spoon.reflect.factory.Factory; -@ShellComponent -@ShellCommandGroup("Refactorings") public class LanguageStructureApplianceCommand { - @ShellMethod("applyLanguageStructureToCode") public void applyLanguageStructureToCode(String language, String code){ - final var codeLauncher = new Launcher(); - codeLauncher.addInputResource(code); - var codeModel = codeLauncher.buildModel(); - - } } From 1bf2af88d13286cb2a5ec544930f87c2e3289be3 Mon Sep 17 00:00:00 2001 From: Sandro Date: Wed, 16 Jun 2021 16:46:43 +0200 Subject: [PATCH 03/15] move from spring cli to picocli --- build.gradle | 30 +++--- .../analysiscli/AnalysisCLI.java | 41 +++----- .../commands/DependencyAdaptionCommand.java | 35 +++++-- .../commands/DependencyCycleCommand.java | 63 +++++++----- .../commands/DependencyDirectionCommand.java | 69 ++++++++----- .../commands/EcoreTypeExtractionCommand.java | 36 ++++--- .../commands/FeatureScatterCommand.java | 64 ++++++++----- .../commands/ImproperLayerCommand.java | 66 ++++++++----- .../commands/LanguageBlobCommand.java | 96 ++++++++++--------- .../LanguageStructureApplianceCommand.java | 5 +- 10 files changed, 291 insertions(+), 214 deletions(-) diff --git a/build.gradle b/build.gradle index 85c2689..beb2c7d 100644 --- a/build.gradle +++ b/build.gradle @@ -4,10 +4,10 @@ plugins { id "com.diffplug.spotless" version "5.12.5" - id 'org.springframework.boot' version '2.5.0' - id 'io.spring.dependency-management' version '1.0.11.RELEASE' id 'net.ltgt.errorprone' version "2.0.1" id 'java' + id 'application' + id 'com.github.johnrengelman.shadow' version '7.0.0' } repositories { @@ -22,16 +22,16 @@ repositories { } dependencies { - implementation 'org.springframework.boot:spring-boot-starter' implementation 'com.diffplug.spotless:spotless-maven-plugin:2.11.1' implementation 'com.github.MoSimEngine:RefactorLizar:3dd329f405' - implementation 'org.springframework.shell:spring-shell-standard:2.0.1.RELEASE' implementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.14.1' implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.14.1' implementation 'fr.inria.gforge.spoon:spoon-core:9.0.0' - errorprone("com.google.errorprone:error_prone_core:2.7.1") implementation 'info.picocli:picocli:4.6.1' - testImplementation 'org.springframework.boot:spring-boot-starter-test' + implementation group: 'org.springframework', name: 'spring-core', version: '2.5.6' + implementation group: 'com.google.flogger', name: 'flogger', version: '0.6' + annotationProcessor 'info.picocli:picocli-codegen:4.6.1' + errorprone("com.google.errorprone:error_prone_core:2.7.1") } group = 'edu.kit.kastel.dsis.mosim.refactorlizar' @@ -39,6 +39,7 @@ version = '0.0.2-SNAPSHOT' description = 'analysiscli' sourceCompatibility = '1.11' +mainClassName = "edu.kit.kastel.dsis.mosim.refactorlizar.analysiscli.AnalysisCLI" spotless { java { target "**/*.java" @@ -54,16 +55,9 @@ spotless { } } -jar { - manifest { - attributes( - 'Main-Class': 'edu.kit.kastel.dsis.mosim.refactorlizar.analysiscli.AnalysiscliApplication' - ) - } -} -tasks.withType(JavaCompile).configureEach { - options.fork = true -} -bootRun { - main = 'edu.kit.kastel.dsis.mosim.refactorlizar.analysiscli.AnalysiscliApplication' +compileJava { + options.compilerArgs += [ + "-Aproject=${project.group}/${project.name}" + ] } + diff --git a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/AnalysisCLI.java b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/AnalysisCLI.java index 513bd2d..584cf4b 100644 --- a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/AnalysisCLI.java +++ b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/AnalysisCLI.java @@ -7,50 +7,31 @@ import edu.kit.kastel.dsis.mosim.refactorlizar.analysiscli.commands.FeatureScatterCommand; import edu.kit.kastel.dsis.mosim.refactorlizar.analysiscli.commands.ImproperLayerCommand; import edu.kit.kastel.dsis.mosim.refactorlizar.analysiscli.commands.LanguageBlobCommand; -import edu.kit.kastel.dsis.mosim.refactorlizar.analysiscli.commands.LanguageStructureApplianceCommand; import picocli.CommandLine; -import picocli.CommandLine.Option; import picocli.CommandLine.Command; -import java.util.concurrent.Callable; - @Command( name = "analysiscli", subcommands = { - DependencyAdaptionCommand.class, - DependencyCycleCommand.class, - DependencyDirectionCommand.class, - EcoreTypeExtractionCommand.class, - FeatureScatterCommand.class, - ImproperLayerCommand.class, - LanguageBlobCommand.class, - LanguageStructureApplianceCommand.class + DependencyAdaptionCommand.class, + DependencyCycleCommand.class, + DependencyDirectionCommand.class, + EcoreTypeExtractionCommand.class, + FeatureScatterCommand.class, + ImproperLayerCommand.class, + LanguageBlobCommand.class }, mixinStandardHelpOptions = true, version = "0.0.1", - description = "Analysis CLI" -) -public class AnalysisCLI implements Callable { - - @Option( - names = {"-l", "--language"}, - description = "Path to the language" - ) - private String language; - - @Option( - names = {"-c", "--code"}, - description = "Path to the code" - ) - private String code; - + description = "Analysis CLI") +public class AnalysisCLI implements Runnable { public static void main(String[] args) { int exitCode = new CommandLine(new AnalysisCLI()).execute(args); System.exit(exitCode); } @Override - public Integer call() throws Exception { - return null; + public void run() { + System.out.println("HALLO"); } } diff --git a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/DependencyAdaptionCommand.java b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/DependencyAdaptionCommand.java index e9c79e7..ec4ed22 100644 --- a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/DependencyAdaptionCommand.java +++ b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/DependencyAdaptionCommand.java @@ -1,6 +1,7 @@ package edu.kit.kastel.dsis.mosim.refactorlizar.analysiscli.commands; import com.google.common.base.Splitter; +import com.google.common.flogger.FluentLogger; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; @@ -11,16 +12,32 @@ import java.util.Map; import java.util.stream.Collectors; import java.util.stream.Stream; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.springframework.shell.standard.ShellMethod; +import picocli.CommandLine.Command; +import picocli.CommandLine.Option; + +@Command( + name = "adaptDependencies", + description = "Change imports of simulator code according to the new, modular metamodel.", + mixinStandardHelpOptions = true) +public class DependencyAdaptionCommand implements Runnable { + private static final FluentLogger LOGGER = FluentLogger.forEnclosingClass(); -public class DependencyAdaptionCommand { - private static final Logger logger = LogManager.getLogger(DependencyAdaptionCommand.class); private final String DELIMITER = ";"; - @ShellMethod("Adapt dependencies from modular language to monolithic program") - public void adaptDependencies(String program, String csv) { + @Option( + names = {"-c", "--csv-path"}, + required = true, + description = "Path to the *.csv mapping file") + String csv; + + @Option( + names = {"-s", "--simulator-code"}, + required = true, + description = "Path to the simulator code") + String program; + + @Override + public void run() { Map dependencyMapping = new HashMap<>(); // Load CSV Path csvPath = Paths.get(csv); @@ -34,7 +51,7 @@ public void adaptDependencies(String program, String csv) { "import " + split.get(0) + ";", "import " + split.get(1) + ";"); }); } catch (IOException e) { - logger.error(e); + LOGGER.atWarning().withCause(e).log(); } // Change Dependencies according to CSV @@ -55,7 +72,7 @@ public void adaptDependencies(String program, String csv) { } } } catch (IOException e) { - logger.error(e); + LOGGER.atWarning().withCause(e).log(); } } } diff --git a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/DependencyCycleCommand.java b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/DependencyCycleCommand.java index 7a854a1..0aca0d5 100644 --- a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/DependencyCycleCommand.java +++ b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/DependencyCycleCommand.java @@ -1,5 +1,6 @@ package edu.kit.kastel.dsis.mosim.refactorlizar.analysiscli.commands; +import com.google.common.flogger.FluentLogger; import edu.kit.kastel.sdq.case4lang.refactorlizar.analyzer.api.Report; import edu.kit.kastel.sdq.case4lang.refactorlizar.analyzer.dependencycycle.DependencyCycleAnalyzer; import edu.kit.kastel.sdq.case4lang.refactorlizar.commons.Settings; @@ -7,24 +8,39 @@ import edu.kit.kastel.sdq.case4lang.refactorlizar.core.SimulatorParser; import edu.kit.kastel.sdq.case4lang.refactorlizar.model.ModularLanguage; import edu.kit.kastel.sdq.case4lang.refactorlizar.model.SimulatorModel; -import java.lang.invoke.MethodHandles; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.springframework.shell.standard.ShellCommandGroup; -import org.springframework.shell.standard.ShellComponent; -import org.springframework.shell.standard.ShellMethod; +import picocli.CommandLine.Command; +import picocli.CommandLine.Option; -@ShellComponent -@ShellCommandGroup("bad-smell-analysis") -public class DependencyCycleCommand { +@Command( + name = "findDependencyCycleSmell", + description = "Find occurrences of the dependency cycle smell.", + mixinStandardHelpOptions = true) +public class DependencyCycleCommand implements Runnable { + private static final FluentLogger LOGGER = FluentLogger.forEnclosingClass(); private static final String STARTING_DEPENDENCY_CYCLE_ANALYSIS = "Starting dependency cycle Analysis"; - private static final Logger logger = LogManager.getLogger(MethodHandles.lookup().lookupClass()); - @ShellMethod( - "Find occurrences of the dependency cycle smell on type level. Available analysis levels are type, component and package") - public void findDependencyCycleSmell(String language, String code, String level) { + @Option( + names = {"-a", "--analysis-level"}, + description = "Available analysis levels are type, component and package", + defaultValue = "component") + String level = "component"; + + @Option( + names = {"-l", "--language"}, + required = true, + description = "Path to the language") + String language; + + @Option( + names = {"-s", "--simulator"}, + required = true, + description = "Path to the simulator code") + String code; + + @Override + public void run() { switch (level) { case "type": findDependencyCycleSmellType(language, code); @@ -36,26 +52,25 @@ public void findDependencyCycleSmell(String language, String code, String level) findDependencyCycleSmellComponent(language, code); break; default: - logger.atError() - .log( - "Level {} not found. Available analysis levels are type,component and package", - level); + LOGGER.atSevere().log( + "Level %s not found. Available analysis levels are type,component and package", + level); } } private void findDependencyCycleSmellType(String language, String code) { - logger.info(STARTING_DEPENDENCY_CYCLE_ANALYSIS); - logger.info("{}", () -> createReport(language, code, "type")); + LOGGER.atInfo().log(STARTING_DEPENDENCY_CYCLE_ANALYSIS); + LOGGER.atInfo().log("%s", createReport(language, code, "type")); } private void findDependencyCycleSmellPackage(String language, String code) { - logger.info(STARTING_DEPENDENCY_CYCLE_ANALYSIS); - logger.info("{}", () -> createReport(language, code, "package")); + LOGGER.atInfo().log(STARTING_DEPENDENCY_CYCLE_ANALYSIS); + LOGGER.atInfo().log("%s", createReport(language, code, "package")); } private void findDependencyCycleSmellComponent(String language, String code) { - logger.info(STARTING_DEPENDENCY_CYCLE_ANALYSIS); - logger.info("{}", () -> createReport(language, code, "component")); + LOGGER.atInfo().log(STARTING_DEPENDENCY_CYCLE_ANALYSIS); + LOGGER.atInfo().log("%s", createReport(language, code, "component")); } private Report createReport(String language, String code, String level) { @@ -63,7 +78,7 @@ private Report createReport(String language, String code, String level) { ModularLanguage lang = LanguageParser.parseLanguage(language); DependencyCycleAnalyzer dca = new DependencyCycleAnalyzer(); - logger.info(dca.getDescription()); + LOGGER.atInfo().log("%s", dca.getDescription()); Settings settings = dca.getSettings(); settings.setValue("level", level); return dca.analyze(lang, model, settings); diff --git a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/DependencyDirectionCommand.java b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/DependencyDirectionCommand.java index 64aea3b..05f71ed 100644 --- a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/DependencyDirectionCommand.java +++ b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/DependencyDirectionCommand.java @@ -1,5 +1,6 @@ package edu.kit.kastel.dsis.mosim.refactorlizar.analysiscli.commands; +import com.google.common.flogger.FluentLogger; import edu.kit.kastel.sdq.case4lang.refactorlizar.analyzer.api.Report; import edu.kit.kastel.sdq.case4lang.refactorlizar.analyzer.dependencydirection.DependencyDirectionAnalyzer; import edu.kit.kastel.sdq.case4lang.refactorlizar.commons.Settings; @@ -7,24 +8,46 @@ import edu.kit.kastel.sdq.case4lang.refactorlizar.core.SimulatorParser; import edu.kit.kastel.sdq.case4lang.refactorlizar.model.ModularLanguage; import edu.kit.kastel.sdq.case4lang.refactorlizar.model.SimulatorModel; -import java.lang.invoke.MethodHandles; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.springframework.shell.standard.ShellCommandGroup; -import org.springframework.shell.standard.ShellComponent; -import org.springframework.shell.standard.ShellMethod; +import picocli.CommandLine.Command; +import picocli.CommandLine.Option; + +@Command( + name = "findDependencyDirectionSmell", + description = + "Find occurrences of the dependency direction smell. Layers must be ordered from bottom to top and separated by ','. Available analysis levels are type, component and package", + mixinStandardHelpOptions = true) +public class DependencyDirectionCommand implements Runnable { + private static final FluentLogger LOGGER = FluentLogger.forEnclosingClass(); -@ShellComponent -@ShellCommandGroup("bad-smell-analysis") -public class DependencyDirectionCommand { private static final String STARTING_DEPENDENCY_CYCLE_ANALYSIS = "Starting dependency direction Analysis"; - private static final Logger logger = LogManager.getLogger(MethodHandles.lookup().lookupClass()); - @ShellMethod( - "Find occurrences of the dependency direction smell. Layers must be ordered from bottom to top and separated by ','. Available analysis levels are type, component and package") - public void findDependencyDirectionSmell( - String language, String code, String layer, String level) { + @Option( + names = {"-l", "--level"}, + description = "Level to apply analysis", + defaultValue = "component") + String level = "component"; + + @Option( + names = {"-m", "--language-model"}, + required = true, + description = "Path to the language") + String language; + + @Option( + names = {"-s", "--simulator-code"}, + required = true, + description = "Path to the simulator code") + String code; + + @Option( + names = {"-a", "--architecture-layer"}, + required = true, + description = "Layer information") + String layer; + + @Override + public void run() { switch (level) { case "type": findDependencyDirectionSmellType(language, code, layer); @@ -36,24 +59,24 @@ public void findDependencyDirectionSmell( findDependencyDirectionSmellComponent(language, code, layer); break; default: - logger.atError() - .log("Level {} not found. Available are type,component and package", level); + LOGGER.atWarning().log( + "Level %s not found. Available are type,component and package", level); } } private void findDependencyDirectionSmellType(String language, String code, String layer) { - logger.info(STARTING_DEPENDENCY_CYCLE_ANALYSIS); - logger.info("{}", () -> createReport(language, code, "type", layer)); + LOGGER.atInfo().log(STARTING_DEPENDENCY_CYCLE_ANALYSIS); + LOGGER.atInfo().log("%s", createReport(language, code, "type", layer)); } private void findDependencyDirectionSmellPackage(String language, String code, String layer) { - logger.info(STARTING_DEPENDENCY_CYCLE_ANALYSIS); - logger.info("{}", () -> createReport(language, code, "package", layer)); + LOGGER.atInfo().log(STARTING_DEPENDENCY_CYCLE_ANALYSIS); + LOGGER.atInfo().log("%s", createReport(language, code, "package", layer)); } private void findDependencyDirectionSmellComponent(String language, String code, String layer) { - logger.info(STARTING_DEPENDENCY_CYCLE_ANALYSIS); - logger.info("{}", () -> createReport(language, code, "component", layer)); + LOGGER.atInfo().log(STARTING_DEPENDENCY_CYCLE_ANALYSIS); + LOGGER.atInfo().log("%s", createReport(language, code, "component", layer)); } private Report createReport(String language, String code, String level, String layer) { @@ -61,7 +84,7 @@ private Report createReport(String language, String code, String level, String l ModularLanguage lang = LanguageParser.parseLanguage(language); DependencyDirectionAnalyzer dda = new DependencyDirectionAnalyzer(); - logger.info(dda.getDescription()); + LOGGER.atInfo().log(dda.getDescription()); Settings settings = dda.getSettings(); settings.setValue("level", level); settings.setValue("layers", layer); diff --git a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/EcoreTypeExtractionCommand.java b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/EcoreTypeExtractionCommand.java index 1da0dfe..c08a29e 100644 --- a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/EcoreTypeExtractionCommand.java +++ b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/EcoreTypeExtractionCommand.java @@ -2,8 +2,8 @@ import static org.apache.logging.log4j.util.Strings.LINE_SEPARATOR; +import com.google.common.flogger.FluentLogger; import java.io.IOException; -import java.lang.invoke.MethodHandles; import java.nio.file.FileSystems; import java.nio.file.Files; import java.nio.file.Path; @@ -18,34 +18,40 @@ import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.springframework.shell.standard.ShellCommandGroup; -import org.springframework.shell.standard.ShellComponent; -import org.springframework.shell.standard.ShellMethod; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; +import picocli.CommandLine.Command; +import picocli.CommandLine.Option; + +@Command( + name = "showTypesInMetamodels", + description = "Metamodels Type Extraction", + mixinStandardHelpOptions = true) +public class EcoreTypeExtractionCommand implements Runnable { + private static final FluentLogger LOGGER = FluentLogger.forEnclosingClass(); -@ShellComponent -@ShellCommandGroup("Language Knowledge Extraction") -public class EcoreTypeExtractionCommand { - private static final Logger logger = LogManager.getLogger(MethodHandles.lookup().lookupClass()); private final String ECORE_FILE_ENDING = "ecore"; private final PathMatcher matcher = FileSystems.getDefault().getPathMatcher("glob:**." + ECORE_FILE_ENDING); private final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); - @ShellMethod("Metamodels Type Extraction") - public void showTypesInMetamodels(String rootPath) { + @Option( + names = {"-l", "--language-root"}, + required = true, + description = "Path to the root of a language/metamodel (*.ecore)") + String rootPath; + + @Override + public void run() { try (Stream paths = Files.walk(Paths.get(rootPath))) { paths.filter(matcher::matches) .map(this::readMetamodels) .forEach(this::printMetamodelTypes); } catch (IOException e) { - logger.error(e); + LOGGER.atWarning().withCause(e).log(); } } @@ -55,7 +61,7 @@ private void printMetamodelTypes(Map> metamodels) { joiner.add("Metamodel:").add(entry.getKey()).add("Types:"); entry.getValue().forEach(joiner::add); } - logger.info(joiner); + LOGGER.atInfo().log("%s", joiner); } private Map> readMetamodels(Path path) { @@ -74,7 +80,7 @@ private Map> readMetamodels(Path path) { } } } catch (ParserConfigurationException | SAXException | IOException e) { - logger.error(e); + LOGGER.atWarning().withCause(e).log(); } return metamodels; } diff --git a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/FeatureScatterCommand.java b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/FeatureScatterCommand.java index 020296c..932e968 100644 --- a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/FeatureScatterCommand.java +++ b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/FeatureScatterCommand.java @@ -1,5 +1,6 @@ package edu.kit.kastel.dsis.mosim.refactorlizar.analysiscli.commands; +import com.google.common.flogger.FluentLogger; import edu.kit.kastel.sdq.case4lang.refactorlizar.analyzer.api.Report; import edu.kit.kastel.sdq.case4lang.refactorlizar.analyzer.featurescatter.FeatureScatterAnalyzer; import edu.kit.kastel.sdq.case4lang.refactorlizar.commons.Settings; @@ -7,24 +8,40 @@ import edu.kit.kastel.sdq.case4lang.refactorlizar.core.SimulatorParser; import edu.kit.kastel.sdq.case4lang.refactorlizar.model.ModularLanguage; import edu.kit.kastel.sdq.case4lang.refactorlizar.model.SimulatorModel; -import java.lang.invoke.MethodHandles; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.springframework.shell.standard.ShellCommandGroup; -import org.springframework.shell.standard.ShellComponent; -import org.springframework.shell.standard.ShellMethod; +import picocli.CommandLine.Command; +import picocli.CommandLine.Option; -@ShellComponent -@ShellCommandGroup("bad-smell-analysis") -public class FeatureScatterCommand { +@Command( + name = "findFeatureScatteringSmell", + description = + "Find occurrences of the feature scattering smell. Available analysis levels are type, component and package", + mixinStandardHelpOptions = true) +public class FeatureScatterCommand implements Runnable { + private static final FluentLogger LOGGER = FluentLogger.forEnclosingClass(); private static final String STARTING_FEATURE_SCATTERING_ANALYSIS = "Starting Feature Scattering Analysis"; - private static final Logger logger = LogManager.getLogger(MethodHandles.lookup().lookupClass()); - @ShellMethod( - "Find occurrences of the feature scattering smell. Available analysis levels are type, component and package") - public void findFeatureScatteringSmell(String language, String code, String level) { + @Option( + names = {"-l", "--level"}, + description = "Level to apply analysis", + defaultValue = "component") + String level = "component"; + + @Option( + names = {"-m", "--language-model"}, + required = true, + description = "Path to the language") + String language; + + @Option( + names = {"-s", "--simulator-code"}, + required = true, + description = "Path to the simulator code") + String code; + + @Override + public void run() { switch (level) { case "type": findFeatureScatteringSmellType(language, code); @@ -36,26 +53,25 @@ public void findFeatureScatteringSmell(String language, String code, String leve findFeatureScatteringSmellComponent(language, code); break; default: - logger.atError() - .log( - "Level {} not found. Available analysis levels are type,component and package", - level); + LOGGER.atWarning().log( + "Level %s not found. Available analysis levels are type,component and package", + level); } } private void findFeatureScatteringSmellType(String language, String code) { - logger.info(STARTING_FEATURE_SCATTERING_ANALYSIS); - logger.info("{}", () -> createReport(language, code, "type")); + LOGGER.atInfo().log(STARTING_FEATURE_SCATTERING_ANALYSIS); + LOGGER.atInfo().log("%s", createReport(language, code, "type")); } private void findFeatureScatteringSmellPackage(String language, String code) { - logger.info(STARTING_FEATURE_SCATTERING_ANALYSIS); - logger.info("{}", () -> createReport(language, code, "package")); + LOGGER.atInfo().log(STARTING_FEATURE_SCATTERING_ANALYSIS); + LOGGER.atInfo().log("%s", createReport(language, code, "package")); } private void findFeatureScatteringSmellComponent(String language, String code) { - logger.info(STARTING_FEATURE_SCATTERING_ANALYSIS); - logger.info("{}", () -> createReport(language, code, "component")); + LOGGER.atInfo().log(STARTING_FEATURE_SCATTERING_ANALYSIS); + LOGGER.atInfo().log("%s", createReport(language, code, "component")); } private Report createReport(String language, String code, String level) { @@ -63,7 +79,7 @@ private Report createReport(String language, String code, String level) { ModularLanguage lang = LanguageParser.parseLanguage(language); FeatureScatterAnalyzer fca = new FeatureScatterAnalyzer(); - logger.info(fca.getDescription()); + LOGGER.atInfo().log(fca.getDescription()); Settings settings = fca.getSettings(); settings.setValue("level", level); return fca.analyze(lang, model, settings); diff --git a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/ImproperLayerCommand.java b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/ImproperLayerCommand.java index 5eef47d..2b7686d 100644 --- a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/ImproperLayerCommand.java +++ b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/ImproperLayerCommand.java @@ -1,5 +1,6 @@ package edu.kit.kastel.dsis.mosim.refactorlizar.analysiscli.commands; +import com.google.common.flogger.FluentLogger; import edu.kit.kastel.sdq.case4lang.refactorlizar.analyzer.api.Report; import edu.kit.kastel.sdq.case4lang.refactorlizar.analyzer.dependencylayer.DependencyLayerAnalyzer; import edu.kit.kastel.sdq.case4lang.refactorlizar.commons.Settings; @@ -7,23 +8,39 @@ import edu.kit.kastel.sdq.case4lang.refactorlizar.core.SimulatorParser; import edu.kit.kastel.sdq.case4lang.refactorlizar.model.ModularLanguage; import edu.kit.kastel.sdq.case4lang.refactorlizar.model.SimulatorModel; -import java.lang.invoke.MethodHandles; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.springframework.shell.standard.ShellCommandGroup; -import org.springframework.shell.standard.ShellComponent; -import org.springframework.shell.standard.ShellMethod; +import picocli.CommandLine.Command; +import picocli.CommandLine.Option; -@ShellComponent -@ShellCommandGroup("bad-smell-analysis") -public class ImproperLayerCommand { +@Command( + name = "findDependencyLayerSmell", + description = + "Find occurrences of the improper simulator layering smell. Available analysis levels are type, component and package", + mixinStandardHelpOptions = true) +public class ImproperLayerCommand implements Runnable { + private static final FluentLogger LOGGER = FluentLogger.forEnclosingClass(); private static final String STARTING_DEPENDENCY_CYCLE_ANALYSIS = "Starting improper layering Analysis"; - private static final Logger logger = LogManager.getLogger(MethodHandles.lookup().lookupClass()); - @ShellMethod( - "Find occurrences of the improper simulator layering smell. Available analysis levels are type, component and package") - public void findDependencyLayerSmell(String language, String code, String level) { + @Option( + names = {"-l", "--level"}, + description = "Level to apply analysis", + defaultValue = "component") + String level = "component"; + + @Option( + names = {"-m", "--language-model"}, + required = true, + description = "Path to the language") + String language; + + @Option( + names = {"-s", "--simulator-code"}, + required = true, + description = "Path to the simulator code") + String code; + + @Override + public void run() { switch (level) { case "type": findDependencyLayerSmellType(language, code); @@ -35,26 +52,27 @@ public void findDependencyLayerSmell(String language, String code, String level) findDependencyLayerSmellComponent(language, code); break; default: - logger.atError() - .log( - "Level {} not found. Available analysis levels are type,component and package", - level); + LOGGER.atWarning().log( + "Level %s not found. Available analysis levels are type,component and package", + level); } } + public void findDependencyLayerSmell(String language, String code, String level) {} + private void findDependencyLayerSmellType(String language, String code) { - logger.info(STARTING_DEPENDENCY_CYCLE_ANALYSIS); - logger.info("{}", () -> createReport(language, code, "type")); + LOGGER.atInfo().log(STARTING_DEPENDENCY_CYCLE_ANALYSIS); + LOGGER.atInfo().log("%s", createReport(language, code, "type")); } private void findDependencyLayerSmellPackage(String language, String code) { - logger.info(STARTING_DEPENDENCY_CYCLE_ANALYSIS); - logger.info("{}", () -> createReport(language, code, "package")); + LOGGER.atInfo().log(STARTING_DEPENDENCY_CYCLE_ANALYSIS); + LOGGER.atInfo().log("%s", createReport(language, code, "package")); } private void findDependencyLayerSmellComponent(String language, String code) { - logger.info(STARTING_DEPENDENCY_CYCLE_ANALYSIS); - logger.info("{}", () -> createReport(language, code, "component")); + LOGGER.atInfo().log(STARTING_DEPENDENCY_CYCLE_ANALYSIS); + LOGGER.atInfo().log("%s", createReport(language, code, "component")); } private Report createReport(String language, String code, String level) { @@ -62,7 +80,7 @@ private Report createReport(String language, String code, String level) { ModularLanguage lang = LanguageParser.parseLanguage(language); DependencyLayerAnalyzer dla = new DependencyLayerAnalyzer(); - logger.info(dla.getDescription()); + LOGGER.atInfo().log(dla.getDescription()); Settings settings = dla.getSettings(); settings.setValue("level", level); return dla.analyze(lang, model, settings); diff --git a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/LanguageBlobCommand.java b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/LanguageBlobCommand.java index e1dabf5..7b2a53d 100644 --- a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/LanguageBlobCommand.java +++ b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/LanguageBlobCommand.java @@ -1,5 +1,6 @@ package edu.kit.kastel.dsis.mosim.refactorlizar.analysiscli.commands; +import com.google.common.flogger.FluentLogger; import edu.kit.kastel.sdq.case4lang.refactorlizar.analyzer.api.Report; import edu.kit.kastel.sdq.case4lang.refactorlizar.analyzer.api.SearchLevels; import edu.kit.kastel.sdq.case4lang.refactorlizar.analyzer.languageblob.LanguageBlobAnalyzer; @@ -8,33 +9,50 @@ import edu.kit.kastel.sdq.case4lang.refactorlizar.core.SimulatorParser; import edu.kit.kastel.sdq.case4lang.refactorlizar.model.ModularLanguage; import edu.kit.kastel.sdq.case4lang.refactorlizar.model.SimulatorModel; -import java.lang.invoke.MethodHandles; -import org.apache.logging.log4j.LogManager; -import org.apache.logging.log4j.Logger; -import org.springframework.shell.standard.ShellCommandGroup; -import org.springframework.shell.standard.ShellComponent; -import org.springframework.shell.standard.ShellMethod; -import org.springframework.shell.standard.ShellOption; import org.springframework.util.StringUtils; +import picocli.CommandLine.Command; +import picocli.CommandLine.Option; -@ShellComponent -@ShellCommandGroup("bad-smell-analysis") -public class LanguageBlobCommand { +@Command( + name = "findLanguageBlobSmell", + description = + "Find occurrences of the language blobs smell. Available analysis levels are type, component and package", + mixinStandardHelpOptions = true) +public class LanguageBlobCommand implements Runnable { + public static final FluentLogger LOGGER = FluentLogger.forEnclosingClass(); private static final String STARTING_LANGUAGE_BLOB_ANALYSIS = "Starting language blobs Analysis"; - private static final Logger logger = LogManager.getLogger(MethodHandles.lookup().lookupClass()); private static final String PACKAGE_HEADER = "Simulator Package:"; private static final String TYPE_HEADER = "Simulator Type:"; private static final String COMPONENT_HEADER = "Simulator Component:"; - @ShellMethod( - "Find occurrences of the language blobs smell. Available analysis levels are type, component and package") - public void findLanguageBlobSmell( - String language, - String code, - String level, - @ShellOption(defaultValue = "none") String simulatorType) { + @Option( + names = {"-l", "--level"}, + description = "Level to apply analysis", + defaultValue = "component") + String level = "component"; + + @Option( + names = {"-m", "--language-model"}, + required = true, + description = "Path to the language") + String language; + + @Option( + names = {"-s", "--simulator-code"}, + required = true, + description = "Path to the simulator code") + String code; + + @Option( + names = {"-t", "--simulator-type"}, + description = "Simulator type filter", + defaultValue = "none") + String simulatorType = "none"; + + @Override + public void run() { switch (level) { case "type": findLanguageBlobSmellType(language, code, simulatorType); @@ -46,50 +64,42 @@ public void findLanguageBlobSmell( findLanguageBlobSmellComponent(language, code, simulatorType); break; default: - logger.atError() - .log( - "Level {} not found. Available analysis levels are type,component and package", - level); + LOGGER.atWarning().log( + "Level %s not found. Available analysis levels are type,component and package", + level); } } - private void findLanguageBlobSmellType( - String language, - String code, - @ShellOption(defaultValue = "none") String simulatorType) { - logger.info(STARTING_LANGUAGE_BLOB_ANALYSIS); + private void findLanguageBlobSmellType(String language, String code, String simulatorType) { + LOGGER.atInfo().log(STARTING_LANGUAGE_BLOB_ANALYSIS); Report report = createReport(language, code, "type"); if (simulatorType.equals("none")) { - logger.info(report.getDescription()); + LOGGER.atInfo().log(report.getDescription()); } else { - logger.info("{}", () -> filterReport(report, simulatorType, SearchLevels.TYPE)); + LOGGER.atInfo().log("%s", filterReport(report, simulatorType, SearchLevels.TYPE)); } } private void findLanguageBlobSmellPackage( - String language, - String code, - @ShellOption(defaultValue = "none") String simulatorPackage) { - logger.info(STARTING_LANGUAGE_BLOB_ANALYSIS); + String language, String code, String simulatorPackage) { + LOGGER.atInfo().log(STARTING_LANGUAGE_BLOB_ANALYSIS); Report report = createReport(language, code, "package"); if (simulatorPackage.equals("none")) { - logger.info(report.getDescription()); + LOGGER.atInfo().log(report.getDescription()); } else { - logger.info("{}", () -> filterReport(report, simulatorPackage, SearchLevels.PACKAGE)); + LOGGER.atInfo().log("%s", filterReport(report, simulatorPackage, SearchLevels.PACKAGE)); } } private void findLanguageBlobSmellComponent( - String language, - String code, - @ShellOption(defaultValue = "none") String simulatorComponent) { - logger.info(STARTING_LANGUAGE_BLOB_ANALYSIS); + String language, String code, String simulatorComponent) { + LOGGER.atInfo().log(STARTING_LANGUAGE_BLOB_ANALYSIS); Report report = createReport(language, code, "component"); if (simulatorComponent.equals("none")) { - logger.info(report.getDescription()); + LOGGER.atInfo().log(report.getDescription()); } else { - logger.info( - "{}", () -> filterReport(report, simulatorComponent, SearchLevels.COMPONENT)); + LOGGER.atInfo().log( + "%s", filterReport(report, simulatorComponent, SearchLevels.COMPONENT)); } } @@ -98,7 +108,7 @@ private Report createReport(String language, String code, String level) { ModularLanguage lang = LanguageParser.parseLanguage(language); LanguageBlobAnalyzer lba = new LanguageBlobAnalyzer(); - logger.info(lba.getDescription()); + LOGGER.atInfo().log(lba.getDescription()); Settings settings = lba.getSettings(); settings.setValue("level", level); return lba.analyze(lang, model, settings); diff --git a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/LanguageStructureApplianceCommand.java b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/LanguageStructureApplianceCommand.java index 47c56bf..91bff9e 100644 --- a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/LanguageStructureApplianceCommand.java +++ b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/LanguageStructureApplianceCommand.java @@ -1,9 +1,6 @@ package edu.kit.kastel.dsis.mosim.refactorlizar.analysiscli.commands; - public class LanguageStructureApplianceCommand { - public void applyLanguageStructureToCode(String language, String code){ - - } + public void applyLanguageStructureToCode(String language, String code) {} } From 469753cbc8f15e8b1dbf1d4fddf5baadf30c99c4 Mon Sep 17 00:00:00 2001 From: Martin Wittlinger Date: Wed, 16 Jun 2021 18:51:51 +0200 Subject: [PATCH 04/15] fix graal build, adding random flags for groovy --- build.gradle | 46 +++++++++++++++++-- .../commands/EcoreTypeExtractionCommand.java | 3 +- .../commands/LanguageBlobCommand.java | 4 +- 3 files changed, 46 insertions(+), 7 deletions(-) diff --git a/build.gradle b/build.gradle index beb2c7d..257cd89 100644 --- a/build.gradle +++ b/build.gradle @@ -8,6 +8,7 @@ plugins { id 'java' id 'application' id 'com.github.johnrengelman.shadow' version '7.0.0' + id "org.mikeneck.graalvm-native-image" version "1.4.1" } repositories { @@ -24,11 +25,8 @@ repositories { dependencies { implementation 'com.diffplug.spotless:spotless-maven-plugin:2.11.1' implementation 'com.github.MoSimEngine:RefactorLizar:3dd329f405' - implementation group: 'org.apache.logging.log4j', name: 'log4j-api', version: '2.14.1' - implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.14.1' implementation 'fr.inria.gforge.spoon:spoon-core:9.0.0' implementation 'info.picocli:picocli:4.6.1' - implementation group: 'org.springframework', name: 'spring-core', version: '2.5.6' implementation group: 'com.google.flogger', name: 'flogger', version: '0.6' annotationProcessor 'info.picocli:picocli-codegen:4.6.1' errorprone("com.google.errorprone:error_prone_core:2.7.1") @@ -60,4 +58,46 @@ compileJava { "-Aproject=${project.group}/${project.name}" ] } +import org.mikeneck.graalvm.BuildTypeSelector + +configurations { + // to remove too long jar path, prepare empty configuration + emptyConfiguration +} + +// copies jar files for manifest can refer to dependencies +task copyDependencies(type: Copy, group: 'build') { + from configurations.runtimeClasspath + destinationDir = file("$buildDir/libs") +} + +jar { + dependsOn 'copyDependencies' + manifest { + // entry jar files via Class-Path attribute + def classpathString = configurations.runtimeClasspath.collect { File f -> f.name }.join(' ') + attributes 'Class-Path': classpathString + } +} + +nativeImage { + // remove jar's paths from command + runtimeClasspath = configurations.emptyConfiguration + graalVmHome = System.getProperty('java.home') + buildType { BuildTypeSelector build -> + build.executable { + main = 'edu.kit.kastel.dsis.mosim.refactorlizar.analysiscli.AnalysisCLI' + } + } + executableName = 'analysiscli' + outputDirectory = file("$buildDir/bin") + arguments { + add '--no-fallback' + add '--enable-all-security-services' + add '--initialize-at-build-time' + add '--initialize-at-run-time=org.codehaus.groovy.control.XStreamUtils,groovy.grape.GrapeIvy' + add '--report-unsupported-elements-at-runtime' + add '--allow-incomplete-classpath' + } +} diff --git a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/EcoreTypeExtractionCommand.java b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/EcoreTypeExtractionCommand.java index c08a29e..bf3bb0e 100644 --- a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/EcoreTypeExtractionCommand.java +++ b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/EcoreTypeExtractionCommand.java @@ -1,6 +1,5 @@ package edu.kit.kastel.dsis.mosim.refactorlizar.analysiscli.commands; -import static org.apache.logging.log4j.util.Strings.LINE_SEPARATOR; import com.google.common.flogger.FluentLogger; import java.io.IOException; @@ -56,7 +55,7 @@ public void run() { } private void printMetamodelTypes(Map> metamodels) { - StringJoiner joiner = new StringJoiner(LINE_SEPARATOR, LINE_SEPARATOR, LINE_SEPARATOR); + StringJoiner joiner = new StringJoiner(System.lineSeparator(), System.lineSeparator(), System.lineSeparator()); for (var entry : metamodels.entrySet()) { joiner.add("Metamodel:").add(entry.getKey()).add("Types:"); entry.getValue().forEach(joiner::add); diff --git a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/LanguageBlobCommand.java b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/LanguageBlobCommand.java index 7b2a53d..a8bd173 100644 --- a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/LanguageBlobCommand.java +++ b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/LanguageBlobCommand.java @@ -1,6 +1,7 @@ package edu.kit.kastel.dsis.mosim.refactorlizar.analysiscli.commands; import com.google.common.flogger.FluentLogger; +import org.apache.commons.lang3.StringUtils; import edu.kit.kastel.sdq.case4lang.refactorlizar.analyzer.api.Report; import edu.kit.kastel.sdq.case4lang.refactorlizar.analyzer.api.SearchLevels; import edu.kit.kastel.sdq.case4lang.refactorlizar.analyzer.languageblob.LanguageBlobAnalyzer; @@ -9,7 +10,6 @@ import edu.kit.kastel.sdq.case4lang.refactorlizar.core.SimulatorParser; import edu.kit.kastel.sdq.case4lang.refactorlizar.model.ModularLanguage; import edu.kit.kastel.sdq.case4lang.refactorlizar.model.SimulatorModel; -import org.springframework.util.StringUtils; import picocli.CommandLine.Command; import picocli.CommandLine.Option; @@ -117,7 +117,7 @@ private Report createReport(String language, String code, String level) { private String filterReport(Report report, String filterLevel, SearchLevels level) { String header = getHeader(level); String reportDescription = report.getDescription(); - int packageOccurrences = StringUtils.countOccurrencesOf(reportDescription, filterLevel); + int packageOccurrences = StringUtils.countMatches(reportDescription, filterLevel); if (reportDescription.contains(filterLevel)) { StringBuilder trimmedReport = new StringBuilder(); for (int i = 0; i < packageOccurrences; i++) { From dc1b23d6a48319e2358c7e5175aad32ab2080174 Mon Sep 17 00:00:00 2001 From: Sandro Date: Wed, 16 Jun 2021 20:02:29 +0200 Subject: [PATCH 05/15] code style --- build.gradle | 56 +++++++++---------- .../commands/EcoreTypeExtractionCommand.java | 5 +- .../commands/LanguageBlobCommand.java | 2 +- 3 files changed, 32 insertions(+), 31 deletions(-) diff --git a/build.gradle b/build.gradle index 257cd89..c5909c0 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,7 @@ plugins { id 'java' id 'application' id 'com.github.johnrengelman.shadow' version '7.0.0' - id "org.mikeneck.graalvm-native-image" version "1.4.1" + id "org.mikeneck.graalvm-native-image" version "1.4.1" } repositories { @@ -62,42 +62,42 @@ import org.mikeneck.graalvm.BuildTypeSelector configurations { - // to remove too long jar path, prepare empty configuration - emptyConfiguration + // to remove too long jar path, prepare empty configuration + emptyConfiguration } // copies jar files for manifest can refer to dependencies task copyDependencies(type: Copy, group: 'build') { - from configurations.runtimeClasspath - destinationDir = file("$buildDir/libs") + from configurations.runtimeClasspath + destinationDir = file("$buildDir/libs") } jar { - dependsOn 'copyDependencies' - manifest { - // entry jar files via Class-Path attribute - def classpathString = configurations.runtimeClasspath.collect { File f -> f.name }.join(' ') - attributes 'Class-Path': classpathString - } + dependsOn 'copyDependencies' + manifest { + // entry jar files via Class-Path attribute + def classpathString = configurations.runtimeClasspath.collect { File f -> f.name }.join(' ') + attributes 'Class-Path': classpathString + } } nativeImage { - // remove jar's paths from command - runtimeClasspath = configurations.emptyConfiguration + // remove jar's paths from command + runtimeClasspath = configurations.emptyConfiguration graalVmHome = System.getProperty('java.home') - buildType { BuildTypeSelector build -> - build.executable { - main = 'edu.kit.kastel.dsis.mosim.refactorlizar.analysiscli.AnalysisCLI' - } - } - executableName = 'analysiscli' - outputDirectory = file("$buildDir/bin") - arguments { - add '--no-fallback' - add '--enable-all-security-services' - add '--initialize-at-build-time' - add '--initialize-at-run-time=org.codehaus.groovy.control.XStreamUtils,groovy.grape.GrapeIvy' - add '--report-unsupported-elements-at-runtime' - add '--allow-incomplete-classpath' - } + buildType { BuildTypeSelector build -> + build.executable { + main = 'edu.kit.kastel.dsis.mosim.refactorlizar.analysiscli.AnalysisCLI' + } + } + executableName = 'analysiscli' + outputDirectory = file("$buildDir/bin") + arguments { + add '--no-fallback' + add '--enable-all-security-services' + add '--initialize-at-build-time' + add '--initialize-at-run-time=org.codehaus.groovy.control.XStreamUtils,groovy.grape.GrapeIvy' + add '--report-unsupported-elements-at-runtime' + add '--allow-incomplete-classpath' + } } diff --git a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/EcoreTypeExtractionCommand.java b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/EcoreTypeExtractionCommand.java index bf3bb0e..de6db85 100644 --- a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/EcoreTypeExtractionCommand.java +++ b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/EcoreTypeExtractionCommand.java @@ -1,6 +1,5 @@ package edu.kit.kastel.dsis.mosim.refactorlizar.analysiscli.commands; - import com.google.common.flogger.FluentLogger; import java.io.IOException; import java.nio.file.FileSystems; @@ -55,7 +54,9 @@ public void run() { } private void printMetamodelTypes(Map> metamodels) { - StringJoiner joiner = new StringJoiner(System.lineSeparator(), System.lineSeparator(), System.lineSeparator()); + StringJoiner joiner = + new StringJoiner( + System.lineSeparator(), System.lineSeparator(), System.lineSeparator()); for (var entry : metamodels.entrySet()) { joiner.add("Metamodel:").add(entry.getKey()).add("Types:"); entry.getValue().forEach(joiner::add); diff --git a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/LanguageBlobCommand.java b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/LanguageBlobCommand.java index a8bd173..7629ef7 100644 --- a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/LanguageBlobCommand.java +++ b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/LanguageBlobCommand.java @@ -1,7 +1,6 @@ package edu.kit.kastel.dsis.mosim.refactorlizar.analysiscli.commands; import com.google.common.flogger.FluentLogger; -import org.apache.commons.lang3.StringUtils; import edu.kit.kastel.sdq.case4lang.refactorlizar.analyzer.api.Report; import edu.kit.kastel.sdq.case4lang.refactorlizar.analyzer.api.SearchLevels; import edu.kit.kastel.sdq.case4lang.refactorlizar.analyzer.languageblob.LanguageBlobAnalyzer; @@ -10,6 +9,7 @@ import edu.kit.kastel.sdq.case4lang.refactorlizar.core.SimulatorParser; import edu.kit.kastel.sdq.case4lang.refactorlizar.model.ModularLanguage; import edu.kit.kastel.sdq.case4lang.refactorlizar.model.SimulatorModel; +import org.apache.commons.lang3.StringUtils; import picocli.CommandLine.Command; import picocli.CommandLine.Option; From d23cdefa7700921d897374e56bd19142dbdf66bb Mon Sep 17 00:00:00 2001 From: Sandro Date: Wed, 16 Jun 2021 20:30:47 +0200 Subject: [PATCH 06/15] aec --- .../ArchitectureEvaluationCommand.java | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/ArchitectureEvaluationCommand.java diff --git a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/ArchitectureEvaluationCommand.java b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/ArchitectureEvaluationCommand.java new file mode 100644 index 0000000..0dadcd1 --- /dev/null +++ b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/ArchitectureEvaluationCommand.java @@ -0,0 +1,53 @@ +package edu.kit.kastel.dsis.mosim.refactorlizar.analysiscli.commands; + +import com.google.common.flogger.FluentLogger; +import edu.kit.kastel.sdq.case4lang.refactorlizar.architecture_evaluation.Application; +import edu.kit.kastel.sdq.case4lang.refactorlizar.architecture_evaluation.CalculationMode; +import edu.kit.kastel.sdq.case4lang.refactorlizar.architecture_evaluation.Result; +import picocli.CommandLine.Command; +import picocli.CommandLine.Option; + +@Command( + name = "evaluateCode", + description = + "Evaluates for the given source path hypergraph code metrics. dataTypePatternsPath and observedSystemPath is a path to file for ignored/included types. Every line in this file is seen as a regex tested against the qualified type names. DataTypePatterns are ignored types and observedSystem are included types") +public class ArchitectureEvaluationCommand implements Runnable { + private static final FluentLogger LOGGER = FluentLogger.forEnclosingClass(); + + @Option( + names = {"-c", "--code"}, + required = true, + description = "Path to the code to create the metrics") + String code; + + @Option( + names = {"-d", "--data-types"}, + required = true, + description = "Path to the data-types-pattern.cfg file") + String dataTypePatternsPath; + + @Option( + names = {"-o", "--observed-system"}, + required = true, + description = "Path to the observed-system.cfg file") + String observedSystemPath; + + @Override + public void run() { + // das array ist dort weil im moment ich meine eigene api kaputt entworfen habe, das kommt + // noch weg + Result result = + new Application() + .evaluate( + CalculationMode.REINER, + dataTypePatternsPath, + observedSystemPath, + new String[] {code}); + LOGGER.atInfo().log("Size of System: %s", result.getSizeOfSystem().getValue()); + LOGGER.atInfo().log("Lines of Code: %s", result.getLoc().getValue()); + LOGGER.atInfo().log("Size of Hypergraph: %s", result.getSize().getValue()); + LOGGER.atInfo().log("Coupling: %s", result.getCoupling().getValue()); + LOGGER.atInfo().log("Cohesion: %s", result.getCohesion().getValue()); + LOGGER.atInfo().log("Complexity: %s", result.getComplexity().getValue()); + } +} From 871d7a7d3849adfe67777fdc0dc720a34bc9967e Mon Sep 17 00:00:00 2001 From: Sandro Date: Wed, 16 Jun 2021 20:32:51 +0200 Subject: [PATCH 07/15] change version of refactorlizar --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index c5909c0..bc01594 100644 --- a/build.gradle +++ b/build.gradle @@ -24,7 +24,7 @@ repositories { dependencies { implementation 'com.diffplug.spotless:spotless-maven-plugin:2.11.1' - implementation 'com.github.MoSimEngine:RefactorLizar:3dd329f405' + implementation 'com.github.MoSimEngine:RefactorLizar:1a1b08a5a4' implementation 'fr.inria.gforge.spoon:spoon-core:9.0.0' implementation 'info.picocli:picocli:4.6.1' implementation group: 'com.google.flogger', name: 'flogger', version: '0.6' From 95f892b0a169be1d80d47276d0b51adf92e044b2 Mon Sep 17 00:00:00 2001 From: Sandro Date: Wed, 16 Jun 2021 20:34:50 +0200 Subject: [PATCH 08/15] formatting... --- .../analysiscli/commands/ArchitectureEvaluationCommand.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/ArchitectureEvaluationCommand.java b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/ArchitectureEvaluationCommand.java index 4aa349b..f948f35 100644 --- a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/ArchitectureEvaluationCommand.java +++ b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/ArchitectureEvaluationCommand.java @@ -50,6 +50,5 @@ public void run() { LOGGER.atInfo().log("Coupling: %s", result.getCoupling().getValue()); LOGGER.atInfo().log("Cohesion: %s", result.getCohesion().getValue()); LOGGER.atInfo().log("Complexity: %s", result.getComplexity().getValue()); - } } From 1dc4cdd2c9c2c5281a5390b3f35c3bf5aa7c1d9c Mon Sep 17 00:00:00 2001 From: Sandro Date: Wed, 16 Jun 2021 22:04:24 +0200 Subject: [PATCH 09/15] add aec command to main command --- .../dsis/mosim/refactorlizar/analysiscli/AnalysisCLI.java | 2 ++ .../analysiscli/commands/ArchitectureEvaluationCommand.java | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/AnalysisCLI.java b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/AnalysisCLI.java index 584cf4b..dbbec8c 100644 --- a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/AnalysisCLI.java +++ b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/AnalysisCLI.java @@ -1,5 +1,6 @@ package edu.kit.kastel.dsis.mosim.refactorlizar.analysiscli; +import edu.kit.kastel.dsis.mosim.refactorlizar.analysiscli.commands.ArchitectureEvaluationCommand; import edu.kit.kastel.dsis.mosim.refactorlizar.analysiscli.commands.DependencyAdaptionCommand; import edu.kit.kastel.dsis.mosim.refactorlizar.analysiscli.commands.DependencyCycleCommand; import edu.kit.kastel.dsis.mosim.refactorlizar.analysiscli.commands.DependencyDirectionCommand; @@ -13,6 +14,7 @@ @Command( name = "analysiscli", subcommands = { + ArchitectureEvaluationCommand.class, DependencyAdaptionCommand.class, DependencyCycleCommand.class, DependencyDirectionCommand.class, diff --git a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/ArchitectureEvaluationCommand.java b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/ArchitectureEvaluationCommand.java index f948f35..8ed6e69 100644 --- a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/ArchitectureEvaluationCommand.java +++ b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/ArchitectureEvaluationCommand.java @@ -10,7 +10,8 @@ @Command( name = "evaluateCode", description = - "Evaluates for the given source path hypergraph code metrics. dataTypePatternsPath and observedSystemPath is a path to file for ignored/included types. Every line in this file is seen as a regex tested against the qualified type names. DataTypePatterns are ignored types and observedSystem are included types") + "Evaluates for the given source path hypergraph code metrics. dataTypePatternsPath and observedSystemPath is a path to file for ignored/included types. Every line in this file is seen as a regex tested against the qualified type names. DataTypePatterns are ignored types and observedSystem are included types", + mixinStandardHelpOptions = true) public class ArchitectureEvaluationCommand implements Runnable { private static final FluentLogger LOGGER = FluentLogger.forEnclosingClass(); From 975f4247dd0bbec0b2dcc0199cac530f11fb54af Mon Sep 17 00:00:00 2001 From: Sandro Date: Wed, 16 Jun 2021 22:09:18 +0200 Subject: [PATCH 10/15] update --- build.gradle | 2 +- .../dsis/mosim/refactorlizar/analysiscli/AnalysisCLI.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index bc01594..6593895 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,6 @@ plugins { id "com.diffplug.spotless" version "5.12.5" id 'net.ltgt.errorprone' version "2.0.1" - id 'java' id 'application' id 'com.github.johnrengelman.shadow' version '7.0.0' id "org.mikeneck.graalvm-native-image" version "1.4.1" @@ -28,6 +27,7 @@ dependencies { implementation 'fr.inria.gforge.spoon:spoon-core:9.0.0' implementation 'info.picocli:picocli:4.6.1' implementation group: 'com.google.flogger', name: 'flogger', version: '0.6' + implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.14.1' annotationProcessor 'info.picocli:picocli-codegen:4.6.1' errorprone("com.google.errorprone:error_prone_core:2.7.1") } diff --git a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/AnalysisCLI.java b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/AnalysisCLI.java index dbbec8c..f2fbcb2 100644 --- a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/AnalysisCLI.java +++ b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/AnalysisCLI.java @@ -34,6 +34,6 @@ public static void main(String[] args) { @Override public void run() { - System.out.println("HALLO"); + System.out.println("use --help to show all commands"); } } From 7c1b3902c86799ddecfcd022577fc9073a423852 Mon Sep 17 00:00:00 2001 From: Sandro Date: Thu, 17 Jun 2021 06:51:02 +0200 Subject: [PATCH 11/15] add flogger backend --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 6593895..c745071 100644 --- a/build.gradle +++ b/build.gradle @@ -27,7 +27,7 @@ dependencies { implementation 'fr.inria.gforge.spoon:spoon-core:9.0.0' implementation 'info.picocli:picocli:4.6.1' implementation group: 'com.google.flogger', name: 'flogger', version: '0.6' - implementation group: 'org.apache.logging.log4j', name: 'log4j-core', version: '2.14.1' + implementation group: 'com.google.flogger', name: 'flogger-log4j-backend', version: '0.6' annotationProcessor 'info.picocli:picocli-codegen:4.6.1' errorprone("com.google.errorprone:error_prone_core:2.7.1") } From 523dc70b620c215ec841b2b816585166165f190c Mon Sep 17 00:00:00 2001 From: Sandro Date: Thu, 17 Jun 2021 06:59:20 +0200 Subject: [PATCH 12/15] switch flogger log4j backend to flogger system backend --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index c745071..e5f0afe 100644 --- a/build.gradle +++ b/build.gradle @@ -27,7 +27,7 @@ dependencies { implementation 'fr.inria.gforge.spoon:spoon-core:9.0.0' implementation 'info.picocli:picocli:4.6.1' implementation group: 'com.google.flogger', name: 'flogger', version: '0.6' - implementation group: 'com.google.flogger', name: 'flogger-log4j-backend', version: '0.6' + implementation group: 'com.google.flogger', name: 'flogger-system-backend', version: '0.6' annotationProcessor 'info.picocli:picocli-codegen:4.6.1' errorprone("com.google.errorprone:error_prone_core:2.7.1") } From 57e730f5a6b965931267455b73a841e8336cb692 Mon Sep 17 00:00:00 2001 From: Sandro Date: Thu, 17 Jun 2021 08:16:40 +0200 Subject: [PATCH 13/15] create skeleton of subcommand and add to command --- .../analysiscli/AnalysisCLI.java | 4 +++- .../LanguageStructureApplianceCommand.java | 23 +++++++++++++++++-- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/AnalysisCLI.java b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/AnalysisCLI.java index f2fbcb2..a735f59 100644 --- a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/AnalysisCLI.java +++ b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/AnalysisCLI.java @@ -8,6 +8,7 @@ import edu.kit.kastel.dsis.mosim.refactorlizar.analysiscli.commands.FeatureScatterCommand; import edu.kit.kastel.dsis.mosim.refactorlizar.analysiscli.commands.ImproperLayerCommand; import edu.kit.kastel.dsis.mosim.refactorlizar.analysiscli.commands.LanguageBlobCommand; +import edu.kit.kastel.dsis.mosim.refactorlizar.analysiscli.commands.LanguageStructureApplianceCommand; import picocli.CommandLine; import picocli.CommandLine.Command; @@ -21,7 +22,8 @@ EcoreTypeExtractionCommand.class, FeatureScatterCommand.class, ImproperLayerCommand.class, - LanguageBlobCommand.class + LanguageBlobCommand.class, + LanguageStructureApplianceCommand.class }, mixinStandardHelpOptions = true, version = "0.0.1", diff --git a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/LanguageStructureApplianceCommand.java b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/LanguageStructureApplianceCommand.java index 91bff9e..6753e09 100644 --- a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/LanguageStructureApplianceCommand.java +++ b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/LanguageStructureApplianceCommand.java @@ -1,6 +1,25 @@ package edu.kit.kastel.dsis.mosim.refactorlizar.analysiscli.commands; -public class LanguageStructureApplianceCommand { +import com.google.common.flogger.FluentLogger; +import picocli.CommandLine.Command; +import picocli.CommandLine.Option; - public void applyLanguageStructureToCode(String language, String code) {} +@Command(name = "applyLanguageStructureToCode", description = "", mixinStandardHelpOptions = true) +public class LanguageStructureApplianceCommand implements Runnable { + public static final FluentLogger LOGGER = FluentLogger.forEnclosingClass(); + + @Option( + names = {"-m", "--language-model"}, + required = true, + description = "Path to the language") + String language; + + @Option( + names = {"-s", "--simulator-code"}, + required = true, + description = "Path to the simulator code") + String code; + + @Override + public void run() {} } From 15e6bd2774f767b5b34a3679d2e80b82b4fe7dd5 Mon Sep 17 00:00:00 2001 From: Sandro Date: Tue, 22 Jun 2021 12:40:25 +0200 Subject: [PATCH 14/15] add flag --- build.gradle | 1 + .../commands/DependencyCycleCommand.java | 9 ++++++++- .../commands/DependencyDirectionCommand.java | 9 ++++++++- .../commands/EcoreTypeExtractionCommand.java | 2 +- .../analysiscli/commands/FeatureScatterCommand.java | 9 ++++++++- .../analysiscli/commands/ImproperLayerCommand.java | 9 ++++++++- .../analysiscli/commands/LanguageBlobCommand.java | 9 ++++++++- .../commands/LanguageStructureApplianceCommand.java | 13 +++++++++++-- 8 files changed, 53 insertions(+), 8 deletions(-) diff --git a/build.gradle b/build.gradle index e5f0afe..328d02b 100644 --- a/build.gradle +++ b/build.gradle @@ -99,5 +99,6 @@ nativeImage { add '--initialize-at-run-time=org.codehaus.groovy.control.XStreamUtils,groovy.grape.GrapeIvy' add '--report-unsupported-elements-at-runtime' add '--allow-incomplete-classpath' + add '-H:IncludeResources=org.eclipse.jdt.internal.compiler.*' } } diff --git a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/DependencyCycleCommand.java b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/DependencyCycleCommand.java index 0aca0d5..67fecba 100644 --- a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/DependencyCycleCommand.java +++ b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/DependencyCycleCommand.java @@ -28,7 +28,7 @@ public class DependencyCycleCommand implements Runnable { String level = "component"; @Option( - names = {"-l", "--language"}, + names = {"-m", "--modular-language"}, required = true, description = "Path to the language") String language; @@ -39,6 +39,13 @@ public class DependencyCycleCommand implements Runnable { description = "Path to the simulator code") String code; + @Option( + names = {"-p", "--path-structure"}, + description = + "Is optional. If the language is part of the code use \"LinC\", if the code is part of the language use \"CinL\", if none of these apply, don't use the flag.", + defaultValue = "none") + String language_location; + @Override public void run() { switch (level) { diff --git a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/DependencyDirectionCommand.java b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/DependencyDirectionCommand.java index 05f71ed..7f22259 100644 --- a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/DependencyDirectionCommand.java +++ b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/DependencyDirectionCommand.java @@ -29,7 +29,7 @@ public class DependencyDirectionCommand implements Runnable { String level = "component"; @Option( - names = {"-m", "--language-model"}, + names = {"-m", "--modular-language"}, required = true, description = "Path to the language") String language; @@ -46,6 +46,13 @@ public class DependencyDirectionCommand implements Runnable { description = "Layer information") String layer; + @Option( + names = {"-p", "--path-structure"}, + description = + "Is optional. If the language is part of the code use \"LinC\", if the code is part of the language use \"CinL\", if none of these apply, don't use the flag.", + defaultValue = "none") + String language_location; + @Override public void run() { switch (level) { diff --git a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/EcoreTypeExtractionCommand.java b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/EcoreTypeExtractionCommand.java index de6db85..caafd61 100644 --- a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/EcoreTypeExtractionCommand.java +++ b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/EcoreTypeExtractionCommand.java @@ -37,7 +37,7 @@ public class EcoreTypeExtractionCommand implements Runnable { private final DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); @Option( - names = {"-l", "--language-root"}, + names = {"-m", "--modular-language"}, required = true, description = "Path to the root of a language/metamodel (*.ecore)") String rootPath; diff --git a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/FeatureScatterCommand.java b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/FeatureScatterCommand.java index 932e968..3c2cc48 100644 --- a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/FeatureScatterCommand.java +++ b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/FeatureScatterCommand.java @@ -29,7 +29,7 @@ public class FeatureScatterCommand implements Runnable { String level = "component"; @Option( - names = {"-m", "--language-model"}, + names = {"-m", "--modular-language"}, required = true, description = "Path to the language") String language; @@ -40,6 +40,13 @@ public class FeatureScatterCommand implements Runnable { description = "Path to the simulator code") String code; + @Option( + names = {"-p", "--path-structure"}, + description = + "Is optional. If the language is part of the code use \"LinC\", if the code is part of the language use \"CinL\", if none of these apply, don't use the flag.", + defaultValue = "none") + String language_location; + @Override public void run() { switch (level) { diff --git a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/ImproperLayerCommand.java b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/ImproperLayerCommand.java index 2b7686d..1586248 100644 --- a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/ImproperLayerCommand.java +++ b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/ImproperLayerCommand.java @@ -28,7 +28,7 @@ public class ImproperLayerCommand implements Runnable { String level = "component"; @Option( - names = {"-m", "--language-model"}, + names = {"-m", "--modular-language"}, required = true, description = "Path to the language") String language; @@ -39,6 +39,13 @@ public class ImproperLayerCommand implements Runnable { description = "Path to the simulator code") String code; + @Option( + names = {"-p", "--path-structure"}, + description = + "Is optional. If the language is part of the code use \"LinC\", if the code is part of the language use \"CinL\", if none of these apply, don't use the flag.", + defaultValue = "none") + String language_location; + @Override public void run() { switch (level) { diff --git a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/LanguageBlobCommand.java b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/LanguageBlobCommand.java index 7629ef7..26afe3c 100644 --- a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/LanguageBlobCommand.java +++ b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/LanguageBlobCommand.java @@ -34,7 +34,7 @@ public class LanguageBlobCommand implements Runnable { String level = "component"; @Option( - names = {"-m", "--language-model"}, + names = {"-m", "--modular-language"}, required = true, description = "Path to the language") String language; @@ -51,6 +51,13 @@ public class LanguageBlobCommand implements Runnable { defaultValue = "none") String simulatorType = "none"; + @Option( + names = {"-p", "--path-structure"}, + description = + "Is optional. If the language is part of the code use \"LinC\", if the code is part of the language use \"CinL\", if none of these apply, don't use the flag.", + defaultValue = "none") + String language_location; + @Override public void run() { switch (level) { diff --git a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/LanguageStructureApplianceCommand.java b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/LanguageStructureApplianceCommand.java index 6753e09..9438de2 100644 --- a/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/LanguageStructureApplianceCommand.java +++ b/src/main/java/edu/kit/kastel/dsis/mosim/refactorlizar/analysiscli/commands/LanguageStructureApplianceCommand.java @@ -4,7 +4,7 @@ import picocli.CommandLine.Command; import picocli.CommandLine.Option; -@Command(name = "applyLanguageStructureToCode", description = "", mixinStandardHelpOptions = true) +@Command(name = "applyLanguageStructureToCode", description = "Not implemented yet.", mixinStandardHelpOptions = true) public class LanguageStructureApplianceCommand implements Runnable { public static final FluentLogger LOGGER = FluentLogger.forEnclosingClass(); @@ -20,6 +20,15 @@ public class LanguageStructureApplianceCommand implements Runnable { description = "Path to the simulator code") String code; + @Option( + names = {"-p", "--path-structure"}, + description = + "Is optional. If the language is part of the code use \"LinC\", if the code is part of the language use \"CinL\", if none of these apply, don't use the flag.", + defaultValue = "none") + String language_location; + @Override - public void run() {} + public void run() { + LOGGER.atWarning().log("Command is not implemented yet!"); + } } From fbe3f05b1c434fb6fc675787466fae11f2b8a98f Mon Sep 17 00:00:00 2001 From: Sandro Date: Tue, 22 Jun 2021 12:40:41 +0200 Subject: [PATCH 15/15] add jenv and *.bak files to ignore --- .gitignore | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 6ca923f..385cbde 100644 --- a/.gitignore +++ b/.gitignore @@ -89,4 +89,8 @@ gradle-app.setting # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml hs_err_pid* # Binary -/bin \ No newline at end of file +/bin + +.java-version +*.bak +