diff options
author | Roel Spilker <r.spilker@gmail.com> | 2016-11-22 00:37:07 +0100 |
---|---|---|
committer | Roel Spilker <r.spilker@gmail.com> | 2016-11-22 00:37:07 +0100 |
commit | d6f1116108754152377cb1e0e276dedb7ffabbab (patch) | |
tree | c5cf699157af47de3800c711855a798ad38b00b6 /src/core | |
parent | 8c2ea4fbc64e8b7b4e553a6f8b9363eb0b70d76a (diff) | |
download | lombok-d6f1116108754152377cb1e0e276dedb7ffabbab.tar.gz lombok-d6f1116108754152377cb1e0e276dedb7ffabbab.tar.bz2 lombok-d6f1116108754152377cb1e0e276dedb7ffabbab.zip |
`var` can now also be configured to emit a warning when used.
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/lombok/core/configuration/AllowHelper.java | 22 | ||||
-rw-r--r-- | src/core/lombok/core/handlers/HandlerUtil.java | 7 |
2 files changed, 14 insertions, 15 deletions
diff --git a/src/core/lombok/core/configuration/AllowHelper.java b/src/core/lombok/core/configuration/AllowHelper.java index 31d09381..3873b055 100644 --- a/src/core/lombok/core/configuration/AllowHelper.java +++ b/src/core/lombok/core/configuration/AllowHelper.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2014 The Project Lombok Authors. + * Copyright (C) 2016 The Project Lombok Authors. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -21,17 +21,19 @@ */ package lombok.core.configuration; -import java.util.HashSet; -import java.util.Set; +import java.util.Collection; +import java.util.Collections; -import static java.util.Arrays.asList; +import lombok.ConfigurationKeys; -public class AllowHelper { - private final static Set<String> allowable = new HashSet<String>(asList( - "var" - )); +public final class AllowHelper { + private final static Collection<? extends ConfigurationKey<?>> ALLOWABLE = Collections.singleton(ConfigurationKeys.VAR_FLAG_USAGE); - public static boolean isAllowable(String feature) { - return allowable.contains(feature); + private AllowHelper() { + // Prevent instantiation + } + + public static boolean isAllowable(ConfigurationKey<?> key) { + return ALLOWABLE.contains(key); } } diff --git a/src/core/lombok/core/handlers/HandlerUtil.java b/src/core/lombok/core/handlers/HandlerUtil.java index a321e67f..ef4ac7d6 100644 --- a/src/core/lombok/core/handlers/HandlerUtil.java +++ b/src/core/lombok/core/handlers/HandlerUtil.java @@ -96,13 +96,10 @@ public class HandlerUtil { return Singulars.autoSingularize(plural); } public static void handleFlagUsage(LombokNode<?, ?, ?> node, ConfigurationKey<FlagUsageType> key, String featureName) { - boolean allowable = AllowHelper.isAllowable(featureName); - FlagUsageType fut = node.getAst().readConfiguration(key); - boolean allowed = !allowable || FlagUsageType.ALLOW == fut; - if (!allowed) { - node.addError("Use of " + featureName + " is disabled by default. Please use flag " + FlagUsageType.ALLOW + " to enable."); + if (fut == null && AllowHelper.isAllowable(key)) { + node.addError("Use of " + featureName + " is disabled by default. Please add '" + key.getKeyName() + " = " + FlagUsageType.ALLOW + "' to 'lombok.config' if you want to enable is."); } if (fut != null) { |