Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJan Belle2018-09-06 12:09:44 -0400
committerJan Belle2018-09-06 12:41:36 -0400
commit59604c4082c3a5e170be9625ee6c4bd517019e5c (patch)
tree1a7350d1e1aa84e30bf125bdb6a16b80b326c9d2
parente7ee5f01c807c86a6088ed321be578af10ce73bf (diff)
downloadorg.eclipse.etrice-59604c4082c3a5e170be9625ee6c4bd517019e5c.tar.gz
org.eclipse.etrice-59604c4082c3a5e170be9625ee6c4bd517019e5c.tar.xz
org.eclipse.etrice-59604c4082c3a5e170be9625ee6c4bd517019e5c.zip
[generator.base] Improve generator options implementation
-rw-r--r--plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/GeneratorApplication.java25
-rw-r--r--plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/args/Arguments.java18
-rw-r--r--plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/args/BooleanOption.java8
-rw-r--r--plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/args/EnumOption.java16
-rw-r--r--plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/args/IOptionModule.java (renamed from plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/args/IOptionsModule.java)2
-rw-r--r--plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/args/IntegerOption.java14
-rw-r--r--plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/args/Option.java45
-rw-r--r--plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/args/Options.java46
-rw-r--r--plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/args/StringListOption.java30
-rw-r--r--plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/args/StringOption.java8
-rw-r--r--plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/cli/CommandLineParser.java56
-rw-r--r--plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/cli/HelpFormatter.java15
-rw-r--r--plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/cli/ICommandLineParser.java15
-rw-r--r--plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/cli/IHelpFormatter.java4
-rw-r--r--plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/io/GeneratorResourceLoader.java6
-rw-r--r--plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/io/IGeneratorResourceLoader.java3
-rw-r--r--plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/setup/GeneratorApplicationModule.java (renamed from plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/setup/GeneratorBaseModule.java)4
-rw-r--r--plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/setup/GeneratorApplicationOptions.java89
-rw-r--r--plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/setup/GeneratorBaseOptions.java48
-rw-r--r--plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/setup/GeneratorBaseOptionsHelper.java22
-rw-r--r--plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/setup/IGeneratorOptions.java28
-rw-r--r--plugins/org.eclipse.etrice.generator.doc/src/org/eclipse/etrice/generator/doc/setup/GeneratorOptions.java3
-rw-r--r--plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/setup/GeneratorOptions.java4
-rw-r--r--plugins/org.eclipse.etrice.generator.launch/src/org/eclipse/etrice/generator/launch/GeneratorLaunchConfigurationDelegate.java9
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGenerator.java5
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGeneratorBaseModule.java4
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGeneratorOptions.java11
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/ModelLoader.java4
-rw-r--r--plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/PrepareFileSystem.xtend4
29 files changed, 318 insertions, 228 deletions
diff --git a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/GeneratorApplication.java b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/GeneratorApplication.java
index 2f9dbbbde..febb60870 100644
--- a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/GeneratorApplication.java
+++ b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/GeneratorApplication.java
@@ -33,7 +33,8 @@ import org.eclipse.etrice.generator.base.io.LineOutput;
import org.eclipse.etrice.generator.base.logging.ILogger;
import org.eclipse.etrice.generator.base.logging.Logger;
import org.eclipse.etrice.generator.base.logging.Loglevel;
-import org.eclipse.etrice.generator.base.setup.GeneratorBaseOptions;
+import org.eclipse.etrice.generator.base.setup.GeneratorApplicationOptions;
+import org.eclipse.etrice.generator.base.setup.IGeneratorOptions;
import org.eclipse.etrice.generator.base.validation.IGeneratorResourceValidator;
import com.google.inject.Guice;
import com.google.inject.Inject;
@@ -79,11 +80,11 @@ public class GeneratorApplication {
private IGeneratorResourceValidator resourceValidator;
@Inject
- public GeneratorApplication(GeneratorBaseOptions optionsModule, ICommandLineParser commandLineParser,
+ public GeneratorApplication(IGeneratorOptions optionsModule, ICommandLineParser commandLineParser,
IHelpFormatter helpFormatter, Provider<Logger> loggerProvider,
Provider<IncrementalGeneratorFileIO> fileIOProvider, Provider<IGenerator> generatorProvider,
IGeneratorResourceLoader resourceLoader, IGeneratorResourceValidator resourceValidator) {
- this.options = new Options(optionsModule);
+ this.options = new Options(new GeneratorApplicationOptions(), optionsModule);
this.commandLineParser = commandLineParser;
this.helpFormatter = helpFormatter;
this.loggerProvider = loggerProvider;
@@ -110,9 +111,9 @@ public class GeneratorApplication {
*/
public void run(String[] args, ILineOutput out) throws GeneratorException {
try {
- Arguments arguments = commandLineParser.parseArgs(options, args);
+ Arguments arguments = commandLineParser.parseArgs(options, GeneratorApplicationOptions.FILES, args);
- if(arguments.get(GeneratorBaseOptions.HELP)) {
+ if(arguments.get(GeneratorApplicationOptions.HELP)) {
printHelp(out);
}
else {
@@ -161,7 +162,7 @@ public class GeneratorApplication {
try {
logger.logDebug(arguments.toString());
- List<Resource> resources = load(arguments.getFiles(), arguments, logger);
+ List<Resource> resources = load(arguments.get(GeneratorApplicationOptions.FILES), arguments, logger);
validate(resources, arguments, logger);
@@ -174,28 +175,28 @@ public class GeneratorApplication {
}
private void printHelp(ILineOutput out) {
- String help = helpFormatter.getHelp(options);
+ String help = helpFormatter.getHelp(options, GeneratorApplicationOptions.FILES);
out.println(help);
}
private ILogger createLogger(Arguments arguments, ILineOutput out) {
Logger logger = loggerProvider.get();
- logger.setLoglevel(arguments.get(GeneratorBaseOptions.LOGLEVEL));
+ logger.setLoglevel(arguments.get(GeneratorApplicationOptions.LOGLEVEL));
logger.setOutput(out);
return logger;
}
private IGeneratorFileIO createGeneratorFileIO(Arguments arguments, ILogger logger) {
IncrementalGeneratorFileIO fileIO = fileIOProvider.get();
- fileIO.setGenDir(arguments.get(GeneratorBaseOptions.GEN_DIR));
- fileIO.setGenInfoDir(arguments.get(GeneratorBaseOptions.GEN_INFO_DIR));
- fileIO.setGenerateIncremental(arguments.get(GeneratorBaseOptions.GEN_INCREMENTAL));
+ fileIO.setGenDir(arguments.get(GeneratorApplicationOptions.GEN_DIR));
+ fileIO.setGenInfoDir(arguments.get(GeneratorApplicationOptions.GEN_INFO_DIR));
+ fileIO.setGenerateIncremental(arguments.get(GeneratorApplicationOptions.GEN_INCREMENTAL));
fileIO.setLogger(logger);
return fileIO;
}
private List<Resource> load(List<String> files, Arguments arguments, ILogger logger) {
- return resourceLoader.load(arguments, logger);
+ return resourceLoader.load(files, arguments, logger);
}
private void validate(List<Resource> models, Arguments arguments, ILogger logger) {
diff --git a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/args/Arguments.java b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/args/Arguments.java
index bc49ddbde..4557d3731 100644
--- a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/args/Arguments.java
+++ b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/args/Arguments.java
@@ -15,17 +15,15 @@
package org.eclipse.etrice.generator.base.args;
-import java.util.ArrayList;
import java.util.HashMap;
-import java.util.List;
/**
* Encapsulates a set of arguments.
*/
public class Arguments {
+
private Options options;
private HashMap<String, Object> option2Arg;
- private List<String> fileList;
/**
* Creates a new set of arguments initialized to their default values.
@@ -35,7 +33,6 @@ public class Arguments {
public Arguments(Options options) {
this.options = options;
option2Arg = new HashMap<>();
- fileList = new ArrayList<>();
for(Option<?> option: options) {
option2Arg.put(option.getName(), option.getDefaultValue());
@@ -74,7 +71,7 @@ public class Arguments {
*/
public void set(String name, Object value) throws IllegalArgumentException {
Option<?> opt = options.get(name);
- if(!opt.checkValue(value)) {
+ if(!opt.getType().isInstance(value)) {
throw new IllegalArgumentException("value " + value.toString() + " is not assignable to Option " + opt.toString());
}
option2Arg.put(name, value);
@@ -91,15 +88,6 @@ public class Arguments {
}
/**
- * Returns the list of input file paths.
- *
- * @return the list of paths
- */
- public List<String> getFiles() {
- return fileList;
- }
-
- /**
* Returns the options for the arguments.
*
* @return options the options
@@ -110,6 +98,6 @@ public class Arguments {
@Override
public String toString() {
- return option2Arg.toString() + ", " + fileList.toString();
+ return option2Arg.toString();
}
}
diff --git a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/args/BooleanOption.java b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/args/BooleanOption.java
index 65d98d23b..217e34c7f 100644
--- a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/args/BooleanOption.java
+++ b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/args/BooleanOption.java
@@ -20,12 +20,8 @@ package org.eclipse.etrice.generator.base.args;
*/
public class BooleanOption extends Option<Boolean> {
- public BooleanOption(String name, String parameterName, String description, boolean defaultValue) {
- super(Boolean.class, name, parameterName, description, defaultValue);
+ public BooleanOption(String group, String name, String argumentName, String description, boolean defaultValue) {
+ super(Boolean.class, group, name, argumentName, description, defaultValue);
}
- @Override
- public Boolean parseValue(String str) {
- return Boolean.parseBoolean(str);
- }
}
diff --git a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/args/EnumOption.java b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/args/EnumOption.java
index c6033b591..9ec73d3ae 100644
--- a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/args/EnumOption.java
+++ b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/args/EnumOption.java
@@ -20,23 +20,11 @@ package org.eclipse.etrice.generator.base.args;
*/
public class EnumOption<T extends Enum<?>> extends Option<T> {
- private T[] enumConstants;
-
/**
* @see Option#Option
*/
- public EnumOption(Class<T> enumClass, String name, String parameterName, String description, T defaultValue) {
- super(enumClass, name, parameterName, description, defaultValue);
- enumConstants = enumClass.getEnumConstants();
+ public EnumOption(Class<T> enumClass, String group, String name, String argumentName, String description, T defaultValue) {
+ super(enumClass, group, name, argumentName, description, defaultValue);
}
- @Override
- public T parseValue(String str) throws IllegalArgumentException {
- for(T c: enumConstants) {
- if(c.toString().equalsIgnoreCase(str)) {
- return c;
- }
- }
- throw new IllegalArgumentException("Argument " + str + " not allowed for option " + getName());
- }
}
diff --git a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/args/IOptionsModule.java b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/args/IOptionModule.java
index eff703a55..06880e7bb 100644
--- a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/args/IOptionsModule.java
+++ b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/args/IOptionModule.java
@@ -20,7 +20,7 @@ import java.util.List;
/**
* Describes options that can be used to create a new {@link Options} set.
*/
-public interface IOptionsModule {
+public interface IOptionModule {
/**
* Configures options on the passed collection.
diff --git a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/args/IntegerOption.java b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/args/IntegerOption.java
index 1ac1c6f97..b3cec8e30 100644
--- a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/args/IntegerOption.java
+++ b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/args/IntegerOption.java
@@ -23,18 +23,8 @@ public class IntegerOption extends Option<Integer> {
/**
* @see Option#Option
*/
- public IntegerOption(String name, String parameterName, String description, int defaultValue) {
- super(Integer.class, name, parameterName, description, defaultValue);
+ public IntegerOption(String group, String name, String argumentName, String description, int defaultValue) {
+ super(Integer.class, group, name, argumentName, description, defaultValue);
}
- @Override
- public Integer parseValue(String str) throws IllegalArgumentException {
- try {
- return Integer.parseInt(str);
- }
- catch(NumberFormatException e) {
- throw new IllegalArgumentException(e);
- }
- }
-
}
diff --git a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/args/Option.java b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/args/Option.java
index 7ee77c00d..c863f6c8e 100644
--- a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/args/Option.java
+++ b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/args/Option.java
@@ -25,7 +25,8 @@ public class Option<T> {
private final Class<T> type;
private final String name;
- private final String parameterName;
+ private final String argumentName;
+ private final String group;
private final String description;
private final T defaultValue;
@@ -38,10 +39,11 @@ public class Option<T> {
* @param description a description for this option
* @param defaultValue a default value for this option
*/
- public Option(Class<T> type, String name, String parameterName, String description, T defaultValue) {
+ public Option(Class<T> type, String group, String name, String argumentName, String description, T defaultValue) {
this.type = type;
+ this.group = group;
this.name = name;
- this.parameterName = parameterName;
+ this.argumentName = argumentName;
this.description = description;
this.defaultValue = defaultValue;
}
@@ -56,6 +58,15 @@ public class Option<T> {
}
/**
+ * Returns the group that this option is associated to.
+ *
+ * @return the group name
+ */
+ public final String getGroup() {
+ return group;
+ }
+
+ /**
* Returns the name of this option.
* Its name uniquely identifies an option.
*
@@ -66,12 +77,12 @@ public class Option<T> {
}
/**
- * Returns the parameter name of this option.
+ * Returns the argument name of this option.
*
- * @return the parameter name
+ * @return the argument name
*/
- public final String getParameterName() {
- return parameterName;
+ public final String getArgumentName() {
+ return argumentName;
}
/**
@@ -92,26 +103,6 @@ public class Option<T> {
return defaultValue;
}
- /**
- * Checks whether the passed value is assignable to this option.
- *
- * @param value the value to be checked
- * @return whether the value is assignable to this option
- */
- public boolean checkValue(Object value) {
- return type.isInstance(value);
- }
-
- /**
- * Parses a value for this option from the passed string.
- *
- * @param str the string to be parsed
- * @return the parsed value
- */
- public T parseValue(String str) throws IllegalArgumentException, UnsupportedOperationException {
- throw new UnsupportedOperationException();
- }
-
@Override
public String toString() {
return getName();
diff --git a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/args/Options.java b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/args/Options.java
index bb3cd7d73..408f9b521 100644
--- a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/args/Options.java
+++ b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/args/Options.java
@@ -25,37 +25,32 @@ import java.util.List;
/**
* Encapsulates an immutable set of options.
*/
-public class Options implements Iterable<Option<?>> {
+public class Options implements IOptionModule, Iterable<Option<?>> {
- private LinkedHashMap<String, Option<?>> name2Option;
+ private final LinkedHashMap<String, Option<?>> name2Option;
/**
- * Creates a new set of options that contains the passed options.
+ * Creates a new set of options that contains the options configured by the passed modules.
*
- * @param options the options
+ * @param modules the options modules
*/
- public Options(Option<?>... options) {
- init(Arrays.asList(options));
+ public Options(IOptionModule... modules) {
+ this(Arrays.asList(modules));
}
/**
- * Creates a new set of options that contains the passed options.
+ * Creates a new set of options that contains the options configured by the passed modules.
*
- * @param options the options
+ * @param modules the options modules
*/
- public Options(List<Option<?>> options) {
- init(options);
- }
-
- /**
- * Creates a new set of options that contains the options configured by the passed module.
- *
- * @param module the options module
- */
- public Options(IOptionsModule module) {
+ public Options(Iterable<IOptionModule> modules) {
List<Option<?>> options = new LinkedList<>();
- module.configure(options);
- init(options);
+ for(IOptionModule module: modules) {
+ module.configure(options);
+ }
+
+ name2Option = new LinkedHashMap<>();
+ options.forEach(opt -> name2Option.put(opt.getName(), opt));
}
/**
@@ -77,12 +72,15 @@ public class Options implements Iterable<Option<?>> {
}
@Override
+ public final void configure(List<Option<?>> options) {
+ for(Option<?> opt: this) {
+ options.add(opt);
+ }
+ }
+
+ @Override
public String toString() {
return name2Option.values().toString();
}
- private final void init(List<Option<?>> options) {
- name2Option = new LinkedHashMap<>(options.size());
- options.forEach(opt -> name2Option.put(opt.getName(), opt));
- }
}
diff --git a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/args/StringListOption.java b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/args/StringListOption.java
new file mode 100644
index 000000000..072b2e1cd
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/args/StringListOption.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+* Copyright (c) 2018 protos software gmbh (http://www.protos.de).
+* All rights reserved.
+*
+* This program and the accompanying materials are made
+* available under the terms of the Eclipse Public License 2.0
+* which is available at https://www.eclipse.org/legal/epl-2.0/
+*
+* SPDX-License-Identifier: EPL-2.0
+*
+* CONTRIBUTORS:
+* Jan Belle (initial contribution)
+*
+ *******************************************************************************/
+
+package org.eclipse.etrice.generator.base.args;
+
+import java.util.List;
+
+public class StringListOption extends Option<List<String>> {
+
+ /**
+ * @see Option#Option
+ */
+ @SuppressWarnings("unchecked")
+ public StringListOption(String group, String name, String argumentName, String description, List<String> defaultValue) {
+ super((Class<List<String>>)(Class<?>) List.class, group, name, argumentName, description, defaultValue);
+ }
+
+}
diff --git a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/args/StringOption.java b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/args/StringOption.java
index dbecaca95..87f28a494 100644
--- a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/args/StringOption.java
+++ b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/args/StringOption.java
@@ -23,12 +23,8 @@ public class StringOption extends Option<String> {
/**
* @see Option#Option
*/
- public StringOption(String name, String parameterName, String description, String defaultValue) {
- super(String.class, name, parameterName, description, defaultValue);
+ public StringOption(String group, String name, String argumentName, String description, String defaultValue) {
+ super(String.class, group, name, argumentName, description, defaultValue);
}
- @Override
- public String parseValue(String str) {
- return str;
- }
}
diff --git a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/cli/CommandLineParser.java b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/cli/CommandLineParser.java
index 3ad8a5efa..39f2277e9 100644
--- a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/cli/CommandLineParser.java
+++ b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/cli/CommandLineParser.java
@@ -15,6 +15,7 @@
package org.eclipse.etrice.generator.base.cli;
+import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
@@ -22,6 +23,7 @@ import java.util.ListIterator;
import org.eclipse.etrice.generator.base.args.Arguments;
import org.eclipse.etrice.generator.base.args.Option;
import org.eclipse.etrice.generator.base.args.Options;
+import org.eclipse.etrice.generator.base.args.StringListOption;
/**
* Simple implementation of a command line parser.
@@ -38,24 +40,29 @@ public class CommandLineParser implements ICommandLineParser {
}
@Override
- public Arguments parseArgs(Options options, List<String> args) throws CommandLineParseException {
- Arguments parameters = new Arguments(options);
+ public Arguments parseArgs(Options options, StringListOption defaultOption, List<String> args) throws CommandLineParseException {
+ Arguments parsedArgs = new Arguments(options);
List<String> nArgs = normalize(args);
ListIterator<String> iterator = nArgs.listIterator();
+ ArrayList<String> defaultArgs = new ArrayList<>();
while(iterator.hasNext()) {
String str = iterator.next().trim();
if(str.startsWith("-")) {
Option<?> opt = parseOption(options, str);
Object value = parseValue(opt, iterator);
- parameters.set(opt.getName(), value);
+ parsedArgs.set(opt.getName(), value);
}
else {
- parameters.getFiles().add(str);
+ defaultArgs.add(str);
}
}
- return parameters;
+ if(!defaultArgs.isEmpty()) {
+ parsedArgs.set(defaultOption, defaultArgs);
+ }
+
+ return parsedArgs;
}
private List<String> normalize(List<String> args) throws CommandLineParseException {
@@ -65,31 +72,50 @@ public class CommandLineParser implements ICommandLineParser {
private Option<?> parseOption(Options options, String str) throws CommandLineParseException {
try {
- Option<?> opt = options.get(str.substring(1));
+ String optionName = str.substring(1);
+ Option<?> opt = options.get(optionName);
return opt;
}
catch(IllegalArgumentException e) {
- throw new CommandLineParseException(e);
+ throw new CommandLineParseException("Option " + str + " not recognized");
}
}
private Object parseValue(Option<?> opt, ListIterator<String> iterator) throws CommandLineParseException {
- if(opt.getType().equals(Boolean.class)) {
+ Class<?> type = opt.getType();
+
+ if(type == Boolean.class) {
return true;
}
- else if(iterator.hasNext()) {
- try {
- return opt.parseValue(iterator.next());
+
+ if(iterator.hasNext()) {
+ String str = iterator.next();
+
+ if(type == String.class) {
+ return str;
}
- catch(IllegalArgumentException e) {
- throw new CommandLineParseException(e);
+ else if(type.isEnum()) {
+ return parseEnum(opt, str);
}
- catch(UnsupportedOperationException e) {
- throw new CommandLineParseException(e);
+ else {
+ throw new CommandLineParseException("Option " + opt.getName() + " is not supported on the command line");
}
+
}
else {
throw new CommandLineParseException("Expected one argument for option " + opt.getName());
}
}
+
+ private Object parseEnum(Option<?> opt, String str) {
+ Object[] constants = opt.getType().getEnumConstants();
+
+ for(Object c: constants) {
+ if(c.toString().equalsIgnoreCase(str)) {
+ return c;
+ }
+ }
+
+ throw new CommandLineParseException("Argument " + str + " not allowed for option " + opt.getName());
+ }
}
diff --git a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/cli/HelpFormatter.java b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/cli/HelpFormatter.java
index 777930841..bc2f9782c 100644
--- a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/cli/HelpFormatter.java
+++ b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/cli/HelpFormatter.java
@@ -19,6 +19,7 @@ import java.util.Formatter;
import org.eclipse.etrice.generator.base.args.Option;
import org.eclipse.etrice.generator.base.args.Options;
+import org.eclipse.etrice.generator.base.args.StringListOption;
/**
* Simple implementation for command line help formatting.
@@ -29,16 +30,18 @@ public class HelpFormatter implements IHelpFormatter {
}
@Override
- public String getHelp(Options options) {
+ public String getHelp(Options options, StringListOption defaultOption) {
try(Formatter formatter = new Formatter()) {
- formatter.format("Usage: [options] files...%n");
+ formatter.format("Usage: [options] %s...%n", defaultOption.getName());
formatter.format("Options:%n");
for(Option<?> opt: options) {
- String optStr = "-" + opt.getName();
- if(!opt.getType().equals(Boolean.class)) {
- optStr += " <" + opt.getParameterName() + ">";
+ if(opt != defaultOption) {
+ String optStr = "-" + opt.getName();
+ if(!opt.getType().equals(Boolean.class)) {
+ optStr += " <" + opt.getArgumentName() + ">";
+ }
+ formatter.format(" %-30s %s%n", optStr, opt.getDescription());
}
- formatter.format(" %-30s %s%n", optStr, opt.getDescription());
}
return formatter.toString();
}
diff --git a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/cli/ICommandLineParser.java b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/cli/ICommandLineParser.java
index ec7a49aa7..507b6fbb1 100644
--- a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/cli/ICommandLineParser.java
+++ b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/cli/ICommandLineParser.java
@@ -20,6 +20,7 @@ import java.util.List;
import org.eclipse.etrice.generator.base.args.Arguments;
import org.eclipse.etrice.generator.base.args.Options;
+import org.eclipse.etrice.generator.base.args.StringListOption;
import com.google.inject.ImplementedBy;
@@ -33,14 +34,20 @@ public interface ICommandLineParser {
* Parses the specified command line arguments using the passed options.
*
* @param options the options
+ * @param defaultOption the option for arguments without option identifier
* @param args the command line arguments
*/
- Arguments parseArgs(Options options, List<String> args) throws CommandLineParseException;
+ Arguments parseArgs(Options options, StringListOption defaultOption, List<String> args) throws CommandLineParseException;
+
/**
- * @see ICommandLineParser#parseArgs(Options, List)
+ * Parses the specified command line arguments using the passed options.
+ *
+ * @param options the options
+ * @param defaultOption the option to store arguments without identifier
+ * @param args the command line arguments
*/
- default Arguments parseArgs(Options options, String[] args) throws CommandLineParseException {
- return parseArgs(options, Arrays.asList(args));
+ default Arguments parseArgs(Options options, StringListOption defaultOption, String[] args) throws CommandLineParseException {
+ return parseArgs(options, defaultOption, Arrays.asList(args));
}
}
diff --git a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/cli/IHelpFormatter.java b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/cli/IHelpFormatter.java
index 9d592ecd4..d7f7e7aa6 100644
--- a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/cli/IHelpFormatter.java
+++ b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/cli/IHelpFormatter.java
@@ -16,6 +16,7 @@
package org.eclipse.etrice.generator.base.cli;
import org.eclipse.etrice.generator.base.args.Options;
+import org.eclipse.etrice.generator.base.args.StringListOption;
import com.google.inject.ImplementedBy;
@@ -29,8 +30,9 @@ public interface IHelpFormatter {
* Produces a help message for the passed options.
*
* @param options the options
+ * @param defaultOption the option for arguments without option identifier
* @return the help message
*/
- String getHelp(Options options);
+ String getHelp(Options options, StringListOption defaultOption);
}
diff --git a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/io/GeneratorResourceLoader.java b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/io/GeneratorResourceLoader.java
index 753115d22..84e1cdd57 100644
--- a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/io/GeneratorResourceLoader.java
+++ b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/io/GeneratorResourceLoader.java
@@ -55,15 +55,15 @@ public class GeneratorResourceLoader implements IGeneratorResourceLoader {
}
@Override
- public List<Resource> load(Arguments arguments, ILogger logger) throws GeneratorException {
+ public List<Resource> load(List<String> files, Arguments arguments, ILogger logger) throws GeneratorException {
doEMFRegistration();
- List<Resource> models = new ArrayList<>(arguments.getFiles().size());
+ List<Resource> models = new ArrayList<>(files.size());
ResourceSet resourceSet = resourceSetProvider.get();
Adapter resourceAddedAdapter = new ResourceAddedAdapter(logger);
resourceSet.eAdapters().add(resourceAddedAdapter);
- for(String f: arguments.getFiles()) {
+ for(String f: files) {
Resource r = loadResource(f, resourceSet, logger);
models.add(r);
}
diff --git a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/io/IGeneratorResourceLoader.java b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/io/IGeneratorResourceLoader.java
index 8e097f961..3fbf77169 100644
--- a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/io/IGeneratorResourceLoader.java
+++ b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/io/IGeneratorResourceLoader.java
@@ -33,10 +33,11 @@ public interface IGeneratorResourceLoader {
/**
* Loads the specified files.
*
+ * @param files the files to load
* @param arguments the generator arguments
* @param logger the logger
* @return the loaded resources
*/
- List<Resource> load(Arguments arguments, ILogger logger) throws GeneratorException;
+ List<Resource> load(List<String> files, Arguments arguments, ILogger logger) throws GeneratorException;
}
diff --git a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/setup/GeneratorBaseModule.java b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/setup/GeneratorApplicationModule.java
index 7fae814dd..a019b7973 100644
--- a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/setup/GeneratorBaseModule.java
+++ b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/setup/GeneratorApplicationModule.java
@@ -23,9 +23,9 @@ import com.google.inject.Binder;
import com.google.inject.Module;
/**
- * An abstract base module for generators that configures standard implementations.
+ * A base module for generator applications that configures standard implementations.
*/
-public abstract class GeneratorBaseModule implements Module {
+public abstract class GeneratorApplicationModule implements Module {
@Override
public void configure(Binder binder) {
diff --git a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/setup/GeneratorApplicationOptions.java b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/setup/GeneratorApplicationOptions.java
new file mode 100644
index 000000000..0b5533d7a
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/setup/GeneratorApplicationOptions.java
@@ -0,0 +1,89 @@
+/*******************************************************************************
+* Copyright (c) 2018 protos software gmbh (http://www.protos.de).
+* All rights reserved.
+*
+* This program and the accompanying materials are made
+* available under the terms of the Eclipse Public License 2.0
+* which is available at https://www.eclipse.org/legal/epl-2.0/
+*
+* SPDX-License-Identifier: EPL-2.0
+*
+* CONTRIBUTORS:
+* Jan Belle (initial contribution)
+*
+ *******************************************************************************/
+
+package org.eclipse.etrice.generator.base.setup;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.etrice.generator.base.args.BooleanOption;
+import org.eclipse.etrice.generator.base.args.EnumOption;
+import org.eclipse.etrice.generator.base.args.IOptionModule;
+import org.eclipse.etrice.generator.base.args.Option;
+import org.eclipse.etrice.generator.base.args.StringListOption;
+import org.eclipse.etrice.generator.base.args.StringOption;
+import org.eclipse.etrice.generator.base.logging.Loglevel;
+
+/**
+ * Configures the options of the generator application.
+ */
+public class GeneratorApplicationOptions implements IOptionModule {
+
+ public static final String GROUP_APPLICATION = "application";
+
+ public static final StringListOption FILES = new StringListOption(
+ GROUP_APPLICATION,
+ "files",
+ "input files",
+ "input files for the generator",
+ new ArrayList<>());
+
+ public static final BooleanOption HELP = new BooleanOption(
+ GROUP_APPLICATION,
+ "help",
+ "isHelp",
+ "display this help text",
+ false);
+
+ public static final BooleanOption GEN_INCREMENTAL = new BooleanOption(
+ GROUP_APPLICATION,
+ "inc",
+ "isInc",
+ "if specified the generation is incremental",
+ false);
+
+ public static final StringOption GEN_DIR = new StringOption(
+ GROUP_APPLICATION,
+ "genDir",
+ "directory",
+ "the directory for generated files",
+ "src-gen");
+
+ public static final StringOption GEN_INFO_DIR = new StringOption(
+ GROUP_APPLICATION,
+ "genInfoDir",
+ "directory",
+ "the directory for generated info files",
+ "src-gen-info");
+
+ public static final EnumOption<Loglevel> LOGLEVEL = new EnumOption<>(
+ Loglevel.class,
+ GROUP_APPLICATION,
+ "loglevel",
+ "level",
+ "the loglevel for the logger [all, debug, info, warning, error, off]",
+ Loglevel.INFO);
+
+ @Override
+ public void configure(List<Option<?>> options) {
+ options.add(FILES);
+ options.add(HELP);
+ options.add(GEN_INCREMENTAL);
+ options.add(GEN_DIR);
+ options.add(GEN_INFO_DIR);
+ options.add(LOGLEVEL);
+ }
+
+}
diff --git a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/setup/GeneratorBaseOptions.java b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/setup/GeneratorBaseOptions.java
index c9d3d53a5..8280a362c 100644
--- a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/setup/GeneratorBaseOptions.java
+++ b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/setup/GeneratorBaseOptions.java
@@ -17,56 +17,14 @@ package org.eclipse.etrice.generator.base.setup;
import java.util.List;
-import org.eclipse.etrice.generator.base.args.BooleanOption;
-import org.eclipse.etrice.generator.base.args.EnumOption;
-import org.eclipse.etrice.generator.base.args.IOptionsModule;
import org.eclipse.etrice.generator.base.args.Option;
-import org.eclipse.etrice.generator.base.args.StringOption;
-import org.eclipse.etrice.generator.base.logging.Loglevel;
/**
* Configures standard options for generators.
*/
-public class GeneratorBaseOptions implements IOptionsModule {
-
- public static final BooleanOption HELP = new BooleanOption(
- "help",
- "isHelp",
- "display this help text",
- false);
-
- public static final BooleanOption GEN_INCREMENTAL = new BooleanOption(
- "inc",
- "isInc",
- "if specified the generation is incremental",
- false);
-
- public static final StringOption GEN_DIR = new StringOption(
- "genDir",
- "directory",
- "the directory for generated files",
- "src-gen");
-
- public static final StringOption GEN_INFO_DIR = new StringOption(
- "genInfoDir",
- "directory",
- "the directory for generated info files",
- "src-gen-info");
-
- public static final EnumOption<Loglevel> LOGLEVEL = new EnumOption<>(
- Loglevel.class,
- "loglevel",
- "level",
- "the loglevel for the logger [all, debug, info, warning, error, off]",
- Loglevel.INFO);
-
+public class GeneratorBaseOptions implements IGeneratorOptions {
+
@Override
- public void configure(List<Option<?>> options) {
- options.add(HELP);
- options.add(GEN_INCREMENTAL);
- options.add(GEN_DIR);
- options.add(GEN_INFO_DIR);
- options.add(LOGLEVEL);
- }
+ public void configure(List<Option<?>> options) {}
}
diff --git a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/setup/GeneratorBaseOptionsHelper.java b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/setup/GeneratorBaseOptionsHelper.java
index 53afd25b7..e91d575a5 100644
--- a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/setup/GeneratorBaseOptionsHelper.java
+++ b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/setup/GeneratorBaseOptionsHelper.java
@@ -15,31 +15,9 @@
package org.eclipse.etrice.generator.base.setup;
-import org.eclipse.etrice.generator.base.args.Arguments;
-import org.eclipse.etrice.generator.base.logging.Loglevel;
-
/**
* Helper class for {@link GeneratorBaseOptions}.
*/
public class GeneratorBaseOptionsHelper {
- public boolean isHelp(Arguments args) {
- return args.get(GeneratorBaseOptions.HELP);
- }
-
- public boolean isIncremental(Arguments args) {
- return args.get(GeneratorBaseOptions.GEN_INCREMENTAL);
- }
-
- public String getGenDir(Arguments args) {
- return args.get(GeneratorBaseOptions.GEN_DIR);
- }
-
- public String getGenInfoDir(Arguments args) {
- return args.get(GeneratorBaseOptions.GEN_INFO_DIR);
- }
-
- public Loglevel getLoglevel(Arguments args) {
- return args.get(GeneratorBaseOptions.LOGLEVEL);
- }
}
diff --git a/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/setup/IGeneratorOptions.java b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/setup/IGeneratorOptions.java
new file mode 100644
index 000000000..d708e3a2d
--- /dev/null
+++ b/plugins/org.eclipse.etrice.generator.base/src/org/eclipse/etrice/generator/base/setup/IGeneratorOptions.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+* Copyright (c) 2018 protos software gmbh (http://www.protos.de).
+* All rights reserved.
+*
+* This program and the accompanying materials are made
+* available under the terms of the Eclipse Public License 2.0
+* which is available at https://www.eclipse.org/legal/epl-2.0/
+*
+* SPDX-License-Identifier: EPL-2.0
+*
+* CONTRIBUTORS:
+* Jan Belle (initial contribution)
+*
+ *******************************************************************************/
+
+package org.eclipse.etrice.generator.base.setup;
+
+import org.eclipse.etrice.generator.base.args.IOptionModule;
+
+import com.google.inject.ImplementedBy;
+
+/**
+ * Interface for generator options.
+ */
+@ImplementedBy(GeneratorBaseOptions.class)
+public interface IGeneratorOptions extends IOptionModule {
+
+}
diff --git a/plugins/org.eclipse.etrice.generator.doc/src/org/eclipse/etrice/generator/doc/setup/GeneratorOptions.java b/plugins/org.eclipse.etrice.generator.doc/src/org/eclipse/etrice/generator/doc/setup/GeneratorOptions.java
index 2e998e50e..802d65409 100644
--- a/plugins/org.eclipse.etrice.generator.doc/src/org/eclipse/etrice/generator/doc/setup/GeneratorOptions.java
+++ b/plugins/org.eclipse.etrice.generator.doc/src/org/eclipse/etrice/generator/doc/setup/GeneratorOptions.java
@@ -23,7 +23,10 @@ import org.eclipse.etrice.generator.base.args.Option;
public class GeneratorOptions extends AbstractGeneratorOptions {
+ public static final String GROUP_ETRICE_DOC = "eTrice Documentation";
+
public static final BooleanOption GEN_INST_DIAG = new BooleanOption(
+ GROUP_ETRICE_DOC,
"genInstDiag",
"generateInstanceDiagram",
"if specified then an instance diagram is created for each subsystem",
diff --git a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/setup/GeneratorOptions.java b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/setup/GeneratorOptions.java
index 279e33f0e..1ab96c399 100644
--- a/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/setup/GeneratorOptions.java
+++ b/plugins/org.eclipse.etrice.generator.java/src/org/eclipse/etrice/generator/java/setup/GeneratorOptions.java
@@ -23,13 +23,17 @@ import org.eclipse.etrice.generator.base.args.Option;
public class GeneratorOptions extends AbstractGeneratorOptions {
+ public static final String GROUP_ETRICE_JAVA = "eTrice Java";
+
public static final BooleanOption GEN_PERSIST = new BooleanOption(
+ GROUP_ETRICE_JAVA,
"persistable",
"generatePersistenceInterface",
"if specified make actor classes persistable",
false);
public static final BooleanOption GEN_STORE_DATA_OBJ = new BooleanOption(
+ GROUP_ETRICE_JAVA,
"storeDataObj",
"generateStoreDataObj",
"if specified equip actor classes with store/restore using POJOs",
diff --git a/plugins/org.eclipse.etrice.generator.launch/src/org/eclipse/etrice/generator/launch/GeneratorLaunchConfigurationDelegate.java b/plugins/org.eclipse.etrice.generator.launch/src/org/eclipse/etrice/generator/launch/GeneratorLaunchConfigurationDelegate.java
index f292fb405..5796a4a13 100644
--- a/plugins/org.eclipse.etrice.generator.launch/src/org/eclipse/etrice/generator/launch/GeneratorLaunchConfigurationDelegate.java
+++ b/plugins/org.eclipse.etrice.generator.launch/src/org/eclipse/etrice/generator/launch/GeneratorLaunchConfigurationDelegate.java
@@ -32,6 +32,7 @@ import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.ui.RefreshTab;
import org.eclipse.etrice.generator.base.AbstractGeneratorOptions;
import org.eclipse.etrice.generator.base.io.ILineOutput;
+import org.eclipse.etrice.generator.base.setup.GeneratorApplicationOptions;
import org.eclipse.etrice.generator.ui.preferences.PreferenceConstants;
import org.eclipse.jdt.launching.AbstractJavaLaunchConfigurationDelegate;
import org.eclipse.swt.widgets.Display;
@@ -211,7 +212,7 @@ public abstract class GeneratorLaunchConfigurationDelegate extends AbstractJavaL
|| configuration.getAttribute(GeneratorConfigTab.GEN_INSTANCE_DIAGRAM, false))
argString.append(" -"+AbstractGeneratorOptions.DOCUMENTATION.getName());
if (configuration.getAttribute(GeneratorConfigTab.DEBUG, false)) {
- argString.append(" -"+AbstractGeneratorOptions.LOGLEVEL.getName());
+ argString.append(" -"+GeneratorApplicationOptions.LOGLEVEL.getName());
argString.append(" debug");
}
if (configuration.getAttribute(GeneratorConfigTab.MSC_INSTR, false)) {
@@ -229,7 +230,7 @@ public abstract class GeneratorLaunchConfigurationDelegate extends AbstractJavaL
ScopedPreferenceStore prefStore = new ScopedPreferenceStore(InstanceScope.INSTANCE, "org.eclipse.etrice.generator.ui");
if (prefStore.getBoolean(PreferenceConstants.GEN_INCREMENTAL)) {
- argString.append(" -"+AbstractGeneratorOptions.GEN_INCREMENTAL.getName());
+ argString.append(" -"+GeneratorApplicationOptions.GEN_INCREMENTAL.getName());
}
boolean override = configuration.getAttribute(GeneratorConfigTab.OVERRIDE_DIRECTORIES, false);
@@ -241,10 +242,10 @@ public abstract class GeneratorLaunchConfigurationDelegate extends AbstractJavaL
infoDir = configuration.getAttribute(GeneratorConfigTab.INFO_PATH, infoDir);
docDir = configuration.getAttribute(GeneratorConfigTab.DOC_PATH, docDir);
}
- argString.append(" -"+AbstractGeneratorOptions.GEN_DIR.getName());
+ argString.append(" -"+GeneratorApplicationOptions.GEN_DIR.getName());
argString.append(" "+srcgenDir);
- argString.append(" -"+AbstractGeneratorOptions.GEN_INFO_DIR.getName());
+ argString.append(" -"+GeneratorApplicationOptions.GEN_INFO_DIR.getName());
argString.append(" "+infoDir);
argString.append(" -"+AbstractGeneratorOptions.GEN_DOC_DIR.getName());
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGenerator.java b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGenerator.java
index 78e752205..90b0d3359 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGenerator.java
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGenerator.java
@@ -41,6 +41,7 @@ import org.eclipse.etrice.generator.base.io.IGeneratorFileIO;
import org.eclipse.etrice.generator.base.io.ILineOutput;
import org.eclipse.etrice.generator.base.io.LineOutput;
import org.eclipse.etrice.generator.base.logging.ILogger;
+import org.eclipse.etrice.generator.base.setup.GeneratorApplicationOptions;
import org.eclipse.etrice.generator.fsm.generic.IDetailCodeTranslator;
import org.eclipse.etrice.generator.generic.RoomExtensions;
import org.eclipse.etrice.generator.generic.TestInstanceCreator;
@@ -154,8 +155,8 @@ public abstract class AbstractGenerator implements IGenerator, IDetailCodeTransl
@Override
public void generate(List<Resource> resources, Arguments arguments, IGeneratorFileIO fileIO, ILogger logger) {
AbstractGenerator.settings = arguments;
- RoomExtensions.setGenDir(arguments.get(AbstractGeneratorOptions.GEN_DIR));
- RoomExtensions.setGenInfoDir(arguments.get(AbstractGeneratorOptions.GEN_INFO_DIR));
+ RoomExtensions.setGenDir(arguments.get(GeneratorApplicationOptions.GEN_DIR));
+ RoomExtensions.setGenInfoDir(arguments.get(GeneratorApplicationOptions.GEN_INFO_DIR));
RoomExtensions.setGenDocDir(arguments.get(AbstractGeneratorOptions.GEN_DOC_DIR));
if(resources.isEmpty()) {
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGeneratorBaseModule.java b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGeneratorBaseModule.java
index 566c34d42..6820898a2 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGeneratorBaseModule.java
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGeneratorBaseModule.java
@@ -21,7 +21,7 @@ import org.eclipse.etrice.generator.base.io.IGeneratorEMFSetup;
import org.eclipse.etrice.generator.base.io.IGeneratorResourceLoader;
import org.eclipse.etrice.generator.base.io.IncrementalGeneratorFileIO;
import org.eclipse.etrice.generator.base.logging.Logger;
-import org.eclipse.etrice.generator.base.setup.GeneratorBaseModule;
+import org.eclipse.etrice.generator.base.setup.GeneratorApplicationModule;
import org.eclipse.etrice.generator.base.setup.GeneratorBaseOptions;
import org.eclipse.etrice.generator.base.validation.IGeneratorResourceValidator;
import org.eclipse.etrice.generator.fsm.base.Diagnostician;
@@ -44,7 +44,7 @@ import com.google.inject.Singleton;
*
* @author Henrik Rentz-Reichert
*/
-public abstract class AbstractGeneratorBaseModule extends GeneratorBaseModule {
+public abstract class AbstractGeneratorBaseModule extends GeneratorApplicationModule {
/**
* Configuration of
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGeneratorOptions.java b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGeneratorOptions.java
index 73fc6af5f..06a53788e 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGeneratorOptions.java
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/AbstractGeneratorOptions.java
@@ -24,55 +24,66 @@ import org.eclipse.etrice.generator.base.setup.GeneratorBaseOptions;
public class AbstractGeneratorOptions extends GeneratorBaseOptions {
+ public static final String GROUP_ETRICE = "eTrice";
+
public static final BooleanOption LIB = new BooleanOption(
+ GROUP_ETRICE,
"lib",
"generateAsLibrary",
"if specified all classes are generated, not only instanciated ones",
false);
public static final BooleanOption DOCUMENTATION = new BooleanOption(
+ GROUP_ETRICE,
"genDocu",
"generateDocumentation",
"if specified documentation is created",
false);
public static final StringOption SAVE_GEN_MODEL = new StringOption(
+ GROUP_ETRICE,
"saveGenModel",
"genmodel path",
"if specified the generator model will be saved to this location",
"");
public static final StringOption MAIN_NAME = new StringOption(
+ GROUP_ETRICE,
"mainName",
"name",
"if specified the generated main method will be named as stated",
"main");
public static final StringOption GEN_DOC_DIR = new StringOption(
+ GROUP_ETRICE,
"genDocDir",
"directory",
"the directory for generated documentation files",
"doc-gen");
public static final BooleanOption MSC_INSTR = new BooleanOption(
+ GROUP_ETRICE,
"msc_instr",
"generateMSCInstrumentation",
"generate instrumentation for MSC generation",
false);
public static final BooleanOption DATA_INSTR = new BooleanOption(
+ GROUP_ETRICE,
"data_instr",
"generateDataInstrumentation",
"generate instrumentation for data logging",
false);
public static final BooleanOption VERBOSE_RT = new BooleanOption(
+ GROUP_ETRICE,
"gen_as_verbose",
"generateWithVerboseOutput",
"generate instrumentation for verbose console output",
false);
public static final BooleanOption NOTRANSLATE = new BooleanOption(
+ GROUP_ETRICE,
"notranslate",
"noTranslation",
"if specified the detail codes won't be translated",
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/ModelLoader.java b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/ModelLoader.java
index 1b074a2c3..596d8615d 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/ModelLoader.java
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/base/ModelLoader.java
@@ -70,14 +70,14 @@ public class ModelLoader implements IGeneratorResourceLoader {
private HashSet<URI> loadedModelURIs = new HashSet<URI>();
@Override
- public List<Resource> load(Arguments arguments, ILogger logger) {
+ public List<Resource> load(List<String> files, Arguments arguments, ILogger logger) {
if(!initializedEMF) {
emfSetup.doEMFRegistration();
}
logger.logInfo("-- reading models");
- if(loadModels(arguments.getFiles(), logger)) {
+ if(loadModels(files, logger)) {
List<Resource> resources = getResourceSet().getResources().stream()
.filter(r -> getMainModelURIs().contains(r.getURI())).collect(Collectors.toList());
return resources;
diff --git a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/PrepareFileSystem.xtend b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/PrepareFileSystem.xtend
index c1cd60415..a9c667816 100644
--- a/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/PrepareFileSystem.xtend
+++ b/plugins/org.eclipse.etrice.generator/src/org/eclipse/etrice/generator/generic/PrepareFileSystem.xtend
@@ -25,7 +25,7 @@ import org.eclipse.etrice.core.genmodel.etricegen.Root
import org.eclipse.xtext.generator.JavaIoFileSystemAccess
import org.eclipse.etrice.generator.base.logging.ILogger
import org.eclipse.etrice.generator.base.AbstractGenerator
-import org.eclipse.etrice.generator.base.AbstractGeneratorOptions
+import org.eclipse.etrice.generator.base.setup.GeneratorApplicationOptions
/**
* A class that is used to recursively erase all folders receiving generated code
@@ -53,7 +53,7 @@ class PrepareFileSystem {
}
def void prepareInfoTargetPaths(Resource resource) {
- if(!AbstractGenerator.settings.get(AbstractGeneratorOptions.GEN_INCREMENTAL))
+ if(!AbstractGenerator.settings.get(GeneratorApplicationOptions.GEN_INCREMENTAL))
return;
var Set<String> pathes = new HashSet<String>();

Back to the top