using language for LanguageCodeStyleSettings provider
authorMaxim.Mossienko <Maxim.Mossienko@jetbrains.com>
Sat, 27 Feb 2010 15:36:27 +0000 (18:36 +0300)
committerMaxim.Mossienko <Maxim.Mossienko@jetbrains.com>
Sat, 27 Feb 2010 15:36:27 +0000 (18:36 +0300)
java/java-impl/src/com/intellij/ide/JavaLanguageCodeStyleSettingsProvider.java
platform/lang-impl/src/com/intellij/application/options/codeStyle/CodeStyleSchemesPanel.java
platform/lang-impl/src/com/intellij/application/options/codeStyle/LanguageCodeStyleSettingsProvider.java
platform/lang-impl/src/com/intellij/application/options/codeStyle/MultilanguageCodeStyleAbstractPanel.java

index 043a18232b975b47a737bea431b864d0966693dc..0382f508d83cb83f6ae3b6b5a30133f8558af909 100644 (file)
@@ -16,8 +16,8 @@
 package com.intellij.ide;
 
 import com.intellij.application.options.codeStyle.LanguageCodeStyleSettingsProvider;
-import com.intellij.openapi.fileTypes.LanguageFileType;
-import com.intellij.openapi.fileTypes.StdFileTypes;
+import com.intellij.lang.Language;
+import com.intellij.lang.StdLanguages;
 import org.jetbrains.annotations.NotNull;
 
 /**
@@ -25,8 +25,8 @@ import org.jetbrains.annotations.NotNull;
  */
 public class JavaLanguageCodeStyleSettingsProvider extends LanguageCodeStyleSettingsProvider {
   @Override
-  public LanguageFileType getLanguageFileType() {
-    return StdFileTypes.JAVA;
+  public Language getLanguage() {
+    return StdLanguages.JAVA;
   }
 
   @Override
index c9158078bba16d2122fa3710bf0537451c158cc3..5480c7e3b7a8cf517862dc1552daa7a84aacd54c 100644 (file)
@@ -19,9 +19,9 @@ package com.intellij.application.options.codeStyle;
 import com.intellij.application.options.ExportSchemeAction;
 import com.intellij.application.options.SaveSchemeDialog;
 import com.intellij.application.options.SchemesToImportPopup;
+import com.intellij.lang.Language;
 import com.intellij.openapi.application.ApplicationBundle;
 import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.fileTypes.LanguageFileType;
 import com.intellij.openapi.options.SchemesManager;
 import com.intellij.openapi.ui.Messages;
 import com.intellij.psi.codeStyle.CodeStyleScheme;
@@ -166,8 +166,8 @@ public class CodeStyleSchemesPanel{
         });
       }
     });
