Search in sources :

Example 1 with RawOption

use of org.erlide.core.builder.CompilerOption.RawOption in project erlide_eclipse by erlang.

the class CompilerOptions method store.

public void store() throws BackingStoreException {
    for (final CompilerOption option : ALL_OPTIONS) {
        final Object value = options.get(option);
        if (option instanceof BooleanOption) {
            final Boolean val = (Boolean) value;
            helper.putString(option.getName(), val.toString());
        } else if (option instanceof PathsOption) {
            if (value != null) {
                @SuppressWarnings("unchecked") final Iterable<String> avalue = (Iterable<String>) value;
                helper.putString(option.getName(), PathsOption.toString(avalue));
            } else {
                helper.remove(option.getName());
            }
        } else if (option instanceof ModuleOption) {
            if (value != null) {
                final String avalue = (String) value;
                helper.putString(option.getName(), avalue);
            } else {
                helper.remove(option.getName());
            }
        } else if (option instanceof RawOption) {
            if (value != null) {
                final String avalue = (String) value;
                helper.putString(option.getName(), avalue);
            } else {
                helper.remove(option.getName());
            }
        } else {
            if (value != null) {
                @SuppressWarnings("unchecked") final Collection<Pair<String, String>> val = (Collection<Pair<String, String>>) value;
                helper.putString(option.getName(), val.toString());
            } else {
                helper.remove(option.getName());
            }
        }
    }
    helper.flush();
}
Also used : ModuleOption(org.erlide.core.builder.CompilerOption.ModuleOption) PathsOption(org.erlide.core.builder.CompilerOption.PathsOption) Collection(java.util.Collection) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) BooleanOption(org.erlide.core.builder.CompilerOption.BooleanOption) RawOption(org.erlide.core.builder.CompilerOption.RawOption) Pair(org.eclipse.xtext.xbase.lib.Pair)

Example 2 with RawOption

use of org.erlide.core.builder.CompilerOption.RawOption in project erlide_eclipse by erlang.

the class CompilerOptions method export.

@SuppressWarnings("unchecked")
public OtpErlangList export() {
    final List<OtpErlangObject> result = new ArrayList<>();
    for (final CompilerOption option : ALL_OPTIONS) {
        final Object optionValue = options.get(option);
        if (optionValue != null) {
            if (option instanceof BooleanOption) {
                final OtpErlangObject val = ((BooleanOption) option).toTerm((Boolean) optionValue);
                if (val != null) {
                    result.add(val);
                }
            } else if (option instanceof PathsOption) {
                final Iterable<String> value = (Iterable<String>) optionValue;
                final OtpErlangList val = (OtpErlangList) ((PathsOption) option).toTerm(value);
                for (final OtpErlangObject inc : val.elements()) {
                    result.add(inc);
                }
            } else if (option instanceof ModuleOption) {
                final String value = (String) optionValue;
                final OtpErlangObject val = ((ModuleOption) option).toTerm(value);
                result.add(val);
            } else if (option instanceof RawOption) {
                final String value = (String) optionValue;
                final OtpErlangList val = (OtpErlangList) ((RawOption) option).toTerm(value);
                for (final OtpErlangObject item : val.elements()) {
                    result.add(item);
                }
            } else {
                try {
                    final OtpErlangList val = ((DefineOption) option).toTerm((List<Pair<String, String>>) optionValue);
                    if (val != null) {
                        result.addAll(Lists.newArrayList(val.elements()));
                    }
                } catch (final OtpParserException e) {
                    ErlLogger.warn(e);
                }
            }
        }
    }
    final OtpErlangList list = OtpErlang.mkList(result);
    return list;
}
Also used : OtpErlangList(com.ericsson.otp.erlang.OtpErlangList) OtpParserException(org.erlide.util.erlang.OtpParserException) PathsOption(org.erlide.core.builder.CompilerOption.PathsOption) ArrayList(java.util.ArrayList) RawOption(org.erlide.core.builder.CompilerOption.RawOption) ModuleOption(org.erlide.core.builder.CompilerOption.ModuleOption) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) OtpErlangObject(com.ericsson.otp.erlang.OtpErlangObject) ArrayList(java.util.ArrayList) OtpErlangList(com.ericsson.otp.erlang.OtpErlangList) List(java.util.List) BooleanOption(org.erlide.core.builder.CompilerOption.BooleanOption)

Aggregations

OtpErlangObject (com.ericsson.otp.erlang.OtpErlangObject)2 BooleanOption (org.erlide.core.builder.CompilerOption.BooleanOption)2 ModuleOption (org.erlide.core.builder.CompilerOption.ModuleOption)2 PathsOption (org.erlide.core.builder.CompilerOption.PathsOption)2 RawOption (org.erlide.core.builder.CompilerOption.RawOption)2 OtpErlangList (com.ericsson.otp.erlang.OtpErlangList)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 List (java.util.List)1 Pair (org.eclipse.xtext.xbase.lib.Pair)1 OtpParserException (org.erlide.util.erlang.OtpParserException)1