27 |
27 |
28 import java.util.ArrayList; |
28 import java.util.ArrayList; |
29 |
29 |
30 import com.sun.source.tree.LambdaExpressionTree; |
30 import com.sun.source.tree.LambdaExpressionTree; |
31 import com.sun.tools.javac.code.Source; |
31 import com.sun.tools.javac.code.Source; |
|
32 import com.sun.tools.javac.code.Source.Feature; |
32 import com.sun.tools.javac.code.Type; |
33 import com.sun.tools.javac.code.Type; |
33 import com.sun.tools.javac.code.Types; |
34 import com.sun.tools.javac.code.Types; |
34 import com.sun.tools.javac.comp.ArgumentAttr.LocalCacheContext; |
35 import com.sun.tools.javac.comp.ArgumentAttr.LocalCacheContext; |
35 import com.sun.tools.javac.resources.CompilerProperties.Warnings; |
36 import com.sun.tools.javac.resources.CompilerProperties.Warnings; |
36 import com.sun.tools.javac.tree.JCTree; |
37 import com.sun.tools.javac.tree.JCTree; |
126 copier = new AnalyzerCopier(); |
127 copier = new AnalyzerCopier(); |
127 Options options = Options.instance(context); |
128 Options options = Options.instance(context); |
128 String findOpt = options.get("find"); |
129 String findOpt = options.get("find"); |
129 //parse modes |
130 //parse modes |
130 Source source = Source.instance(context); |
131 Source source = Source.instance(context); |
131 allowDiamondWithAnonymousClassCreation = source.allowDiamondWithAnonymousClassCreation(); |
132 allowDiamondWithAnonymousClassCreation = Feature.DIAMOND_WITH_ANONYMOUS_CLASS_CREATION.allowedInSource(source); |
132 analyzerModes = AnalyzerMode.getAnalyzerModes(findOpt, source); |
133 analyzerModes = AnalyzerMode.getAnalyzerModes(findOpt, source); |
133 } |
134 } |
134 |
135 |
135 /** |
136 /** |
136 * This enum defines supported analyzer modes, as well as defining the logic for decoding |
137 * This enum defines supported analyzer modes, as well as defining the logic for decoding |
137 * the {@code -XDfind} option. |
138 * the {@code -XDfind} option. |
138 */ |
139 */ |
139 enum AnalyzerMode { |
140 enum AnalyzerMode { |
140 DIAMOND("diamond", Source::allowDiamond), |
141 DIAMOND("diamond", Feature.DIAMOND), |
141 LAMBDA("lambda", Source::allowLambda), |
142 LAMBDA("lambda", Feature.LAMBDA), |
142 METHOD("method", Source::allowGraphInference), |
143 METHOD("method", Feature.GRAPH_INFERENCE), |
143 LOCAL("local", Source::allowLocalVariableTypeInference); |
144 LOCAL("local", Feature.LOCAL_VARIABLE_TYPE_INFERENCE); |
144 |
145 |
145 final String opt; |
146 final String opt; |
146 final Predicate<Source> sourceFilter; |
147 final Feature feature; |
147 |
148 |
148 AnalyzerMode(String opt, Predicate<Source> sourceFilter) { |
149 AnalyzerMode(String opt, Feature feature) { |
149 this.opt = opt; |
150 this.opt = opt; |
150 this.sourceFilter = sourceFilter; |
151 this.feature = feature; |
151 } |
152 } |
152 |
153 |
153 /** |
154 /** |
154 * This method is used to parse the {@code find} option. |
155 * This method is used to parse the {@code find} option. |
155 * Possible modes are separated by colon; a mode can be excluded by |
156 * Possible modes are separated by colon; a mode can be excluded by |