package net.ssehub.kernel_haven.typechef.wrapper;

import static net.ssehub.kernel_haven.config.Setting.Type.BOOLEAN;
import static net.ssehub.kernel_haven.config.Setting.Type.DIRECTORY;
import static net.ssehub.kernel_haven.config.Setting.Type.FILE;
import static net.ssehub.kernel_haven.config.Setting.Type.INTEGER;
import static net.ssehub.kernel_haven.config.Setting.Type.SETTING_LIST;
import static net.ssehub.kernel_haven.config.Setting.Type.STRING;

import java.io.File;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import net.ssehub.kernel_haven.SetUpException;
import net.ssehub.kernel_haven.config.Configuration;
import net.ssehub.kernel_haven.config.EnumSetting;
import net.ssehub.kernel_haven.config.Setting;

/**
 * Settings used to configure typechef.
 *
 * @author Adam
 */
public class TypeChefSettings {
    
    public static final Setting<Boolean> IGNORE_OTHER_MODELS
        = new Setting<>("code.extractor.ignore_other_models", BOOLEAN, true, "false", "TODO");
    
    /**
     * Different types of parsing results.
     */
    public static enum ParseType {
        FULL_AST,
        ONLY_C_AST,
        LEXER,
    }
    
    public static final Setting<ParseType> PARSE_TYPE
        = new EnumSetting<ParseType>("code.extractor.parse_type", ParseType.class, true, null,
            "Specifies the granularity of the translation result:\n"
            + " - " + ParseType.LEXER + ": Stops the translation after the lexer and returns a flat list of presence "
            + "conditions only\n"
            + " - " + ParseType.ONLY_C_AST + ": Translates the content of the C-Code only. This includes also embedded "
            + "marco class of a C-functions. However, this will skip all header-specific elements, which are not "
            + "nested inside a C-code element. For instance, these may be structs or function declarations.\n"
            + " - " + ParseType.FULL_AST + ": These will generate a full AST. This will also include definitions of "
            + "included headers, even if this code is not embedded of a C-code. This facilitates more detailed "
            + "analyses like data flow analysis. However, this requires significantly more hard drive space if the "
            + "result is cached.");
    
    public static final Setting<File> SYSTEM_ROOT
        = new Setting<>("code.extractor.system_root", DIRECTORY, true, "/", "TODO");
    
    public static final Setting<Boolean> SKIP_DEFAULT_INCLUDE_DIRS
        = new Setting<>("code.extractor.skip_default_include_dirs", BOOLEAN, true, "false", "TODO");
    
    public static final Setting<String> PROCES_RAM
        = new Setting<>("code.extractor.process_ram", STRING, true, "15g", "TODO");

    public static final Setting<List<String>> STATIC_INCLUDES
        = new Setting<>("code.extractor.static_include", SETTING_LIST, false, null, "TODO");
    
    public static final Setting<List<String>> POST_INCLUDE_DIRS
        = new Setting<>("code.extractor.post_include_dir", SETTING_LIST, false, null, "TODO");
    
    public static final Setting<List<String>> SOURCE_INCLUDE_DIRS
        = new Setting<>("code.extractor.source_include_dir", SETTING_LIST, false, null, "TODO");
    
    public static final Setting<Boolean> ADD_LINUX_SOURCE_INCLUDE_DIRS
        = new Setting<>("code.extractor.add_linux_source_include_dirs", BOOLEAN, true, "false", "TODO");
    
    public static final Setting<List<String>> PREPROCESSOR_DEFINES
        = new Setting<>("code.extractor.preprocessor_define", SETTING_LIST, false, null, "TODO");
    
    public static final Setting<File> KBUILDPARAM_FILE
        = new Setting<>("code.extractor.kbuildparam_file", FILE, false, null, "TODO");
    
    public static final Setting<File> PLATFORM_HEADER
        = new Setting<>("code.extractor.platform_header", FILE, false, null, "TODO");
    
    public static final Setting<File> OPEN_VARIABLES_FILE
        = new Setting<>("code.extractor.open_variables", FILE, false, null, "TODO");
    
    public static final Setting<File> SMALL_FEATURE_MODEL_FILE
        = new Setting<>("code.extractor.small_feature_model", FILE, false, null, "TODO");
        
    public static final Setting<Integer> MAX_RECEIVING_THREADS
        = new Setting<>("code.extractor.max_receiving_threads", INTEGER, true, "0", "TODO");
    
    public static final Setting<Boolean> DEBUG_CALL_IN_SAME_VM
        = new Setting<>("code.extractor.debug.call_in_same_vm", BOOLEAN, true, "false", "TODO");
    
    public static final Setting<Boolean> DEBUG_LOG_CALL_PARAMS
        = new Setting<>("ode.extractor.debug.log_call_params", BOOLEAN, true, "false", "TODO");
    
    public static final Setting<Boolean> DEBUG_INHERIT_OUTPUT
        = new Setting<>("code.extractor.debug.inherit_output", BOOLEAN, true, "false", "TODO");
    
    /**
     * Holds all declared setting constants.
     */
    private static final Set<Setting<?>> SETTINGS = new HashSet<>();
    
    static {
        for (Field field : TypeChefSettings.class.getFields()) {
            if (Setting.class.isAssignableFrom(field.getType())
                    && Modifier.isStatic(field.getModifiers()) && Modifier.isFinal(field.getModifiers())) {
                try {
                    SETTINGS.add((Setting<?>) field.get(null));
                } catch (IllegalArgumentException | IllegalAccessException e) {
                    e.printStackTrace();
                }
            }
        }
    }
    
    /**
     * Don't allow instance of this class.
     */
    private TypeChefSettings() {
    }
    
    /**
     * Registers all settings declared in this class to the given configuration object.
     * 
     * @param config The configuration to register the settings to.
     * 
     * @throws SetUpException If any setting restrictions are violated.
     */
    public static void registerAllSettings(Configuration config) throws SetUpException {
        for (Setting<?> setting : SETTINGS) {
            config.registerSetting(setting);
        }
    }
    
}

@@ -1566,17 +1566,18 @@
 presence
- 
+%5Cn
 %22%0A      
@@ -1585,16 +1585,19 @@
      + %22
+   
 conditio
@@ -1716,26 +1716,18 @@
 des also
- embedded 
+%5Cn
 %22%0A      
@@ -1735,16 +1735,28 @@
      + %22
+   embedded 
 marco cl
@@ -1804,16 +1804,37 @@
 skip all
+%5Cn%22%0A            + %22  
  header-
@@ -1866,33 +1866,16 @@
 are not 
-%22%0A            + %22
 nested i
@@ -1897,16 +1897,37 @@
 element.
+%5Cn%22%0A            + %22  
  For ins
@@ -2095,20 +2095,18 @@
 initions
- of 
+%5Cn
 %22%0A      
@@ -2114,16 +2114,22 @@
      + %22
+   of 
 included
@@ -2189,16 +2189,37 @@
 de. This
+%5Cn%22%0A            + %22  
  facilit
@@ -2237,33 +2237,16 @@
 etailed 
-%22%0A            + %22
 analyses
@@ -2284,16 +2284,37 @@
 er, this
+%5Cn%22%0A            + %22  
  require
@@ -2358,33 +2358,16 @@
  if the 
-%22%0A            + %22
 result i

Correct line breaks for description text