brace enforcer / js language code style settings
authorMaxim.Mossienko <Maxim.Mossienko@jetbrains.com>
Thu, 25 Feb 2010 13:22:02 +0000 (16:22 +0300)
committerMaxim.Mossienko <Maxim.Mossienko@jetbrains.com>
Thu, 25 Feb 2010 13:22:02 +0000 (16:22 +0300)
platform/lang-impl/src/com/intellij/application/options/codeStyle/CodeStyleBlankLinesPanel.java
platform/lang-impl/src/com/intellij/application/options/codeStyle/CodeStyleIndentAndBracesPanel.java
platform/lang-impl/src/com/intellij/application/options/codeStyle/CodeStyleSpacesPanel.java
platform/lang-impl/src/com/intellij/application/options/codeStyle/LanguageCodeStyleSettingsProvider.java
platform/lang-impl/src/com/intellij/application/options/codeStyle/MultilanguageCodeStyleAbstractPanel.java

index 4d76d07a4d440c04b7526fb3f405f6138e1e7537..60c7952ca835fc6120fd8af72985c81c5d0d99f9 100644 (file)
@@ -72,8 +72,8 @@ public class CodeStyleBlankLinesPanel extends MultilanguageCodeStyleAbstractPane
   }
 
   @Override
-  protected int getSettingsType() {
-    return LanguageCodeStyleSettingsProvider.BLANK_LINE_SETTINGS;
+  protected LanguageCodeStyleSettingsProvider.SettingsType getSettingsType() {
+    return LanguageCodeStyleSettingsProvider.SettingsType.BLANK_LINE_SETTINGS;
   }
 
   private JPanel createBlankLinesPanel() {
index 2fc3ec37d3a2bd294b5604c2754c082df6ae4681..830948e8d9434cdfe812b89e19c3f930b5ff8287 100644 (file)
@@ -127,8 +127,8 @@ public class CodeStyleIndentAndBracesPanel extends MultilanguageCodeStyleAbstrac
   }
 
   @Override
-  protected int getSettingsType() {
-    return LanguageCodeStyleSettingsProvider.INDENT_AND_BRACES_SETTINGS;
+  protected LanguageCodeStyleSettingsProvider.SettingsType getSettingsType() {
+    return LanguageCodeStyleSettingsProvider.SettingsType.INDENT_AND_BRACES_SETTINGS;
   }
 
   private Component createKeepWhenReformatingPanel() {
index 65798cf8293a0b2cab05881e5c5f46cf22b5d00a..795ff9dec64430b5af21dcd6a104cb7b880166f6 100644 (file)
@@ -28,8 +28,8 @@ public class CodeStyleSpacesPanel extends OptionTreeWithPreviewPanel {
   }
 
   @Override
-  protected int getSettingsType() {
-    return LanguageCodeStyleSettingsProvider.SPACING_SETTINGS;
+  protected LanguageCodeStyleSettingsProvider.SettingsType getSettingsType() {
+    return LanguageCodeStyleSettingsProvider.SettingsType.SPACING_SETTINGS;
   }
 
   private static final String AROUND_OPERATORS = ApplicationBundle.message("group.spaces.around.operators");
index b159842f6cfa2d7957609a31691114750af79ca0..6fbae4891c8a9d670688d8b1566c6408b968d8e1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2010 JetBrains s.r.o.
+ * Copyright 2000-2010 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.
@@ -19,8 +19,10 @@ import com.intellij.lang.Language;
 import com.intellij.openapi.extensions.ExtensionPointName;
 import com.intellij.openapi.extensions.Extensions;
 import com.intellij.openapi.fileTypes.LanguageFileType;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
 
-import java.util.Vector;
+import java.util.ArrayList;
 
 /**
  * Base class and extension point for code style settings shared between multiple languages
@@ -29,28 +31,26 @@ import java.util.Vector;
  * @author rvishnyakov
  */
 public abstract class LanguageCodeStyleSettingsProvider {
-
-  public final static int BLANK_LINE_SETTINGS = 1;
-  public final static int INDENT_AND_BRACES_SETTINGS = 2;
-  public final static int SPACING_SETTINGS = 3;
-
+  public enum SettingsType {
+    BLANK_LINE_SETTINGS, INDENT_AND_BRACES_SETTINGS, SPACING_SETTINGS
+  }
+  
   public static final ExtensionPointName<LanguageCodeStyleSettingsProvider> EP_NAME =
     ExtensionPointName.create("com.intellij.langCodeStyleSettingsProvider");
 
   public abstract LanguageFileType getLanguageFileType();
 
-  public abstract String getCodeSample(int settingsType);
+  public abstract String getCodeSample(@NotNull SettingsType settingsType);
 
   public static LanguageFileType[] getLanguageFileTypes() {
-    Vector<LanguageFileType> langFileTypes = new Vector<LanguageFileType>();
+    ArrayList<LanguageFileType> langFileTypes = new ArrayList<LanguageFileType>();
     for (LanguageCodeStyleSettingsProvider provider : Extensions.getExtensions(EP_NAME)) {
       langFileTypes.add(provider.getLanguageFileType());
     }
-    LanguageFileType fileType;
-    return langFileTypes.toArray(new LanguageFileType[0]);
+    return langFileTypes.toArray(new LanguageFileType[langFileTypes.size()]);
   }
 
-  public static String getCodeSample(Language lang, int settingsType) {
+  public static @Nullable String getCodeSample(Language lang, @NotNull SettingsType settingsType) {
     for (LanguageCodeStyleSettingsProvider provider : Extensions.getExtensions(EP_NAME)) {
       if (provider.getLanguageFileType().getLanguage().equals(lang)) {
         return provider.getCodeSample(settingsType);
@@ -59,7 +59,7 @@ public abstract class LanguageCodeStyleSettingsProvider {
     return null;
   }
 
-  public static LanguageFileType getFileType(String langName) {
+  public static @Nullable LanguageFileType getFileType(String langName) {
     for (LanguageCodeStyleSettingsProvider provider : Extensions.getExtensions(EP_NAME)) {
       if (langName.equals(provider.getLanguageFileType().getLanguage().getDisplayName())) {
         return provider.getLanguageFileType();
index 87c2ca90628435830fe80eb70283bdcf0cad6ccb..3087e3e755a4eec8f8246bac2b6a7a07246b9abd 100644 (file)
@@ -16,7 +16,6 @@
 package com.intellij.application.options.codeStyle;
 
 import com.intellij.application.options.CodeStyleAbstractPanel;
-import com.intellij.codeInsight.actions.ReformatCodeProcessor;
 import com.intellij.ide.DataManager;
 import com.intellij.lang.Language;
 import com.intellij.openapi.actionSystem.PlatformDataKeys;
@@ -26,13 +25,11 @@ import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.editor.Document;
 import com.intellij.openapi.editor.colors.EditorColorsScheme;
 import com.intellij.openapi.editor.highlighter.EditorHighlighter;
-import com.intellij.openapi.editor.impl.DocumentImpl;
 import com.intellij.openapi.fileTypes.FileType;
 import com.intellij.openapi.fileTypes.LanguageFileType;
 import com.intellij.openapi.fileTypes.StdFileTypes;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.project.ProjectManager;
-import com.intellij.openapi.util.TextRange;
 import com.intellij.psi.PsiDocumentManager;
 import com.intellij.psi.PsiFile;
 import com.intellij.psi.PsiFileFactory;
@@ -69,7 +66,7 @@ public abstract class MultilanguageCodeStyleAbstractPanel extends CodeStyleAbstr
     updatePreviewEditor();
   }
 
-  protected abstract int getSettingsType();
+  protected abstract LanguageCodeStyleSettingsProvider.SettingsType getSettingsType();
 
   @Override
   protected String getPreviewText() {