< prev index next >

src/jdk.compiler/share/classes/com/sun/tools/javac/code/Preview.java

Print this page
rev 56806 : 8232684: Make switch expressions final
Reviewed-by: TBD


 148     }
 149 
 150     public void reportPreviewWarning(DiagnosticPosition pos, Warning warnKey) {
 151         previewHandler.report(pos, warnKey);
 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             feature == Feature.TEXT_BLOCKS)
 172             return true;
 173         //Note: this is a backdoor which allows to optionally treat all features as 'preview' (for testing).
 174         //When real preview features will be added, this method can be implemented to return 'true'
 175         //for those selected features, and 'false' for all the others.
 176         return forcePreview;
 177     }
 178 
 179     /**
 180      * Generate an error key which captures the fact that a given preview feature could not be used
 181      * due to the preview feature support being disabled.
 182      * @param feature the feature for which the diagnostic has to be generated.
 183      * @return the diagnostic.
 184      */
 185     public Error disabledError(Feature feature) {
 186         Assert.check(!isEnabled());
 187         return feature.isPlural() ?
 188                 Errors.PreviewFeatureDisabledPlural(feature.nameFragment()) :
 189                 Errors.PreviewFeatureDisabled(feature.nameFragment());
 190     }
 191 




 148     }
 149 
 150     public void reportPreviewWarning(DiagnosticPosition pos, Warning warnKey) {
 151         previewHandler.report(pos, warnKey);
 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.TEXT_BLOCKS)



 169             return true;
 170         //Note: this is a backdoor which allows to optionally treat all features as 'preview' (for testing).
 171         //When real preview features will be added, this method can be implemented to return 'true'
 172         //for those selected features, and 'false' for all the others.
 173         return forcePreview;
 174     }
 175 
 176     /**
 177      * Generate an error key which captures the fact that a given preview feature could not be used
 178      * due to the preview feature support being disabled.
 179      * @param feature the feature for which the diagnostic has to be generated.
 180      * @return the diagnostic.
 181      */
 182     public Error disabledError(Feature feature) {
 183         Assert.check(!isEnabled());
 184         return feature.isPlural() ?
 185                 Errors.PreviewFeatureDisabledPlural(feature.nameFragment()) :
 186                 Errors.PreviewFeatureDisabled(feature.nameFragment());
 187     }
 188 


< prev index next >