brandjon | 60be531 | 2017-10-04 23:06:41 +0200 | [diff] [blame] | 1 | // Copyright 2017 The Bazel Authors. All rights reserved. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | package com.google.devtools.build.lib.syntax; |
| 16 | |
| 17 | import com.google.auto.value.AutoValue; |
| 18 | |
| 19 | /** |
| 20 | * Options that affect Skylark semantics. |
| 21 | * |
| 22 | * <p>For descriptions of what these options do, see {@link SkylarkSemanticsOptions}. |
| 23 | */ |
| 24 | // TODO(brandjon): User error messages that reference options should maybe be substituted with the |
| 25 | // option name outside of the core Skylark interpreter? |
| 26 | // TODO(brandjon): Eventually these should be documented in full here, and SkylarkSemanticsOptions |
| 27 | // should refer to this class for documentation. But this doesn't play nice with the options |
| 28 | // parser's annotation mechanism. |
| 29 | @AutoValue |
| 30 | public abstract class SkylarkSemantics { |
| 31 | |
brandjon | 617f8ff | 2017-10-06 06:07:13 +0200 | [diff] [blame] | 32 | /** |
| 33 | * The AutoValue-generated concrete class implementing this one. |
| 34 | * |
| 35 | * <p>AutoValue implementation classes are usually package-private. We expose it here for the |
| 36 | * benefit of code that relies on reflection. |
| 37 | */ |
| 38 | public static final Class<? extends SkylarkSemantics> IMPL_CLASS = |
| 39 | AutoValue_SkylarkSemantics.class; |
| 40 | |
brandjon | 60be531 | 2017-10-04 23:06:41 +0200 | [diff] [blame] | 41 | // <== Add new options here in alphabetic order ==> |
| 42 | public abstract boolean incompatibleBzlDisallowLoadAfterStatement(); |
| 43 | public abstract boolean incompatibleCheckedArithmetic(); |
| 44 | public abstract boolean incompatibleComprehensionVariablesDoNotLeak(); |
| 45 | public abstract boolean incompatibleDepsetIsNotIterable(); |
laurentlb | 2bbda4a | 2017-12-07 10:38:46 -0800 | [diff] [blame] | 46 | |
| 47 | public abstract boolean incompatibleDepsetUnion(); |
| 48 | |
brandjon | 60be531 | 2017-10-04 23:06:41 +0200 | [diff] [blame] | 49 | public abstract boolean incompatibleDictLiteralHasNoDuplicates(); |
laurentlb | d7f87aa | 2017-12-12 07:55:15 -0800 | [diff] [blame] | 50 | |
| 51 | public abstract boolean incompatibleDisableGlobTracking(); |
| 52 | |
brandjon | 60be531 | 2017-10-04 23:06:41 +0200 | [diff] [blame] | 53 | public abstract boolean incompatibleDisallowDictPlus(); |
| 54 | public abstract boolean incompatibleDisallowKeywordOnlyArgs(); |
brandjon | 60be531 | 2017-10-04 23:06:41 +0200 | [diff] [blame] | 55 | public abstract boolean incompatibleDisallowToplevelIfStatement(); |
vladmos | 9bb93ee | 2017-11-21 04:40:08 -0800 | [diff] [blame] | 56 | public abstract boolean incompatibleDisallowUncalledSetConstructor(); |
brandjon | 60be531 | 2017-10-04 23:06:41 +0200 | [diff] [blame] | 57 | public abstract boolean incompatibleLoadArgumentIsLabel(); |
| 58 | public abstract boolean incompatibleNewActionsApi(); |
vladmos | 1df4635 | 2017-11-30 03:02:36 -0800 | [diff] [blame] | 59 | public abstract boolean incompatibleShowAllPrintMessages(); |
brandjon | 60be531 | 2017-10-04 23:06:41 +0200 | [diff] [blame] | 60 | public abstract boolean incompatibleStringIsNotIterable(); |
brandjon | 60be531 | 2017-10-04 23:06:41 +0200 | [diff] [blame] | 61 | public abstract boolean internalSkylarkFlagTestCanary(); |
| 62 | |
brandjon | 6ac92f9 | 2017-12-06 13:57:15 -0800 | [diff] [blame] | 63 | /** Returns a {@link Builder} initialized with the values of this instance. */ |
| 64 | public abstract Builder toBuilder(); |
| 65 | |
brandjon | 60be531 | 2017-10-04 23:06:41 +0200 | [diff] [blame] | 66 | public static Builder builder() { |
| 67 | return new AutoValue_SkylarkSemantics.Builder(); |
| 68 | } |
| 69 | |
brandjon | 6ac92f9 | 2017-12-06 13:57:15 -0800 | [diff] [blame] | 70 | /** Returns a {@link Builder} initialized with default values for all options. */ |
| 71 | public static Builder builderWithDefaults() { |
| 72 | return DEFAULT_SEMANTICS.toBuilder(); |
| 73 | } |
| 74 | |
vladmos | 1df4635 | 2017-11-30 03:02:36 -0800 | [diff] [blame] | 75 | public static final SkylarkSemantics DEFAULT_SEMANTICS = |
| 76 | builder() |
| 77 | // <== Add new options here in alphabetic order ==> |
| 78 | .incompatibleBzlDisallowLoadAfterStatement(false) |
| 79 | .incompatibleCheckedArithmetic(true) |
| 80 | .incompatibleComprehensionVariablesDoNotLeak(true) |
| 81 | .incompatibleDepsetIsNotIterable(false) |
laurentlb | 2bbda4a | 2017-12-07 10:38:46 -0800 | [diff] [blame] | 82 | .incompatibleDepsetUnion(false) |
vladmos | 1df4635 | 2017-11-30 03:02:36 -0800 | [diff] [blame] | 83 | .incompatibleDictLiteralHasNoDuplicates(true) |
laurentlb | d7f87aa | 2017-12-12 07:55:15 -0800 | [diff] [blame] | 84 | .incompatibleDisableGlobTracking(false) |
vladmos | 1df4635 | 2017-11-30 03:02:36 -0800 | [diff] [blame] | 85 | .incompatibleDisallowDictPlus(false) |
| 86 | .incompatibleDisallowKeywordOnlyArgs(true) |
| 87 | .incompatibleDisallowToplevelIfStatement(true) |
vladmos | 3132024 | 2017-12-06 06:02:01 -0800 | [diff] [blame] | 88 | .incompatibleDisallowUncalledSetConstructor(true) |
laurentlb | 7cf1c69 | 2017-12-04 05:44:54 -0800 | [diff] [blame] | 89 | .incompatibleLoadArgumentIsLabel(true) |
vladmos | 1df4635 | 2017-11-30 03:02:36 -0800 | [diff] [blame] | 90 | .incompatibleNewActionsApi(false) |
| 91 | .incompatibleShowAllPrintMessages(true) |
brandjon | 85e8d51 | 2017-12-21 16:57:31 -0800 | [diff] [blame^] | 92 | .incompatibleStringIsNotIterable(false) |
| 93 | .internalSkylarkFlagTestCanary(false) |
| 94 | .build(); |
brandjon | 60be531 | 2017-10-04 23:06:41 +0200 | [diff] [blame] | 95 | |
| 96 | /** Builder for {@link SkylarkSemantics}. All fields are mandatory. */ |
| 97 | @AutoValue.Builder |
| 98 | public abstract static class Builder { |
| 99 | |
| 100 | // <== Add new options here in alphabetic order ==> |
| 101 | public abstract Builder incompatibleBzlDisallowLoadAfterStatement(boolean value); |
| 102 | public abstract Builder incompatibleCheckedArithmetic(boolean value); |
| 103 | public abstract Builder incompatibleComprehensionVariablesDoNotLeak(boolean value); |
| 104 | public abstract Builder incompatibleDepsetIsNotIterable(boolean value); |
laurentlb | 2bbda4a | 2017-12-07 10:38:46 -0800 | [diff] [blame] | 105 | |
| 106 | public abstract Builder incompatibleDepsetUnion(boolean value); |
| 107 | |
brandjon | 60be531 | 2017-10-04 23:06:41 +0200 | [diff] [blame] | 108 | public abstract Builder incompatibleDictLiteralHasNoDuplicates(boolean value); |
laurentlb | d7f87aa | 2017-12-12 07:55:15 -0800 | [diff] [blame] | 109 | |
| 110 | public abstract Builder incompatibleDisableGlobTracking(boolean value); |
| 111 | |
brandjon | 60be531 | 2017-10-04 23:06:41 +0200 | [diff] [blame] | 112 | public abstract Builder incompatibleDisallowDictPlus(boolean value); |
| 113 | public abstract Builder incompatibleDisallowKeywordOnlyArgs(boolean value); |
brandjon | 60be531 | 2017-10-04 23:06:41 +0200 | [diff] [blame] | 114 | public abstract Builder incompatibleDisallowToplevelIfStatement(boolean value); |
vladmos | 9bb93ee | 2017-11-21 04:40:08 -0800 | [diff] [blame] | 115 | public abstract Builder incompatibleDisallowUncalledSetConstructor(boolean value); |
brandjon | 60be531 | 2017-10-04 23:06:41 +0200 | [diff] [blame] | 116 | public abstract Builder incompatibleLoadArgumentIsLabel(boolean value); |
| 117 | public abstract Builder incompatibleNewActionsApi(boolean value); |
vladmos | 1df4635 | 2017-11-30 03:02:36 -0800 | [diff] [blame] | 118 | public abstract Builder incompatibleShowAllPrintMessages(boolean value); |
brandjon | 60be531 | 2017-10-04 23:06:41 +0200 | [diff] [blame] | 119 | public abstract Builder incompatibleStringIsNotIterable(boolean value); |
brandjon | 60be531 | 2017-10-04 23:06:41 +0200 | [diff] [blame] | 120 | public abstract Builder internalSkylarkFlagTestCanary(boolean value); |
| 121 | |
| 122 | public abstract SkylarkSemantics build(); |
| 123 | } |
| 124 | } |