java: compiler compliance option encapsulated

This commit is contained in:
Roman Shevchenko
2015-05-11 12:23:27 +02:00
parent 6d2e193373
commit 6f605b245c
2 changed files with 21 additions and 15 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2013 JetBrains s.r.o.
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -749,18 +749,7 @@ public class JavaBuilder extends ModuleLevelBuilder {
private static String getLanguageLevel(JpsModule module) {
final LanguageLevel level = JpsJavaExtensionService.getInstance().getLanguageLevel(module);
if (level != null) {
switch (level) {
case JDK_1_3: return "1.3";
case JDK_1_4: return "1.4";
case JDK_1_5: return "1.5";
case JDK_1_6: return "1.6";
case JDK_1_7: return "1.7";
case JDK_1_8: return "8";
case JDK_1_9: return "9";
}
}
return null;
return level != null ? level.getComplianceOption() : null;
}
private static boolean isEncodingSet(List<String> options) {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2012 JetBrains s.r.o.
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,9 +15,26 @@
*/
package org.jetbrains.jps.model.java;
import org.jetbrains.annotations.NotNull;
/**
* @author nik
*/
public enum LanguageLevel {
JDK_1_3, JDK_1_4, JDK_1_5, JDK_1_6, JDK_1_7, JDK_1_8, JDK_1_9
JDK_1_3("1.3"), JDK_1_4("1.4"), JDK_1_5("1.5"), JDK_1_6("1.6"), JDK_1_7("1.7"), JDK_1_8("1.8"), JDK_1_9("1.9");
private final String myComplianceOption;
LanguageLevel(String complianceOption) {
myComplianceOption = complianceOption;
}
/**
* String representation of the level, suitable to pass as a value of compiler's "-source" and "-target" options.
* Should work for Javac and ECJ (including ECJ-based) compilers.
*/
@NotNull
public String getComplianceOption() {
return myComplianceOption;
}
}