< prev index next >

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

Print this page




 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             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 


 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 
< prev index next >