package com.intellij.codeInsight.intention.impl.config;

import com.intellij.codeInsight.CodeInsightBundle;
import com.intellij.codeInsight.daemon.HighlightDisplayKey;
import com.intellij.codeInsight.daemon.impl.*;
import com.intellij.codeInsight.daemon.impl.quickfix.*;
import com.intellij.codeInsight.intention.IntentionAction;
import com.intellij.codeInsight.intention.IntentionManager;
import com.intellij.codeInsight.intention.impl.*;
import com.intellij.codeInspection.ex.EditInspectionToolsSettingsAction;
import com.intellij.openapi.project.Project;
import com.intellij.pom.java.LanguageLevel;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiManager;

import java.util.ArrayList;
import java.util.List;

/**
 *  @author dsl
 */
public class IntentionManagerImpl extends IntentionManager {
  private List<IntentionAction> myActions = new ArrayList<IntentionAction>();
  private Project myProject;
  private IntentionManagerSettings mySettings;

  public IntentionManagerImpl(Project project, IntentionManagerSettings intentionManagerSettings) {
    myProject = project;
    mySettings = intentionManagerSettings;

    addAction(new QuickFixAction());
    addAction(new PostIntentionsQuickFixAction());

    String[] CONTROL_FLOW_CAT = new String[]{CodeInsightBundle.message("intentions.category.control.flow")};
    registerIntentionAndMetaData(new SplitIfAction(), CONTROL_FLOW_CAT);
    registerIntentionAndMetaData(new InvertIfConditionAction(), CONTROL_FLOW_CAT);
    registerIntentionAndMetaData(new RemoveRedundantElseAction(), CONTROL_FLOW_CAT);

    String[] DECLARATION_CAT = new String[]{CodeInsightBundle.message("intentions.category.declaration")};
    registerIntentionAndMetaData(new CreateFieldFromParameterAction(), DECLARATION_CAT);
    registerIntentionAndMetaData(new AssignFieldFromParameterAction(), DECLARATION_CAT);
    registerIntentionAndMetaData(new CreateLocalVarFromInstanceofAction(), DECLARATION_CAT);
    registerIntentionAndMetaData(new ImplementAbstractClassAction(), DECLARATION_CAT);
    registerIntentionAndMetaData(new ImplementAbstractMethodAction(), DECLARATION_CAT);
    registerIntentionAndMetaData(new SplitDeclarationAction(), DECLARATION_CAT);
    registerIntentionAndMetaData(new AddRuntimeExceptionToThrowsAction(), DECLARATION_CAT);

    registerIntentionAndMetaData(new SimplifyBooleanExpressionAction(), CodeInsightBundle.message("intentions.category.boolean"));

    registerIntentionAndMetaData(new ConcatenationToMessageFormatAction(), CodeInsightBundle.message("intentions.category.i18n"));
  }

  public void registerIntentionAndMetaData(IntentionAction action, String... category) {
    registerIntentionAndMetaData(action, category, getDescriptionDirectoryName(action));
  }

  private static String getDescriptionDirectoryName(final IntentionAction action) {
    final String fqn = action.getClass().getName();
    return fqn.substring(fqn.lastIndexOf('.') + 1);
  }

  public void registerIntentionAndMetaData(IntentionAction action, String[] category, String descriptionDirectoryName) {
    addAction(action);
    mySettings.registerIntentionMetaData(action, category, descriptionDirectoryName);
  }

  public List<IntentionAction> getStandardIntentionOptions(final HighlightDisplayKey displayKey, final PsiElement context) {
    List<IntentionAction> options = new ArrayList<IntentionAction>();
    options.add(new EditInspectionToolsSettingsAction(displayKey));
    options.add(new AddNoInspectionCommentAction(displayKey, context));
    options.add(new AddNoInspectionDocTagAction(displayKey, context));
    options.add(new AddNoInspectionForClassAction(displayKey, context));
    options.add(new AddNoInspectionAllForClassAction(context));
    options.add(new AddSuppressWarningsAnnotationAction(displayKey, context));
    options.add(new AddSuppressWarningsAnnotationForClassAction(displayKey, context));
    options.add(new AddSuppressWarningsAnnotationForAllAction(context));
    return options;
  }

  public void initComponent() { }

  public void disposeComponent(){
  }

  public String getComponentName(){
    return "IntentionManager";
  }

  public void projectOpened(){
    if (LanguageLevel.JDK_1_5.compareTo(PsiManager.getInstance(myProject).getEffectiveLanguageLevel()) <= 0) {
      registerIntentionAndMetaData(new MakeTypeGeneric(), CodeInsightBundle.message("intentions.category.declaration"));
      registerIntentionAndMetaData(new AddOverrideAnnotationAction(), CodeInsightBundle.message("intentions.category.declaration"));

      registerIntentionAndMetaData(new AddOnDemandStaticImportAction(), CodeInsightBundle.message("intentions.category.imports"));
      registerIntentionAndMetaData(new AddSingleMemberStaticImportAction(), CodeInsightBundle.message("intentions.category.imports"));
    }
  }

  public void projectClosed(){
  }

  public void addAction(IntentionAction action) {
    myActions.add(action);
  }

  public IntentionAction[] getIntentionActions() {
    return myActions.toArray(new IntentionAction[myActions.size()]);
  }
}

@@ -140,35 +140,31 @@
 .daemon.
-HighlightDisplayKey
+impl.quickfix.*
 ;%0Aimport
@@ -239,39 +239,43 @@
 ight.daemon.
-impl.quickfix.*
+HighlightDisplayKey
 ;%0Aimport com
@@ -437,81 +437,8 @@
 .*;%0A
-import com.intellij.codeInspection.ex.EditInspectionToolsSettingsAction;%0A
 impo
@@ -549,23 +549,23 @@
 .psi.Psi
-Element
+Manager
 ;%0Aimport
@@ -585,23 +585,23 @@
 .psi.Psi
-Manager
+Element
 ;%0A%0Aimpor
@@ -1170,24 +1170,29 @@
 ROL_FLOW_CAT
+EGORY
  = new Strin
@@ -1321,32 +1321,37 @@
 CONTROL_FLOW_CAT
+EGORY
 );%0A    registerI
@@ -1413,24 +1413,29 @@
 ROL_FLOW_CAT
+EGORY
 );%0A    regis
@@ -1503,24 +1503,29 @@
 ROL_FLOW_CAT
+EGORY
 );%0A%0A    Stri
@@ -1544,16 +1544,21 @@
 TION_CAT
+EGORY
  = new S
@@ -1706,32 +1706,37 @@
  DECLARATION_CAT
+EGORY
 );%0A    registerI
@@ -1800,32 +1800,37 @@
  DECLARATION_CAT
+EGORY
 );%0A    registerI
@@ -1898,32 +1898,37 @@
  DECLARATION_CAT
+EGORY
 );%0A    registerI
@@ -1990,32 +1990,37 @@
  DECLARATION_CAT
+EGORY
 );%0A    registerI
@@ -2083,32 +2083,37 @@
  DECLARATION_CAT
+EGORY
 );%0A    registerI
@@ -2177,16 +2177,119 @@
 TION_CAT
+EGORY);%0A    registerIntentionAndMetaData(new MoveInitializerToConstructorAction(), DECLARATION_CATEGORY
 );%0A    r
@@ -2372,16 +2372,21 @@
 TION_CAT
+EGORY
 );%0A%0A    

rollback Ann changes