Advertisement
Serafim

Untitled

Feb 19th, 2015
281
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 7.88 KB | None | 0 0
  1. //
  2. // Source code recreated from a .class file by IntelliJ IDEA
  3. // (powered by Fernflower decompiler)
  4. //
  5.  
  6. package com.jetbrains.php.config;
  7.  
  8. import com.intellij.openapi.util.text.StringUtil;
  9. import com.intellij.util.containers.HashSet;
  10. import com.jetbrains.php.PhpBundle;
  11. import com.jetbrains.php.config.PhpLanguageFeature;
  12. import com.jetbrains.php.config.phpInfo.PhpInfo;
  13. import java.util.Collections;
  14. import java.util.List;
  15. import java.util.Set;
  16. import org.jetbrains.annotations.NotNull;
  17. import org.jetbrains.annotations.Nullable;
  18.  
  19. public enum PhpLanguageLevel {
  20.     PHP530,
  21.     PHP540,
  22.     PHP550,
  23.     PHP560;
  24.  
  25.     public static final PhpLanguageLevel DEFAULT;
  26.     @NotNull
  27.     private final String myVersionString;
  28.     @NotNull
  29.     private final String myPresentableName;
  30.     @NotNull
  31.     private final String myShortDescription;
  32.     @NotNull
  33.     private final Set<PhpLanguageFeature> myFeatures;
  34.  
  35.     private PhpLanguageLevel(@NotNull String versionString, @NotNull String presentableName, @NotNull String shortDescription, @NotNull PhpLanguageFeature[] languageFeatures) {
  36.         this.myVersionString = versionString;
  37.         this.myPresentableName = presentableName;
  38.         this.myShortDescription = shortDescription;
  39.         this.myFeatures = new HashSet();
  40.         Collections.addAll(this.myFeatures, languageFeatures);
  41.     }
  42.  
  43.     private PhpLanguageLevel(@NotNull String versionString, @NotNull String presentableName, @NotNull String shortDescription, @NotNull PhpLanguageLevel base, @NotNull PhpLanguageFeature[] languageFeatures) {
  44.         this.myVersionString = versionString;
  45.         this.myPresentableName = presentableName;
  46.         this.myShortDescription = shortDescription;
  47.         this.myFeatures = new HashSet();
  48.         this.myFeatures.addAll(base.myFeatures);
  49.         Collections.addAll(this.myFeatures, languageFeatures);
  50.     }
  51.  
  52.     @NotNull
  53.     public String getPresentableName() {
  54.         String var10000 = this.myPresentableName;
  55.         if(this.myPresentableName == null) {
  56.             throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[]{"com/jetbrains/php/config/PhpLanguageLevel", "getPresentableName"}));
  57.         } else {
  58.             return var10000;
  59.         }
  60.     }
  61.  
  62.     @NotNull
  63.     public String getVersionString() {
  64.         String var10000 = this.myVersionString;
  65.         if(this.myVersionString == null) {
  66.             throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[]{"com/jetbrains/php/config/PhpLanguageLevel", "getVersionString"}));
  67.         } else {
  68.             return var10000;
  69.         }
  70.     }
  71.  
  72.     @NotNull
  73.     public String getShortDescription() {
  74.         String var10000 = this.myShortDescription;
  75.         if(this.myShortDescription == null) {
  76.             throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[]{"com/jetbrains/php/config/PhpLanguageLevel", "getShortDescription"}));
  77.         } else {
  78.             return var10000;
  79.         }
  80.     }
  81.  
  82.     public boolean hasFeature(@NotNull PhpLanguageFeature languageFeature) {
  83.         return this.myFeatures.contains(languageFeature);
  84.     }
  85.  
  86.     @NotNull
  87.     public static PhpLanguageLevel parse(@NotNull String versionString) {
  88.         PhpLanguageLevel var10000;
  89.         if(PHP530.getVersionString().equals(versionString)) {
  90.             var10000 = PHP530;
  91.             if(PHP530 == null) {
  92.                 throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[]{"com/jetbrains/php/config/PhpLanguageLevel", "parse"}));
  93.             } else {
  94.                 return var10000;
  95.             }
  96.         } else if(PHP540.getVersionString().equals(versionString)) {
  97.             var10000 = PHP540;
  98.             if(PHP540 == null) {
  99.                 throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[]{"com/jetbrains/php/config/PhpLanguageLevel", "parse"}));
  100.             } else {
  101.                 return var10000;
  102.             }
  103.         } else if(PHP550.getVersionString().equals(versionString)) {
  104.             var10000 = PHP550;
  105.             if(PHP550 == null) {
  106.                 throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[]{"com/jetbrains/php/config/PhpLanguageLevel", "parse"}));
  107.             } else {
  108.                 return var10000;
  109.             }
  110.         } else if(PHP560.getVersionString().equals(versionString)) {
  111.             var10000 = PHP560;
  112.             if(PHP560 == null) {
  113.                 throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[]{"com/jetbrains/php/config/PhpLanguageLevel", "parse"}));
  114.             } else {
  115.                 return var10000;
  116.             }
  117.         } else {
  118.             var10000 = DEFAULT;
  119.             if(DEFAULT == null) {
  120.                 throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[]{"com/jetbrains/php/config/PhpLanguageLevel", "parse"}));
  121.             } else {
  122.                 return var10000;
  123.             }
  124.         }
  125.     }
  126.  
  127.     @Nullable
  128.     public static PhpLanguageLevel parse(@NotNull PhpInfo phpInfo) {
  129.         List split = StringUtil.split(phpInfo.getVersion(), ".");
  130.         if(split.size() > 1 && ((String)split.get(0)).equals("5")) {
  131.             String version = (String)split.get(1);
  132.             if(version.equals("3")) {
  133.                 return PHP530;
  134.             }
  135.  
  136.             if(version.equals("4")) {
  137.                 return PHP540;
  138.             }
  139.  
  140.             if(version.equals("5")) {
  141.                 return PHP550;
  142.             }
  143.  
  144.             if(version.equals("6")) {
  145.                 return PHP560;
  146.             }
  147.         }
  148.  
  149.         return null;
  150.     }
  151.  
  152.     static {
  153.         PHP530 = new PhpLanguageLevel("PHP530", 0, "5.3.0", PhpBundle.message("PhpLanguageLevel.5.3.0.presentable.name", new Object[0]), PhpBundle.message("PhpLanguageLevel.5.3.0.short.description", new Object[0]), new PhpLanguageFeature[]{PhpLanguageFeature.VAR_CONTINUE_ARGUMENT, PhpLanguageFeature.VAR_BREAK_ARGUMENT, PhpLanguageFeature.VAR_CONTINUE_ZERO_ARGUMENT, PhpLanguageFeature.VAR_BREAK_ZERO_ARGUMENT, PhpLanguageFeature.CALL_TIME_PASS_BY_REFERENCE});
  154.         PHP540 = new PhpLanguageLevel("PHP540", 1, "5.4.0", PhpBundle.message("PhpLanguageLevel.5.4.0.presentable.name", new Object[0]), PhpBundle.message("PhpLanguageLevel.5.4.0.short.description", new Object[0]), new PhpLanguageFeature[]{PhpLanguageFeature.TRAITS, PhpLanguageFeature.SHORT_ARRAY_SYNTAX, PhpLanguageFeature.CLASS_MEMBER_ACCESS_ON_INSTANTIATION, PhpLanguageFeature.ARRAY_DEREFERENCING, PhpLanguageFeature.THIS_IN_CLOSURE, PhpLanguageFeature.SELF_IN_CLOSURE, PhpLanguageFeature.PARENT_IN_CLOSURE, PhpLanguageFeature.STATIC_IN_CLOSURE, PhpLanguageFeature.BINARY_LITERAL, PhpLanguageFeature.LITERAL_IN_STATIC_CALL, PhpLanguageFeature.BUILT_IN_WEB_SERVER});
  155.         PHP550 = new PhpLanguageLevel("PHP550", 2, "5.5.0", PhpBundle.message("PhpLanguageLevel.5.5.0.presentable.name", new Object[0]), PhpBundle.message("PhpLanguageLevel.5.5.0.short.description", new Object[0]), PHP540, new PhpLanguageFeature[]{PhpLanguageFeature.FINALLY, PhpLanguageFeature.GENERATORS, PhpLanguageFeature.FOREACH_LIST, PhpLanguageFeature.EMPTY_ANY_EXPRESSION, PhpLanguageFeature.IMMEDIATE_DEREFERENCING, PhpLanguageFeature.CLASS_NAME_CONST});
  156.         PHP560 = new PhpLanguageLevel("PHP560", 3, "5.6.0", PhpBundle.message("PhpLanguageLevel.5.6.0.presentable.name", new Object[0]), PhpBundle.message("PhpLanguageLevel.5.6.0.short.description", new Object[0]), PHP550, new PhpLanguageFeature[]{PhpLanguageFeature.CONSTANT_SCALAR_EXPRESSIONS, PhpLanguageFeature.VARIADIC_FUNCTIONS, PhpLanguageFeature.ARGUMENT_UNPACKING, PhpLanguageFeature.EXPONENTIATION, PhpLanguageFeature.USE_FUNCTION_AND_CONST});
  157.         DEFAULT = PHP540;
  158.     }
  159. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement