148 if (!lint.isSuppressed(LintCategory.PREVIEW)) {
149 previewHandler.report(null,
150 Warnings.PreviewFeatureUseClassfile(classfile, majorVersionToSource.get(majorVersion).name));
151 }
152 }
153
154 /**
155 * Are preview features enabled?
156 * @return true, if preview features are enabled.
157 */
158 public boolean isEnabled() {
159 return enabled;
160 }
161
162 /**
163 * Is given feature a preview feature?
164 * @param feature the feature to be tested.
165 * @return true, if given feature is a preview feature.
166 */
167 public boolean isPreview(Feature feature) {
168 //Note: this is a backdoor which allows to optionally treat all features as 'preview' (for testing).
169 //When real preview features will be added, this method can be implemented to return 'true'
170 //for those selected features, and 'false' for all the others.
171 return forcePreview;
172 }
173
174 /**
175 * Generate an error key which captures the fact that a given preview feature could not be used
176 * due to the preview feature support being disabled.
177 * @param feature the feature for which the diagnostic has to be generated.
178 * @return the diagnostic.
179 */
180 public Error disabledError(Feature feature) {
181 Assert.check(!isEnabled());
182 return feature.isPlural() ?
183 Errors.PreviewFeatureDisabledPlural(feature.nameFragment()) :
184 Errors.PreviewFeatureDisabled(feature.nameFragment());
185 }
186
187 /**
|
148 if (!lint.isSuppressed(LintCategory.PREVIEW)) {
149 previewHandler.report(null,
150 Warnings.PreviewFeatureUseClassfile(classfile, majorVersionToSource.get(majorVersion).name));
151 }
152 }
153
154 /**
155 * Are preview features enabled?
156 * @return true, if preview features are enabled.
157 */
158 public boolean isEnabled() {
159 return enabled;
160 }
161
162 /**
163 * Is given feature a preview feature?
164 * @param feature the feature to be tested.
165 * @return true, if given feature is a preview feature.
166 */
167 public boolean isPreview(Feature feature) {
168 if (feature == Feature.SWITCH_EXPRESSION ||
169 feature == Feature.SWITCH_MULTIPLE_CASE_LABELS ||
170 feature == Feature.SWITCH_RULE)
171 return true;
172 //Note: this is a backdoor which allows to optionally treat all features as 'preview' (for testing).
173 //When real preview features will be added, this method can be implemented to return 'true'
174 //for those selected features, and 'false' for all the others.
175 return forcePreview;
176 }
177
178 /**
179 * Generate an error key which captures the fact that a given preview feature could not be used
180 * due to the preview feature support being disabled.
181 * @param feature the feature for which the diagnostic has to be generated.
182 * @return the diagnostic.
183 */
184 public Error disabledError(Feature feature) {
185 Assert.check(!isEnabled());
186 return feature.isPlural() ?
187 Errors.PreviewFeatureDisabledPlural(feature.nameFragment()) :
188 Errors.PreviewFeatureDisabled(feature.nameFragment());
189 }
190
191 /**
|