67 JDK5("5"), 68 69 /** 1.6 reports encoding problems as errors instead of warnings. */ 70 JDK6("6"), 71 72 /** 1.7 introduced try-with-resources, multi-catch, string switch, etc. */ 73 JDK7("7"), 74 75 /** 1.8 lambda expressions and default methods. */ 76 JDK8("8"), 77 78 /** 1.9 modularity. */ 79 JDK9("9"), 80 81 /** 1.10 local-variable type inference (var). */ 82 JDK10("10"), 83 84 /** 1.11 local-variable syntax for lambda parameters */ 85 JDK11("11"), 86 87 /** 12, no language features; switch expression were in preview */ 88 JDK12("12"), 89 90 /** 91 * 13, no language features; text blocks and revised switch 92 * expressions in preview 93 */ 94 JDK13("13"), 95 96 /** 97 * 14 covers the to be determined language features that will be 98 * added in JDK 14. 99 */ 100 JDK14("14"); 101 102 private static final Context.Key<Source> sourceKey = new Context.Key<>(); 103 104 public static Source instance(Context context) { 105 Source instance = context.get(sourceKey); 106 if (instance == null) { 107 Options options = Options.instance(context); 108 String sourceString = options.get(SOURCE); 109 if (sourceString != null) instance = lookup(sourceString); 110 if (instance == null) instance = DEFAULT; 111 context.put(sourceKey, instance); 112 } 113 return instance; 114 } 115 116 public final String name; 117 118 private static final Map<String,Source> tab = new HashMap<>(); | 67 JDK5("5"), 68 69 /** 1.6 reports encoding problems as errors instead of warnings. */ 70 JDK6("6"), 71 72 /** 1.7 introduced try-with-resources, multi-catch, string switch, etc. */ 73 JDK7("7"), 74 75 /** 1.8 lambda expressions and default methods. */ 76 JDK8("8"), 77 78 /** 1.9 modularity. */ 79 JDK9("9"), 80 81 /** 1.10 local-variable type inference (var). */ 82 JDK10("10"), 83 84 /** 1.11 local-variable syntax for lambda parameters */ 85 JDK11("11"), 86 87 /** 12, no language features; switch expression in preview */ 88 JDK12("12"), 89 90 /** 91 * 13, no language features; text blocks and revised switch 92 * expressions in preview 93 */ 94 JDK13("13"), 95 96 /** 97 * 14, switch expressions 98 */ 99 JDK14("14"); 100 101 private static final Context.Key<Source> sourceKey = new Context.Key<>(); 102 103 public static Source instance(Context context) { 104 Source instance = context.get(sourceKey); 105 if (instance == null) { 106 Options options = Options.instance(context); 107 String sourceString = options.get(SOURCE); 108 if (sourceString != null) instance = lookup(sourceString); 109 if (instance == null) instance = DEFAULT; 110 context.put(sourceKey, instance); 111 } 112 return instance; 113 } 114 115 public final String name; 116 117 private static final Map<String,Source> tab = new HashMap<>(); |