-    for(LanguageFileType fileType : LanguageCodeStyleSettingsProvider.getLanguageFileTypes()) {
-      myLanguageCombo.addItem(fileType.getLanguage().getDisplayName());
+    for(Language language : LanguageCodeStyleSettingsProvider.getLanguagesWithCodeStyleSettings()) {
+      myLanguageCombo.addItem(language.getDisplayName());
     }
     myLanguageLabel.setVisible(false);
     myLanguageCombo.setVisible(false);
@@ -334,9 +334,9 @@ public class CodeStyleSchemesPanel{
   private void onLanguageCombo() {
     Object selection = myLanguageCombo.getSelectedItem();
     if (selection instanceof String) {
-      LanguageFileType fileType = LanguageCodeStyleSettingsProvider.getFileType((String)selection);
-      if (fileType != null && mySettingsPanel != null) {
-        mySettingsPanel.setLanguage(fileType.getLanguage());
+      Language language = LanguageCodeStyleSettingsProvider.getLanguage((String)selection);
+      if (language != null && mySettingsPanel != null) {
+        mySettingsPanel.setLanguage(language);
       }
     }
   }
index 6fbae4891c8a9d670688d8b1566c6408b968d8e1..3d4c8a24acfc0f0972a6b36bcf93ac677a597a9d 100644 (file)
@@ -18,7 +18,6 @@ package com.intellij.application.options.codeStyle;
 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;
 
@@ -38,31 +37,31 @@ public abstract class LanguageCodeStyleSettingsProvider {
   public static final ExtensionPointName<LanguageCodeStyleSettingsProvider> EP_NAME =
     ExtensionPointName.create("com.intellij.langCodeStyleSettingsProvider");
 
-  public abstract LanguageFileType getLanguageFileType();
+  public abstract Language getLanguage();
 
   public abstract String getCodeSample(@NotNull SettingsType settingsType);
 
-  public static LanguageFileType[] getLanguageFileTypes() {
-    ArrayList<LanguageFileType> langFileTypes = new ArrayList<LanguageFileType>();
+  public static Language[] getLanguagesWithCodeStyleSettings() {
+    ArrayList<Language> langs = new ArrayList<Language>();
     for (LanguageCodeStyleSettingsProvider provider : Extensions.getExtensions(EP_NAME)) {
-      langFileTypes.add(provider.getLanguageFileType());
+      langs.add(provider.getLanguage());
     }
-    return langFileTypes.toArray(new LanguageFileType[langFileTypes.size()]);
+    return langs.toArray(new Language[langs.size()]);
   }
 
   public static @Nullable String getCodeSample(Language lang, @NotNull SettingsType settingsType) {
     for (LanguageCodeStyleSettingsProvider provider : Extensions.getExtensions(EP_NAME)) {
-      if (provider.getLanguageFileType().getLanguage().equals(lang)) {
+      if (provider.getLanguage().equals(lang)) {
         return provider.getCodeSample(settingsType);
       }
     }
     return null;
   }
 
-  public static @Nullable LanguageFileType getFileType(String langName) {
+  public static @Nullable Language getLanguage(String langName) {
     for (LanguageCodeStyleSettingsProvider provider : Extensions.getExtensions(EP_NAME)) {
-      if (langName.equals(provider.getLanguageFileType().getLanguage().getDisplayName())) {
-        return provider.getLanguageFileType();
+      if (langName.equals(provider.getLanguage().getDisplayName())) {
+        return provider.getLanguage();
       }
     }
     return null;
index c376698900d5883a544cf66a56e0ce6c9b6c2746..67a1d4af84e39c947e3d7ee6b5a4cfd9ccffadd5 100644 (file)
@@ -18,7 +18,6 @@ package com.intellij.application.options.codeStyle;
 import com.intellij.application.options.CodeStyleAbstractPanel;
 import com.intellij.ide.DataManager;
 import com.intellij.lang.Language;
-import com.intellij.openapi.Disposable;
 import com.intellij.openapi.actionSystem.PlatformDataKeys;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.command.CommandProcessor;
@@ -43,7 +42,6 @@ import com.intellij.util.LocalTimeCounter;
 import org.jetbrains.annotations.NotNull;
 
 import java.io.File;
-import java.io.IOException;
 
 /**
  * Base class for code style settings panels supporting multiple programming languages.
@@ -90,10 +88,11 @@ public abstract class MultilanguageCodeStyleAbstractPanel extends CodeStyleAbstr
     if (myLanguage != null) {
       return myLanguage.getAssociatedFileType();
     }
-    LanguageFileType availTypes[] = LanguageCodeStyleSettingsProvider.getLanguageFileTypes();
-    if (availTypes.length > 0) {
-      myLanguage = availTypes[0].getLanguage();
-      return availTypes[0];
+    Language langs[] = LanguageCodeStyleSettingsProvider.getLanguagesWithCodeStyleSettings();
+    if (langs.length > 0) {
+      myLanguage = langs[0];
+      FileType type = langs[0].getAssociatedFileType();
+      if (type != null) return type;
     }
     return StdFileTypes.JAVA;
   }