Arrangement tokens creation patch.
authorRoman Shein <marso.des@gmail.com>
Thu, 6 Feb 2014 11:58:08 +0000 (15:58 +0400)
committerjamesbrain <marso.des@gmail.com>
Thu, 6 Feb 2014 12:02:25 +0000 (16:02 +0400)
platform/lang-api/src/com/intellij/psi/codeStyle/arrangement/std/StdArrangementSettingsToken.java
platform/lang-api/src/com/intellij/psi/codeStyle/arrangement/std/StdArrangementTokens.java

index 06e2c781611ed2290dbdae5c0d2549ee7c4741a2..d6503f56e6f3d5e87b681f38ef85bab3cc697211 100644 (file)
@@ -28,18 +28,34 @@ public class StdArrangementSettingsToken extends ArrangementSettingsToken {
 
   @NotNull private final StdArrangementTokenType myTokenType;
 
-  public StdArrangementSettingsToken(@NotNull String id, @NotNull StdArrangementTokenType tokenType) {
-    super(id, id.toLowerCase().replace("_", " "));
-    myTokenType = tokenType;
+  @NotNull
+  public static StdArrangementSettingsToken tokenById(@NotNull String id,
+                                                      @NotNull StdArrangementTokenType tokenType) {
+    return new StdArrangementSettingsToken(id, id.toLowerCase().replace("_", " "), tokenType);
   }
 
-  public StdArrangementSettingsToken (@NotNull String id, @NotNull @PropertyKey(resourceBundle = ApplicationBundle.BUNDLE) String key,
-                                      @NotNull StdArrangementTokenType tokenType) {
-    super(id, ApplicationBundle.message(key));
-    myTokenType = tokenType;
+  @NotNull
+  public static StdArrangementSettingsToken token(@NotNull String id,
+                                                  @NotNull String name,
+                                                  @NotNull StdArrangementTokenType tokenType) {
+    return new StdArrangementSettingsToken(id, name, tokenType);
+  }
+
+  @NotNull
+  public static StdArrangementSettingsToken tokenByBundle(@NotNull String id,
+                                                          @NotNull @PropertyKey(resourceBundle = ApplicationBundle.BUNDLE) String key,
+                                                          @NotNull StdArrangementTokenType tokenType) {
+    return new StdArrangementSettingsToken(id, ApplicationBundle.message(key), tokenType);
   }
 
   @NotNull public StdArrangementTokenType getTokenType() {
     return myTokenType;
   }
+
+  private StdArrangementSettingsToken(@NotNull String id,
+                                      @NotNull String uiName,
+                                      @NotNull StdArrangementTokenType tokenType) {
+    super(id, uiName);
+    myTokenType = tokenType;
+  }
 }
index 6977aa8b40e049927eb13c6f2b3243553bfe1bbb..3dfff48acdbb1184ce52a17ca33d835f30144412 100644 (file)
@@ -88,14 +88,14 @@ public class StdArrangementTokens {
   }
 
   private static StdArrangementSettingsToken token(@NotNull String id, @NotNull StdArrangementTokenType type) {
-    StdArrangementSettingsToken result = new StdArrangementSettingsToken(id, type);
+    StdArrangementSettingsToken result = StdArrangementSettingsToken.tokenById(id, type);
     TOKENS_BY_ID.put(id, result);
     return result;
   }
 
   private static StdArrangementSettingsToken token(@NotNull String id, @NotNull @PropertyKey(resourceBundle = ApplicationBundle.BUNDLE) String key,
                                                    @NotNull StdArrangementTokenType type) {
-    StdArrangementSettingsToken result = new StdArrangementSettingsToken(id, key, type);
+    StdArrangementSettingsToken result = StdArrangementSettingsToken.tokenByBundle(id, key, type);
     TOKENS_BY_ID.put(id, result);
     return result;
   }