-
Notifications
You must be signed in to change notification settings - Fork 966
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added -source flag to cycle_finder, with shared flag parsing and vali…
…dation with j2objc. Change on 2016/02/26 by tball <tball@google.com> ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=115691788
- Loading branch information
Showing
10 changed files
with
114 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
62 changes: 62 additions & 0 deletions
62
translator/src/main/java/com/google/devtools/j2objc/util/SourceVersion.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,62 @@ | |||
/* | |||
* Licensed under the Apache License, Version 2.0 (the "License"); | |||
* you may not use this file except in compliance with the License. | |||
* You may obtain a copy of the License at | |||
* | |||
* http://www.apache.org/licenses/LICENSE-2.0 | |||
* | |||
* Unless required by applicable law or agreed to in writing, software | |||
* distributed under the License is distributed on an "AS IS" BASIS, | |||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
* See the License for the specific language governing permissions and | |||
* limitations under the License. | |||
*/ | |||
|
|||
package com.google.devtools.j2objc.util; | |||
|
|||
/** | |||
* Supported Java versions, used by the -source and -target flags. | |||
*/ | |||
public enum SourceVersion { | |||
|
|||
JAVA_8(8, "1.8"), JAVA_7(7, "1.7"), JAVA_6(6, "1.6"), JAVA_5(5, "1.5"); | |||
|
|||
private final int version; | |||
private final String flag; | |||
|
|||
SourceVersion(int version, String flag) { | |||
this.flag = flag; | |||
this.version = version; | |||
} | |||
|
|||
public int version() { | |||
return version; | |||
} | |||
|
|||
public String flag() { | |||
return flag; | |||
} | |||
|
|||
public static SourceVersion parse(String flag) { | |||
String fullFlag = flag.length() == 1 ? "1." + flag : flag; | |||
for (SourceVersion sv : values()) { | |||
if (sv.flag.equals(fullFlag)) { | |||
return sv; | |||
} | |||
} | |||
throw new IllegalArgumentException(flag); | |||
} | |||
|
|||
public static boolean java7Minimum(SourceVersion sourceVersion) { | |||
return sourceVersion.version >= 7; | |||
} | |||
|
|||
public static boolean java8Minimum(SourceVersion sourceVersion) { | |||
return sourceVersion.version >= 8; | |||
} | |||
|
|||
@Override | |||
public String toString() { | |||
return flag; | |||
} | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters