Snapshot f5ae6e3be7e12e1ef9e12f48fe3a674266288e4e from master branch of git://git.jetbrains.org/idea/community.git

Change-Id: I756af70fb2910aa2687e94e28338fb9727bce518
diff --git a/.idea/modules.xml b/.idea/modules.xml
index 446556c..562c21b 100644
--- a/.idea/modules.xml
+++ b/.idea/modules.xml
@@ -12,6 +12,8 @@
       <module fileurl="file://$PROJECT_DIR$/RegExpSupport/RegExpSupport.iml" filepath="$PROJECT_DIR$/RegExpSupport/RegExpSupport.iml" />
       <module fileurl="file://$PROJECT_DIR$/platform/analysis-api/analysis-api.iml" filepath="$PROJECT_DIR$/platform/analysis-api/analysis-api.iml" group="platform" />
       <module fileurl="file://$PROJECT_DIR$/platform/analysis-impl/analysis-impl.iml" filepath="$PROJECT_DIR$/platform/analysis-impl/analysis-impl.iml" group="platform" />
+      <module fileurl="file://$PROJECT_DIR$/java/java-analysis-api/java-analysis-api.iml" filepath="$PROJECT_DIR$/java/java-analysis-api/java-analysis-api.iml" group="community/java" />
+      <module fileurl="file://$PROJECT_DIR$/java/java-analysis-impl/java-analysis-impl.iml" filepath="$PROJECT_DIR$/java/java-analysis-impl/java-analysis-impl.iml" group="community/java" />
       <module fileurl="file://$PROJECT_DIR$/plugins/android/android.iml" filepath="$PROJECT_DIR$/plugins/android/android.iml" group="plugins/Android" />
       <module fileurl="file://$PROJECT_DIR$/plugins/android/common/android-common.iml" filepath="$PROJECT_DIR$/plugins/android/common/android-common.iml" group="plugins/Android" />
       <module fileurl="file://$PROJECT_DIR$/plugins/android-designer/android-designer.iml" filepath="$PROJECT_DIR$/plugins/android-designer/android-designer.iml" group="plugins/Android" />
diff --git a/build/scripts/layouts.gant b/build/scripts/layouts.gant
index ca2c6f2..3994579 100644
--- a/build/scripts/layouts.gant
+++ b/build/scripts/layouts.gant
@@ -61,6 +61,8 @@
           "java-psi-impl",
           "java-indexing-impl",
           "java-impl",
+          "java-analysis-impl",
+          "analysis-impl",
           "compiler-impl",
           "debugger-impl",
           "dom-impl",
@@ -709,6 +711,8 @@
       module("platform-resources-en")
       module("analysis-api")
       module("analysis-impl")
+      module("java-analysis-api")
+      module("java-analysis-impl")
     }
 
     jar("annotations.jar") {
diff --git a/build/update.cmd b/build/update.cmd
index a49d2da..74b4995 100644
--- a/build/update.cmd
+++ b/build/update.cmd
@@ -31,6 +31,7 @@
 SET ANT_HOME=%DEV_IDEA_HOME%\lib\ant
 SET EXEC_ANT="%JAVA_HOME%\bin\java.exe" -Dant.home=%ANT_HOME% -classpath "%ANT_HOME%\lib\ant-launcher.jar" org.apache.tools.ant.launch.Launcher
 CALL %EXEC_ANT% -f build/update.xml %*
+IF NOT ERRORLEVEL 0 GOTO failed
 
 DEL /Q /S %WORK_IDEA_HOME%\lib
 DEL /Q /S %WORK_IDEA_HOME%\plugins
@@ -39,5 +40,10 @@
 XCOPY %DEV_IDEA_HOME%\bin\win\fsnotifier.exe %WORK_IDEA_HOME%\bin\ /Q /E /Y
 XCOPY %DEV_IDEA_HOME%\bin\win\runnerw.exe %WORK_IDEA_HOME%\bin\ /Q /E /Y
 XCOPY %DEV_IDEA_HOME%\out\deploy\*.* %WORK_IDEA_HOME%\ /Q /E /Y
+GOTO done
 
+:failed
+ECHO "Update failed; work IDEA build not modified."
+
+:done
 CD /D %WORK_IDEA_HOME%\bin
diff --git a/build/update.sh b/build/update.sh
index ad81cb0..7fdd502 100755
--- a/build/update.sh
+++ b/build/update.sh
@@ -11,12 +11,12 @@
 
 if [ ! -f "$WORK_IDEA_HOME/bin/inspect.sh" ]; then
   echo "WORK_IDEA_HOME must be defined and point to build you're updating."
-  exit
+  exit 1
 fi
 
 if [ ! -f "$DEV_IDEA_HOME/build/update.sh" ]; then
   echo "DEV_IDEA_HOME must be defined and point to source base you're updating from."
-  exit
+  exit 1
 fi
 
 echo "Updating $WORK_IDEA_HOME from compiled classes in $DEV_IDEA_HOME"
@@ -26,6 +26,12 @@
 java -Xms64m -Xmx512m -Dant.home="$ANT_HOME" -classpath "$ANT_HOME/lib/ant-launcher.jar" org.apache.tools.ant.launch.Launcher \
  -lib "$ANT_CLASSPATH" -f $DEV_IDEA_HOME/build/update.xml $TARGET
 
+if [ "$?" != "0" ]; then
+  echo "Update failed; work IDEA build not modified."
+  rm -rf "$WORK_IDEA_HOME/___tmp___"
+  exit 2
+fi
+
 rm -rf $WORK_IDEA_HOME/lib
 rm -rf $WORK_IDEA_HOME/plugins
 
diff --git a/java/compiler/impl/compiler-impl.iml b/java/compiler/impl/compiler-impl.iml
index 9bb8c9a..5e6ae9d 100644
--- a/java/compiler/impl/compiler-impl.iml
+++ b/java/compiler/impl/compiler-impl.iml
@@ -26,6 +26,7 @@
     <orderEntry type="library" name="Netty" level="project" />
     <orderEntry type="module" module-name="testFramework-java" scope="TEST" />
     <orderEntry type="module" module-name="jps-model-impl" />
+    <orderEntry type="module" module-name="java-analysis-impl" />
   </component>
   <component name="copyright">
     <Base>
diff --git a/java/compiler/impl/src/com/intellij/compiler/impl/CompilerErrorTreeView.java b/java/compiler/impl/src/com/intellij/compiler/impl/CompilerErrorTreeView.java
index 8213504..25991f0 100644
--- a/java/compiler/impl/src/com/intellij/compiler/impl/CompilerErrorTreeView.java
+++ b/java/compiler/impl/src/com/intellij/compiler/impl/CompilerErrorTreeView.java
@@ -25,7 +25,6 @@
 import com.intellij.openapi.actionSystem.*;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.command.CommandProcessor;
-import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.fileEditor.OpenFileDescriptor;
 import com.intellij.openapi.module.LanguageLevelUtil;
 import com.intellij.openapi.module.Module;
@@ -86,7 +85,7 @@
           ApplicationManager.getApplication().runWriteAction(new Runnable() {
             public void run() {
               try {
-                suppressInspectionFix.invoke(project, null, file.findElementAt(navigatable.getOffset()));
+                suppressInspectionFix.invoke(project, file.findElementAt(navigatable.getOffset()));
               }
               catch (IncorrectOperationException e1) {
                 LOG.error(e1);
@@ -139,7 +138,7 @@
               }
               final String id = text[0].substring(1, text[0].indexOf("]"));
               final SuppressFix suppressInspectionFix = getSuppressAction(id);
-              final boolean available = suppressInspectionFix.isAvailable(project, null, context);
+              final boolean available = suppressInspectionFix.isAvailable(project, context);
               presentation.setEnabled(available);
               presentation.setVisible(available);
               if (available) {
@@ -151,13 +150,13 @@
       }
     }
 
-    protected SuppressFix getSuppressAction(final String id) {
+    protected SuppressFix getSuppressAction(@NotNull final String id) {
       return new SuppressFix(id) {
         @Override
         @SuppressWarnings({"SimplifiableIfStatement"})
-        public boolean isAvailable(@NotNull final Project project, final Editor editor, @NotNull final PsiElement context) {
+        public boolean isAvailable(@NotNull final Project project, @NotNull final PsiElement context) {
           if (getContainer(context) instanceof PsiClass) return false;
-          return super.isAvailable(project, editor, context);
+          return super.isAvailable(project, context);
         }
 
         @Override
@@ -170,7 +169,7 @@
 
   private class SuppressJavacWarningForClassAction extends SuppressJavacWarningsAction {
     @Override
-    protected SuppressFix getSuppressAction(final String id) {
+    protected SuppressFix getSuppressAction(@NotNull final String id) {
       return new SuppressForClassFix(id){
         @Override
         protected boolean use15Suppressions(@NotNull final PsiDocCommentOwner container) {
diff --git a/java/debugger/impl/src/com/intellij/debugger/actions/JavaEditBreakpointActionHandler.java b/java/debugger/impl/src/com/intellij/debugger/actions/JavaEditBreakpointActionHandler.java
index 8776937..deb5752 100644
--- a/java/debugger/impl/src/com/intellij/debugger/actions/JavaEditBreakpointActionHandler.java
+++ b/java/debugger/impl/src/com/intellij/debugger/actions/JavaEditBreakpointActionHandler.java
@@ -26,7 +26,6 @@
 import com.intellij.openapi.editor.markup.GutterIconRenderer;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.ui.popup.Balloon;
-import com.intellij.openapi.ui.popup.JBPopup;
 import com.intellij.openapi.ui.popup.JBPopupListener;
 import com.intellij.openapi.ui.popup.LightweightWindowEvent;
 import com.intellij.openapi.util.Key;
@@ -35,7 +34,7 @@
 import com.intellij.util.ui.UIUtil;
 import com.intellij.xdebugger.impl.actions.EditBreakpointActionHandler;
 import com.intellij.xdebugger.impl.breakpoints.XBreakpointUtil;
-import com.intellij.xdebugger.impl.breakpoints.ui.BreakpointsMasterDetailPopupFactory;
+import com.intellij.xdebugger.impl.breakpoints.ui.BreakpointsDialogFactory;
 import com.intellij.xdebugger.impl.ui.DebuggerUIUtil;
 import org.jetbrains.annotations.NotNull;
 
@@ -93,11 +92,8 @@
         UIUtil.invokeLaterIfNeeded(new Runnable() {
           @Override
           public void run() {
-            final JBPopup popup = BreakpointsMasterDetailPopupFactory.
-              getInstance(project).createPopup(javaBreakpoint);
-            if (popup != null) {
-              popup.showCenteredInCurrentWindow(project);
-            }
+            BreakpointsDialogFactory.getInstance(project).showDialog(javaBreakpoint);
+
           }
         });
       }
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/XBreakpointGroupingByClassRule.java b/java/debugger/impl/src/com/intellij/debugger/ui/XBreakpointGroupingByClassRule.java
index 338f65d..f06a17e 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/XBreakpointGroupingByClassRule.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/XBreakpointGroupingByClassRule.java
@@ -16,10 +16,13 @@
 package com.intellij.debugger.ui;
 
 import com.intellij.debugger.ui.breakpoints.Breakpoint;
+import com.intellij.icons.AllIcons;
 import com.intellij.xdebugger.breakpoints.ui.XBreakpointGroupingRule;
 import com.intellij.xdebugger.breakpoints.ui.XBreakpointsGroupingPriorities;
 import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
 
+import javax.swing.*;
 import java.util.Collection;
 
 class XBreakpointGroupingByClassRule<B> extends XBreakpointGroupingRule<B, XBreakpointClassGroup> {
@@ -55,4 +58,10 @@
     }
     return null;
   }
+
+  @Nullable
+  @Override
+  public Icon getIcon() {
+    return AllIcons.Nodes.Class;
+  }
 }
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/XBreakpointGroupingByPackageRule.java b/java/debugger/impl/src/com/intellij/debugger/ui/XBreakpointGroupingByPackageRule.java
index 12ff08b..5763a36 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/XBreakpointGroupingByPackageRule.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/XBreakpointGroupingByPackageRule.java
@@ -17,11 +17,14 @@
 
 import com.intellij.debugger.ui.breakpoints.BreakpointWithHighlighter;
 import com.intellij.debugger.ui.breakpoints.ExceptionBreakpoint;
+import com.intellij.icons.AllIcons;
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.xdebugger.breakpoints.ui.XBreakpointGroupingRule;
 import com.intellij.xdebugger.breakpoints.ui.XBreakpointsGroupingPriorities;
 import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
 
+import javax.swing.*;
 import java.util.Collection;
 
 public class XBreakpointGroupingByPackageRule<B> extends XBreakpointGroupingRule<B, XBreakpointPackageGroup> {
@@ -54,4 +57,10 @@
     }
     return new XBreakpointPackageGroup(packageName);
   }
+
+  @Nullable
+  @Override
+  public Icon getIcon() {
+    return AllIcons.Nodes.Package;
+  }
 }
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointPropertiesPanel.form b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointPropertiesPanel.form
index 894a4f1..206aef2 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointPropertiesPanel.form
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointPropertiesPanel.form
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.debugger.ui.breakpoints.BreakpointPropertiesPanel">
-  <grid id="6570" binding="myPanel" custom-create="true" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
+  <grid id="6570" binding="myPanel" custom-create="true" layout-manager="GridLayoutManager" row-count="4" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
     <margin top="0" left="0" bottom="0" right="0"/>
     <constraints>
       <xy x="23" y="37" width="751" height="404"/>
@@ -11,7 +11,7 @@
       <grid id="7978d" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
         <margin top="0" left="0" bottom="0" right="0"/>
         <constraints>
-          <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="1" fill="1" indent="0" use-parent-layout="false"/>
+          <grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="1" fill="1" indent="0" use-parent-layout="false"/>
         </constraints>
         <properties/>
         <border type="none"/>
@@ -25,9 +25,9 @@
             <border type="none"/>
             <children/>
           </xy>
-          <component id="f3923" class="com.intellij.ui.components.JBCheckBox" binding="myConditionCheckbox">
+          <component id="ecb15" class="javax.swing.JCheckBox" binding="myConditionCheckbox">
             <constraints>
-              <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
+              <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
             </constraints>
             <properties>
               <text value="&amp;Condition"/>
@@ -36,9 +36,9 @@
         </children>
       </grid>
       <grid id="763d0" layout-manager="GridLayoutManager" row-count="1" column-count="5" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
-        <margin top="0" left="0" bottom="0" right="0"/>
+        <margin top="0" left="5" bottom="0" right="0"/>
         <constraints>
-          <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
+          <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="true"/>
         </constraints>
         <properties/>
         <clientProperties>
@@ -77,9 +77,9 @@
               <text resource-bundle="messages/DebuggerBundle" key="breakpoint.properties.panel.option.suspend.default"/>
             </properties>
           </component>
-          <component id="cd928" class="com.intellij.ui.components.JBCheckBox" binding="myCbSuspend">
+          <component id="f0c10" class="javax.swing.JCheckBox" binding="myCbSuspend">
             <constraints>
-              <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
+              <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
             </constraints>
             <properties>
               <text value="&amp;Suspend"/>
@@ -90,7 +90,7 @@
       <grid id="5aab2" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
         <margin top="0" left="0" bottom="0" right="0"/>
         <constraints>
-          <grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
+          <grid row="3" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
         </constraints>
         <properties/>
         <border type="none"/>
@@ -412,6 +412,25 @@
           </grid>
         </children>
       </grid>
+      <grid id="22269" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
+        <margin top="0" left="0" bottom="0" right="0"/>
+        <constraints>
+          <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
+        </constraints>
+        <properties/>
+        <border type="none"/>
+        <children>
+          <component id="247a5" class="javax.swing.JCheckBox" binding="myEnabledCheckbox">
+            <constraints>
+              <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
+            </constraints>
+            <properties>
+              <font size="11" style="1"/>
+              <text value="Enabled"/>
+            </properties>
+          </component>
+        </children>
+      </grid>
     </children>
   </grid>
   <buttonGroups>
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointPropertiesPanel.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointPropertiesPanel.java
index a846590..f70c6ce 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointPropertiesPanel.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointPropertiesPanel.java
@@ -66,12 +66,9 @@
   private BreakpointChooser myMasterBreakpointChooser;
 
   public void setDetailView(DetailView detailView) {
-    myDetailView = detailView;
     myMasterBreakpointChooser.setDetailView(detailView);
   }
 
-  private DetailView myDetailView;
-
   protected final Project myProject;
   private final Key<? extends Breakpoint> myBreakpointCategory;
   private boolean myCompact;
@@ -102,7 +99,7 @@
 
   private JRadioButton myRbSuspendThread;
   private JRadioButton myRbSuspendAll;
-  private JBCheckBox myCbSuspend;
+  private JCheckBox myCbSuspend;
   private JButton myMakeDefaultButton;
 
   private JRadioButton myDisableAgainRadio;
@@ -115,8 +112,9 @@
   private JPanel myPassCountPanel;
   private JPanel myConditionsPanel;
   private JPanel myActionsPanel;
-  private JBCheckBox myConditionCheckbox;
+  private JCheckBox myConditionCheckbox;
   private JCheckBox myTemporaryCheckBox;
+  private JCheckBox myEnabledCheckbox;
 
   ButtonGroup mySuspendPolicyGroup;
   public static final String CONTROL_LOG_MESSAGE = "logMessage";
@@ -403,6 +401,7 @@
     IJSwingUtilities.adjustComponentsOnMac(myLogExpressionCheckBox);
     IJSwingUtilities.adjustComponentsOnMac(myLogMessageCheckBox);
     IJSwingUtilities.adjustComponentsOnMac(myTemporaryCheckBox);
+    IJSwingUtilities.adjustComponentsOnMac(myEnabledCheckbox);
   }
 
   private List<BreakpointItem> getBreakpointItemsExceptMy() {
@@ -533,6 +532,17 @@
     });
     myLogMessageCheckBox.setSelected(breakpoint.LOG_ENABLED);
     myTemporaryCheckBox.setSelected(breakpoint.REMOVE_AFTER_HIT);
+    myEnabledCheckbox.setSelected(breakpoint.ENABLED);
+    myEnabledCheckbox.setText(breakpoint.getDisplayName());
+    myEnabledCheckbox.addActionListener(new ActionListener() {
+      @Override
+      public void actionPerformed(ActionEvent event) {
+        if (myBreakpoint.ENABLED != myEnabledCheckbox.isSelected()) {
+          myBreakpoint.ENABLED = myEnabledCheckbox.isSelected();
+          getBreakpointManager(myProject).fireBreakpointChanged(myBreakpoint);
+        }
+      }
+    });
     myTemporaryCheckBox.setVisible(breakpoint instanceof LineBreakpoint);
     myLogExpressionCheckBox.setSelected(breakpoint.LOG_EXPRESSION_ENABLED);
     if (breakpoint.LOG_ENABLED || breakpoint.LOG_EXPRESSION_ENABLED || (breakpoint instanceof LineBreakpoint && breakpoint.REMOVE_AFTER_HIT)) {
@@ -649,6 +659,7 @@
     breakpoint.setLogMessage(myLogExpressionCombo.getText());
     breakpoint.LOG_EXPRESSION_ENABLED = !breakpoint.getLogMessage().isEmpty() && myLogExpressionCheckBox.isSelected();
     breakpoint.LOG_ENABLED = myLogMessageCheckBox.isSelected();
+    breakpoint.ENABLED = myEnabledCheckbox.isSelected();
     breakpoint.REMOVE_AFTER_HIT = myTemporaryCheckBox.isSelected();
     breakpoint.SUSPEND = myCbSuspend.isSelected();
     breakpoint.SUSPEND_POLICY = getSelectedSuspendPolicy();
diff --git a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointWithHighlighter.java b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointWithHighlighter.java
index 7ff853b..abd786f 100644
--- a/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointWithHighlighter.java
+++ b/java/debugger/impl/src/com/intellij/debugger/ui/breakpoints/BreakpointWithHighlighter.java
@@ -645,63 +645,13 @@
 
     @Override
     public ActionGroup getPopupMenuActions() {
-      final BreakpointManager breakpointManager = DebuggerManagerEx.getInstanceEx(myProject).getBreakpointManager();
-      /**
-       * Used from Popup Menu
-       */
-      class RemoveAction extends AnAction {
-        @Nullable private Breakpoint myBreakpoint;
+      return null;
+    }
 
-        public RemoveAction(Breakpoint breakpoint) {
-          super(DebuggerBundle.message("action.remove.text"));
-          myBreakpoint = breakpoint;
-        }
-
-        @Override
-        public void actionPerformed(AnActionEvent e) {
-          if (myBreakpoint != null) {
-            breakpointManager.removeBreakpoint(myBreakpoint);
-            myBreakpoint = null;
-          }
-        }
-      }
-
-      /**
-       * Used from Popup Menu
-       */
-      class SetEnabledAction extends AnAction {
-        private final boolean myNewValue;
-        private final Breakpoint myBreakpoint;
-
-        public SetEnabledAction(Breakpoint breakpoint, boolean newValue) {
-          super(newValue ? DebuggerBundle.message("action.enable.text") : DebuggerBundle.message("action.disable.text"));
-          myBreakpoint = breakpoint;
-          myNewValue = newValue;
-        }
-
-        @Override
-        public void actionPerformed(AnActionEvent e) {
-          myBreakpoint.ENABLED = myNewValue;
-          breakpointManager.fireBreakpointChanged(myBreakpoint);
-          myBreakpoint.updateUI();
-        }
-      }
-
-
-      AnAction viewBreakpointsAction =
-        new ViewBreakpointsAction(ActionsBundle.actionText(XDebuggerActions.VIEW_BREAKPOINTS), BreakpointWithHighlighter.this);
-
-      DefaultActionGroup group = new DefaultActionGroup();
-      RangeHighlighter highlighter = getHighlighter();
-      if (highlighter != null) {
-        group.add(new EditBreakpointAction.ContextAction(this, BreakpointWithHighlighter.this, DebuggerSupport.getDebuggerSupport(JavaDebuggerSupport.class)));
-        group.addSeparator();
-      }
-      group.add(new SetEnabledAction(BreakpointWithHighlighter.this, !ENABLED));
-      group.add(new RemoveAction(BreakpointWithHighlighter.this));
-      group.addSeparator();
-      group.add(viewBreakpointsAction);
-      return group;
+    @Nullable
+    @Override
+    public AnAction getRightButtonClickAction() {
+      return new EditBreakpointAction.ContextAction(this, BreakpointWithHighlighter.this, DebuggerSupport.getDebuggerSupport(JavaDebuggerSupport.class));
     }
 
     @Override
diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/FrameworkSupportNodeBase.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/FrameworkSupportNodeBase.java
index fbbf28b..c4632c0 100644
--- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/FrameworkSupportNodeBase.java
+++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/FrameworkSupportNodeBase.java
@@ -47,8 +47,9 @@
   @NotNull
   public abstract Icon getIcon();
 
+  @NotNull
   public List<FrameworkSupportNodeBase> getChildren() {
-    return children;
+    return children != null ? children : Collections.<FrameworkSupportNodeBase>emptyList();
   }
 
   public FrameworkSupportNodeBase getParentNode() {
diff --git a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/modes/CreateFromScratchMode.java b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/modes/CreateFromScratchMode.java
index 78f909d..cac536b 100644
--- a/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/modes/CreateFromScratchMode.java
+++ b/java/idea-ui/src/com/intellij/ide/util/newProjectWizard/modes/CreateFromScratchMode.java
@@ -33,6 +33,7 @@
 import org.jetbrains.annotations.Nullable;
 
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 public class CreateFromScratchMode extends WizardMode {
@@ -51,7 +52,7 @@
 
   @Nullable
   protected StepSequence createSteps(final WizardContext context, @NotNull final ModulesProvider modulesProvider) {
-    ModuleBuilder[] builders = context.getAllBuilders();
+    List<ModuleBuilder> builders = ModuleBuilder.getAllBuilders();
     for (ModuleBuilder builder : builders) {
       myBuildersMap.put(builder.getBuilderId(), builder);
     }
diff --git a/java/idea-ui/src/com/intellij/ide/util/projectWizard/ProjectWizardStepFactoryImpl.java b/java/idea-ui/src/com/intellij/ide/util/projectWizard/ProjectWizardStepFactoryImpl.java
index 877cce3..0d16ad5 100644
--- a/java/idea-ui/src/com/intellij/ide/util/projectWizard/ProjectWizardStepFactoryImpl.java
+++ b/java/idea-ui/src/com/intellij/ide/util/projectWizard/ProjectWizardStepFactoryImpl.java
@@ -27,6 +27,7 @@
 import com.intellij.openapi.roots.ui.configuration.projectRoot.LibrariesContainerFactory;
 import com.intellij.openapi.util.Computable;
 import com.intellij.openapi.util.Condition;
+import com.intellij.openapi.util.Key;
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
@@ -39,6 +40,7 @@
  *         Date: Oct 6, 2004
  */
 public class ProjectWizardStepFactoryImpl extends ProjectWizardStepFactory {
+  private static final Key<ProjectJdkStep> PROJECT_JDK_STEP_KEY = Key.create("ProjectJdkStep");
 
   public ModuleWizardStep createNameAndLocationStep(WizardContext wizardContext, JavaModuleBuilder builder, ModulesProvider modulesProvider, Icon icon, String helpId) {
     return new NameLocationStep(wizardContext, builder, modulesProvider, icon, helpId);
@@ -106,8 +108,8 @@
   }
 
   public ModuleWizardStep createProjectJdkStep(final WizardContext wizardContext) {
-    ModuleWizardStep projectSdkStep = wizardContext.getProjectSdkStep();
-    if (projectSdkStep instanceof ProjectJdkStep) {
+    ProjectJdkStep projectSdkStep = wizardContext.getUserData(PROJECT_JDK_STEP_KEY);
+    if (projectSdkStep != null) {
       return projectSdkStep;
     }
     projectSdkStep = new ProjectJdkStep(wizardContext) {
@@ -118,7 +120,7 @@
         return projectBuilder != null && !projectBuilder.isSuitableSdk(newProjectJdk);
       }
     };
-    wizardContext.setProjectSdkStep(projectSdkStep);
+    wizardContext.putUserData(PROJECT_JDK_STEP_KEY, projectSdkStep);
     return projectSdkStep;
   }
 
diff --git a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ClasspathEditor.java b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ClasspathEditor.java
index 19bb9be..89cc49e 100644
--- a/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ClasspathEditor.java
+++ b/java/idea-ui/src/com/intellij/openapi/roots/ui/configuration/ClasspathEditor.java
@@ -24,6 +24,7 @@
 import com.intellij.openapi.roots.ModuleRootEvent;
 import com.intellij.openapi.roots.ModuleRootListener;
 import com.intellij.openapi.roots.OrderEntry;
+import com.intellij.openapi.roots.impl.storage.ClassPathStorageUtil;
 import com.intellij.openapi.roots.impl.storage.ClasspathStorage;
 import com.intellij.openapi.roots.impl.storage.ClasspathStorageProvider;
 import com.intellij.openapi.roots.ui.configuration.classpath.ClasspathPanelImpl;
@@ -53,7 +54,7 @@
     super(state);
 
     final Disposable disposable = Disposer.newDisposable();
-    
+
     state.getProject().getMessageBus().connect(disposable).subscribe(ProjectTopics.PROJECT_ROOTS, this);
     registerDisposable(disposable);
   }
@@ -211,7 +212,7 @@
 
     @NotNull
     private String getModuleClasspathFormat() {
-      return ClasspathStorage.getStorageType(getModel().getModule());
+      return ClassPathStorageUtil.getStorageType(getModel().getModule());
     }
 
     boolean isModified() {
diff --git a/java/idea-ui/src/com/intellij/platform/templates/PlainModuleTemplatesFactory.java b/java/idea-ui/src/com/intellij/platform/templates/PlainModuleTemplatesFactory.java
index cd7d2c6..3ce17ab 100644
--- a/java/idea-ui/src/com/intellij/platform/templates/PlainModuleTemplatesFactory.java
+++ b/java/idea-ui/src/com/intellij/platform/templates/PlainModuleTemplatesFactory.java
@@ -70,14 +70,15 @@
         }
       })};
     }
-    ModuleBuilder[] builders = context.getAllBuilders();
-    return ContainerUtil.mapNotNull(builders, new NullableFunction<ModuleBuilder, ProjectTemplate>() {
+    List<ModuleBuilder> builders = ModuleBuilder.getAllBuilders();
+    List<ProjectTemplate> templates = ContainerUtil.mapNotNull(builders, new NullableFunction<ModuleBuilder, ProjectTemplate>() {
       @Nullable
       @Override
       public ProjectTemplate fun(ModuleBuilder builder) {
         return builder.getGroupName().equals(group) ? new BuilderBasedTemplate(builder) : null;
       }
-    }, ProjectTemplate.EMPTY_ARRAY);
+    });
+    return templates.toArray(new ProjectTemplate[templates.size()]);
   }
 
   @Override
diff --git a/java/java-analysis-api/java-analysis-api.iml b/java/java-analysis-api/java-analysis-api.iml
new file mode 100644
index 0000000..e4fd614
--- /dev/null
+++ b/java/java-analysis-api/java-analysis-api.iml
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="JAVA_MODULE" version="4">
+  <component name="NewModuleRootManager" inherit-compiler-output="true">
+    <exclude-output />
+    <content url="file://$MODULE_DIR$">
+      <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
+    </content>
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+    <orderEntry type="module" module-name="analysis-api" />
+    <orderEntry type="module" module-name="java-psi-api" />
+    <orderEntry type="module" module-name="projectModel-api" />
+  </component>
+</module>
+
diff --git a/java/java-analysis-api/src/com/intellij/codeInspection/AbstractBaseJavaLocalInspectionTool.java b/java/java-analysis-api/src/com/intellij/codeInspection/AbstractBaseJavaLocalInspectionTool.java
new file mode 100644
index 0000000..71054ce
--- /dev/null
+++ b/java/java-analysis-api/src/com/intellij/codeInspection/AbstractBaseJavaLocalInspectionTool.java
@@ -0,0 +1,110 @@
+/*
+ * Copyright 2000-2013 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.codeInspection;
+
+import com.intellij.psi.*;
+import com.intellij.psi.util.PsiTreeUtil;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+public class AbstractBaseJavaLocalInspectionTool extends LocalInspectionTool {
+  /**
+   * Override this to report problems at method level.
+   *
+   * @param method     to check.
+   * @param manager    InspectionManager to ask for ProblemDescriptors from.
+   * @param isOnTheFly true if called during on the fly editor highlighting. Called from Inspect Code action otherwise.
+   * @return <code>null</code> if no problems found or not applicable at method level.
+   */
+  @Nullable
+  public ProblemDescriptor[] checkMethod(@NotNull PsiMethod method, @NotNull InspectionManager manager, boolean isOnTheFly) {
+    return null;
+  }
+
+  /**
+   * Override this to report problems at class level.
+   *
+   * @param aClass     to check.
+   * @param manager    InspectionManager to ask for ProblemDescriptors from.
+   * @param isOnTheFly true if called during on the fly editor highlighting. Called from Inspect Code action otherwise.
+   * @return <code>null</code> if no problems found or not applicable at class level.
+   */
+  @Nullable
+  public ProblemDescriptor[] checkClass(@NotNull PsiClass aClass, @NotNull InspectionManager manager, boolean isOnTheFly) {
+    return null;
+  }
+
+  /**
+   * Override this to report problems at field level.
+   *
+   * @param field      to check.
+   * @param manager    InspectionManager to ask for ProblemDescriptors from.
+   * @param isOnTheFly true if called during on the fly editor highlighting. Called from Inspect Code action otherwise.
+   * @return <code>null</code> if no problems found or not applicable at field level.
+   */
+  @Nullable
+  public ProblemDescriptor[] checkField(@NotNull PsiField field, @NotNull InspectionManager manager, boolean isOnTheFly) {
+    return null;
+  }
+
+  /**
+     * Override this to report problems at file level.
+     *
+     * @param file       to check.
+     * @param manager    InspectionManager to ask for ProblemDescriptors from.
+     * @param isOnTheFly true if called during on the fly editor highlighting. Called from Inspect Code action otherwise.
+     * @return <code>null</code> if no problems found or not applicable at file level.
+     */
+  @Override
+  @Nullable
+  public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
+    return null;
+  }
+
+  @Override
+  @NotNull
+  public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, final boolean isOnTheFly) {
+    return new JavaElementVisitor() {
+      @Override public void visitMethod(PsiMethod method) {
+        addDescriptors(checkMethod(method, holder.getManager(), isOnTheFly));
+      }
+
+      @Override public void visitClass(PsiClass aClass) {
+        addDescriptors(checkClass(aClass, holder.getManager(), isOnTheFly));
+      }
+
+      @Override public void visitField(PsiField field) {
+        addDescriptors(checkField(field, holder.getManager(), isOnTheFly));
+      }
+
+      @Override public void visitFile(PsiFile file) {
+        addDescriptors(checkFile(file, holder.getManager(), isOnTheFly));
+      }
+      private void addDescriptors(final ProblemDescriptor[] descriptors) {
+        if (descriptors != null) {
+          for (ProblemDescriptor descriptor : descriptors) {
+            holder.registerProblem(descriptor);
+          }
+        }
+      }
+    };
+  }
+
+  @Override
+  public PsiNamedElement getProblemElement(final PsiElement psiElement) {
+    return PsiTreeUtil.getNonStrictParentOfType(psiElement, PsiFile.class, PsiClass.class, PsiMethod.class, PsiField.class);
+  }
+}
diff --git a/java/java-analysis-api/src/com/intellij/codeInspection/BaseJavaBatchLocalInspectionTool.java b/java/java-analysis-api/src/com/intellij/codeInspection/BaseJavaBatchLocalInspectionTool.java
new file mode 100644
index 0000000..36d4596
--- /dev/null
+++ b/java/java-analysis-api/src/com/intellij/codeInspection/BaseJavaBatchLocalInspectionTool.java
@@ -0,0 +1,43 @@
+/*
+ * Copyright 2000-2013 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.codeInspection;
+
+import com.intellij.codeInsight.daemon.HighlightDisplayKey;
+import com.intellij.psi.PsiElement;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+public abstract class BaseJavaBatchLocalInspectionTool extends AbstractBaseJavaLocalInspectionTool implements BatchSuppressableTool {
+  @NotNull
+  @Override
+  public SuppressQuickFix[] getBatchSuppressActions(@Nullable PsiElement element) {
+    return BatchSuppressManager.SERVICE.getInstance().createBatchSuppressActions(HighlightDisplayKey.find(getShortName()));
+  }
+
+  @Override
+  public boolean isSuppressedFor(@NotNull PsiElement element) {
+    return isSuppressedFor(element, this);
+  }
+
+  public static boolean isSuppressedFor(@NotNull PsiElement element, @NotNull LocalInspectionTool tool) {
+    BatchSuppressManager manager = BatchSuppressManager.SERVICE.getInstance();
+    String alternativeId;
+    String toolId = tool.getID();
+    return manager.isSuppressedFor(element, toolId) ||
+           (alternativeId = tool.getAlternativeID()) != null &&
+           !alternativeId.equals(toolId) && manager.isSuppressedFor(element, alternativeId);
+  }
+}
diff --git a/java/java-analysis-api/src/com/intellij/codeInspection/BatchSuppressManager.java b/java/java-analysis-api/src/com/intellij/codeInspection/BatchSuppressManager.java
new file mode 100644
index 0000000..1c96c8d
--- /dev/null
+++ b/java/java-analysis-api/src/com/intellij/codeInspection/BatchSuppressManager.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2000-2013 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.codeInspection;
+
+import com.intellij.codeInsight.daemon.HighlightDisplayKey;
+import com.intellij.openapi.components.ServiceManager;
+import com.intellij.psi.PsiDocCommentOwner;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiModifierListOwner;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.Collection;
+
+public interface BatchSuppressManager {
+  class SERVICE {
+    public static BatchSuppressManager getInstance() {
+      return ServiceManager.getService(BatchSuppressManager.class);
+    }
+  }
+  @NotNull
+  SuppressQuickFix[] createBatchSuppressActions(@NotNull HighlightDisplayKey key);
+
+  boolean isSuppressedFor(@NotNull PsiElement element, String toolId);
+
+  PsiElement getElementMemberSuppressedIn(@NotNull PsiDocCommentOwner owner, String inspectionToolID);
+
+  @Nullable
+  PsiElement getAnnotationMemberSuppressedIn(@NotNull PsiModifierListOwner owner, String inspectionToolID);
+
+  @Nullable
+  PsiElement getDocCommentToolSuppressedIn(@NotNull PsiDocCommentOwner owner, String inspectionToolID);
+
+  @NotNull
+  Collection<String> getInspectionIdsSuppressedInAnnotation(@NotNull PsiModifierListOwner owner);
+
+  @Nullable
+  String getSuppressedInspectionIdsIn(@NotNull PsiElement element);
+
+  @Nullable
+  PsiElement getElementToolSuppressedIn(@NotNull PsiElement place, String toolId);
+
+  boolean canHave15Suppressions(@NotNull PsiElement file);
+
+  boolean alreadyHas14Suppressions(@NotNull PsiDocCommentOwner commentOwner);
+}
diff --git a/java/java-analysis-impl/java-analysis-impl.iml b/java/java-analysis-impl/java-analysis-impl.iml
new file mode 100644
index 0000000..d4756de
--- /dev/null
+++ b/java/java-analysis-impl/java-analysis-impl.iml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="JAVA_MODULE" version="4">
+  <component name="NewModuleRootManager" inherit-compiler-output="true">
+    <exclude-output />
+    <content url="file://$MODULE_DIR$">
+      <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
+    </content>
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+    <orderEntry type="module" module-name="analysis-impl" exported="" />
+    <orderEntry type="module" module-name="java-indexing-impl" exported="" />
+    <orderEntry type="module" module-name="java-psi-impl" exported="" />
+    <orderEntry type="module" module-name="projectModel-impl" exported="" />
+    <orderEntry type="module" module-name="java-analysis-api" exported="" />
+  </component>
+</module>
+
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/actions/SuppressAllForClassFix.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/actions/SuppressAllForClassFix.java
similarity index 84%
rename from java/java-impl/src/com/intellij/codeInsight/daemon/impl/actions/SuppressAllForClassFix.java
rename to java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/actions/SuppressAllForClassFix.java
index abd7cef..d0154dc 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/actions/SuppressAllForClassFix.java
+++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/actions/SuppressAllForClassFix.java
@@ -16,12 +16,10 @@
 package com.intellij.codeInsight.daemon.impl.actions;
 
 import com.intellij.codeInsight.FileModificationService;
-import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
 import com.intellij.codeInspection.InspectionsBundle;
-import com.intellij.codeInspection.SuppressManager;
+import com.intellij.codeInspection.JavaSuppressionUtil;
 import com.intellij.codeInspection.SuppressionUtil;
 import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.project.Project;
 import com.intellij.psi.*;
 import com.intellij.psi.javadoc.PsiDocComment;
@@ -44,7 +42,7 @@
 
   @Override
   @Nullable
-  protected PsiDocCommentOwner getContainer(final PsiElement element) {
+  public PsiDocCommentOwner getContainer(final PsiElement element) {
     PsiDocCommentOwner container = super.getContainer(element);
     if (container == null) {
       return null;
@@ -66,17 +64,17 @@
   }
 
   @Override
-  public void invoke(@NotNull final Project project, final Editor editor, @NotNull final PsiElement element) throws IncorrectOperationException {
+  public void invoke(@NotNull final Project project, @NotNull final PsiElement element) throws IncorrectOperationException {
     final PsiDocCommentOwner container = getContainer(element);
     LOG.assertTrue(container != null);
     if (!FileModificationService.getInstance().preparePsiElementForWrite(container)) return;
     if (use15Suppressions(container)) {
       final PsiModifierList modifierList = container.getModifierList();
       if (modifierList != null) {
-        final PsiAnnotation annotation = modifierList.findAnnotation(SuppressManager.SUPPRESS_INSPECTIONS_ANNOTATION_NAME);
+        final PsiAnnotation annotation = modifierList.findAnnotation(JavaSuppressionUtil.SUPPRESS_INSPECTIONS_ANNOTATION_NAME);
         if (annotation != null) {
           annotation.replace(JavaPsiFacade.getInstance(project).getElementFactory().createAnnotationFromText("@" +
-                                                                                                             SuppressManager.SUPPRESS_INSPECTIONS_ANNOTATION_NAME + "(\"" +
+                                                                                                             JavaSuppressionUtil.SUPPRESS_INSPECTIONS_ANNOTATION_NAME + "(\"" +
                                                                                                              SuppressionUtil.ALL + "\")", container));
           return;
         }
@@ -89,12 +87,13 @@
         if (noInspectionTag != null) {
           String tagText = "@" + SuppressionUtil.SUPPRESS_INSPECTIONS_TAG_NAME + " " + SuppressionUtil.ALL;
           noInspectionTag.replace(JavaPsiFacade.getInstance(project).getElementFactory().createDocTagFromText(tagText));
-          DaemonCodeAnalyzer.getInstance(project).restart();
+          // todo suppress
+          //DaemonCodeAnalyzer.getInstance(project).restart();
           return;
         }
       }
     }
 
-    super.invoke(project, editor, element);
+    super.invoke(project, element);
   }
 }
diff --git a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/actions/SuppressByJavaCommentFix.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/actions/SuppressByJavaCommentFix.java
new file mode 100644
index 0000000..5ab772d
--- /dev/null
+++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/actions/SuppressByJavaCommentFix.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2000-2013 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.codeInsight.daemon.impl.actions;
+
+import com.intellij.codeInsight.daemon.HighlightDisplayKey;
+import com.intellij.codeInspection.JavaSuppressionUtil;
+import com.intellij.openapi.project.Project;
+import com.intellij.psi.*;
+import com.intellij.psi.util.PsiTreeUtil;
+import com.intellij.util.IncorrectOperationException;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * @author yole
+ */
+public class SuppressByJavaCommentFix extends SuppressByCommentFix {
+  public SuppressByJavaCommentFix(@NotNull HighlightDisplayKey key) {
+    super(key, PsiStatement.class);
+  }
+
+  @Override
+  @Nullable
+  public PsiElement getContainer(PsiElement context) {
+    if (hasJspMethodCallAsParent(context)) return null;
+    return PsiTreeUtil.getParentOfType(context, PsiStatement.class, false);
+  }
+
+  private static boolean hasJspMethodCallAsParent(PsiElement context) {
+    while (true) {
+      PsiMethod method = PsiTreeUtil.getParentOfType(context, PsiMethod.class);
+      if (method == null) return false;
+      if (method instanceof SyntheticElement) return true;
+      context = method;
+    }
+  }
+
+  @Override
+  protected void createSuppression(@NotNull final Project project,
+                                   @NotNull final PsiElement element,
+                                   @NotNull final PsiElement container) throws IncorrectOperationException {
+    PsiElement declaredElement = JavaSuppressionUtil.getElementToAnnotate(element, container);
+    if (declaredElement == null) {
+      suppressWithComment(project, element, container);
+    }
+    else {
+      JavaSuppressionUtil.addSuppressAnnotation(project, container, (PsiLocalVariable)declaredElement, myID);
+    }
+  }
+
+  protected void suppressWithComment(Project project, PsiElement element, PsiElement container) {
+    super.createSuppression(project, element, container);
+  }
+}
diff --git a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/actions/SuppressFix.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/actions/SuppressFix.java
new file mode 100644
index 0000000..67c483e
--- /dev/null
+++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/actions/SuppressFix.java
@@ -0,0 +1,159 @@
+/*
+ * Copyright 2000-2013 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.codeInsight.daemon.impl.actions;
+
+import com.intellij.codeInsight.FileModificationService;
+import com.intellij.codeInsight.daemon.HighlightDisplayKey;
+import com.intellij.codeInspection.InspectionsBundle;
+import com.intellij.codeInspection.JavaSuppressionUtil;
+import com.intellij.codeInspection.SuppressionUtil;
+import com.intellij.lang.java.JavaLanguage;
+import com.intellij.openapi.command.undo.UndoUtil;
+import com.intellij.openapi.module.Module;
+import com.intellij.openapi.module.ModuleUtilCore;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.roots.impl.storage.ClassPathStorageUtil;
+import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.psi.*;
+import com.intellij.psi.javadoc.PsiDocComment;
+import com.intellij.psi.javadoc.PsiDocTag;
+import com.intellij.psi.util.PsiTreeUtil;
+import com.intellij.util.IncorrectOperationException;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * @author ven
+ */
+public class SuppressFix extends AbstractBatchSuppressByNoInspectionCommentFix {
+  private String myAlternativeID;
+
+  public SuppressFix(@NotNull HighlightDisplayKey key) {
+    this(key.getID());
+    myAlternativeID = HighlightDisplayKey.getAlternativeID(key);
+  }
+
+  public SuppressFix(@NotNull String ID) {
+    super(ID, false);
+  }
+
+  @Override
+  @NotNull
+  public String getText() {
+    String myText = super.getText();
+    return StringUtil.isEmpty(myText) ? "Suppress for member" : myText;
+  }
+
+  @Override
+  @Nullable
+  public PsiDocCommentOwner getContainer(final PsiElement context) {
+    if (context == null || !context.getManager().isInProject(context)) {
+      return null;
+    }
+    final PsiFile containingFile = context.getContainingFile();
+    if (containingFile == null) {
+      // for PsiDirectory
+      return null;
+    }
+    if (!containingFile.getLanguage().isKindOf(JavaLanguage.INSTANCE) || context instanceof PsiFile) {
+      return null;
+    }
+    PsiElement container = context;
+    while (container instanceof PsiAnonymousClass || !(container instanceof PsiDocCommentOwner) || container instanceof PsiTypeParameter) {
+      container = PsiTreeUtil.getParentOfType(container, PsiDocCommentOwner.class);
+      if (container == null) return null;
+    }
+    return (PsiDocCommentOwner)container;
+  }
+
+  @Override
+  public boolean isAvailable(@NotNull final Project project, @NotNull final PsiElement context) {
+    PsiDocCommentOwner container = getContainer(context);
+    boolean isValid = container != null && !(container instanceof PsiMethod && container instanceof SyntheticElement);
+    if (!isValid) {
+      return false;
+    }
+    setText(container instanceof PsiClass
+            ? InspectionsBundle.message("suppress.inspection.class")
+            : container instanceof PsiMethod ? InspectionsBundle.message("suppress.inspection.method") : InspectionsBundle.message("suppress.inspection.field"));
+    return true;
+  }
+
+  @Override
+  public void invoke(@NotNull final Project project, @NotNull final PsiElement element) throws IncorrectOperationException {
+    if (doSuppress(project, getContainer(element))) return;
+    // todo suppress
+    //DaemonCodeAnalyzer.getInstance(project).restart();
+    UndoUtil.markPsiFileForUndo(element.getContainingFile());
+  }
+
+  private boolean doSuppress(@NotNull Project project, PsiDocCommentOwner container) {
+    assert container != null;
+    if (!FileModificationService.getInstance().preparePsiElementForWrite(container)) return true;
+    if (use15Suppressions(container)) {
+      final PsiModifierList modifierList = container.getModifierList();
+      if (modifierList != null) {
+        JavaSuppressionUtil.addSuppressAnnotation(project, container, container, getID(container));
+      }
+    }
+    else {
+      PsiDocComment docComment = container.getDocComment();
+      PsiManager manager = PsiManager.getInstance(project);
+      if (docComment == null) {
+        String commentText = "/** @" + SuppressionUtil.SUPPRESS_INSPECTIONS_TAG_NAME + " " + getID(container) + "*/";
+        docComment = JavaPsiFacade.getInstance(manager.getProject()).getElementFactory().createDocCommentFromText(commentText);
+        PsiElement firstChild = container.getFirstChild();
+        container.addBefore(docComment, firstChild);
+      }
+      else {
+        PsiDocTag noInspectionTag = docComment.findTagByName(SuppressionUtil.SUPPRESS_INSPECTIONS_TAG_NAME);
+        if (noInspectionTag != null) {
+          String tagText = noInspectionTag.getText() + ", " + getID(container);
+          noInspectionTag.replace(JavaPsiFacade.getInstance(manager.getProject()).getElementFactory().createDocTagFromText(tagText));
+        }
+        else {
+          String tagText = "@" + SuppressionUtil.SUPPRESS_INSPECTIONS_TAG_NAME + " " + getID(container);
+          docComment.add(JavaPsiFacade.getInstance(manager.getProject()).getElementFactory().createDocTagFromText(tagText));
+        }
+      }
+    }
+    return false;
+  }
+
+  protected boolean use15Suppressions(@NotNull PsiDocCommentOwner container) {
+    return JavaSuppressionUtil.canHave15Suppressions(container) &&
+           !JavaSuppressionUtil.alreadyHas14Suppressions(container);
+  }
+
+  private String getID(@NotNull PsiElement place) {
+    String id = getID(place, myAlternativeID);
+    return id != null ? id : myID;
+  }
+
+  @Nullable
+  static String getID(@NotNull PsiElement place, String alternativeID) {
+    if (alternativeID != null) {
+      final Module module = ModuleUtilCore.findModuleForPsiElement(place);
+      if (module != null) {
+        if (!ClassPathStorageUtil.isDefaultStorage(module)) {
+          return alternativeID;
+        }
+      }
+    }
+
+    return null;
+  }
+}
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/actions/SuppressForClassFix.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/actions/SuppressForClassFix.java
similarity index 95%
rename from java/java-impl/src/com/intellij/codeInsight/daemon/impl/actions/SuppressForClassFix.java
rename to java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/actions/SuppressForClassFix.java
index d8e5126..a24fd46 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/actions/SuppressForClassFix.java
+++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/actions/SuppressForClassFix.java
@@ -39,7 +39,8 @@
   }
 
   @Override
-  @Nullable protected PsiDocCommentOwner getContainer(final PsiElement element) {
+  @Nullable
+  public PsiDocCommentOwner getContainer(final PsiElement element) {
     PsiDocCommentOwner container = super.getContainer(element);
     if (container == null || container instanceof PsiClass){
       return null;
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/actions/SuppressLocalWithCommentFix.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/actions/SuppressLocalWithCommentFix.java
similarity index 75%
rename from java/java-impl/src/com/intellij/codeInsight/daemon/impl/actions/SuppressLocalWithCommentFix.java
rename to java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/actions/SuppressLocalWithCommentFix.java
index 6f589aa..638bb9f 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/actions/SuppressLocalWithCommentFix.java
+++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/actions/SuppressLocalWithCommentFix.java
@@ -16,7 +16,7 @@
 package com.intellij.codeInsight.daemon.impl.actions;
 
 import com.intellij.codeInsight.daemon.HighlightDisplayKey;
-import com.intellij.openapi.editor.Editor;
+import com.intellij.codeInspection.JavaSuppressionUtil;
 import com.intellij.openapi.project.Project;
 import com.intellij.psi.PsiElement;
 import com.intellij.util.IncorrectOperationException;
@@ -27,25 +27,25 @@
  * User: anna
  */
 public class SuppressLocalWithCommentFix extends SuppressByJavaCommentFix {
-  public SuppressLocalWithCommentFix(HighlightDisplayKey key) {
+  public SuppressLocalWithCommentFix(@NotNull HighlightDisplayKey key) {
     super(key);
   }
 
   @Nullable
   @Override
-  protected PsiElement getContainer(PsiElement context) {
+  public PsiElement getContainer(PsiElement context) {
     final PsiElement container = super.getContainer(context);
     if (container != null) {
-      final PsiElement elementToAnnotate = getElementToAnnotate(context, container);
+      final PsiElement elementToAnnotate = JavaSuppressionUtil.getElementToAnnotate(context, container);
       if (elementToAnnotate == null) return null;
     }
     return container;
   }
 
   @Override
-  protected void createSuppression(Project project, Editor editor, PsiElement element, PsiElement container)
+  protected void createSuppression(@NotNull Project project, @NotNull PsiElement element, @NotNull PsiElement container)
     throws IncorrectOperationException {
-    suppressWithComment(project, editor, element, container);
+    suppressWithComment(project, element, container);
   }
 
   @NotNull
diff --git a/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/actions/SuppressParameterFix.java b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/actions/SuppressParameterFix.java
new file mode 100644
index 0000000..55b0bb9
--- /dev/null
+++ b/java/java-analysis-impl/src/com/intellij/codeInsight/daemon/impl/actions/SuppressParameterFix.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2000-2011 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.codeInsight.daemon.impl.actions;
+
+import com.intellij.codeInsight.daemon.HighlightDisplayKey;
+import com.intellij.codeInspection.JavaSuppressionUtil;
+import com.intellij.openapi.project.Project;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiModifierList;
+import com.intellij.psi.PsiModifierListOwner;
+import com.intellij.psi.PsiParameter;
+import com.intellij.psi.util.PsiTreeUtil;
+import com.intellij.util.IncorrectOperationException;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * @author ven
+ */
+public class SuppressParameterFix extends AbstractBatchSuppressByNoInspectionCommentFix {
+  private String myAlternativeID;
+
+  public SuppressParameterFix(@NotNull HighlightDisplayKey key) {
+    this(key.getID());
+    myAlternativeID = HighlightDisplayKey.getAlternativeID(key);
+  }
+
+  public SuppressParameterFix(String ID) {
+    super(ID, false);
+  }
+
+  @Override
+  @NotNull
+  public String getText() {
+    return "Suppress for parameter";
+  }
+
+  @Nullable
+  @Override
+  public PsiElement getContainer(PsiElement context) {
+    PsiParameter psiParameter = PsiTreeUtil.getParentOfType(context, PsiParameter.class, false);
+    return psiParameter != null && JavaSuppressionUtil.canHave15Suppressions(psiParameter) ? psiParameter : null;
+  }
+
+  @Override
+  protected boolean replaceSuppressionComments(PsiElement container) {
+    return false;
+  }
+
+  @Override
+  protected void createSuppression(@NotNull Project project, @NotNull PsiElement element, @NotNull PsiElement cont)
+    throws IncorrectOperationException {
+    PsiModifierListOwner container = (PsiModifierListOwner)cont;
+    final PsiModifierList modifierList = container.getModifierList();
+    if (modifierList != null) {
+      final String id = SuppressFix.getID(container, myAlternativeID);
+      JavaSuppressionUtil.addSuppressAnnotation(project, container, container, id != null ? id : myID);
+    }
+  }
+}
diff --git a/java/java-impl/src/com/intellij/codeInspection/AnonymousCanBeLambdaInspection.java b/java/java-analysis-impl/src/com/intellij/codeInspection/AnonymousCanBeLambdaInspection.java
similarity index 98%
rename from java/java-impl/src/com/intellij/codeInspection/AnonymousCanBeLambdaInspection.java
rename to java/java-analysis-impl/src/com/intellij/codeInspection/AnonymousCanBeLambdaInspection.java
index 16d6554..b5b3d3e 100644
--- a/java/java-impl/src/com/intellij/codeInspection/AnonymousCanBeLambdaInspection.java
+++ b/java/java-analysis-impl/src/com/intellij/codeInspection/AnonymousCanBeLambdaInspection.java
@@ -35,7 +35,7 @@
 /**
  * User: anna
  */
-public class AnonymousCanBeLambdaInspection extends BaseJavaLocalInspectionTool {
+public class AnonymousCanBeLambdaInspection extends BaseJavaBatchLocalInspectionTool {
   public static final Logger LOG = Logger.getInstance("#" + AnonymousCanBeLambdaInspection.class.getName());
 
   @Nls
diff --git a/java/java-impl/src/com/intellij/codeInspection/AnonymousCanBeMethodReferenceInspection.java b/java/java-analysis-impl/src/com/intellij/codeInspection/AnonymousCanBeMethodReferenceInspection.java
similarity index 90%
rename from java/java-impl/src/com/intellij/codeInspection/AnonymousCanBeMethodReferenceInspection.java
rename to java/java-analysis-impl/src/com/intellij/codeInspection/AnonymousCanBeMethodReferenceInspection.java
index ca75ae4..4e30fc3 100644
--- a/java/java-impl/src/com/intellij/codeInspection/AnonymousCanBeMethodReferenceInspection.java
+++ b/java/java-analysis-impl/src/com/intellij/codeInspection/AnonymousCanBeMethodReferenceInspection.java
@@ -30,7 +30,7 @@
 /**
  * User: anna
  */
-public class AnonymousCanBeMethodReferenceInspection extends BaseJavaLocalInspectionTool {
+public class AnonymousCanBeMethodReferenceInspection extends BaseJavaBatchLocalInspectionTool {
   public static final Logger LOG = Logger.getInstance("#" + AnonymousCanBeMethodReferenceInspection.class.getName());
 
   @Nls
@@ -73,13 +73,14 @@
             if (methods.length == 1 && aClass.getFields().length == 0) {
               final PsiCodeBlock body = methods[0].getBody();
               final PsiCallExpression callExpression =
-                LambdaCanBeMethReferenceInspection.canBeMethodReferenceProblem(body, methods[0].getParameterList().getParameters(), baseClassType);
+                LambdaCanBeMethodReferenceInspection
+                  .canBeMethodReferenceProblem(body, methods[0].getParameterList().getParameters(), baseClassType);
               if (callExpression != null && callExpression.resolveMethod() != methods[0]) {
                 final PsiElement parent = aClass.getParent();
                 if (parent instanceof PsiNewExpression) {
                   final PsiJavaCodeReferenceElement classReference = ((PsiNewExpression)parent).getClassOrAnonymousClassReference();
                   if (classReference != null) {
-                    holder.registerProblem(classReference, 
+                    holder.registerProblem(classReference,
                                            "Anonymous type can be replaced with method reference", new ReplaceWithMethodRefFix());
                   }
                 }
@@ -97,13 +98,13 @@
       public String getName() {
         return "Replace with method reference";
       }
-  
+
       @NotNull
       @Override
       public String getFamilyName() {
         return getName();
       }
-  
+
       @Override
       public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
         final PsiElement element = descriptor.getPsiElement();
@@ -113,10 +114,11 @@
         if (methods.length != 1) return;
 
         final PsiParameter[] parameters = methods[0].getParameterList().getParameters();
-        final PsiCallExpression callExpression = LambdaCanBeMethReferenceInspection.canBeMethodReferenceProblem(methods[0].getBody(), parameters, anonymousClass.getBaseClassType());
+        final PsiCallExpression callExpression = LambdaCanBeMethodReferenceInspection
+          .canBeMethodReferenceProblem(methods[0].getBody(), parameters, anonymousClass.getBaseClassType());
         if (callExpression == null) return;
         final String methodRefText =
-          LambdaCanBeMethReferenceInspection.createMethodReferenceText(callExpression, anonymousClass.getBaseClassType());
+          LambdaCanBeMethodReferenceInspection.createMethodReferenceText(callExpression, anonymousClass.getBaseClassType());
 
         if (methodRefText != null) {
           final String canonicalText = anonymousClass.getBaseClassType().getCanonicalText();
diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/BatchSuppressManagerImpl.java b/java/java-analysis-impl/src/com/intellij/codeInspection/BatchSuppressManagerImpl.java
new file mode 100644
index 0000000..d2a2675
--- /dev/null
+++ b/java/java-analysis-impl/src/com/intellij/codeInspection/BatchSuppressManagerImpl.java
@@ -0,0 +1,93 @@
+/*
+ * Copyright 2000-2013 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.codeInspection;
+
+import com.intellij.codeInsight.daemon.HighlightDisplayKey;
+import com.intellij.codeInsight.daemon.impl.actions.*;
+import com.intellij.psi.PsiDocCommentOwner;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiModifierListOwner;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.Collection;
+
+public class BatchSuppressManagerImpl implements BatchSuppressManager {
+  @NotNull
+  @Override
+  public SuppressQuickFix[] createBatchSuppressActions(@NotNull HighlightDisplayKey displayKey) {
+    return new SuppressQuickFix[] {
+        new SuppressByJavaCommentFix(displayKey),
+        new SuppressLocalWithCommentFix(displayKey),
+        new SuppressParameterFix(displayKey),
+        new SuppressFix(displayKey),
+        new SuppressForClassFix(displayKey),
+        new SuppressAllForClassFix()
+      };
+
+  }
+
+  @Override
+  public boolean isSuppressedFor(@NotNull final PsiElement element, final String toolId) {
+    return JavaSuppressionUtil.getElementToolSuppressedIn(element, toolId) != null;
+  }
+
+  @Override
+  @Nullable
+  public PsiElement getElementMemberSuppressedIn(@NotNull final PsiDocCommentOwner owner, final String inspectionToolID) {
+    return JavaSuppressionUtil.getElementMemberSuppressedIn(owner, inspectionToolID);
+  }
+
+  @Override
+  @Nullable
+  public PsiElement getAnnotationMemberSuppressedIn(@NotNull final PsiModifierListOwner owner, final String inspectionToolID) {
+    return JavaSuppressionUtil.getAnnotationMemberSuppressedIn(owner, inspectionToolID);
+  }
+
+  @Override
+  @Nullable
+  public PsiElement getDocCommentToolSuppressedIn(@NotNull final PsiDocCommentOwner owner, final String inspectionToolID) {
+    return JavaSuppressionUtil.getDocCommentToolSuppressedIn(owner, inspectionToolID);
+  }
+
+  @Override
+  @NotNull
+  public Collection<String> getInspectionIdsSuppressedInAnnotation(@NotNull final PsiModifierListOwner owner) {
+    return JavaSuppressionUtil.getInspectionIdsSuppressedInAnnotation(owner);
+  }
+
+  @Override
+  @Nullable
+  public String getSuppressedInspectionIdsIn(@NotNull PsiElement element) {
+    return JavaSuppressionUtil.getSuppressedInspectionIdsIn(element);
+  }
+
+  @Override
+  @Nullable
+  public PsiElement getElementToolSuppressedIn(@NotNull final PsiElement place, final String toolId) {
+    return JavaSuppressionUtil.getElementToolSuppressedIn(place, toolId);
+  }
+
+  @Override
+  public boolean canHave15Suppressions(@NotNull final PsiElement file) {
+    return JavaSuppressionUtil.canHave15Suppressions(file);
+  }
+
+  @Override
+  public boolean alreadyHas14Suppressions(@NotNull final PsiDocCommentOwner commentOwner) {
+    return JavaSuppressionUtil.alreadyHas14Suppressions(commentOwner);
+  }
+}
diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/JavaSuppressionUtil.java b/java/java-analysis-impl/src/com/intellij/codeInspection/JavaSuppressionUtil.java
new file mode 100644
index 0000000..10ec76b
--- /dev/null
+++ b/java/java-analysis-impl/src/com/intellij/codeInspection/JavaSuppressionUtil.java
@@ -0,0 +1,320 @@
+/*
+ * Copyright 2000-2013 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.codeInspection;
+
+import com.intellij.codeInsight.AnnotationUtil;
+import com.intellij.codeInsight.daemon.DaemonCodeAnalyzerSettings;
+import com.intellij.codeInsight.intention.AddAnnotationPsiFix;
+import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.module.Module;
+import com.intellij.openapi.module.ModuleUtilCore;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.projectRoots.JavaSdkVersion;
+import com.intellij.openapi.projectRoots.JdkVersionUtil;
+import com.intellij.openapi.projectRoots.Sdk;
+import com.intellij.openapi.roots.ModuleRootManager;
+import com.intellij.openapi.util.Computable;
+import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.psi.*;
+import com.intellij.psi.impl.PsiVariableEx;
+import com.intellij.psi.javadoc.PsiDocComment;
+import com.intellij.psi.javadoc.PsiDocTag;
+import com.intellij.psi.util.PsiTreeUtil;
+import com.intellij.psi.util.PsiUtil;
+import com.intellij.util.IncorrectOperationException;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import javax.annotation.Generated;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.regex.Matcher;
+
+public class JavaSuppressionUtil {
+  public static final String SUPPRESS_INSPECTIONS_ANNOTATION_NAME = "java.lang.SuppressWarnings";
+  public static boolean alreadyHas14Suppressions(@NotNull PsiDocCommentOwner commentOwner) {
+    final PsiDocComment docComment = commentOwner.getDocComment();
+    return docComment != null && docComment.findTagByName(SuppressionUtil.SUPPRESS_INSPECTIONS_TAG_NAME) != null;
+  }
+
+  @Nullable
+  public static String getInspectionIdSuppressedInAnnotationAttribute(PsiElement element) {
+    if (element instanceof PsiLiteralExpression) {
+      final Object value = ((PsiLiteralExpression)element).getValue();
+      if (value instanceof String) {
+        return (String)value;
+      }
+    }
+    else if (element instanceof PsiReferenceExpression) {
+      final PsiElement psiElement = ((PsiReferenceExpression)element).resolve();
+      if (psiElement instanceof PsiVariableEx) {
+        final Object val = ((PsiVariableEx)psiElement).computeConstantValue(new HashSet<PsiVariable>());
+        if (val instanceof String) {
+          return (String)val;
+        }
+      }
+    }
+    return null;
+  }
+
+  @NotNull
+  public static Collection<String> getInspectionIdsSuppressedInAnnotation(final PsiModifierList modifierList) {
+    if (modifierList == null) {
+      return Collections.emptyList();
+    }
+    final PsiModifierListOwner owner = (PsiModifierListOwner)modifierList.getParent();
+    PsiAnnotation annotation = AnnotationUtil.findAnnotation(owner, SUPPRESS_INSPECTIONS_ANNOTATION_NAME);
+    if (annotation == null) {
+      return Collections.emptyList();
+    }
+    final PsiNameValuePair[] attributes = annotation.getParameterList().getAttributes();
+    if (attributes.length == 0) {
+      return Collections.emptyList();
+    }
+    final PsiAnnotationMemberValue attributeValue = attributes[0].getValue();
+    Collection<String> result = new ArrayList<String>();
+    if (attributeValue instanceof PsiArrayInitializerMemberValue) {
+      final PsiAnnotationMemberValue[] initializers = ((PsiArrayInitializerMemberValue)attributeValue).getInitializers();
+      for (PsiAnnotationMemberValue annotationMemberValue : initializers) {
+        final String id = getInspectionIdSuppressedInAnnotationAttribute(annotationMemberValue);
+        if (id != null) {
+          result.add(id);
+        }
+      }
+    }
+    else {
+      final String id = getInspectionIdSuppressedInAnnotationAttribute(attributeValue);
+      if (id != null) {
+        result.add(id);
+      }
+    }
+    return result;
+  }
+
+  static PsiElement getElementMemberSuppressedIn(@NotNull PsiDocCommentOwner owner, String inspectionToolID) {
+    PsiElement element = getDocCommentToolSuppressedIn(owner, inspectionToolID);
+    if (element != null) return element;
+    element = getAnnotationMemberSuppressedIn(owner, inspectionToolID);
+    if (element != null) return element;
+    PsiDocCommentOwner classContainer = PsiTreeUtil.getParentOfType(owner, PsiDocCommentOwner.class);
+    while (classContainer != null) {
+      element = getDocCommentToolSuppressedIn(classContainer, inspectionToolID);
+      if (element != null) return element;
+
+      element = getAnnotationMemberSuppressedIn(classContainer, inspectionToolID);
+      if (element != null) return element;
+
+      classContainer = PsiTreeUtil.getParentOfType(classContainer, PsiDocCommentOwner.class);
+    }
+    return null;
+  }
+
+  static PsiElement getAnnotationMemberSuppressedIn(@NotNull PsiModifierListOwner owner, String inspectionToolID) {
+    final PsiAnnotation generatedAnnotation = AnnotationUtil.findAnnotation(owner, Generated.class.getName());
+    if (generatedAnnotation != null) return generatedAnnotation;
+    PsiModifierList modifierList = owner.getModifierList();
+    Collection<String> suppressedIds = getInspectionIdsSuppressedInAnnotation(modifierList);
+    for (String ids : suppressedIds) {
+      if (SuppressionUtil.isInspectionToolIdMentioned(ids, inspectionToolID)) {
+        return modifierList != null ? AnnotationUtil.findAnnotation(owner, SUPPRESS_INSPECTIONS_ANNOTATION_NAME) : null;
+      }
+    }
+    return null;
+  }
+
+  static PsiElement getDocCommentToolSuppressedIn(@NotNull PsiDocCommentOwner owner, String inspectionToolID) {
+    PsiDocComment docComment = owner.getDocComment();
+    if (docComment == null && owner.getParent() instanceof PsiDeclarationStatement) {
+      final PsiElement el = PsiTreeUtil.skipSiblingsBackward(owner.getParent(), PsiWhiteSpace.class);
+      if (el instanceof PsiDocComment) {
+        docComment = (PsiDocComment)el;
+      }
+    }
+    if (docComment != null) {
+      PsiDocTag inspectionTag = docComment.findTagByName(SuppressionUtil.SUPPRESS_INSPECTIONS_TAG_NAME);
+      if (inspectionTag != null) {
+        final PsiElement[] dataElements = inspectionTag.getDataElements();
+        for (PsiElement dataElement : dataElements) {
+          String valueText = dataElement.getText();
+          if (SuppressionUtil.isInspectionToolIdMentioned(valueText, inspectionToolID)) {
+            return docComment;
+          }
+        }
+      }
+    }
+    return null;
+  }
+
+  static Collection<String> getInspectionIdsSuppressedInAnnotation(@NotNull PsiModifierListOwner owner) {
+    if (!PsiUtil.isLanguageLevel5OrHigher(owner)) return Collections.emptyList();
+    PsiModifierList modifierList = owner.getModifierList();
+    return getInspectionIdsSuppressedInAnnotation(modifierList);
+  }
+
+  static String getSuppressedInspectionIdsIn(@NotNull PsiElement element) {
+    if (element instanceof PsiComment) {
+      String text = element.getText();
+      Matcher matcher = SuppressionUtil.SUPPRESS_IN_LINE_COMMENT_PATTERN.matcher(text);
+      if (matcher.matches()) {
+        return matcher.group(1).trim();
+      }
+    }
+    if (element instanceof PsiDocCommentOwner) {
+      PsiDocComment docComment = ((PsiDocCommentOwner)element).getDocComment();
+      if (docComment != null) {
+        PsiDocTag inspectionTag = docComment.findTagByName(SuppressionUtil.SUPPRESS_INSPECTIONS_TAG_NAME);
+        if (inspectionTag != null) {
+          String valueText = "";
+          for (PsiElement dataElement : inspectionTag.getDataElements()) {
+            valueText += dataElement.getText();
+          }
+          return valueText;
+        }
+      }
+    }
+    if (element instanceof PsiModifierListOwner) {
+      Collection<String> suppressedIds = getInspectionIdsSuppressedInAnnotation((PsiModifierListOwner)element);
+      return suppressedIds.isEmpty() ? null : StringUtil.join(suppressedIds, ",");
+    }
+    return null;
+  }
+
+  static PsiElement getElementToolSuppressedIn(@NotNull final PsiElement place, final String toolId) {
+    if (place instanceof PsiFile) return null;
+    return ApplicationManager.getApplication().runReadAction(new Computable<PsiElement>() {
+      @Override
+      @Nullable
+      public PsiElement compute() {
+        final PsiElement statement = SuppressionUtil.getStatementToolSuppressedIn(place, toolId, PsiStatement.class);
+        if (statement != null) {
+          return statement;
+        }
+
+        PsiVariable local = PsiTreeUtil.getParentOfType(place, PsiVariable.class);
+        if (local != null && getAnnotationMemberSuppressedIn(local, toolId) != null) {
+          PsiModifierList modifierList = local.getModifierList();
+          return modifierList != null ? modifierList.findAnnotation(SUPPRESS_INSPECTIONS_ANNOTATION_NAME) : null;
+        }
+
+        PsiDocCommentOwner container = PsiTreeUtil.getNonStrictParentOfType(place, PsiDocCommentOwner.class);
+        while (true) {
+          if (!(container instanceof PsiTypeParameter)) break;
+          container = PsiTreeUtil.getParentOfType(container, PsiDocCommentOwner.class);
+        }
+
+        if (container != null) {
+          PsiElement element = getElementMemberSuppressedIn(container, toolId);
+          if (element != null) return element;
+        }
+        PsiDocCommentOwner classContainer = PsiTreeUtil.getParentOfType(container, PsiDocCommentOwner.class, true);
+        if (classContainer != null) {
+          PsiElement element = getElementMemberSuppressedIn(classContainer, toolId);
+          if (element != null) return element;
+        }
+
+        return null;
+      }
+    });
+  }
+
+  public static void addSuppressAnnotation(@NotNull Project project,
+                                           final PsiElement container,
+                                           final PsiModifierListOwner modifierOwner,
+                                           @NotNull String id) throws IncorrectOperationException {
+    PsiAnnotation annotation = AnnotationUtil.findAnnotation(modifierOwner, SUPPRESS_INSPECTIONS_ANNOTATION_NAME);
+    final PsiAnnotation newAnnotation = createNewAnnotation(project, container, annotation, id);
+    if (newAnnotation != null) {
+      if (annotation != null && annotation.isPhysical()) {
+        annotation.replace(newAnnotation);
+      }
+      else {
+        final PsiNameValuePair[] attributes = newAnnotation.getParameterList().getAttributes();
+        new AddAnnotationPsiFix(SUPPRESS_INSPECTIONS_ANNOTATION_NAME, modifierOwner, attributes).applyFix();
+      }
+    }
+  }
+
+  private static PsiAnnotation createNewAnnotation(@NotNull Project project,
+                                                   PsiElement container,
+                                                   PsiAnnotation annotation,
+                                                   @NotNull String id) throws IncorrectOperationException {
+    if (annotation == null) {
+      return JavaPsiFacade.getInstance(project).getElementFactory()
+        .createAnnotationFromText("@" + SUPPRESS_INSPECTIONS_ANNOTATION_NAME + "(\"" + id + "\")", container);
+    }
+    final String currentSuppressedId = "\"" + id + "\"";
+    if (!annotation.getText().contains("{")) {
+      final PsiNameValuePair[] attributes = annotation.getParameterList().getAttributes();
+      if (attributes.length == 1) {
+        final String suppressedWarnings = attributes[0].getText();
+        if (suppressedWarnings.contains(currentSuppressedId)) return null;
+        return JavaPsiFacade.getInstance(project).getElementFactory().createAnnotationFromText(
+            "@" + SUPPRESS_INSPECTIONS_ANNOTATION_NAME + "({" + suppressedWarnings + ", " + currentSuppressedId + "})", container);
+
+      }
+    }
+    else {
+      final int curlyBraceIndex = annotation.getText().lastIndexOf("}");
+      if (curlyBraceIndex > 0) {
+        final String oldSuppressWarning = annotation.getText().substring(0, curlyBraceIndex);
+        if (oldSuppressWarning.contains(currentSuppressedId)) return null;
+        return JavaPsiFacade.getInstance(project).getElementFactory().createAnnotationFromText(
+          oldSuppressWarning + ", " + currentSuppressedId + "})", container);
+      }
+      else {
+        throw new IncorrectOperationException(annotation.getText());
+      }
+    }
+    return null;
+  }
+
+  public static boolean canHave15Suppressions(@NotNull PsiElement file) {
+    final Module module = ModuleUtilCore.findModuleForPsiElement(file);
+    if (module == null) return false;
+    final Sdk jdk = ModuleRootManager.getInstance(module).getSdk();
+    if (jdk == null) return false;
+    JavaSdkVersion version = getVersion(jdk);
+    if (version == null) return false;
+    final boolean is_1_5 = version.isAtLeast(JavaSdkVersion.JDK_1_5);
+    return DaemonCodeAnalyzerSettings.getInstance().isSuppressWarnings() && is_1_5 && PsiUtil.isLanguageLevel5OrHigher(file);
+  }
+
+  @Nullable
+  private static JavaSdkVersion getVersion(@NotNull Sdk sdk) {
+    String version = sdk.getVersionString();
+    if (version == null) return null;
+    return JdkVersionUtil.getVersion(version);
+  }
+
+  @Nullable
+  public static PsiElement getElementToAnnotate(PsiElement element, PsiElement container) {
+    if (container instanceof PsiDeclarationStatement && canHave15Suppressions(element)) {
+      final PsiDeclarationStatement declarationStatement = (PsiDeclarationStatement)container;
+      final PsiElement[] declaredElements = declarationStatement.getDeclaredElements();
+      for (PsiElement declaredElement : declaredElements) {
+        if (declaredElement instanceof PsiLocalVariable) {
+          final PsiModifierList modifierList = ((PsiLocalVariable)declaredElement).getModifierList();
+          if (modifierList != null) {
+            return declaredElement;
+          }
+        }
+      }
+    }
+    return null;
+  }
+}
diff --git a/java/java-impl/src/com/intellij/codeInspection/LambdaCanBeMethReferenceInspection.java b/java/java-analysis-impl/src/com/intellij/codeInspection/LambdaCanBeMethodReferenceInspection.java
similarity index 98%
rename from java/java-impl/src/com/intellij/codeInspection/LambdaCanBeMethReferenceInspection.java
rename to java/java-analysis-impl/src/com/intellij/codeInspection/LambdaCanBeMethodReferenceInspection.java
index aabb43a..d374657 100644
--- a/java/java-impl/src/com/intellij/codeInspection/LambdaCanBeMethReferenceInspection.java
+++ b/java/java-analysis-impl/src/com/intellij/codeInspection/LambdaCanBeMethodReferenceInspection.java
@@ -32,8 +32,8 @@
 /**
  * User: anna
  */
-public class LambdaCanBeMethReferenceInspection extends BaseJavaLocalInspectionTool {
-  public static final Logger LOG = Logger.getInstance("#" + LambdaCanBeMethReferenceInspection.class.getName());
+public class LambdaCanBeMethodReferenceInspection extends BaseJavaBatchLocalInspectionTool {
+  public static final Logger LOG = Logger.getInstance("#" + LambdaCanBeMethodReferenceInspection.class.getName());
 
   @Nls
   @NotNull
diff --git a/java/java-impl/src/com/intellij/codeInspection/NumericOverflowInspection.java b/java/java-analysis-impl/src/com/intellij/codeInspection/NumericOverflowInspection.java
similarity index 95%
rename from java/java-impl/src/com/intellij/codeInspection/NumericOverflowInspection.java
rename to java/java-analysis-impl/src/com/intellij/codeInspection/NumericOverflowInspection.java
index 866f39c..7d1bd62 100644
--- a/java/java-impl/src/com/intellij/codeInspection/NumericOverflowInspection.java
+++ b/java/java-analysis-impl/src/com/intellij/codeInspection/NumericOverflowInspection.java
@@ -17,7 +17,6 @@
 
 import com.intellij.codeInsight.daemon.GroupNames;
 import com.intellij.codeInsight.daemon.JavaErrorMessages;
-import com.intellij.codeInspection.ex.BaseLocalInspectionTool;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.Key;
 import com.intellij.psi.*;
@@ -29,7 +28,7 @@
 /**
  * User: cdr
  */
-public class NumericOverflowInspection extends BaseLocalInspectionTool {
+public class NumericOverflowInspection extends BaseJavaBatchLocalInspectionTool {
   private static final Key<String> HAS_OVERFLOW_IN_CHILD = Key.create("HAS_OVERFLOW_IN_CHILD");
 
   @Nls
diff --git a/java/java-impl/src/com/intellij/codeInspection/equalsAndHashcode/EqualsAndHashcode.java b/java/java-analysis-impl/src/com/intellij/codeInspection/equalsAndHashcode/EqualsAndHashcode.java
similarity index 95%
rename from java/java-impl/src/com/intellij/codeInspection/equalsAndHashcode/EqualsAndHashcode.java
rename to java/java-analysis-impl/src/com/intellij/codeInspection/equalsAndHashcode/EqualsAndHashcode.java
index 486e3f4..4c41d90 100644
--- a/java/java-impl/src/com/intellij/codeInspection/equalsAndHashcode/EqualsAndHashcode.java
+++ b/java/java-analysis-impl/src/com/intellij/codeInspection/equalsAndHashcode/EqualsAndHashcode.java
@@ -15,7 +15,7 @@
  */
 package com.intellij.codeInspection.equalsAndHashcode;
 
-import com.intellij.codeInspection.BaseJavaLocalInspectionTool;
+import com.intellij.codeInspection.BaseJavaBatchLocalInspectionTool;
 import com.intellij.codeInspection.InspectionsBundle;
 import com.intellij.codeInspection.LocalQuickFix;
 import com.intellij.codeInspection.ProblemsHolder;
@@ -36,12 +36,10 @@
 /**
  * @author max
  */
-public class EqualsAndHashcode extends BaseJavaLocalInspectionTool {
-
+public class EqualsAndHashcode extends BaseJavaBatchLocalInspectionTool {
   @Override
   @NotNull
   public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, boolean isOnTheFly) {
-
     final Project project = holder.getProject();
     Pair<PsiMethod, PsiMethod> pair = CachedValuesManager.getManager(project).getCachedValue(project, new CachedValueProvider<Pair<PsiMethod, PsiMethod>>() {
       @Override
@@ -85,8 +83,8 @@
     return new JavaElementVisitor() {
       @Override public void visitClass(PsiClass aClass) {
         super.visitClass(aClass);
-        boolean [] hasEquals = new boolean[] {false};
-        boolean [] hasHashCode = new boolean[] {false};
+        boolean [] hasEquals = {false};
+        boolean [] hasHashCode = {false};
         processClass(aClass, hasEquals, hasHashCode, myEquals, myHashCode);
         if (hasEquals[0] != hasHashCode[0]) {
           PsiIdentifier identifier = aClass.getNameIdentifier();
diff --git a/java/java-impl/src/com/intellij/codeInspection/java15api/Java15APIUsageInspection.java b/java/java-analysis-impl/src/com/intellij/codeInspection/java15api/Java15APIUsageInspection.java
similarity index 96%
rename from java/java-impl/src/com/intellij/codeInspection/java15api/Java15APIUsageInspection.java
rename to java/java-analysis-impl/src/com/intellij/codeInspection/java15api/Java15APIUsageInspection.java
index 8d40750..fabc58d 100644
--- a/java/java-impl/src/com/intellij/codeInspection/java15api/Java15APIUsageInspection.java
+++ b/java/java-analysis-impl/src/com/intellij/codeInspection/java15api/Java15APIUsageInspection.java
@@ -15,13 +15,13 @@
  */
 package com.intellij.codeInspection.java15api;
 
-import com.intellij.ExtensionPoints;
+import com.intellij.ToolExtensionPoints;
 import com.intellij.codeHighlighting.HighlightDisplayLevel;
 import com.intellij.codeInsight.daemon.GroupNames;
 import com.intellij.codeInspection.*;
 import com.intellij.openapi.extensions.ExtensionPoint;
 import com.intellij.openapi.extensions.Extensions;
-import com.intellij.openapi.module.LanguageLevelUtil;
+import com.intellij.openapi.module.EffectiveLanguageLevelUtil;
 import com.intellij.openapi.module.Module;
 import com.intellij.openapi.module.ModuleUtilCore;
 import com.intellij.openapi.ui.VerticalFlowLayout;
@@ -34,7 +34,7 @@
 import com.intellij.psi.util.PsiTreeUtil;
 import com.intellij.psi.util.PsiUtil;
 import com.intellij.reference.SoftReference;
-import com.intellij.ui.ListCellRendererWrapper;
+import com.intellij.ide.ui.ListCellRendererWrapper;
 import com.intellij.util.ui.UIUtil;
 import gnu.trove.THashSet;
 import org.jdom.Element;
@@ -55,7 +55,7 @@
 /**
  * @author max
  */
-public class Java15APIUsageInspection extends BaseJavaLocalInspectionTool {
+public class Java15APIUsageInspection extends BaseJavaBatchLocalInspectionTool {
   @NonNls public static final String SHORT_NAME = "Since15";
 
   private static final Map<LanguageLevel, Reference<Set<String>>> ourForbiddenAPI = new EnumMap<LanguageLevel, Reference<Set<String>>>(LanguageLevel.class);
@@ -180,7 +180,7 @@
       cModel.addElement(level);
     }
     llCombo.setSelectedItem(myEffectiveLanguageLevel != null ? myEffectiveLanguageLevel : LanguageLevel.JDK_1_3);
-    llCombo.setRenderer(new ListCellRendererWrapper() {
+    llCombo.setRenderer(new ListCellRendererWrapper(llCombo) {
       @Override
       public void customize(JList list, Object value, int index, boolean selected, boolean hasFocus) {
         if (value instanceof LanguageLevel) {
@@ -235,7 +235,7 @@
   private class MyVisitor extends JavaElementVisitor {
     private final ProblemsHolder myHolder;
     private final boolean myOnTheFly;
-    private final ExtensionPoint<FileCheckingInspection> point = Extensions.getRootArea().getExtensionPoint(ExtensionPoints.JAVA15_INSPECTION_TOOL);
+    private final ExtensionPoint<FileCheckingInspection> point = Extensions.getRootArea().getExtensionPoint(ToolExtensionPoints.JAVA15_INSPECTION_TOOL);
 
     public MyVisitor(final ProblemsHolder holder, boolean onTheFly) {
       myHolder = holder;
@@ -306,7 +306,7 @@
 
     private LanguageLevel getEffectiveLanguageLevel(Module module) {
       if (myEffectiveLanguageLevel != null) return myEffectiveLanguageLevel;
-      return LanguageLevelUtil.getEffectiveLanguageLevel(module);
+      return EffectiveLanguageLevelUtil.getEffectiveLanguageLevel(module);
     }
 
     private void registerError(PsiJavaCodeReferenceElement reference, LanguageLevel api) {
diff --git a/java/java-impl/src/com/intellij/codeInspection/java15api/api1.4.txt b/java/java-analysis-impl/src/com/intellij/codeInspection/java15api/api1.4.txt
similarity index 100%
rename from java/java-impl/src/com/intellij/codeInspection/java15api/api1.4.txt
rename to java/java-analysis-impl/src/com/intellij/codeInspection/java15api/api1.4.txt
diff --git a/java/java-impl/src/com/intellij/codeInspection/java15api/api1.5.txt b/java/java-analysis-impl/src/com/intellij/codeInspection/java15api/api1.5.txt
similarity index 100%
rename from java/java-impl/src/com/intellij/codeInspection/java15api/api1.5.txt
rename to java/java-analysis-impl/src/com/intellij/codeInspection/java15api/api1.5.txt
diff --git a/java/java-impl/src/com/intellij/codeInspection/java15api/api1.6.txt b/java/java-analysis-impl/src/com/intellij/codeInspection/java15api/api1.6.txt
similarity index 100%
rename from java/java-impl/src/com/intellij/codeInspection/java15api/api1.6.txt
rename to java/java-analysis-impl/src/com/intellij/codeInspection/java15api/api1.6.txt
diff --git a/java/java-impl/src/com/intellij/codeInspection/java15api/api1.7.txt b/java/java-analysis-impl/src/com/intellij/codeInspection/java15api/api1.7.txt
similarity index 99%
rename from java/java-impl/src/com/intellij/codeInspection/java15api/api1.7.txt
rename to java/java-analysis-impl/src/com/intellij/codeInspection/java15api/api1.7.txt
index 316c990..c9db75b 100644
--- a/java/java-impl/src/com/intellij/codeInspection/java15api/api1.7.txt
+++ b/java/java-analysis-impl/src/com/intellij/codeInspection/java15api/api1.7.txt
@@ -560,4 +560,4 @@
 java.util.zip.DeflaterOutputStream#flush()
 java.util.zip.ZipOutputStream#ZipOutputStream(java.io.OutputStream;java.nio.charset.Charset;)
 java.util.Scanner#Scanner(java.nio.file.Path;)
-java.util.Scanner#Scanner(java.nio.file.Path;java.lang.String;)
\ No newline at end of file
+java.util.Scanner#Scanner(java.nio.file.Path;java.lang.String;)
diff --git a/java/java-impl/src/com/intellij/codeInspection/java15api/ignore16List.txt b/java/java-analysis-impl/src/com/intellij/codeInspection/java15api/ignore16List.txt
similarity index 95%
rename from java/java-impl/src/com/intellij/codeInspection/java15api/ignore16List.txt
rename to java/java-analysis-impl/src/com/intellij/codeInspection/java15api/ignore16List.txt
index 613e8e5..267e75d 100644
--- a/java/java-impl/src/com/intellij/codeInspection/java15api/ignore16List.txt
+++ b/java/java-analysis-impl/src/com/intellij/codeInspection/java15api/ignore16List.txt
@@ -1 +1 @@
-java.awt.geom.GeneralPath
\ No newline at end of file
+java.awt.geom.GeneralPath
diff --git a/java/java-impl/src/com/intellij/codeInspection/localCanBeFinal/LocalCanBeFinal.java b/java/java-analysis-impl/src/com/intellij/codeInspection/localCanBeFinal/LocalCanBeFinal.java
similarity index 98%
rename from java/java-impl/src/com/intellij/codeInspection/localCanBeFinal/LocalCanBeFinal.java
rename to java/java-analysis-impl/src/com/intellij/codeInspection/localCanBeFinal/LocalCanBeFinal.java
index 6e39dde..112aee0 100644
--- a/java/java-impl/src/com/intellij/codeInspection/localCanBeFinal/LocalCanBeFinal.java
+++ b/java/java-analysis-impl/src/com/intellij/codeInspection/localCanBeFinal/LocalCanBeFinal.java
@@ -18,7 +18,6 @@
 import com.intellij.codeInsight.FileModificationService;
 import com.intellij.codeInsight.daemon.GroupNames;
 import com.intellij.codeInspection.*;
-import com.intellij.codeInspection.ex.BaseLocalInspectionTool;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.project.Project;
 import com.intellij.psi.*;
@@ -42,7 +41,7 @@
 /**
  * @author max
  */
-public class LocalCanBeFinal extends BaseLocalInspectionTool {
+public class LocalCanBeFinal extends BaseJavaBatchLocalInspectionTool {
   private static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.localCanBeFinal.LocalCanBeFinal");
 
   public boolean REPORT_VARIABLES = true;
diff --git a/java/java-impl/src/com/intellij/codeInspection/miscGenerics/GenericsInspectionToolBase.java b/java/java-analysis-impl/src/com/intellij/codeInspection/miscGenerics/GenericsInspectionToolBase.java
similarity index 91%
rename from java/java-impl/src/com/intellij/codeInspection/miscGenerics/GenericsInspectionToolBase.java
rename to java/java-analysis-impl/src/com/intellij/codeInspection/miscGenerics/GenericsInspectionToolBase.java
index 35f1a6c..78429fd 100644
--- a/java/java-impl/src/com/intellij/codeInspection/miscGenerics/GenericsInspectionToolBase.java
+++ b/java/java-analysis-impl/src/com/intellij/codeInspection/miscGenerics/GenericsInspectionToolBase.java
@@ -15,9 +15,9 @@
  */
 package com.intellij.codeInspection.miscGenerics;
 
+import com.intellij.codeInspection.BaseJavaBatchLocalInspectionTool;
 import com.intellij.codeInspection.InspectionManager;
 import com.intellij.codeInspection.ProblemDescriptor;
-import com.intellij.codeInspection.ex.BaseLocalInspectionTool;
 import com.intellij.psi.*;
 import com.intellij.util.containers.ContainerUtil;
 import org.jetbrains.annotations.NotNull;
@@ -29,7 +29,11 @@
 /**
  * @author ven
  */
-public abstract class GenericsInspectionToolBase extends BaseLocalInspectionTool {
+public abstract class GenericsInspectionToolBase extends BaseJavaBatchLocalInspectionTool {
+  @Override
+  public boolean isEnabledByDefault() {
+    return true;
+  }
   @Override
   public ProblemDescriptor[] checkClass(@NotNull PsiClass aClass, @NotNull InspectionManager manager, boolean isOnTheFly) {
     final PsiClassInitializer[] initializers = aClass.getInitializers();
diff --git a/java/java-impl/src/com/intellij/codeInspection/miscGenerics/RedundantTypeArgsInspection.java b/java/java-analysis-impl/src/com/intellij/codeInspection/miscGenerics/RedundantTypeArgsInspection.java
similarity index 100%
rename from java/java-impl/src/com/intellij/codeInspection/miscGenerics/RedundantTypeArgsInspection.java
rename to java/java-analysis-impl/src/com/intellij/codeInspection/miscGenerics/RedundantTypeArgsInspection.java
diff --git a/java/java-analysis-impl/src/com/intellij/codeInspection/miscGenerics/SuspiciousMethodCallUtil.java b/java/java-analysis-impl/src/com/intellij/codeInspection/miscGenerics/SuspiciousMethodCallUtil.java
new file mode 100644
index 0000000..0732c29
--- /dev/null
+++ b/java/java-analysis-impl/src/com/intellij/codeInspection/miscGenerics/SuspiciousMethodCallUtil.java
@@ -0,0 +1,165 @@
+/*
+ * Copyright 2000-2013 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.codeInspection.miscGenerics;
+
+import com.intellij.codeInspection.InspectionsBundle;
+import com.intellij.psi.*;
+import com.intellij.psi.search.GlobalSearchScope;
+import com.intellij.psi.util.*;
+import com.intellij.util.containers.IntArrayList;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.List;
+
+public class SuspiciousMethodCallUtil {
+  static void setupPatternMethods(PsiManager manager,
+                                  GlobalSearchScope searchScope,
+                                  List<PsiMethod> patternMethods,
+                                  IntArrayList indices) {
+    final PsiClass
+      collectionClass = JavaPsiFacade.getInstance(manager.getProject()).findClass(CommonClassNames.JAVA_UTIL_COLLECTION, searchScope);
+    PsiType[] javaLangObject = {PsiType.getJavaLangObject(manager, searchScope)};
+    MethodSignature removeSignature = MethodSignatureUtil
+      .createMethodSignature("remove", javaLangObject, PsiTypeParameter.EMPTY_ARRAY, PsiSubstitutor.EMPTY);
+    if (collectionClass != null) {
+      PsiMethod remove = MethodSignatureUtil.findMethodBySignature(collectionClass, removeSignature, false);
+      addMethod(remove, 0, patternMethods, indices);
+      MethodSignature containsSignature = MethodSignatureUtil.createMethodSignature("contains", javaLangObject, PsiTypeParameter.EMPTY_ARRAY, PsiSubstitutor.EMPTY);
+      PsiMethod contains = MethodSignatureUtil.findMethodBySignature(collectionClass, containsSignature, false);
+      addMethod(contains, 0, patternMethods, indices);
+    }
+
+    final PsiClass listClass = JavaPsiFacade.getInstance(manager.getProject()).findClass(CommonClassNames.JAVA_UTIL_LIST, searchScope);
+    if (listClass != null) {
+      MethodSignature indexofSignature = MethodSignatureUtil.createMethodSignature("indexOf", javaLangObject, PsiTypeParameter.EMPTY_ARRAY, PsiSubstitutor.EMPTY);
+      PsiMethod indexof = MethodSignatureUtil.findMethodBySignature(listClass, indexofSignature, false);
+      addMethod(indexof, 0, patternMethods, indices);
+      MethodSignature lastindexofSignature = MethodSignatureUtil.createMethodSignature("lastIndexOf", javaLangObject, PsiTypeParameter.EMPTY_ARRAY, PsiSubstitutor.EMPTY);
+      PsiMethod lastindexof = MethodSignatureUtil.findMethodBySignature(listClass, lastindexofSignature, false);
+      addMethod(lastindexof, 0, patternMethods, indices);
+    }
+
+    final PsiClass mapClass = JavaPsiFacade.getInstance(manager.getProject()).findClass(CommonClassNames.JAVA_UTIL_MAP, searchScope);
+    if (mapClass != null) {
+      PsiMethod remove = MethodSignatureUtil.findMethodBySignature(mapClass, removeSignature, false);
+      addMethod(remove, 0, patternMethods, indices);
+      MethodSignature getSignature = MethodSignatureUtil.createMethodSignature("get", javaLangObject, PsiTypeParameter.EMPTY_ARRAY, PsiSubstitutor.EMPTY);
+      PsiMethod get = MethodSignatureUtil.findMethodBySignature(mapClass, getSignature, false);
+      addMethod(get, 0, patternMethods, indices);
+      MethodSignature containsKeySignature = MethodSignatureUtil.createMethodSignature("containsKey", javaLangObject, PsiTypeParameter.EMPTY_ARRAY, PsiSubstitutor.EMPTY);
+      PsiMethod containsKey = MethodSignatureUtil.findMethodBySignature(mapClass, containsKeySignature, false);
+      addMethod(containsKey, 0, patternMethods, indices);
+      MethodSignature containsValueSignature = MethodSignatureUtil.createMethodSignature("containsValue", javaLangObject, PsiTypeParameter.EMPTY_ARRAY, PsiSubstitutor.EMPTY);
+      PsiMethod containsValue = MethodSignatureUtil.findMethodBySignature(mapClass, containsValueSignature, false);
+      addMethod(containsValue, 1, patternMethods, indices);
+    }
+  }
+
+  private static void addMethod(final PsiMethod patternMethod, int typeParamIndex, List<PsiMethod> patternMethods, IntArrayList indices) {
+    if (patternMethod != null) {
+      patternMethods.add(patternMethod);
+      indices.add(typeParamIndex);
+    }
+  }
+
+  static boolean isInheritorOrSelf(PsiMethod inheritorCandidate, PsiMethod base) {
+    PsiClass aClass = inheritorCandidate.getContainingClass();
+    PsiClass bClass = base.getContainingClass();
+    if (aClass == null || bClass == null) return false;
+    PsiSubstitutor substitutor = TypeConversionUtil.getClassSubstitutor(bClass, aClass, PsiSubstitutor.EMPTY);
+    return substitutor != null &&
+           MethodSignatureUtil.findMethodBySignature(bClass, inheritorCandidate.getSignature(substitutor), false) == base;
+  }
+
+  @Nullable
+  public static String getSuspiciousMethodCallMessage(@NotNull PsiMethodCallExpression methodCall,
+                                                      PsiType argType,
+                                                      boolean reportConvertibleMethodCalls,
+                                                      @NotNull List<PsiMethod> patternMethods,
+                                                      @NotNull IntArrayList indices) {
+    final PsiReferenceExpression methodExpression = methodCall.getMethodExpression();
+    final PsiExpression qualifier = methodExpression.getQualifierExpression();
+    if (qualifier == null || qualifier instanceof PsiThisExpression || qualifier instanceof PsiSuperExpression) return null;
+    if (argType instanceof PsiPrimitiveType) {
+      argType = ((PsiPrimitiveType)argType).getBoxedType(methodCall);
+    }
+
+    if (!(argType instanceof PsiClassType)) return null;
+
+    final JavaResolveResult resolveResult = methodExpression.advancedResolve(false);
+    PsiMethod calleeMethod = (PsiMethod)resolveResult.getElement();
+    if (calleeMethod == null) return null;
+    PsiMethod contextMethod = PsiTreeUtil.getParentOfType(methodCall, PsiMethod.class);
+
+    //noinspection SynchronizationOnLocalVariableOrMethodParameter
+    synchronized (patternMethods) {
+      if (patternMethods.isEmpty()) {
+        setupPatternMethods(methodCall.getManager(), methodCall.getResolveScope(), patternMethods, indices);
+      }
+    }
+
+    for (int i = 0; i < patternMethods.size(); i++) {
+      PsiMethod patternMethod = patternMethods.get(i);
+      if (!patternMethod.getName().equals(methodExpression.getReferenceName())) continue;
+      int index = indices.get(i);
+
+      //we are in collections method implementation
+      if (contextMethod != null && isInheritorOrSelf(contextMethod, patternMethod)) return null;
+
+      final PsiClass calleeClass = calleeMethod.getContainingClass();
+      PsiSubstitutor substitutor = resolveResult.getSubstitutor();
+      final PsiClass patternClass = patternMethod.getContainingClass();
+      assert patternClass != null;
+      assert calleeClass != null;
+      substitutor = TypeConversionUtil.getClassSubstitutor(patternClass, calleeClass, substitutor);
+      if (substitutor == null) continue;
+
+      if (!patternMethod.getSignature(substitutor).equals(calleeMethod.getSignature(PsiSubstitutor.EMPTY))) continue;
+
+      PsiTypeParameter[] typeParameters = patternClass.getTypeParameters();
+      if (typeParameters.length <= index) return null;
+      final PsiTypeParameter typeParameter = typeParameters[index];
+      PsiType typeParamMapping = substitutor.substitute(typeParameter);
+      if (typeParamMapping == null) return null;
+      String message = null;
+      if (typeParamMapping instanceof PsiCapturedWildcardType) {
+        typeParamMapping = ((PsiCapturedWildcardType)typeParamMapping).getWildcard();
+      }
+      if (!typeParamMapping.isAssignableFrom(argType)) {
+        if (typeParamMapping.isConvertibleFrom(argType)) {
+          if (reportConvertibleMethodCalls) {
+            message = InspectionsBundle.message("inspection.suspicious.collections.method.calls.problem.descriptor1",
+                                                PsiFormatUtil.formatMethod(calleeMethod, substitutor,
+                                                                           PsiFormatUtilBase.SHOW_NAME |
+                                                                           PsiFormatUtilBase.SHOW_CONTAINING_CLASS,
+                                                                           PsiFormatUtilBase.SHOW_TYPE));
+          }
+        }
+        else {
+          PsiType qualifierType = qualifier.getType();
+          if (qualifierType != null) {
+            message = InspectionsBundle.message("inspection.suspicious.collections.method.calls.problem.descriptor",
+                                                PsiFormatUtil.formatType(qualifierType, 0, PsiSubstitutor.EMPTY),
+                                                PsiFormatUtil.formatType(argType, 0, PsiSubstitutor.EMPTY));
+          }
+        }
+      }
+      return message;
+    }
+    return null;
+  }
+}
diff --git a/java/java-impl/src/com/intellij/codeInspection/redundantCast/RedundantCastInspection.java b/java/java-analysis-impl/src/com/intellij/codeInspection/redundantCast/RedundantCastInspection.java
similarity index 94%
rename from java/java-impl/src/com/intellij/codeInspection/redundantCast/RedundantCastInspection.java
rename to java/java-analysis-impl/src/com/intellij/codeInspection/redundantCast/RedundantCastInspection.java
index 38b7a94..e1b7685 100644
--- a/java/java-impl/src/com/intellij/codeInspection/redundantCast/RedundantCastInspection.java
+++ b/java/java-analysis-impl/src/com/intellij/codeInspection/redundantCast/RedundantCastInspection.java
@@ -20,9 +20,8 @@
 import com.intellij.codeInsight.daemon.GroupNames;
 import com.intellij.codeInspection.*;
 import com.intellij.codeInspection.miscGenerics.GenericsInspectionToolBase;
-import com.intellij.codeInspection.miscGenerics.SuspiciousCollectionsMethodCallsInspection;
+import com.intellij.codeInspection.miscGenerics.SuspiciousMethodCallUtil;
 import com.intellij.codeInspection.ui.MultipleCheckboxOptionsPanel;
-import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.WriteExternalException;
 import com.intellij.psi.*;
@@ -43,7 +42,6 @@
  * Date: Dec 24, 2001
  */
 public class RedundantCastInspection extends GenericsInspectionToolBase {
-  private static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.redundantCast.RedundantCastInspection");
   private final LocalQuickFix myQuickFixAction;
   private static final String DISPLAY_NAME = InspectionsBundle.message("inspection.redundant.cast.display.name");
   @NonNls private static final String SHORT_NAME = "RedundantCast";
@@ -117,8 +115,9 @@
     } else if (parent instanceof PsiExpressionList)  {
       final PsiElement gParent = parent.getParent();
       if (gParent instanceof PsiMethodCallExpression && IGNORE_SUSPICIOUS_METHOD_CALLS) {
-        final String message = SuspiciousCollectionsMethodCallsInspection
-          .getSuspiciousMethodCallMessage((PsiMethodCallExpression)gParent, operand.getType(), true, new ArrayList<PsiMethod>(), new IntArrayList());
+        final String message = SuspiciousMethodCallUtil
+          .getSuspiciousMethodCallMessage((PsiMethodCallExpression)gParent, operand.getType(), true, new ArrayList<PsiMethod>(),
+                                          new IntArrayList());
         if (message != null) {
           return null;
         }
diff --git a/java/java-impl/java-impl.iml b/java/java-impl/java-impl.iml
index e838953..b305503 100644
--- a/java/java-impl/java-impl.iml
+++ b/java/java-impl/java-impl.iml
@@ -32,6 +32,7 @@
     <orderEntry type="module" module-name="java-indexing-impl" exported="" />
     <orderEntry type="module" module-name="java-indexing-api" />
     <orderEntry type="module" module-name="jps-model-impl" />
+    <orderEntry type="module" module-name="java-analysis-impl" exported="" />
   </component>
   <component name="copyright">
     <Base>
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/actions/SuppressByJavaCommentFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/actions/SuppressByJavaCommentFix.java
deleted file mode 100644
index 1db5a39..0000000
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/actions/SuppressByJavaCommentFix.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * Copyright 2000-2009 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.codeInsight.daemon.impl.actions;
-
-import com.intellij.codeInsight.daemon.HighlightDisplayKey;
-import com.intellij.codeInspection.SuppressManager;
-import com.intellij.openapi.editor.Editor;
-import com.intellij.openapi.project.Project;
-import com.intellij.psi.*;
-import com.intellij.psi.impl.source.jsp.jspJava.JspMethodCall;
-import com.intellij.psi.util.PsiTreeUtil;
-import com.intellij.util.IncorrectOperationException;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * @author yole
- */
-public class SuppressByJavaCommentFix extends SuppressByCommentFix {
-  public SuppressByJavaCommentFix(HighlightDisplayKey key) {
-    super(key, PsiStatement.class);
-  }
-
-  @Override
-  @Nullable
-  protected PsiElement getContainer(PsiElement context) {
-    if (context == null || PsiTreeUtil.getParentOfType(context, JspMethodCall.class) != null) return null;
-    return PsiTreeUtil.getParentOfType(context, PsiStatement.class, false);
-  }
-
-  @Override
-  protected void createSuppression(final Project project,
-                                   final Editor editor,
-                                   final PsiElement element,
-                                   final PsiElement container) throws IncorrectOperationException {
-    PsiElement declaredElement = getElementToAnnotate(element, container);
-    if (declaredElement != null) {
-      SuppressFix.addSuppressAnnotation(project, editor, container, (PsiLocalVariable)declaredElement, myID);
-    } else {
-      suppressWithComment(project, editor, element, container);
-    }
-  }
-
-  protected void suppressWithComment(Project project, Editor editor, PsiElement element, PsiElement container) {
-    super.createSuppression(project, editor, element, container);
-  }
-
-  @Nullable
-  protected static PsiElement getElementToAnnotate(PsiElement element, PsiElement container) {
-    if (container instanceof PsiDeclarationStatement && SuppressManager.getInstance().canHave15Suppressions(element)) {
-      final PsiDeclarationStatement declarationStatement = (PsiDeclarationStatement)container;
-      final PsiElement[] declaredElements = declarationStatement.getDeclaredElements();
-      for (PsiElement declaredElement : declaredElements) {
-        if (declaredElement instanceof PsiLocalVariable) {
-          final PsiModifierList modifierList = ((PsiLocalVariable)declaredElement).getModifierList();
-          if (modifierList != null) {
-            return declaredElement;
-          }
-        }
-      }
-    }
-    return null;
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/actions/SuppressFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/actions/SuppressFix.java
deleted file mode 100644
index 35ee17e..0000000
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/actions/SuppressFix.java
+++ /dev/null
@@ -1,222 +0,0 @@
-/*
- * Copyright 2000-2011 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.codeInsight.daemon.impl.actions;
-
-import com.intellij.codeInsight.AnnotationUtil;
-import com.intellij.codeInsight.FileModificationService;
-import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
-import com.intellij.codeInsight.daemon.HighlightDisplayKey;
-import com.intellij.codeInsight.intention.AddAnnotationFix;
-import com.intellij.codeInspection.InspectionsBundle;
-import com.intellij.codeInspection.SuppressIntentionAction;
-import com.intellij.codeInspection.SuppressManager;
-import com.intellij.codeInspection.SuppressionUtil;
-import com.intellij.lang.StdLanguages;
-import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.editor.Editor;
-import com.intellij.openapi.module.Module;
-import com.intellij.openapi.module.ModuleUtilCore;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.roots.impl.storage.ClasspathStorage;
-import com.intellij.openapi.ui.Messages;
-import com.intellij.psi.*;
-import com.intellij.psi.impl.source.jsp.jspJava.JspHolderMethod;
-import com.intellij.psi.javadoc.PsiDocComment;
-import com.intellij.psi.javadoc.PsiDocTag;
-import com.intellij.psi.util.PsiTreeUtil;
-import com.intellij.util.IncorrectOperationException;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-/**
- * @author ven
- */
-public class SuppressFix extends SuppressIntentionAction {
-  private final String myID;
-  private String myAlternativeID;
-  private String myText;
-
-  public SuppressFix(HighlightDisplayKey key) {
-    this(key.getID());
-    myAlternativeID = HighlightDisplayKey.getAlternativeID(key);
-  }
-
-  public SuppressFix(String ID) {
-    myID = ID;
-  }
-
-  @Override
-  @NotNull
-  public String getText() {
-    return myText == null ? "Suppress for member" : myText;
-  }
-
-  @Nullable
-  protected PsiDocCommentOwner getContainer(final PsiElement context) {
-    if (context == null || !context.getManager().isInProject(context)) {
-      return null;
-    }
-    final PsiFile containingFile = context.getContainingFile();
-    if (containingFile == null) {
-      // for PsiDirectory
-      return null;
-    }
-    if (!containingFile.getLanguage().isKindOf(StdLanguages.JAVA) || context instanceof PsiFile) {
-      return null;
-    }
-    PsiElement container = context;
-    while (container instanceof PsiAnonymousClass || !(container instanceof PsiDocCommentOwner) || container instanceof PsiTypeParameter) {
-      container = PsiTreeUtil.getParentOfType(container, PsiDocCommentOwner.class);
-      if (container == null) return null;
-    }
-    return (PsiDocCommentOwner)container;
-  }
-
-  @Override
-  @NotNull
-  public String getFamilyName() {
-    return InspectionsBundle.message("suppress.inspection.family");
-  }
-
-  @Override
-  public boolean isAvailable(@NotNull final Project project, final Editor editor, @NotNull final PsiElement context) {
-    PsiDocCommentOwner container = getContainer(context);
-    boolean isValid = container != null && !(container instanceof JspHolderMethod);
-    if (!isValid) {
-      return false;
-    }
-    myText = container instanceof PsiClass
-            ? InspectionsBundle.message("suppress.inspection.class")
-            : container instanceof PsiMethod ? InspectionsBundle.message("suppress.inspection.method") : InspectionsBundle.message("suppress.inspection.field");
-    return true;
-  }
-
-  @Override
-  public void invoke(@NotNull final Project project, final Editor editor, @NotNull final PsiElement element) throws IncorrectOperationException {
-    PsiDocCommentOwner container = getContainer(element);
-    assert container != null;
-    if (!FileModificationService.getInstance().preparePsiElementForWrite(container)) return;
-    if (use15Suppressions(container)) {
-      final PsiModifierList modifierList = container.getModifierList();
-      if (modifierList != null) {
-        addSuppressAnnotation(project, editor, container, container, getID(container));
-      }
-    }
-    else {
-      PsiDocComment docComment = container.getDocComment();
-      PsiManager manager = PsiManager.getInstance(project);
-      if (docComment == null) {
-        String commentText = "/** @" + SuppressionUtil.SUPPRESS_INSPECTIONS_TAG_NAME + " " + getID(container) + "*/";
-        docComment = JavaPsiFacade.getInstance(manager.getProject()).getElementFactory().createDocCommentFromText(commentText);
-        PsiElement firstChild = container.getFirstChild();
-        container.addBefore(docComment, firstChild);
-      }
-      else {
-        PsiDocTag noInspectionTag = docComment.findTagByName(SuppressionUtil.SUPPRESS_INSPECTIONS_TAG_NAME);
-        if (noInspectionTag != null) {
-          String tagText = noInspectionTag.getText() + ", " + getID(container);
-          noInspectionTag.replace(JavaPsiFacade.getInstance(manager.getProject()).getElementFactory().createDocTagFromText(tagText));
-        }
-        else {
-          String tagText = "@" + SuppressionUtil.SUPPRESS_INSPECTIONS_TAG_NAME + " " + getID(container);
-          docComment.add(JavaPsiFacade.getInstance(manager.getProject()).getElementFactory().createDocTagFromText(tagText));
-        }
-      }
-    }
-    DaemonCodeAnalyzer.getInstance(project).restart();
-  }
-
-  public static void addSuppressAnnotation(final Project project,
-                                           final Editor editor,
-                                           final PsiElement container,
-                                           final PsiModifierListOwner modifierOwner,
-                                           final String id) throws IncorrectOperationException {
-    PsiAnnotation annotation = AnnotationUtil.findAnnotation(modifierOwner, SuppressManager.SUPPRESS_INSPECTIONS_ANNOTATION_NAME);
-    final PsiAnnotation newAnnotation = createNewAnnotation(project, editor, container, annotation, id);
-    if (newAnnotation != null) {
-      if (annotation != null && annotation.isPhysical()) {
-        annotation.replace(newAnnotation);
-      }
-      else {
-        final PsiNameValuePair[] attributes = newAnnotation.getParameterList().getAttributes();
-        new AddAnnotationFix(SuppressManager.SUPPRESS_INSPECTIONS_ANNOTATION_NAME, modifierOwner, attributes).invoke(project, editor, container.getContainingFile());
-      }
-    }
-  }
-
-  private static PsiAnnotation createNewAnnotation(final Project project,
-                                                   final Editor editor,
-                                                   final PsiElement container,
-                                                   @Nullable final PsiAnnotation annotation,
-                                                   final String id) {
-
-    if (annotation != null) {
-      final String currentSuppressedId = "\"" + id + "\"";
-      if (!annotation.getText().contains("{")) {
-        final PsiNameValuePair[] attributes = annotation.getParameterList().getAttributes();
-        if (attributes.length == 1) {
-          final String suppressedWarnings = attributes[0].getText();
-          if (suppressedWarnings.contains(currentSuppressedId)) return null;
-          return JavaPsiFacade.getInstance(project).getElementFactory().createAnnotationFromText(
-              "@" + SuppressManager.SUPPRESS_INSPECTIONS_ANNOTATION_NAME + "({" + suppressedWarnings + ", " + currentSuppressedId + "})", container);
-
-        }
-      }
-      else {
-        final int curlyBraceIndex = annotation.getText().lastIndexOf("}");
-        if (curlyBraceIndex > 0) {
-          final String oldSuppressWarning = annotation.getText().substring(0, curlyBraceIndex);
-          if (oldSuppressWarning.contains(currentSuppressedId)) return null;
-          return JavaPsiFacade.getInstance(project).getElementFactory().createAnnotationFromText(
-            oldSuppressWarning + ", " + currentSuppressedId + "})", container);
-        }
-        else if (!ApplicationManager.getApplication().isUnitTestMode() && editor != null) {
-          Messages.showErrorDialog(editor.getComponent(),
-                                   InspectionsBundle.message("suppress.inspection.annotation.syntax.error", annotation.getText()));
-        }
-      }
-    }
-    else {
-      return JavaPsiFacade.getInstance(project).getElementFactory()
-        .createAnnotationFromText("@" + SuppressManager.SUPPRESS_INSPECTIONS_ANNOTATION_NAME + "(\"" + id + "\")", container);
-    }
-    return null;
-  }
-
-  protected boolean use15Suppressions(final PsiDocCommentOwner container) {
-    return SuppressManager.getInstance().canHave15Suppressions(container) &&
-           !SuppressManager.getInstance().alreadyHas14Suppressions(container);
-  }
-
-  private String getID(PsiElement place) {
-    String id = getID(place, myAlternativeID);
-    return id != null ? id : myID;
-  }
-
-  @Nullable
-  static String getID(PsiElement place, String alternativeID) {
-    if (alternativeID != null) {
-      final Module module = ModuleUtilCore.findModuleForPsiElement(place);
-      if (module != null) {
-        if (!ClasspathStorage.getStorageType(module).equals(ClasspathStorage.DEFAULT_STORAGE)) {
-          return alternativeID;
-        }
-      }
-    }
-
-    return null;
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/actions/SuppressParameterFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/actions/SuppressParameterFix.java
deleted file mode 100644
index af31f98..0000000
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/actions/SuppressParameterFix.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * Copyright 2000-2011 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.codeInsight.daemon.impl.actions;
-
-import com.intellij.codeInsight.FileModificationService;
-import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
-import com.intellij.codeInsight.daemon.HighlightDisplayKey;
-import com.intellij.codeInspection.InspectionsBundle;
-import com.intellij.codeInspection.SuppressIntentionAction;
-import com.intellij.codeInspection.SuppressManager;
-import com.intellij.openapi.editor.Editor;
-import com.intellij.openapi.project.Project;
-import com.intellij.psi.PsiElement;
-import com.intellij.psi.PsiModifierList;
-import com.intellij.psi.PsiParameter;
-import com.intellij.psi.util.PsiTreeUtil;
-import com.intellij.util.IncorrectOperationException;
-import org.jetbrains.annotations.NotNull;
-
-/**
- * @author ven
- */
-public class SuppressParameterFix extends SuppressIntentionAction {
-  private final String myID;
-  private String myAlternativeID;
-
-  public SuppressParameterFix(HighlightDisplayKey key) {
-    this(key.getID());
-    myAlternativeID = HighlightDisplayKey.getAlternativeID(key);
-  }
-
-  public SuppressParameterFix(String ID) {
-    myID = ID;
-  }
-
-  @Override
-  @NotNull
-  public String getText() {
-    return "Suppress for parameter";
-  }
-
-  @Override
-  @NotNull
-  public String getFamilyName() {
-    return InspectionsBundle.message("suppress.inspection.family");
-  }
-
-  @Override
-  public boolean isAvailable(@NotNull final Project project, final Editor editor, @NotNull final PsiElement context) {
-    PsiParameter psiParameter = PsiTreeUtil.getParentOfType(context, PsiParameter.class, false);
-    return psiParameter != null && SuppressManager.getInstance().canHave15Suppressions(psiParameter);
-  }
-
-  @Override
-  public void invoke(@NotNull final Project project, final Editor editor, @NotNull final PsiElement element) throws IncorrectOperationException {
-    PsiParameter container = PsiTreeUtil.getParentOfType(element, PsiParameter.class, false);
-    assert container != null;
-    if (!FileModificationService.getInstance().preparePsiElementForWrite(container)) return;
-    final PsiModifierList modifierList = container.getModifierList();
-    if (modifierList != null) {
-      final String id = SuppressFix.getID(container, myAlternativeID);
-      SuppressFix.addSuppressAnnotation(project, editor, container, container, id != null ? id : myID);
-    }
-    DaemonCodeAnalyzer.getInstance(project).restart();
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/GenericsHighlightUtil.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/GenericsHighlightUtil.java
index a44d932..000a035 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/GenericsHighlightUtil.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/GenericsHighlightUtil.java
@@ -415,7 +415,6 @@
   }
 
   public static HighlightInfo checkInterfaceMultipleInheritance(PsiClass aClass) {
-    if (aClass instanceof PsiTypeParameter) return null;
     final PsiClassType[] types = aClass.getSuperTypes();
     if (types.length < 2) return null;
     Map<PsiClass, PsiSubstitutor> inheritedClasses = new HashMap<PsiClass, PsiSubstitutor>();
@@ -442,8 +441,8 @@
       if (inheritedSubstitutor != null) {
         final PsiTypeParameter[] typeParameters = superClass.getTypeParameters();
         for (PsiTypeParameter typeParameter : typeParameters) {
-          PsiType type1 = inheritedSubstitutor.substitute(typeParameter);
-          PsiType type2 = superTypeSubstitutor.substitute(typeParameter);
+          PsiType type1 = GenericsUtil.eliminateWildcards(inheritedSubstitutor.substitute(typeParameter));
+          PsiType type2 = GenericsUtil.eliminateWildcards(superTypeSubstitutor.substitute(typeParameter));
 
           if (!Comparing.equal(type1, type2)) {
             String description = JavaErrorMessages.message("generics.cannot.be.inherited.with.different.type.arguments",
@@ -1009,6 +1008,14 @@
           return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(typeParameter2).descriptionAndTooltip(message).create();
         }
       }
+      if (!JavaVersionService.getInstance().isAtLeast(parameterList, JavaSdkVersion.JDK_1_7)) {
+        for (PsiJavaCodeReferenceElement referenceElement : typeParameter1.getExtendsList().getReferenceElements()) {
+          final PsiElement resolve = referenceElement.resolve();
+          if (resolve instanceof PsiTypeParameter && ArrayUtilRt.find(typeParameters, resolve) > i) {
+            return HighlightInfo.newHighlightInfo(HighlightInfoType.ERROR).range(referenceElement.getTextRange()).descriptionAndTooltip("Illegal forward reference").create();
+          }
+        }
+      }
     }
     return null;
   }
@@ -1400,6 +1407,27 @@
         if ((parent instanceof PsiCallExpression || parent instanceof PsiMethodReferenceExpression) && PsiUtil.isLanguageLevel7OrHigher(parent)) {
           return null;
         }
+        
+        if (element instanceof PsiMethod) {
+          if (((PsiMethod)element).findSuperMethods().length > 0) return null;
+          if (qualifier instanceof PsiReferenceExpression){
+            final PsiClass typeParameter = PsiUtil.resolveClassInType(((PsiReferenceExpression)qualifier).getType());
+            if (typeParameter instanceof PsiTypeParameter) {
+              if (JavaVersionService.getInstance().isAtLeast(element, JavaSdkVersion.JDK_1_7)) return null;
+              for (PsiClassType classType : typeParameter.getExtendsListTypes()) {
+                final PsiClass resolve = classType.resolve();
+                if (resolve != null) {
+                  final PsiMethod[] superMethods = resolve.findMethodsBySignature((PsiMethod)element, true);
+                  for (PsiMethod superMethod : superMethods) {
+                    if (!PsiUtil.isRawSubstitutor(superMethod, resolveResult.getSubstitutor())) {
+                      return null;
+                    }
+                  }
+                }
+              }
+            }
+          }
+        }
         final String message = element instanceof PsiClass
                                ? JavaErrorMessages.message("generics.type.arguments.on.raw.type")
                                : JavaErrorMessages.message("generics.type.arguments.on.raw.method");
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightClassUtil.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightClassUtil.java
index 58e2acc..62a59b0 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightClassUtil.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightClassUtil.java
@@ -50,6 +50,7 @@
 import com.intellij.psi.impl.source.jsp.jspJava.JspClass;
 import com.intellij.psi.search.GlobalSearchScope;
 import com.intellij.psi.util.*;
+import com.intellij.refactoring.util.RefactoringChangeUtil;
 import com.intellij.util.IncorrectOperationException;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
@@ -800,7 +801,7 @@
       PsiStatement firstStatement = statements[0];
       if (!(firstStatement instanceof PsiExpressionStatement)) return false;
       PsiExpression expression = ((PsiExpressionStatement)firstStatement).getExpression();
-      if (!HighlightUtil.isSuperOrThisMethodCall(expression)) return false;
+      if (!RefactoringChangeUtil.isSuperOrThisMethodCall(expression)) return false;
       PsiMethodCallExpression methodCallExpression = (PsiMethodCallExpression)expression;
       if (PsiKeyword.THIS.equals(methodCallExpression.getMethodExpression().getReferenceName())) continue;
       PsiReferenceExpression referenceExpression = methodCallExpression.getMethodExpression();
@@ -887,7 +888,7 @@
 
   @Nullable
   public static HighlightInfo checkSuperQualifierType(@NotNull Project project, @NotNull PsiMethodCallExpression superCall) {
-    if (!HighlightUtil.isSuperMethodCall(superCall)) return null;
+    if (!RefactoringChangeUtil.isSuperMethodCall(superCall)) return null;
     PsiMethod ctr = PsiTreeUtil.getParentOfType(superCall, PsiMethod.class, true, PsiMember.class);
     if (ctr == null) return null;
     final PsiClass aClass = ctr.getContainingClass();
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMethodUtil.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMethodUtil.java
index bc35620..1f5e33a 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMethodUtil.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightMethodUtil.java
@@ -32,6 +32,7 @@
 import com.intellij.psi.infos.CandidateInfo;
 import com.intellij.psi.infos.MethodCandidateInfo;
 import com.intellij.psi.util.*;
+import com.intellij.refactoring.util.RefactoringChangeUtil;
 import com.intellij.ui.ColorUtil;
 import com.intellij.util.ui.UIUtil;
 import com.intellij.xml.util.XmlStringUtil;
@@ -914,7 +915,7 @@
   @Nullable
   static HighlightInfo checkConstructorCallMustBeFirstStatement(PsiReferenceExpression expression) {
     PsiElement methodCall = expression.getParent();
-    if (!HighlightUtil.isSuperOrThisMethodCall(methodCall)) return null;
+    if (!RefactoringChangeUtil.isSuperOrThisMethodCall(methodCall)) return null;
     PsiElement codeBlock = methodCall.getParent().getParent();
     if (codeBlock instanceof PsiCodeBlock
         && codeBlock.getParent() instanceof PsiMethod
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java
index 8fc4b73..eb75a70 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/HighlightUtil.java
@@ -54,6 +54,7 @@
 import com.intellij.psi.templateLanguages.OuterLanguageElement;
 import com.intellij.psi.tree.IElementType;
 import com.intellij.psi.util.*;
+import com.intellij.refactoring.util.RefactoringChangeUtil;
 import com.intellij.util.ArrayUtil;
 import com.intellij.util.ArrayUtilRt;
 import com.intellij.util.Function;
@@ -1859,7 +1860,7 @@
       type = qualifier instanceof PsiExpression ? ((PsiExpression)qualifier).getType() : null;
       referencedClass = PsiUtil.resolveClassInType(type);
 
-      boolean isSuperCall = isSuperMethodCall(expression.getParent());
+      boolean isSuperCall = RefactoringChangeUtil.isSuperMethodCall(expression.getParent());
       if (resolved == null && isSuperCall) {
         if (qualifier instanceof PsiReferenceExpression) {
           resolved = ((PsiReferenceExpression)qualifier).resolve();
@@ -1953,7 +1954,7 @@
     PsiElement element = expression.getParent();
     while (element != null) {
       // check if expression inside super()/this() call
-      if (isSuperOrThisMethodCall(element)) {
+      if (RefactoringChangeUtil.isSuperOrThisMethodCall(element)) {
         PsiElement parentClass = new PsiMatcherImpl(element)
           .parent(PsiMatchers.hasClass(PsiExpressionStatement.class))
           .parent(PsiMatchers.hasClass(PsiCodeBlock.class))
@@ -2010,7 +2011,7 @@
   @Nullable
   public static HighlightInfo checkImplicitThisReferenceBeforeSuper(@NotNull PsiClass aClass) {
     if (JavaVersionService.getInstance().isAtLeast(aClass, JavaSdkVersion.JDK_1_7)) return null;
-    if (aClass instanceof PsiAnonymousClass) return null;
+    if (aClass instanceof PsiAnonymousClass || aClass instanceof PsiTypeParameter) return null;
     PsiClass superClass = aClass.getSuperClass();
     if (superClass == null || !PsiUtil.isInnerClass(superClass)) return null;
     PsiClass outerClass = superClass.getContainingClass();
@@ -2047,23 +2048,6 @@
     return element != null;
   }
 
-  @Nullable
-  private static String getMethodExpressionName(@Nullable PsiElement element) {
-    if (!(element instanceof PsiMethodCallExpression)) return null;
-    PsiReferenceExpression methodExpression = ((PsiMethodCallExpression)element).getMethodExpression();
-    return methodExpression.getReferenceName();
-  }
-
-  public static boolean isSuperOrThisMethodCall(@Nullable PsiElement element) {
-    String name = getMethodExpressionName(element);
-    return PsiKeyword.SUPER.equals(name) || PsiKeyword.THIS.equals(name);
-  }
-
-  public static boolean isSuperMethodCall(@Nullable PsiElement element) {
-    String name = getMethodExpressionName(element);
-    return PsiKeyword.SUPER.equals(name);
-  }
-
   private static boolean thisOrSuperReference(@Nullable PsiExpression qualifierExpression, PsiClass aClass) {
     if (qualifierExpression == null) return true;
     PsiJavaCodeReferenceElement qualifier;
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/QualifyWithThisFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/QualifyWithThisFix.java
index 123dbda..bfe2d8c 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/QualifyWithThisFix.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/analysis/QualifyWithThisFix.java
@@ -19,7 +19,7 @@
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.project.Project;
 import com.intellij.psi.*;
-import com.intellij.refactoring.util.RefactoringUtil;
+import com.intellij.refactoring.util.RefactoringChangeUtil;
 import com.intellij.util.IncorrectOperationException;
 import org.jetbrains.annotations.NotNull;
 
@@ -55,7 +55,7 @@
   @Override
   public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
     final PsiThisExpression thisExpression =
-      RefactoringUtil.createThisExpression(PsiManager.getInstance(project), myContainingClass);
+      RefactoringChangeUtil.createThisExpression(PsiManager.getInstance(project), myContainingClass);
     ((PsiReferenceExpression)myExpression).setQualifierExpression(thisExpression);
   }
 
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddTypeArgumentsFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddTypeArgumentsFix.java
index 4f0a29e..805a045 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddTypeArgumentsFix.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/AddTypeArgumentsFix.java
@@ -20,7 +20,7 @@
 import com.intellij.pom.java.LanguageLevel;
 import com.intellij.psi.*;
 import com.intellij.psi.util.PsiUtil;
-import com.intellij.refactoring.util.RefactoringUtil;
+import com.intellij.refactoring.util.RefactoringChangeUtil;
 import com.intellij.util.IncorrectOperationException;
 import org.jetbrains.annotations.NotNull;
 
@@ -89,7 +89,7 @@
               if (method.hasModifierProperty(PsiModifier.STATIC)) {
                 qualifierExpression = factory.createReferenceExpression(containingClass);
               } else {
-                qualifierExpression = RefactoringUtil.createThisExpression(method.getManager(), null);
+                qualifierExpression = RefactoringChangeUtil.createThisExpression(method.getManager(), null);
               }
               methodExpression.setQualifierExpression(qualifierExpression);
             }
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateConstructorFromCallFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateConstructorFromCallFix.java
index 7fcbd98..7074f27 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateConstructorFromCallFix.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateConstructorFromCallFix.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -53,7 +53,8 @@
   @Override
   protected void invokeImpl(final PsiClass targetClass) {
     final Project project = myConstructorCall.getProject();
-    PsiElementFactory elementFactory = JavaPsiFacade.getInstance(project).getElementFactory();
+    JVMElementFactory elementFactory = JVMElementFactories.getFactory(targetClass.getLanguage(), project);
+    if (elementFactory == null) elementFactory = JavaPsiFacade.getElementFactory(project);
 
     try {
       PsiMethod constructor = (PsiMethod)targetClass.add(elementFactory.createConstructor());
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateMethodFromUsageFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateMethodFromUsageFix.java
index 71013fd..a7cc465 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateMethodFromUsageFix.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/CreateMethodFromUsageFix.java
@@ -36,7 +36,7 @@
 import com.intellij.psi.*;
 import com.intellij.psi.util.PsiTreeUtil;
 import com.intellij.psi.util.PsiUtil;
-import com.intellij.refactoring.util.FieldConflictsResolver;
+import com.intellij.refactoring.util.RefactoringChangeUtil;
 import com.intellij.util.IncorrectOperationException;
 import com.intellij.util.Processor;
 import com.intellij.util.containers.ContainerUtil;
@@ -120,7 +120,7 @@
     PsiMethodCallExpression call = getMethodCall();
     if (call == null) return Collections.emptyList();
     for (PsiClass target : targets) {
-      if (target.isInterface() && shouldCreateStaticMember(call.getMethodExpression(), target)) continue; 
+      if (target.isInterface() && shouldCreateStaticMember(call.getMethodExpression(), target)) continue;
       if (!isMethodSignatureExists(call, target)) {
         result.add(target);
       }
@@ -170,7 +170,7 @@
 
     if (enclosingContext instanceof PsiMethod && methodName.equals(enclosingContext.getName()) &&
         PsiTreeUtil.isAncestor(targetClass, parentClass, true) && !ref.isQualified()) {
-      FieldConflictsResolver.qualifyReference(ref, method, null);
+      RefactoringChangeUtil.qualifyReference(ref, method, null);
     }
 
     PsiCodeBlock body = method.getBody();
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/QualifyThisArgumentFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/QualifyThisArgumentFix.java
index bb54763..1fdef31 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/QualifyThisArgumentFix.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/QualifyThisArgumentFix.java
@@ -33,7 +33,7 @@
 import com.intellij.psi.util.PsiTreeUtil;
 import com.intellij.psi.util.PsiUtil;
 import com.intellij.psi.util.TypeConversionUtil;
-import com.intellij.refactoring.util.RefactoringUtil;
+import com.intellij.refactoring.util.RefactoringChangeUtil;
 import com.intellij.util.IncorrectOperationException;
 import org.jetbrains.annotations.NotNull;
 
@@ -44,7 +44,7 @@
   private final PsiThisExpression myExpression;
   private final PsiClass myPsiClass;
 
-  
+
   public QualifyThisArgumentFix(@NotNull PsiThisExpression expression, @NotNull PsiClass psiClass) {
     myExpression = expression;
     myPsiClass = psiClass;
@@ -67,7 +67,7 @@
 
   @Override
   public void invoke(@NotNull Project project, Editor editor, @NotNull PsiElement element) throws IncorrectOperationException {
-    myExpression.replace(RefactoringUtil.createThisExpression(PsiManager.getInstance(project), myPsiClass));
+    myExpression.replace(RefactoringChangeUtil.createThisExpression(PsiManager.getInstance(project), myPsiClass));
   }
 
   public static void registerQuickFixAction(CandidateInfo[] candidates, PsiCall call, HighlightInfo highlightInfo, final TextRange fixRange) {
diff --git a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/SurroundWithTryCatchFix.java b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/SurroundWithTryCatchFix.java
index a4bdf0c..1e91f9d 100644
--- a/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/SurroundWithTryCatchFix.java
+++ b/java/java-impl/src/com/intellij/codeInsight/daemon/impl/quickfix/SurroundWithTryCatchFix.java
@@ -17,7 +17,6 @@
 
 import com.intellij.codeInsight.FileModificationService;
 import com.intellij.codeInsight.daemon.QuickFixBundle;
-import com.intellij.codeInsight.daemon.impl.analysis.HighlightUtil;
 import com.intellij.codeInsight.generation.surroundWith.JavaWithTryCatchSurrounder;
 import com.intellij.codeInsight.intention.IntentionAction;
 import com.intellij.openapi.diagnostic.Logger;
@@ -28,6 +27,7 @@
 import com.intellij.openapi.util.TextRange;
 import com.intellij.psi.*;
 import com.intellij.psi.util.PsiTreeUtil;
+import com.intellij.refactoring.util.RefactoringChangeUtil;
 import com.intellij.util.IncorrectOperationException;
 import org.jetbrains.annotations.NotNull;
 
@@ -67,7 +67,7 @@
     return myStatement != null &&
            myStatement.isValid() &&
            (!(myStatement instanceof PsiExpressionStatement) ||
-            !HighlightUtil.isSuperOrThisMethodCall(((PsiExpressionStatement)myStatement).getExpression()));
+            !RefactoringChangeUtil.isSuperOrThisMethodCall(((PsiExpressionStatement)myStatement).getExpression()));
   }
 
   @Override
diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/GenerateMembersUtil.java b/java/java-impl/src/com/intellij/codeInsight/generation/GenerateMembersUtil.java
index f12fe42..2c91b12 100644
--- a/java/java-impl/src/com/intellij/codeInsight/generation/GenerateMembersUtil.java
+++ b/java/java-impl/src/com/intellij/codeInsight/generation/GenerateMembersUtil.java
@@ -18,17 +18,18 @@
 import com.intellij.codeInsight.daemon.impl.quickfix.CreateFromUsageUtils;
 import com.intellij.lang.ASTNode;
 import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.editor.Document;
 import com.intellij.openapi.editor.Editor;
+import com.intellij.openapi.editor.RangeMarker;
 import com.intellij.openapi.editor.ScrollType;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.Comparing;
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.psi.*;
-import com.intellij.psi.codeStyle.CodeStyleSettings;
-import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
-import com.intellij.psi.codeStyle.JavaCodeStyleManager;
-import com.intellij.psi.codeStyle.VariableKind;
+import com.intellij.psi.codeStyle.*;
 import com.intellij.psi.impl.light.LightTypeElement;
+import com.intellij.psi.impl.source.tree.LeafElement;
+import com.intellij.psi.impl.source.tree.PsiWhiteSpaceImpl;
 import com.intellij.psi.javadoc.PsiDocComment;
 import com.intellij.psi.util.PsiTreeUtil;
 import com.intellij.psi.util.PsiUtil;
@@ -133,21 +134,44 @@
       PsiMethod method = (PsiMethod)firstMember;
       PsiCodeBlock body = method.getBody();
       if (body != null) {
-        PsiElement l = body.getFirstBodyElement();
+        PsiElement firstBodyElement = body.getFirstBodyElement();
+        PsiElement l = firstBodyElement;
         while (l instanceof PsiWhiteSpace) l = l.getNextSibling();
         if (l == null) l = body;
-        PsiElement r = body.getLastBodyElement();
+        PsiElement lastBodyElement = body.getLastBodyElement();
+        PsiElement r = lastBodyElement;
         while (r instanceof PsiWhiteSpace) r = r.getPrevSibling();
         if (r == null) r = body;
 
         int start = l.getTextRange().getStartOffset();
         int end = r.getTextRange().getEndOffset();
 
+        boolean adjustLineIndent = false;
+
+        // body is whitespace
+        if (start > end &&
+            firstBodyElement == lastBodyElement &&
+            firstBodyElement instanceof PsiWhiteSpaceImpl
+          ) {
+          CharSequence chars = ((PsiWhiteSpaceImpl)firstBodyElement).getChars();
+          if (chars.length() > 1 && chars.charAt(0) == '\n' && chars.charAt(1) == '\n') {
+            start = end = firstBodyElement.getTextRange().getStartOffset() + 1;
+            adjustLineIndent = true;
+          }
+        }
+
         editor.getCaretModel().moveToOffset(Math.min(start, end));
         editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
         if (start < end) {
           //Not an empty body
           editor.getSelectionModel().setSelection(start, end);
+        } else if (adjustLineIndent) {
+          Document document = editor.getDocument();
+          RangeMarker marker = document.createRangeMarker(start, start);
+          PsiDocumentManager.getInstance(body.getProject()).doPostponedOperationsAndUnblockDocument(document);
+          if (marker.isValid()) {
+            CodeStyleManager.getInstance(body.getProject()).adjustLineIndent(document, marker.getStartOffset());
+          }
         }
         return;
       }
diff --git a/java/java-impl/src/com/intellij/codeInsight/generation/OverrideImplementUtil.java b/java/java-impl/src/com/intellij/codeInsight/generation/OverrideImplementUtil.java
index 3bc0edb..69205b4 100644
--- a/java/java-impl/src/com/intellij/codeInsight/generation/OverrideImplementUtil.java
+++ b/java/java-impl/src/com/intellij/codeInsight/generation/OverrideImplementUtil.java
@@ -50,6 +50,7 @@
 import com.intellij.openapi.ui.DialogWrapper;
 import com.intellij.openapi.ui.Messages;
 import com.intellij.openapi.util.Ref;
+import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.psi.*;
 import com.intellij.psi.codeStyle.CodeStyleManager;
 import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
@@ -393,10 +394,9 @@
     JVMElementFactory factory = JVMElementFactories.getFactory(targetClass.getLanguage(), originalMethod.getProject());
     if (factory == null) factory = JavaPsiFacade.getInstance(originalMethod.getProject()).getElementFactory();
     @NonNls String methodText;
+
     try {
-      String bodyText = template.getText(properties);
-      if (bodyText != null && !bodyText.isEmpty()) bodyText += "\n";
-      methodText = "void foo () {\n" + bodyText + "}";
+      methodText = "void foo () {\n" + template.getText(properties) + "\n}";
       methodText = FileTemplateUtil.indent(methodText, result.getProject(), fileType);
     } catch (Exception e) {
       throw new IncorrectOperationException("Failed to parse file template",e);
diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/AddAnnotationFix.java b/java/java-impl/src/com/intellij/codeInsight/intention/AddAnnotationFix.java
index 352417a..f8d2501 100644
--- a/java/java-impl/src/com/intellij/codeInsight/intention/AddAnnotationFix.java
+++ b/java/java-impl/src/com/intellij/codeInsight/intention/AddAnnotationFix.java
@@ -16,139 +16,41 @@
 
 package com.intellij.codeInsight.intention;
 
-import com.intellij.codeInsight.AnnotationUtil;
-import com.intellij.codeInsight.CodeInsightBundle;
-import com.intellij.codeInsight.ExternalAnnotationsManager;
-import com.intellij.codeInsight.FileModificationService;
-import com.intellij.codeInspection.LocalQuickFixAndIntentionActionOnPsiElement;
-import com.intellij.lang.findUsages.FindUsagesProvider;
-import com.intellij.lang.findUsages.LanguageFindUsages;
-import com.intellij.openapi.command.undo.UndoUtil;
-import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.project.Project;
-import com.intellij.psi.*;
-import com.intellij.psi.codeStyle.JavaCodeStyleManager;
-import com.intellij.psi.util.PsiTreeUtil;
-import com.intellij.psi.util.PsiUtil;
+import com.intellij.psi.PsiFile;
+import com.intellij.psi.PsiModifierListOwner;
+import com.intellij.psi.PsiNameValuePair;
+import com.intellij.util.IncorrectOperationException;
 import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
 
 /**
  * @author ven
  */
-public class AddAnnotationFix extends LocalQuickFixAndIntentionActionOnPsiElement {
-  protected final String myAnnotation;
-  private final String[] myAnnotationsToRemove;
-  private final PsiNameValuePair[] myPairs; // not used when registering local quick fix
-  private static final Logger LOG = Logger.getInstance("#" + AddAnnotationFix.class.getName());
-  private final String myText;
-
+public class AddAnnotationFix extends AddAnnotationPsiFix implements IntentionAction {
   public AddAnnotationFix(@NotNull String fqn, @NotNull PsiModifierListOwner modifierListOwner, @NotNull String... annotationsToRemove) {
     this(fqn, modifierListOwner, PsiNameValuePair.EMPTY_ARRAY, annotationsToRemove);
   }
 
-  public AddAnnotationFix(@NotNull String fqn, @NotNull PsiModifierListOwner modifierListOwner, @NotNull PsiNameValuePair[] values, @NotNull String... annotationsToRemove) {
-    super(modifierListOwner);
-    myAnnotation = fqn;
-    myAnnotationsToRemove = annotationsToRemove;
-    myPairs = values;
-
-    myText = calcText(modifierListOwner, myAnnotation);
-  }
-
-  public static String calcText(PsiModifierListOwner modifierListOwner, @NotNull String annotation) {
-    final String shortName = annotation.substring(annotation.lastIndexOf('.') + 1);
-    if (modifierListOwner instanceof PsiNamedElement) {
-      final String name = ((PsiNamedElement)modifierListOwner).getName();
-      if (name != null) {
-        FindUsagesProvider provider = LanguageFindUsages.INSTANCE.forLanguage(modifierListOwner.getLanguage());
-        return CodeInsightBundle
-          .message("inspection.i18n.quickfix.annotate.element.as", provider.getType(modifierListOwner), name, shortName);
-      }
-    }
-    return CodeInsightBundle.message("inspection.i18n.quickfix.annotate.as", shortName);
+  public AddAnnotationFix(@NotNull String fqn,
+                          @NotNull PsiModifierListOwner modifierListOwner,
+                          @NotNull PsiNameValuePair[] values,
+                          @NotNull String... annotationsToRemove) {
+    super(fqn, modifierListOwner, values, annotationsToRemove);
   }
 
   @Override
-  @NotNull
-  public String getText() {
-    return myText;
+  public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
+    return isAvailable();
   }
 
   @Override
-  @NotNull
-  public String getFamilyName() {
-    return CodeInsightBundle.message("intention.add.annotation.family");
-  }
-
-  @Nullable
-  public static PsiModifierListOwner getContainer(final PsiElement element) {
-    PsiModifierListOwner listOwner = PsiTreeUtil.getParentOfType(element, PsiParameter.class, false);
-    if (listOwner == null) {
-      final PsiIdentifier psiIdentifier = PsiTreeUtil.getParentOfType(element, PsiIdentifier.class, false);
-      if (psiIdentifier != null && psiIdentifier.getParent() instanceof PsiModifierListOwner) {
-        listOwner = (PsiModifierListOwner)psiIdentifier.getParent();
-      }
-    }
-    return listOwner;
+  public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
+    applyFix();
   }
 
   @Override
-  public boolean isAvailable(@NotNull Project project,
-                             @NotNull PsiFile file,
-                             @NotNull PsiElement startElement,
-                             @NotNull PsiElement endElement) {
-    if (!startElement.isValid()) return false;
-    if (!PsiUtil.isLanguageLevel5OrHigher(startElement)) return false;
-    final PsiModifierListOwner myModifierListOwner = (PsiModifierListOwner)startElement;
-
-    return !AnnotationUtil.isAnnotated(myModifierListOwner, myAnnotation, false, false);
-  }
-
-  @Override
-  public void invoke(@NotNull Project project,
-                     @NotNull PsiFile file,
-                     @Nullable("is null when called from inspection") Editor editor,
-                     @NotNull PsiElement startElement,
-                     @NotNull PsiElement endElement) {
-    final PsiModifierListOwner myModifierListOwner = (PsiModifierListOwner)startElement;
-
-    final ExternalAnnotationsManager annotationsManager = ExternalAnnotationsManager.getInstance(project);
-    final PsiModifierList modifierList = myModifierListOwner.getModifierList();
-    LOG.assertTrue(modifierList != null);
-    if (modifierList.findAnnotation(myAnnotation) != null) return;
-    final ExternalAnnotationsManager.AnnotationPlace annotationAnnotationPlace = annotationsManager.chooseAnnotationsPlace(myModifierListOwner);
-    if (annotationAnnotationPlace == ExternalAnnotationsManager.AnnotationPlace.NOWHERE) return;
-    if (annotationAnnotationPlace == ExternalAnnotationsManager.AnnotationPlace.EXTERNAL) {
-      for (String fqn : myAnnotationsToRemove) {
-        annotationsManager.deannotate(myModifierListOwner, fqn);
-      }
-      annotationsManager.annotateExternally(myModifierListOwner, myAnnotation, file, myPairs);
-    }
-    else {
-      final PsiFile containingFile = myModifierListOwner.getContainingFile();
-      if (!FileModificationService.getInstance().preparePsiElementForWrite(containingFile)) return;
-      for (String fqn : myAnnotationsToRemove) {
-        PsiAnnotation annotation = AnnotationUtil.findAnnotation(myModifierListOwner, fqn);
-        if (annotation != null) {
-          annotation.delete();
-        }
-      }
-
-      PsiAnnotation inserted = modifierList.addAnnotation(myAnnotation);
-      for (PsiNameValuePair pair : myPairs) {
-        inserted.setDeclaredAttributeValue(pair.getName(), pair.getValue());
-      }
-      JavaCodeStyleManager.getInstance(project).shortenClassReferences(inserted);
-      if (containingFile != file) {
-        UndoUtil.markPsiFileForUndo(file);
-      }
-    }
-  }
-
-  @NotNull
-  public String[] getAnnotationsToRemove() {
-    return myAnnotationsToRemove;
+  public boolean startInWriteAction() {
+    return true;
   }
 }
diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddAnnotationIntention.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddAnnotationIntention.java
index 2a14b23..2862189 100644
--- a/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddAnnotationIntention.java
+++ b/java/java-impl/src/com/intellij/codeInsight/intention/impl/AddAnnotationIntention.java
@@ -25,6 +25,7 @@
 import com.intellij.codeInsight.AnnotationUtil;
 import com.intellij.codeInsight.CodeInsightBundle;
 import com.intellij.codeInsight.intention.AddAnnotationFix;
+import com.intellij.codeInsight.intention.AddAnnotationPsiFix;
 import com.intellij.openapi.editor.CaretModel;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.project.Project;
@@ -59,7 +60,7 @@
     if (!PsiUtil.isLanguageLevel5OrHigher(element)) return false;
     final PsiModifierListOwner owner;
     if (!element.getManager().isInProject(element) || CodeStyleSettingsManager.getSettings(project).USE_EXTERNAL_ANNOTATIONS) {
-      owner = AddAnnotationFix.getContainer(element);
+      owner = AddAnnotationPsiFix.getContainer(element);
     }
     else {
       return false;
@@ -69,7 +70,7 @@
     String toAdd = annotations.first;
     String[] toRemove = annotations.second;
     if (toRemove.length > 0 && AnnotationUtil.isAnnotated(owner, toRemove[0], false, false)) return false;
-    setText(AddAnnotationFix.calcText(owner, toAdd));
+    setText(AddAnnotationPsiFix.calcText(owner, toAdd));
     if (AnnotationUtil.isAnnotated(owner, toAdd, false, false)) return false;
 
     if (owner instanceof PsiMethod) {
@@ -86,7 +87,7 @@
     int position = caretModel.getOffset();
     PsiElement element = file.findElementAt(position);
 
-    PsiModifierListOwner owner = AddAnnotationFix.getContainer(element);
+    PsiModifierListOwner owner = AddAnnotationPsiFix.getContainer(element);
     if (owner == null || !owner.isValid()) return;
     Pair<String, String[]> annotations = getAnnotations(project);
     String toAdd = annotations.first;
diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/BaseMoveInitializerToMethodAction.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/BaseMoveInitializerToMethodAction.java
index a543b26..556c762 100644
--- a/java/java-impl/src/com/intellij/codeInsight/intention/impl/BaseMoveInitializerToMethodAction.java
+++ b/java/java-impl/src/com/intellij/codeInsight/intention/impl/BaseMoveInitializerToMethodAction.java
@@ -16,7 +16,6 @@
 package com.intellij.codeInsight.intention.impl;
 
 import com.intellij.codeInsight.FileModificationService;
-import com.intellij.codeInsight.daemon.impl.analysis.HighlightUtil;
 import com.intellij.codeInsight.daemon.impl.quickfix.CreateFromUsageUtils;
 import com.intellij.codeInsight.highlighting.HighlightManager;
 import com.intellij.codeInsight.intention.PsiElementBaseIntentionAction;
@@ -30,6 +29,7 @@
 import com.intellij.psi.impl.source.jsp.jspJava.JspClass;
 import com.intellij.psi.javadoc.PsiDocComment;
 import com.intellij.psi.util.PsiTreeUtil;
+import com.intellij.refactoring.util.RefactoringChangeUtil;
 import com.intellij.util.IncorrectOperationException;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
@@ -152,7 +152,7 @@
   private static boolean isSuperOrThisMethodCall(@NotNull PsiStatement statement) {
     if (statement instanceof PsiExpressionStatement) {
       final PsiElement expression = ((PsiExpressionStatement)statement).getExpression();
-      if (HighlightUtil.isSuperOrThisMethodCall(expression)) {
+      if (RefactoringChangeUtil.isSuperOrThisMethodCall(expression)) {
         return true;
       }
     }
diff --git a/java/java-impl/src/com/intellij/codeInsight/intention/impl/InvertIfConditionAction.java b/java/java-impl/src/com/intellij/codeInsight/intention/impl/InvertIfConditionAction.java
index 2deccb0..9815601 100644
--- a/java/java-impl/src/com/intellij/codeInsight/intention/impl/InvertIfConditionAction.java
+++ b/java/java-impl/src/com/intellij/codeInsight/intention/impl/InvertIfConditionAction.java
@@ -36,6 +36,7 @@
 import com.intellij.psi.codeStyle.CodeStyleManager;
 import com.intellij.psi.controlFlow.*;
 import com.intellij.psi.util.PsiTreeUtil;
+import com.intellij.util.ArrayUtilRt;
 import com.intellij.util.IncorrectOperationException;
 import org.jetbrains.annotations.NotNull;
 
@@ -304,8 +305,21 @@
     codeStyle.reformat(statement);
   }
 
-  private static void setElseBranch(PsiIfStatement ifStatement, PsiStatement thenBranch, ControlFlow flow) throws IncorrectOperationException {
+  private static void setElseBranch(PsiIfStatement ifStatement, PsiStatement thenBranch, ControlFlow flow)
+    throws IncorrectOperationException {
     if (flow.getEndOffset(ifStatement) == flow.getEndOffset(thenBranch)) {
+      final PsiLoopStatement loopStmt = PsiTreeUtil.getParentOfType(ifStatement, PsiLoopStatement.class);
+      if (loopStmt != null) {
+        final PsiStatement body = loopStmt.getBody();
+        if (body instanceof PsiBlockStatement) {
+          final PsiStatement[] statements = ((PsiBlockStatement)body).getCodeBlock().getStatements();
+          if (statements.length > 0 && !PsiTreeUtil.isAncestor(statements[statements.length - 1], ifStatement, false) &&
+              ArrayUtilRt.find(statements, ifStatement) < 0) {
+            ifStatement.setElseBranch(thenBranch);
+            return;
+          }
+        }
+      }
       if (thenBranch instanceof PsiContinueStatement) {
         PsiStatement elseBranch = ifStatement.getElseBranch();
         if (elseBranch != null) {
diff --git a/java/java-impl/src/com/intellij/codeInspection/SuppressManagerImpl.java b/java/java-impl/src/com/intellij/codeInspection/SuppressManagerImpl.java
index dda8613..de7f6dc 100644
--- a/java/java-impl/src/com/intellij/codeInspection/SuppressManagerImpl.java
+++ b/java/java-impl/src/com/intellij/codeInspection/SuppressManagerImpl.java
@@ -20,260 +20,84 @@
  */
 package com.intellij.codeInspection;
 
-import com.intellij.codeInsight.AnnotationUtil;
-import com.intellij.codeInsight.daemon.DaemonCodeAnalyzerSettings;
 import com.intellij.codeInsight.daemon.HighlightDisplayKey;
-import com.intellij.codeInsight.daemon.impl.actions.*;
-import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.module.Module;
-import com.intellij.openapi.module.ModuleUtilCore;
-import com.intellij.openapi.projectRoots.JavaSdk;
-import com.intellij.openapi.projectRoots.JavaSdkVersion;
-import com.intellij.openapi.projectRoots.Sdk;
-import com.intellij.openapi.roots.ModuleRootManager;
-import com.intellij.openapi.util.Computable;
-import com.intellij.openapi.util.text.StringUtil;
-import com.intellij.psi.*;
-import com.intellij.psi.impl.PsiVariableEx;
-import com.intellij.psi.javadoc.PsiDocComment;
-import com.intellij.psi.javadoc.PsiDocTag;
-import com.intellij.psi.util.PsiTreeUtil;
-import com.intellij.psi.util.PsiUtil;
+import com.intellij.codeInspection.ex.InspectionManagerEx;
+import com.intellij.psi.PsiDocCommentOwner;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiModifierListOwner;
+import com.intellij.util.Function;
+import com.intellij.util.containers.ContainerUtil;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
-import javax.annotation.Generated;
-import java.util.ArrayList;
 import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.regex.Matcher;
 
 public class SuppressManagerImpl extends SuppressManager {
-
   @Override
   @NotNull
   public SuppressIntentionAction[] createSuppressActions(@NotNull final HighlightDisplayKey displayKey) {
-    return new SuppressIntentionAction[]{
-        new SuppressByJavaCommentFix(displayKey),
-        new SuppressLocalWithCommentFix(displayKey),
-        new SuppressParameterFix(displayKey),
-        new SuppressFix(displayKey),
-        new SuppressForClassFix(displayKey),
-        new SuppressAllForClassFix()
-      };
+    SuppressQuickFix[] batchSuppressActions = createBatchSuppressActions(displayKey);
+    return convertBatchToSuppressIntentionActions(batchSuppressActions);
+  }
+
+  @NotNull
+  private static SuppressIntentionAction[] convertBatchToSuppressIntentionActions(@NotNull SuppressQuickFix[] actions) {
+    return ContainerUtil.map2Array(actions, SuppressIntentionAction.class, new Function<SuppressQuickFix, SuppressIntentionAction>() {
+      @Override
+      public SuppressIntentionAction fun(SuppressQuickFix fix) {
+        return InspectionManagerEx.convertBatchToSuppressIntentionAction(fix);
+      }
+    });
   }
 
   @Override
   public boolean isSuppressedFor(@NotNull final PsiElement element, final String toolId) {
-    return getElementToolSuppressedIn(element, toolId) != null;
+    return JavaSuppressionUtil.getElementToolSuppressedIn(element, toolId) != null;
   }
 
   @Override
   @Nullable
   public PsiElement getElementMemberSuppressedIn(@NotNull final PsiDocCommentOwner owner, final String inspectionToolID) {
-    PsiElement element = getDocCommentToolSuppressedIn(owner, inspectionToolID);
-    if (element != null) return element;
-    element = getAnnotationMemberSuppressedIn(owner, inspectionToolID);
-    if (element != null) return element;
-    PsiDocCommentOwner classContainer = PsiTreeUtil.getParentOfType(owner, PsiDocCommentOwner.class);
-    while (classContainer != null) {
-      element = getDocCommentToolSuppressedIn(classContainer, inspectionToolID);
-      if (element != null) return element;
-
-      element = getAnnotationMemberSuppressedIn(classContainer, inspectionToolID);
-      if (element != null) return element;
-
-      classContainer = PsiTreeUtil.getParentOfType(classContainer, PsiDocCommentOwner.class);
-    }
-    return null;
+    return JavaSuppressionUtil.getElementMemberSuppressedIn(owner, inspectionToolID);
   }
 
   @Override
   @Nullable
   public PsiElement getAnnotationMemberSuppressedIn(@NotNull final PsiModifierListOwner owner, final String inspectionToolID) {
-    final PsiAnnotation generatedAnnotation = AnnotationUtil.findAnnotation(owner, Generated.class.getName());
-    if (generatedAnnotation != null) return generatedAnnotation;
-    PsiModifierList modifierList = owner.getModifierList();
-    Collection<String> suppressedIds = getInspectionIdsSuppressedInAnnotation(modifierList);
-    for (String ids : suppressedIds) {
-      if (SuppressionUtil.isInspectionToolIdMentioned(ids, inspectionToolID)) {
-        return modifierList != null ? AnnotationUtil.findAnnotation(owner, SUPPRESS_INSPECTIONS_ANNOTATION_NAME) : null;
-      }
-    }
-    return null;
+    return JavaSuppressionUtil.getAnnotationMemberSuppressedIn(owner, inspectionToolID);
   }
 
   @Override
   @Nullable
   public PsiElement getDocCommentToolSuppressedIn(@NotNull final PsiDocCommentOwner owner, final String inspectionToolID) {
-    PsiDocComment docComment = owner.getDocComment();
-    if (docComment == null && owner.getParent() instanceof PsiDeclarationStatement) {
-      final PsiElement el = PsiTreeUtil.skipSiblingsBackward(owner.getParent(), PsiWhiteSpace.class);
-      if (el instanceof PsiDocComment) {
-        docComment = (PsiDocComment)el;
-      }
-    }
-    if (docComment != null) {
-      PsiDocTag inspectionTag = docComment.findTagByName(SuppressionUtil.SUPPRESS_INSPECTIONS_TAG_NAME);
-      if (inspectionTag != null) {
-        final PsiElement[] dataElements = inspectionTag.getDataElements();
-        for (PsiElement dataElement : dataElements) {
-          String valueText = dataElement.getText();
-          if (SuppressionUtil.isInspectionToolIdMentioned(valueText, inspectionToolID)) {
-            return docComment;
-          }
-        }
-      }
-    }
-    return null;
+    return JavaSuppressionUtil.getDocCommentToolSuppressedIn(owner, inspectionToolID);
   }
 
   @Override
   @NotNull
   public Collection<String> getInspectionIdsSuppressedInAnnotation(@NotNull final PsiModifierListOwner owner) {
-    if (!PsiUtil.isLanguageLevel5OrHigher(owner)) return Collections.emptyList();
-    PsiModifierList modifierList = owner.getModifierList();
-    return getInspectionIdsSuppressedInAnnotation(modifierList);
+    return JavaSuppressionUtil.getInspectionIdsSuppressedInAnnotation(owner);
   }
 
   @Override
   @Nullable
   public String getSuppressedInspectionIdsIn(@NotNull PsiElement element) {
-    if (element instanceof PsiComment) {
-      String text = element.getText();
-      Matcher matcher = SuppressionUtil.SUPPRESS_IN_LINE_COMMENT_PATTERN.matcher(text);
-      if (matcher.matches()) {
-        return matcher.group(1).trim();
-      }
-    }
-    if (element instanceof PsiDocCommentOwner) {
-      PsiDocComment docComment = ((PsiDocCommentOwner)element).getDocComment();
-      if (docComment != null) {
-        PsiDocTag inspectionTag = docComment.findTagByName(SuppressionUtil.SUPPRESS_INSPECTIONS_TAG_NAME);
-        if (inspectionTag != null) {
-          String valueText = "";
-          for (PsiElement dataElement : inspectionTag.getDataElements()) {
-            valueText += dataElement.getText();
-          }
-          return valueText;
-        }
-      }
-    }
-    if (element instanceof PsiModifierListOwner) {
-      Collection<String> suppressedIds = getInspectionIdsSuppressedInAnnotation((PsiModifierListOwner)element);
-      return suppressedIds.isEmpty() ? null : StringUtil.join(suppressedIds, ",");
-    }
-    return null;
+    return JavaSuppressionUtil.getSuppressedInspectionIdsIn(element);
   }
 
   @Override
   @Nullable
   public PsiElement getElementToolSuppressedIn(@NotNull final PsiElement place, final String toolId) {
-    if (place instanceof PsiFile) return null;
-    return ApplicationManager.getApplication().runReadAction(new Computable<PsiElement>() {
-      @Override
-      @Nullable
-      public PsiElement compute() {
-        final PsiElement statement = SuppressionUtil.getStatementToolSuppressedIn(place, toolId, PsiStatement.class);
-        if (statement != null) {
-          return statement;
-        }
-
-        PsiVariable local = PsiTreeUtil.getParentOfType(place, PsiVariable.class);
-        if (local != null && getAnnotationMemberSuppressedIn(local, toolId) != null) {
-          PsiModifierList modifierList = local.getModifierList();
-          return modifierList != null ? modifierList.findAnnotation(SUPPRESS_INSPECTIONS_ANNOTATION_NAME) : null;
-        }
-
-        PsiDocCommentOwner container = PsiTreeUtil.getNonStrictParentOfType(place, PsiDocCommentOwner.class);
-        while (true) {
-          if (!(container instanceof PsiTypeParameter)) break;
-          container = PsiTreeUtil.getParentOfType(container, PsiDocCommentOwner.class);
-        }
-
-        if (container != null) {
-          PsiElement element = getElementMemberSuppressedIn(container, toolId);
-          if (element != null) return element;
-        }
-        PsiDocCommentOwner classContainer = PsiTreeUtil.getParentOfType(container, PsiDocCommentOwner.class, true);
-        if (classContainer != null) {
-          PsiElement element = getElementMemberSuppressedIn(classContainer, toolId);
-          if (element != null) return element;
-        }
-
-        return null;
-      }
-    });
-  }
-
-  @NotNull
-  public static Collection<String> getInspectionIdsSuppressedInAnnotation(final PsiModifierList modifierList) {
-    if (modifierList == null) {
-      return Collections.emptyList();
-    }
-    final PsiModifierListOwner owner = (PsiModifierListOwner)modifierList.getParent();
-    PsiAnnotation annotation = AnnotationUtil.findAnnotation(owner, SUPPRESS_INSPECTIONS_ANNOTATION_NAME);
-    if (annotation == null) {
-      return Collections.emptyList();
-    }
-    final PsiNameValuePair[] attributes = annotation.getParameterList().getAttributes();
-    if (attributes.length == 0) {
-      return Collections.emptyList();
-    }
-    final PsiAnnotationMemberValue attributeValue = attributes[0].getValue();
-    Collection<String> result = new ArrayList<String>();
-    if (attributeValue instanceof PsiArrayInitializerMemberValue) {
-      final PsiAnnotationMemberValue[] initializers = ((PsiArrayInitializerMemberValue)attributeValue).getInitializers();
-      for (PsiAnnotationMemberValue annotationMemberValue : initializers) {
-        final String id = getInspectionIdSuppressedInAnnotationAttribute(annotationMemberValue);
-        if (id != null) {
-          result.add(id);
-        }
-      }
-    }
-    else {
-      final String id = getInspectionIdSuppressedInAnnotationAttribute(attributeValue);
-      if (id != null) {
-        result.add(id);
-      }
-    }
-    return result;
-  }
-
-  @Nullable
-  public static String getInspectionIdSuppressedInAnnotationAttribute(PsiElement element) {
-    if (element instanceof PsiLiteralExpression) {
-      final Object value = ((PsiLiteralExpression)element).getValue();
-      if (value instanceof String) {
-        return (String)value;
-      }
-    }
-    else if (element instanceof PsiReferenceExpression) {
-      final PsiElement psiElement = ((PsiReferenceExpression)element).resolve();
-      if (psiElement instanceof PsiVariableEx) {
-        final Object val = ((PsiVariableEx)psiElement).computeConstantValue(new HashSet<PsiVariable>());
-        if (val instanceof String) {
-          return (String)val;
-        }
-      }
-    }
-    return null;
+    return JavaSuppressionUtil.getElementToolSuppressedIn(place, toolId);
   }
 
   @Override
   public boolean canHave15Suppressions(@NotNull final PsiElement file) {
-    final Module module = ModuleUtilCore.findModuleForPsiElement(file);
-    if (module == null) return false;
-    final Sdk jdk = ModuleRootManager.getInstance(module).getSdk();
-    if (jdk == null) return false;
-    final boolean is_1_5 = JavaSdk.getInstance().isOfVersionOrHigher(jdk, JavaSdkVersion.JDK_1_5);
-    return DaemonCodeAnalyzerSettings.getInstance().SUPPRESS_WARNINGS && is_1_5 && PsiUtil.isLanguageLevel5OrHigher(file);
+    return JavaSuppressionUtil.canHave15Suppressions(file);
   }
 
   @Override
   public boolean alreadyHas14Suppressions(@NotNull final PsiDocCommentOwner commentOwner) {
-    final PsiDocComment docComment = commentOwner.getDocComment();
-    return docComment != null && docComment.findTagByName(SuppressionUtil.SUPPRESS_INSPECTIONS_TAG_NAME) != null;
+    return JavaSuppressionUtil.alreadyHas14Suppressions(commentOwner);
   }
 }
diff --git a/java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/CatchBodyVisitor.java b/java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/CatchBodyVisitor.java
deleted file mode 100644
index d1cd474..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/CatchBodyVisitor.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Copyright 2000-2009 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.codeInspection.defaultFileTemplateUsage;
-
-import com.intellij.codeInsight.PsiEquivalenceUtil;
-import com.intellij.codeInspection.*;
-import com.intellij.ide.fileTemplates.FileTemplate;
-import com.intellij.ide.fileTemplates.FileTemplateManager;
-import com.intellij.ide.fileTemplates.JavaTemplateUtil;
-import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.progress.ProcessCanceledException;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.Pair;
-import com.intellij.psi.*;
-import com.intellij.psi.util.PsiTreeUtil;
-import com.intellij.util.IncorrectOperationException;
-import org.jetbrains.annotations.NotNull;
-
-import java.io.IOException;
-import java.util.Collection;
-import java.util.Comparator;
-import java.util.Properties;
-
-/**
- * @author cdr
- */
-class CatchBodyVisitor extends JavaRecursiveElementWalkingVisitor {
-  private static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.defaultFileTemplateUsage.CatchBodyVisitor");
-
-  Collection<ProblemDescriptor> myProblemDescriptors;
-  private final boolean myOnTheFly;
-  private final InspectionManager myManager;
-
-  public CatchBodyVisitor(InspectionManager manager, Collection<ProblemDescriptor> descriptors, boolean onTheFly) {
-    myManager = manager;
-    myProblemDescriptors = descriptors;
-    myOnTheFly = onTheFly;
-  }
-
-  @Override public void visitCatchSection(PsiCatchSection section) {
-    checkSection(section);
-    super.visitCatchSection(section);
-  }
-
-  @Override public void visitClass(PsiClass aClass) {
-    // ignore anonymous
-  }
-
-  private void checkSection(final PsiCatchSection section) {
-    final PsiParameter parameter = section.getParameter();
-    if (parameter == null) return;
-    PsiCodeBlock catchBlock = section.getCatchBlock();
-    if (catchBlock == null) return;
-    PsiType type = parameter.getType();
-    if (!(type instanceof PsiClassType || type instanceof PsiDisjunctionType)) return;
-    PsiCodeBlock templateCatchBlock;
-    final PsiParameter templateParameter;
-    try {
-      final PsiElementFactory elementFactory = JavaPsiFacade.getInstance(section.getProject()).getElementFactory();
-      PsiCatchSection sectionTemplate = elementFactory.createCatchSection(type, parameter.getName(), parameter);
-      templateCatchBlock = sectionTemplate.getCatchBlock();
-
-      // replace with default template text
-      FileTemplate catchBodyTemplate = FileTemplateManager.getInstance().getDefaultTemplate(JavaTemplateUtil.TEMPLATE_CATCH_BODY);
-
-      Properties props = new Properties();
-      props.setProperty(FileTemplate.ATTRIBUTE_EXCEPTION, parameter.getName());
-      String catchBody = catchBodyTemplate.getText(props);
-      PsiCodeBlock codeBlockFromText = elementFactory.createCodeBlockFromText("{\n" + catchBody + "\n}", null);
-      templateCatchBlock = (PsiCodeBlock)templateCatchBlock.replace(codeBlockFromText);
-
-      templateParameter = sectionTemplate.getParameter();
-    }
-    catch (ProcessCanceledException e) {
-      /// @#^$%*?
-      return;
-    }
-    catch (IncorrectOperationException e) {
-      LOG.error(e);
-      return;
-    }
-    catch (IOException e) {
-      LOG.error(e);
-      return;
-    }
-    // should be equal except parameter names which should resolve to corresponding parameters
-    if (!PsiEquivalenceUtil.areElementsEquivalent(catchBlock, templateCatchBlock, new Comparator<PsiElement>() {
-      @Override
-      public int compare(final PsiElement o1, final PsiElement o2) {
-        if (o1 == parameter && o2 == templateParameter) return 0;
-        return -1;
-      }
-    }, true)) {
-      return;
-    }
-    Pair<? extends PsiElement, ? extends PsiElement> range = DefaultFileTemplateUsageInspection.getInteriorRange(catchBlock);
-    final String description = InspectionsBundle.message("default.file.template.description");
-    ProblemDescriptor descriptor = myManager.createProblemDescriptor(range.first, range.second, description, ProblemHighlightType.GENERIC_ERROR_OR_WARNING,
-                                                                     myOnTheFly, createQuickFix());
-    myProblemDescriptors.add(descriptor);
-  }
-
-  private static LocalQuickFix[] createQuickFix() {
-    FileTemplate template = FileTemplateManager.getInstance().getCodeTemplate(JavaTemplateUtil.TEMPLATE_CATCH_BODY);
-    ReplaceWithFileTemplateFix replaceWithFileTemplateFix = new ReplaceWithFileTemplateFix() {
-      @Override
-      public void applyFix(@NotNull Project project, @NotNull final ProblemDescriptor descriptor) {
-        final PsiCatchSection section = PsiTreeUtil.getParentOfType(descriptor.getPsiElement(), PsiCatchSection.class);
-        if (section == null) return;
-        final PsiParameter parameter = section.getParameter();
-        if (parameter == null) return;
-        PsiCodeBlock catchBlock = section.getCatchBlock();
-        if (catchBlock == null) return;
-        PsiType type = parameter.getType();
-        if (!(type instanceof PsiClassType)) return;
-        final PsiElementFactory elementFactory = JavaPsiFacade.getInstance(section.getProject()).getElementFactory();
-        try {
-          PsiCatchSection sectionTemplate = elementFactory.createCatchSection(type, parameter.getName(), parameter);
-          section.replace(sectionTemplate);
-        }
-        catch (IncorrectOperationException e) {
-          LOG.error(e);
-        }
-      }
-    };
-    LocalQuickFix editFileTemplateFix = DefaultFileTemplateUsageInspection.createEditFileTemplateFix(template, replaceWithFileTemplateFix);
-    if (template.isDefault()) {
-      return new LocalQuickFix[]{editFileTemplateFix};
-    }
-    return new LocalQuickFix[]{replaceWithFileTemplateFix, editFileTemplateFix};
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/DefaultFileTemplateUsageInspection.java b/java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/DefaultFileTemplateUsageInspection.java
index 7b3a2bb..53f1583 100644
--- a/java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/DefaultFileTemplateUsageInspection.java
+++ b/java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/DefaultFileTemplateUsageInspection.java
@@ -36,10 +36,6 @@
  * @author cdr
  */
 public class DefaultFileTemplateUsageInspection extends BaseJavaLocalInspectionTool {
-  public boolean CHECK_FILE_HEADER = true;
-  public boolean CHECK_TRY_CATCH_SECTION = true;
-  public boolean CHECK_METHOD_BODY = true;
-
   @Override
   @NotNull
   public String getGroupDisplayName() {
@@ -59,23 +55,6 @@
     return "DefaultFileTemplate";
   }
 
-  @Override
-  @Nullable
-  public ProblemDescriptor[] checkMethod(@NotNull PsiMethod method, @NotNull InspectionManager manager, boolean isOnTheFly) {
-    Collection<ProblemDescriptor> descriptors = new ArrayList<ProblemDescriptor>();
-    if (CHECK_METHOD_BODY) {
-      MethodBodyChecker.checkMethodBody(method, manager, descriptors, isOnTheFly);
-    }
-    if (CHECK_TRY_CATCH_SECTION) {
-      CatchBodyVisitor visitor = new CatchBodyVisitor(manager, descriptors, isOnTheFly);
-      PsiCodeBlock body = method.getBody();
-      if (body != null) {
-        body.accept(visitor);
-      }
-    }
-    return descriptors.toArray(new ProblemDescriptor[descriptors.size()]);
-  }
-
   static Pair<? extends PsiElement, ? extends PsiElement> getInteriorRange(PsiCodeBlock codeBlock) {
     PsiElement[] children = codeBlock.getChildren();
     if (children.length == 0) return Pair.create(codeBlock, codeBlock);
@@ -98,21 +77,7 @@
 
   @Override
   @Nullable
-  public ProblemDescriptor[] checkClass(@NotNull PsiClass aClass, @NotNull InspectionManager manager, boolean isOnTheFly) {
-    if (!CHECK_TRY_CATCH_SECTION) return null;
-    CatchBodyVisitor visitor = new CatchBodyVisitor(manager, new ArrayList<ProblemDescriptor>(), isOnTheFly);
-    PsiClassInitializer[] initializers = aClass.getInitializers();
-    for (PsiClassInitializer initializer : initializers) {
-      initializer.accept(visitor);
-    }
-
-    return visitor.myProblemDescriptors.toArray(new ProblemDescriptor[visitor.myProblemDescriptors.size()]);
-  }
-
-  @Override
-  @Nullable
   public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
-    if (!CHECK_FILE_HEADER) return null;
     ProblemDescriptor descriptor = FileHeaderChecker.checkFileHeader(file, manager, isOnTheFly);
     return descriptor == null ? null : new ProblemDescriptor[]{descriptor};
   }
@@ -122,12 +87,6 @@
     return true;
   }
 
-  @Override
-  @Nullable
-  public JComponent createOptionsPanel() {
-    return new InspectionOptions(this).getComponent();
-  }
-
   public static LocalQuickFix createEditFileTemplateFix(final FileTemplate templateToEdit, final ReplaceWithFileTemplateFix replaceTemplateFix) {
     return new MyLocalQuickFix(templateToEdit, replaceTemplateFix);
   }
diff --git a/java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/InspectionOptions.form b/java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/InspectionOptions.form
deleted file mode 100644
index e5fe15f..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/InspectionOptions.form
+++ /dev/null
@@ -1,51 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.codeInspection.defaultFileTemplateUsage.InspectionOptions" layout-manager="GridLayoutManager">
-  <grid id="91cb4" binding="myPanel" row-count="4" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
-    <margin top="0" left="0" bottom="0" right="0"/>
-    <constraints>
-      <xy x="76" y="81" width="347" height="114"/>
-      <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3"/>
-    </constraints>
-    <properties>
-      <enabled value="true"/>
-    </properties>
-    <border type="none"/>
-    <children>
-      <component id="7d028" class="javax.swing.JCheckBox" binding="inspectFileHeader">
-        <constraints>
-          <xy x="2" y="2" width="291" height="25"/>
-          <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0">
-            <preferred-size width="291" height="25"/>
-          </grid>
-        </constraints>
-        <properties>
-          <text resource-bundle="messages/InspectionsBundle" key="default.file.template.report.file.header"/>
-        </properties>
-      </component>
-      <component id="fbb42" class="javax.swing.JCheckBox" binding="inspectMethodBody">
-        <constraints>
-          <xy x="2" y="32" width="321" height="22"/>
-          <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0"/>
-        </constraints>
-        <properties>
-          <text resource-bundle="messages/InspectionsBundle" key="default.file.template.report.method.body"/>
-        </properties>
-      </component>
-      <component id="478d" class="javax.swing.JCheckBox" binding="inspectCatchSection">
-        <constraints>
-          <xy x="2" y="59" width="343" height="22"/>
-          <grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0"/>
-        </constraints>
-        <properties>
-          <text resource-bundle="messages/InspectionsBundle" key="default.file.template.report.catch.section"/>
-        </properties>
-      </component>
-      <vspacer id="895aa">
-        <constraints>
-          <xy x="168" y="81" width="11" height="31"/>
-          <grid row="3" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2"/>
-        </constraints>
-      </vspacer>
-    </children>
-  </grid>
-</form>
diff --git a/java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/InspectionOptions.java b/java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/InspectionOptions.java
deleted file mode 100644
index 8dc55bf..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/InspectionOptions.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright 2000-2009 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.codeInspection.defaultFileTemplateUsage;
-
-import javax.swing.*;
-import java.awt.event.ActionListener;
-import java.awt.event.ActionEvent;
-
-/**
- * @author Alexey
- */
-public class InspectionOptions {
-  private JPanel myPanel;
-  private JCheckBox inspectFileHeader;
-  private JCheckBox inspectMethodBody;
-  private JCheckBox inspectCatchSection;
-
-  public InspectionOptions(final DefaultFileTemplateUsageInspection inspection) {
-    inspectCatchSection.setSelected(inspection.CHECK_TRY_CATCH_SECTION);
-    inspectMethodBody.setSelected(inspection.CHECK_METHOD_BODY);
-    inspectFileHeader.setSelected(inspection.CHECK_FILE_HEADER);
-
-    ActionListener listener = new ActionListener() {
-      @Override
-      public void actionPerformed(ActionEvent e) {
-         inspection.CHECK_FILE_HEADER = inspectFileHeader.isSelected();
-         inspection.CHECK_METHOD_BODY = inspectMethodBody.isSelected();
-         inspection.CHECK_TRY_CATCH_SECTION = inspectCatchSection.isSelected();
-      }
-    };
-    inspectCatchSection.addActionListener(listener);
-    inspectFileHeader.addActionListener(listener);
-    inspectMethodBody.addActionListener(listener);
-  }
-
-  public JPanel getComponent() {
-    return myPanel;
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/MethodBodyChecker.java b/java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/MethodBodyChecker.java
deleted file mode 100644
index 420afb2..0000000
--- a/java/java-impl/src/com/intellij/codeInspection/defaultFileTemplateUsage/MethodBodyChecker.java
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- * Copyright 2000-2013 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.codeInspection.defaultFileTemplateUsage;
-
-import com.intellij.codeInsight.CodeInsightUtil;
-import com.intellij.codeInsight.PsiEquivalenceUtil;
-import com.intellij.codeInsight.daemon.impl.quickfix.CreateFromUsageUtils;
-import com.intellij.codeInsight.generation.OverrideImplementUtil;
-import com.intellij.codeInspection.*;
-import com.intellij.ide.fileTemplates.FileTemplate;
-import com.intellij.ide.fileTemplates.FileTemplateManager;
-import com.intellij.ide.fileTemplates.JavaTemplateUtil;
-import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.Key;
-import com.intellij.openapi.util.Pair;
-import com.intellij.psi.*;
-import com.intellij.psi.codeStyle.CodeStyleManager;
-import com.intellij.psi.search.GlobalSearchScope;
-import com.intellij.psi.util.PsiTreeUtil;
-import com.intellij.reference.SoftReference;
-import com.intellij.util.IncorrectOperationException;
-import com.intellij.util.containers.ConcurrentHashMap;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.Collection;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Map;
-
-/**
- * @author Alexey
- */
-public class MethodBodyChecker {
-  private static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.defaultFileTemplateUsage.MethodBodyChecker");
-
-  @Nullable
-  private static PsiMethod getTemplateMethod(PsiType returnType, List<HierarchicalMethodSignature> superSignatures, final PsiClass aClass) {
-    Project project = aClass.getProject();
-
-    if (!(returnType instanceof PsiPrimitiveType)) {
-      returnType = PsiType.getJavaLangObject(PsiManager.getInstance(project), GlobalSearchScope.allScope(project));
-    }
-    try {
-      final FileTemplate template = getMethodFileTemplate(superSignatures, true);
-      if (template == null) return null;
-      final String fileTemplateName = template.getName();
-      String methodName = superSignatures.isEmpty() ? "" : superSignatures.get(0).getName();
-      String key = returnType.getCanonicalText() + "+" + methodName + "+"+fileTemplateName;
-      final Map<String, PsiMethod> cache = getTemplatesCache(aClass);
-      PsiMethod method = cache.get(key);
-      if (method == null) {
-        method = JavaPsiFacade.getInstance(project).getElementFactory().createMethod("x", returnType);
-        setupMethodBody(superSignatures, method, aClass, true);
-        cache.put(key, method);
-      }
-      return method;
-    }
-    catch (IncorrectOperationException e) {
-      return null;
-    }
-  }
-
-  private static final Key<SoftReference<Map<String, PsiMethod>>> CACHE_KEY = Key.create("MethodBodyChecker templates cache");
-
-  private static Map<String, PsiMethod> getTemplatesCache(PsiClass aClass) {
-    SoftReference<Map<String, PsiMethod>> ref = aClass.getUserData(CACHE_KEY);
-    Map<String, PsiMethod> cache = ref == null ? null : ref.get();
-    if (cache == null) {
-      aClass.putUserData(CACHE_KEY, new SoftReference<Map<String, PsiMethod>>(cache = new ConcurrentHashMap<String, PsiMethod>()));
-    }
-    return cache;
-  }
-
-  static void checkMethodBody(final PsiMethod method,
-                              final InspectionManager manager,
-                              final Collection<ProblemDescriptor> problemDescriptors, boolean onTheFly) {
-    PsiType returnType = method.getReturnType();
-    if (method.isConstructor() || returnType == null) return;
-    PsiCodeBlock body = method.getBody();
-    if (body == null) return;
-    PsiClass aClass = method.getContainingClass();
-    if (aClass == null || aClass.isInterface()) return;
-    List<HierarchicalMethodSignature> superSignatures = method.getHierarchicalMethodSignature().getSuperSignatures();
-    final PsiMethod superMethod = superSignatures.isEmpty() ? null : superSignatures.get(0).getMethod();
-
-    final PsiMethod templateMethod = getTemplateMethod(returnType, superSignatures, aClass);
-    if (templateMethod == null) return;
-
-    final PsiCodeBlock templateBody = templateMethod.getBody();
-    if (templateBody == null) return;
-
-    if (PsiEquivalenceUtil.areElementsEquivalent(body, templateBody, new Comparator<PsiElement>(){
-      @Override
-      public int compare(final PsiElement element1, final PsiElement element2) {
-        // templates may be different on super method name
-        if (element1 == superMethod && (element2 == templateMethod || element2 == null)) return 0;
-        return 1;
-      }
-    }, true)) {
-      Pair<? extends PsiElement, ? extends PsiElement> range = DefaultFileTemplateUsageInspection.getInteriorRange(body);
-      final String description = InspectionsBundle.message("default.file.template.description");
-      ProblemDescriptor problem = manager.createProblemDescriptor(range.first, range.second, description,
-                                                                  ProblemHighlightType.GENERIC_ERROR_OR_WARNING, onTheFly,
-                                                                  createMethodBodyQuickFix(method));
-      problemDescriptors.add(problem);
-    }
-  }
-
-  @Nullable
-  private static FileTemplate getMethodFileTemplate(final List<HierarchicalMethodSignature> superSignatures,
-                                                    final boolean useDefaultTemplate) {
-    FileTemplateManager templateManager = FileTemplateManager.getInstance();
-    FileTemplate template;
-    if (superSignatures.isEmpty()) {
-      String name = JavaTemplateUtil.TEMPLATE_FROM_USAGE_METHOD_BODY;
-      template = useDefaultTemplate ? templateManager.getDefaultTemplate(name) : templateManager.getCodeTemplate(name);
-    }
-    else {
-      PsiMethod superMethod = superSignatures.get(0).getMethod();
-      String name = superMethod.hasModifierProperty(PsiModifier.ABSTRACT) ?
-                    JavaTemplateUtil.TEMPLATE_IMPLEMENTED_METHOD_BODY : JavaTemplateUtil.TEMPLATE_OVERRIDDEN_METHOD_BODY;
-      template = useDefaultTemplate ? templateManager.getDefaultTemplate(name) : templateManager.getCodeTemplate(name);
-    }
-    return template;
-  }
-
-  private static final String NEW_METHOD_BODY_TEMPLATE_NAME = FileTemplateManager.getInstance().getDefaultTemplate(JavaTemplateUtil.TEMPLATE_FROM_USAGE_METHOD_BODY).getName();
-  @Nullable
-  private static FileTemplate setupMethodBody(final List<HierarchicalMethodSignature> superSignatures,
-                                              final PsiMethod templateMethod,
-                                              final PsiClass aClass,
-                                              final boolean useDefaultTemplate) throws IncorrectOperationException {
-    FileTemplate template = getMethodFileTemplate(superSignatures, useDefaultTemplate);
-    if (template == null) return null;
-    if (NEW_METHOD_BODY_TEMPLATE_NAME.equals(template.getName())) {
-      CreateFromUsageUtils.setupMethodBody(templateMethod, aClass, template);
-    }
-    else {
-      PsiMethod superMethod = superSignatures.get(0).getMethod();
-      OverrideImplementUtil.setupMethodBody(templateMethod, superMethod, aClass,template);
-    }
-    return template;
-  }
-
-  @Nullable
-  private static LocalQuickFix[] createMethodBodyQuickFix(final PsiMethod method) {
-    PsiType returnType = method.getReturnType();
-    PsiClass aClass = method.getContainingClass();
-    List<HierarchicalMethodSignature> superSignatures = method.getHierarchicalMethodSignature().getSuperSignatures();
-    FileTemplate template;
-    try {
-      PsiMethod templateMethod = JavaPsiFacade.getInstance(method.getProject()).getElementFactory().createMethod("x", returnType);
-      template = setupMethodBody(superSignatures, templateMethod, aClass, false);
-    }
-    catch (IncorrectOperationException e) {
-      return null;
-    }
-
-    final ReplaceWithFileTemplateFix replaceWithFileTemplateFix = new ReplaceWithFileTemplateFix() {
-      @Override
-      public void applyFix(@NotNull final Project project, @NotNull ProblemDescriptor descriptor) {
-        PsiMethod method = PsiTreeUtil.getParentOfType(descriptor.getPsiElement(), PsiMethod.class);
-        if (method == null) return;
-        PsiType returnType = method.getReturnType();
-        if (method.isConstructor() || returnType == null) return;
-        PsiCodeBlock body = method.getBody();
-        if (body == null) return;
-        if (!CodeInsightUtil.preparePsiElementsForWrite(body)) return;
-        PsiClass aClass = method.getContainingClass();
-        if (aClass == null) return;
-        List<HierarchicalMethodSignature> superSignatures = method.getHierarchicalMethodSignature().getSuperSignatures();
-        try {
-          PsiMethod templateMethod = JavaPsiFacade.getInstance(method.getProject()).getElementFactory().createMethod("x", returnType);
-          setupMethodBody(superSignatures, templateMethod, aClass, false);
-          final PsiCodeBlock templateBody = templateMethod.getBody();
-          if (templateBody == null) return;
-
-          PsiElement newBody = body.replace(templateBody);
-          CodeStyleManager.getInstance(aClass.getManager()).reformat(newBody);
-        }
-        catch (IncorrectOperationException e) {
-          LOG.error(e);
-        }
-      }
-    };
-    LocalQuickFix editFileTemplateFix = DefaultFileTemplateUsageInspection.createEditFileTemplateFix(template, replaceWithFileTemplateFix);
-    if (template != null && template.isDefault()) {
-      return new LocalQuickFix[]{editFileTemplateFix};
-    }
-    return new LocalQuickFix[]{replaceWithFileTemplateFix, editFileTemplateFix};
-  }
-}
diff --git a/java/java-impl/src/com/intellij/codeInspection/miscGenerics/SuspiciousCollectionsMethodCallsInspection.java b/java/java-impl/src/com/intellij/codeInspection/miscGenerics/SuspiciousCollectionsMethodCallsInspection.java
index 469cb22..91e4012 100644
--- a/java/java-impl/src/com/intellij/codeInspection/miscGenerics/SuspiciousCollectionsMethodCallsInspection.java
+++ b/java/java-impl/src/com/intellij/codeInspection/miscGenerics/SuspiciousCollectionsMethodCallsInspection.java
@@ -22,8 +22,6 @@
 import com.intellij.codeInspection.ex.BaseLocalInspectionTool;
 import com.intellij.codeInspection.ui.SingleCheckboxOptionsPanel;
 import com.intellij.psi.*;
-import com.intellij.psi.search.GlobalSearchScope;
-import com.intellij.psi.util.*;
 import com.intellij.util.containers.IntArrayList;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
@@ -44,54 +42,6 @@
     return new SingleCheckboxOptionsPanel(InspectionsBundle.message("report.suspicious.but.possibly.correct.method.calls"), this, "REPORT_CONVERTIBLE_METHOD_CALLS");
   }
 
-  private static void setupPatternMethods(PsiManager manager,
-                                          GlobalSearchScope searchScope,
-                                          List<PsiMethod> patternMethods,
-                                          IntArrayList indices) {
-    final PsiClass collectionClass = JavaPsiFacade.getInstance(manager.getProject()).findClass(CommonClassNames.JAVA_UTIL_COLLECTION, searchScope);
-    PsiType[] javaLangObject = {PsiType.getJavaLangObject(manager, searchScope)};
-    MethodSignature removeSignature = MethodSignatureUtil.createMethodSignature("remove", javaLangObject, PsiTypeParameter.EMPTY_ARRAY, PsiSubstitutor.EMPTY);
-    if (collectionClass != null) {
-      PsiMethod remove = MethodSignatureUtil.findMethodBySignature(collectionClass, removeSignature, false);
-      addMethod(remove, 0, patternMethods, indices);
-      MethodSignature containsSignature = MethodSignatureUtil.createMethodSignature("contains", javaLangObject, PsiTypeParameter.EMPTY_ARRAY, PsiSubstitutor.EMPTY);
-      PsiMethod contains = MethodSignatureUtil.findMethodBySignature(collectionClass, containsSignature, false);
-      addMethod(contains, 0, patternMethods, indices);
-    }
-
-    final PsiClass listClass = JavaPsiFacade.getInstance(manager.getProject()).findClass(CommonClassNames.JAVA_UTIL_LIST, searchScope);
-    if (listClass != null) {
-      MethodSignature indexofSignature = MethodSignatureUtil.createMethodSignature("indexOf", javaLangObject, PsiTypeParameter.EMPTY_ARRAY, PsiSubstitutor.EMPTY);
-      PsiMethod indexof = MethodSignatureUtil.findMethodBySignature(listClass, indexofSignature, false);
-      addMethod(indexof, 0, patternMethods, indices);
-      MethodSignature lastindexofSignature = MethodSignatureUtil.createMethodSignature("lastIndexOf", javaLangObject, PsiTypeParameter.EMPTY_ARRAY, PsiSubstitutor.EMPTY);
-      PsiMethod lastindexof = MethodSignatureUtil.findMethodBySignature(listClass, lastindexofSignature, false);
-      addMethod(lastindexof, 0, patternMethods, indices);
-    }
-
-    final PsiClass mapClass = JavaPsiFacade.getInstance(manager.getProject()).findClass(CommonClassNames.JAVA_UTIL_MAP, searchScope);
-    if (mapClass != null) {
-      PsiMethod remove = MethodSignatureUtil.findMethodBySignature(mapClass, removeSignature, false);
-      addMethod(remove, 0, patternMethods, indices);
-      MethodSignature getSignature = MethodSignatureUtil.createMethodSignature("get", javaLangObject, PsiTypeParameter.EMPTY_ARRAY, PsiSubstitutor.EMPTY);
-      PsiMethod get = MethodSignatureUtil.findMethodBySignature(mapClass, getSignature, false);
-      addMethod(get, 0, patternMethods, indices);
-      MethodSignature containsKeySignature = MethodSignatureUtil.createMethodSignature("containsKey", javaLangObject, PsiTypeParameter.EMPTY_ARRAY, PsiSubstitutor.EMPTY);
-      PsiMethod containsKey = MethodSignatureUtil.findMethodBySignature(mapClass, containsKeySignature, false);
-      addMethod(containsKey, 0, patternMethods, indices);
-      MethodSignature containsValueSignature = MethodSignatureUtil.createMethodSignature("containsValue", javaLangObject, PsiTypeParameter.EMPTY_ARRAY, PsiSubstitutor.EMPTY);
-      PsiMethod containsValue = MethodSignatureUtil.findMethodBySignature(mapClass, containsValueSignature, false);
-      addMethod(containsValue, 1, patternMethods, indices);
-    }
-  }
-
-  private static void addMethod(final PsiMethod patternMethod, int typeParamIndex, List<PsiMethod> patternMethods, IntArrayList indices) {
-    if (patternMethod != null) {
-      patternMethods.add(patternMethod);
-      indices.add(typeParamIndex);
-    }
-  }
-
   @Override
   @NotNull
   public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, final boolean isOnTheFly) {
@@ -141,99 +91,16 @@
     if (args.length != 1) return null;
 
     PsiType argType = args[0].getType();
-    final String plainMessage = getSuspiciousMethodCallMessage(methodCall, argType, reportConvertibleMethodCalls, patternMethods, indices);
+    final String plainMessage = SuspiciousMethodCallUtil
+      .getSuspiciousMethodCallMessage(methodCall, argType, reportConvertibleMethodCalls, patternMethods, indices);
     if (plainMessage != null) {
       final PsiType dfaType = GuessManager.getInstance(methodCall.getProject()).getControlFlowExpressionType(args[0]);
-      if (dfaType != null && getSuspiciousMethodCallMessage(methodCall, dfaType, reportConvertibleMethodCalls, patternMethods, indices) == null) {
+      if (dfaType != null && SuspiciousMethodCallUtil
+                               .getSuspiciousMethodCallMessage(methodCall, dfaType, reportConvertibleMethodCalls, patternMethods, indices) == null) {
         return null;
       }
     }
 
     return plainMessage;
   }
-
-  @Nullable
-  public static String getSuspiciousMethodCallMessage(PsiMethodCallExpression methodCall,
-                                                      PsiType argType, boolean reportConvertibleMethodCalls, List<PsiMethod> patternMethods,
-                                                      IntArrayList indices) {
-    final PsiReferenceExpression methodExpression = methodCall.getMethodExpression();
-    final PsiExpression qualifier = methodExpression.getQualifierExpression();
-    if (qualifier == null || qualifier instanceof PsiThisExpression || qualifier instanceof PsiSuperExpression) return null;
-    if (argType instanceof PsiPrimitiveType) {
-      argType = ((PsiPrimitiveType)argType).getBoxedType(methodCall);
-    }
-
-    if (!(argType instanceof PsiClassType)) return null;
-
-    final JavaResolveResult resolveResult = methodExpression.advancedResolve(false);
-    PsiMethod calleeMethod = (PsiMethod)resolveResult.getElement();
-    if (calleeMethod == null) return null;
-    PsiMethod contextMethod = PsiTreeUtil.getParentOfType(methodCall, PsiMethod.class);
-
-    //noinspection SynchronizationOnLocalVariableOrMethodParameter
-    synchronized (patternMethods) {
-      if (patternMethods.isEmpty()) {
-        setupPatternMethods(methodCall.getManager(), methodCall.getResolveScope(), patternMethods, indices);
-      }
-    }
-
-    for (int i = 0; i < patternMethods.size(); i++) {
-      PsiMethod patternMethod = patternMethods.get(i);
-      if (!patternMethod.getName().equals(methodExpression.getReferenceName())) continue;
-      int index = indices.get(i);
-
-      //we are in collections method implementation
-      if (contextMethod != null && isInheritorOrSelf(contextMethod, patternMethod)) return null;
-
-      final PsiClass calleeClass = calleeMethod.getContainingClass();
-      PsiSubstitutor substitutor = resolveResult.getSubstitutor();
-      final PsiClass patternClass = patternMethod.getContainingClass();
-      assert patternClass != null;
-      assert calleeClass != null;
-      substitutor = TypeConversionUtil.getClassSubstitutor(patternClass, calleeClass, substitutor);
-      if (substitutor == null) continue;
-
-      if (!patternMethod.getSignature(substitutor).equals(calleeMethod.getSignature(PsiSubstitutor.EMPTY))) continue;
-
-      PsiTypeParameter[] typeParameters = patternClass.getTypeParameters();
-      if (typeParameters.length <= index) return null;
-      final PsiTypeParameter typeParameter = typeParameters[index];
-      PsiType typeParamMapping = substitutor.substitute(typeParameter);
-      if (typeParamMapping == null) return null;
-      String message = null;
-      if (typeParamMapping instanceof PsiCapturedWildcardType) {
-        typeParamMapping = ((PsiCapturedWildcardType)typeParamMapping).getWildcard();
-      }
-      if (!typeParamMapping.isAssignableFrom(argType)) {
-        if (typeParamMapping.isConvertibleFrom(argType)) {
-          if (reportConvertibleMethodCalls) {
-            message = InspectionsBundle.message("inspection.suspicious.collections.method.calls.problem.descriptor1",
-                                                PsiFormatUtil.formatMethod(calleeMethod, substitutor,
-                                                                           PsiFormatUtilBase.SHOW_NAME |
-                                                                           PsiFormatUtilBase.SHOW_CONTAINING_CLASS,
-                                                                           PsiFormatUtilBase.SHOW_TYPE));
-          }
-        }
-        else {
-          PsiType qualifierType = qualifier.getType();
-          if (qualifierType != null) {
-            message = InspectionsBundle.message("inspection.suspicious.collections.method.calls.problem.descriptor",
-                                                PsiFormatUtil.formatType(qualifierType, 0, PsiSubstitutor.EMPTY),
-                                                PsiFormatUtil.formatType(argType, 0, PsiSubstitutor.EMPTY));
-          }
-        }
-      }
-      return message;
-    }
-    return null;
-  }
-
-  private static boolean isInheritorOrSelf(PsiMethod inheritorCandidate, PsiMethod base) {
-    PsiClass aClass = inheritorCandidate.getContainingClass();
-    PsiClass bClass = base.getContainingClass();
-    if (aClass == null || bClass == null) return false;
-    PsiSubstitutor substitutor = TypeConversionUtil.getClassSubstitutor(bClass, aClass, PsiSubstitutor.EMPTY);
-    return substitutor != null &&
-           MethodSignatureUtil.findMethodBySignature(bClass, inheritorCandidate.getSignature(substitutor), false) == base;
-  }
 }
diff --git a/java/java-impl/src/com/intellij/openapi/projectRoots/impl/JavaSdkImpl.java b/java/java-impl/src/com/intellij/openapi/projectRoots/impl/JavaSdkImpl.java
index 4110285..248f5a7 100644
--- a/java/java-impl/src/com/intellij/openapi/projectRoots/impl/JavaSdkImpl.java
+++ b/java/java-impl/src/com/intellij/openapi/projectRoots/impl/JavaSdkImpl.java
@@ -56,21 +56,8 @@
   @NonNls private final Pattern myVersionStringPattern = Pattern.compile("^(.*)java version \"([1234567890_.]*)\"(.*)$");
   @NonNls private static final String JAVA_VERSION_PREFIX = "java version ";
   @NonNls private static final String OPENJDK_VERSION_PREFIX = "openjdk version ";
-  private static final Map<JavaSdkVersion, String[]> VERSION_STRINGS = new EnumMap<JavaSdkVersion, String[]>(JavaSdkVersion.class);
   public static final DataKey<Boolean> KEY = DataKey.create("JavaSdk");
 
-  static {
-    VERSION_STRINGS.put(JavaSdkVersion.JDK_1_0, new String[]{"1.0"});
-    VERSION_STRINGS.put(JavaSdkVersion.JDK_1_1, new String[]{"1.1"});
-    VERSION_STRINGS.put(JavaSdkVersion.JDK_1_2, new String[]{"1.2"});
-    VERSION_STRINGS.put(JavaSdkVersion.JDK_1_3, new String[]{"1.3"});
-    VERSION_STRINGS.put(JavaSdkVersion.JDK_1_4, new String[]{"1.4"});
-    VERSION_STRINGS.put(JavaSdkVersion.JDK_1_5, new String[]{"1.5", "5.0"});
-    VERSION_STRINGS.put(JavaSdkVersion.JDK_1_6, new String[]{"1.6", "6.0"});
-    VERSION_STRINGS.put(JavaSdkVersion.JDK_1_7, new String[]{"1.7", "7.0"});
-    VERSION_STRINGS.put(JavaSdkVersion.JDK_1_8, new String[]{"1.8", "8.0"});
-  }
-
   public JavaSdkImpl() {
     super("JavaSDK");
   }
@@ -264,11 +251,11 @@
     if (SystemInfo.isMac) {
       File home = new File(homePath, MAC_HOME_PATH);
       if (home.exists()) return home.getPath();
-      
+
       home = new File(new File(homePath, "Contents"), "Home");
       if (home.exists()) return home.getPath();
     }
-    
+
     return homePath;
   }
 
@@ -302,7 +289,7 @@
   @NotNull
   private static String getVersionNumber(@NotNull String versionString) {
     if (versionString.startsWith(JAVA_VERSION_PREFIX) || versionString.startsWith(OPENJDK_VERSION_PREFIX)) {
-      boolean openJdk = versionString.startsWith(OPENJDK_VERSION_PREFIX); 
+      boolean openJdk = versionString.startsWith(OPENJDK_VERSION_PREFIX);
       versionString = versionString.substring(openJdk ? OPENJDK_VERSION_PREFIX.length() : JAVA_VERSION_PREFIX.length());
       if (versionString.startsWith("\"") && versionString.endsWith("\"")) {
         versionString = versionString.substring(1, versionString.length() - 1);
@@ -440,22 +427,19 @@
 
   @Override
   public JavaSdkVersion getVersion(@NotNull Sdk sdk) {
+    return getVersion1(sdk);
+  }
+
+  private static JavaSdkVersion getVersion1(Sdk sdk) {
     String version = sdk.getVersionString();
     if (version == null) return null;
-    return getVersion(version);
+    return JdkVersionUtil.getVersion(version);
   }
 
   @Override
   @Nullable
   public JavaSdkVersion getVersion(@NotNull String versionString) {
-    for (Map.Entry<JavaSdkVersion, String[]> entry : VERSION_STRINGS.entrySet()) {
-      for (String s : entry.getValue()) {
-        if (versionString.contains(s)) {
-          return entry.getKey();
-        }
-      }
-    }
-    return null;
+    return JdkVersionUtil.getVersion(versionString);
   }
 
   @Override
diff --git a/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureUsageProcessor.java b/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureUsageProcessor.java
index 4d81284..e480912 100644
--- a/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureUsageProcessor.java
+++ b/java/java-impl/src/com/intellij/refactoring/changeSignature/JavaChangeSignatureUsageProcessor.java
@@ -538,8 +538,9 @@
             containingClass = PsiTreeUtil.getParentOfType(containingClass, PsiClass.class);
           }
           if (containingClasses.size() == 1) {
-            return RefactoringUtil.createThisExpression(parentClass.getManager(), containingClasses.contains(parentClass) ? null
-                                                                                                                          : containingClasses.iterator().next());
+            return RefactoringChangeUtil.createThisExpression(parentClass.getManager(), containingClasses.contains(parentClass) ? null
+                                                                                                                                : containingClasses
+                                                                                          .iterator().next());
           }
         }
       }
@@ -761,8 +762,8 @@
         baseMethod == null ? PsiSubstitutor.EMPTY : ChangeSignatureProcessor.calculateSubstitutor(caller, baseMethod);
       final PsiClass aClass = changeInfo.getMethod().getContainingClass();
       final PsiClass callerContainingClass = caller.getContainingClass();
-      final PsiSubstitutor psiSubstitutor = aClass != null && callerContainingClass != null && callerContainingClass.isInheritor(aClass, true) 
-                                            ? TypeConversionUtil.getSuperClassSubstitutor(aClass, callerContainingClass, substitutor) 
+      final PsiSubstitutor psiSubstitutor = aClass != null && callerContainingClass != null && callerContainingClass.isInheritor(aClass, true)
+                                            ? TypeConversionUtil.getSuperClassSubstitutor(aClass, callerContainingClass, substitutor)
                                             : PsiSubstitutor.EMPTY;
       for (JavaParameterInfo info : primaryNewParms) {
         if (info.getOldIndex() < 0) newParameters.add(createNewParameter(changeInfo, info, psiSubstitutor, substitutor));
diff --git a/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodProcessor.java b/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodProcessor.java
index b6d3395..14535e0 100644
--- a/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodProcessor.java
+++ b/java/java-impl/src/com/intellij/refactoring/extractMethod/ExtractMethodProcessor.java
@@ -203,7 +203,7 @@
   public boolean prepare() throws PrepareFailedException {
     return prepare(null);
   }
-  
+
   /**
    * Invoked in atomic action
    */
@@ -551,7 +551,7 @@
       myVariableDatum[i] = myInputVariables.getInputVariables().get(i);
     }
   }
-  
+
   @TestOnly
   public void doNotPassParameter(int i) {
     myVariableDatum[i].passAsParameter = false;
@@ -824,10 +824,10 @@
 
     myExtractedMethod = (PsiMethod)myTargetClass.addAfter(newMethod, myAnchor);
     if (isNeedToChangeCallContext() && myNeedChangeContext) {
-      ChangeContextUtil.decodeContextInfo(myExtractedMethod, myTargetClass, RefactoringUtil.createThisExpression(myManager, null));
+      ChangeContextUtil.decodeContextInfo(myExtractedMethod, myTargetClass, RefactoringChangeUtil.createThisExpression(myManager, null));
       if (myMethodCall.resolveMethod() != myExtractedMethod) {
         final PsiReferenceExpression methodExpression = myMethodCall.getMethodExpression();
-        methodExpression.setQualifierExpression(RefactoringUtil.createThisExpression(myManager, myTargetClass));
+        methodExpression.setQualifierExpression(RefactoringChangeUtil.createThisExpression(myManager, myTargetClass));
       }
     }
 
@@ -1000,7 +1000,7 @@
   private PsiMethod generateEmptyMethod(PsiClassType[] exceptions, boolean isStatic) throws IncorrectOperationException {
     PsiMethod newMethod;
     if (myIsChainedConstructor) {
-      newMethod = myElementFactory.createConstructor();      
+      newMethod = myElementFactory.createConstructor();
     }
     else {
       newMethod = myElementFactory.createMethod(myMethodName, myReturnType);
diff --git a/java/java-impl/src/com/intellij/refactoring/inline/InlineMethodProcessor.java b/java/java-impl/src/com/intellij/refactoring/inline/InlineMethodProcessor.java
index 17a083c..7c55aae 100644
--- a/java/java-impl/src/com/intellij/refactoring/inline/InlineMethodProcessor.java
+++ b/java/java-impl/src/com/intellij/refactoring/inline/InlineMethodProcessor.java
@@ -16,7 +16,6 @@
 package com.intellij.refactoring.inline;
 
 import com.intellij.codeInsight.ChangeContextUtil;
-import com.intellij.codeInsight.daemon.impl.analysis.HighlightUtil;
 import com.intellij.history.LocalHistory;
 import com.intellij.history.LocalHistoryAction;
 import com.intellij.lang.Language;
@@ -621,7 +620,7 @@
       }
     }
 
-    
+
     PsiClass thisClass = myMethod.getContainingClass();
     PsiExpression thisAccessExpr;
     if (thisVar != null) {
@@ -968,8 +967,8 @@
       for (PsiReference ref : refs) {
         final PsiJavaCodeReferenceElement javaRef = (PsiJavaCodeReferenceElement)ref;
         if (initializer instanceof PsiThisExpression && ((PsiThisExpression)initializer).getQualifier() == null) {
-          final PsiClass varThisClass = RefactoringUtil.getThisClass(variable);
-          if (RefactoringUtil.getThisClass(javaRef) != varThisClass) {
+          final PsiClass varThisClass = RefactoringChangeUtil.getThisClass(variable);
+          if (RefactoringChangeUtil.getThisClass(javaRef) != varThisClass) {
             initializer = JavaPsiFacade.getInstance(myManager.getProject()).getElementFactory().createExpressionFromText(varThisClass.getName() + ".this", variable);
           }
         }
@@ -1438,7 +1437,7 @@
     if (methodBody.getStatements().length > 1) {
       PsiExpression expr = PsiTreeUtil.getParentOfType(element, PsiExpression.class);
       while (expr != null) {
-        if (HighlightUtil.isSuperOrThisMethodCall(expr)) {
+        if (RefactoringChangeUtil.isSuperOrThisMethodCall(expr)) {
           return "Inline cannot be applied to multiline method in constructor call";
         }
         expr = PsiTreeUtil.getParentOfType(expr, PsiExpression.class, true);
diff --git a/java/java-impl/src/com/intellij/refactoring/introduceField/BaseExpressionToFieldHandler.java b/java/java-impl/src/com/intellij/refactoring/introduceField/BaseExpressionToFieldHandler.java
index fa21611..0d1aacf 100644
--- a/java/java-impl/src/com/intellij/refactoring/introduceField/BaseExpressionToFieldHandler.java
+++ b/java/java-impl/src/com/intellij/refactoring/introduceField/BaseExpressionToFieldHandler.java
@@ -62,6 +62,7 @@
 import com.intellij.refactoring.rename.RenameJavaVariableProcessor;
 import com.intellij.refactoring.util.CommonRefactoringUtil;
 import com.intellij.refactoring.util.EnumConstantsUtil;
+import com.intellij.refactoring.util.RefactoringChangeUtil;
 import com.intellij.refactoring.util.RefactoringUtil;
 import com.intellij.refactoring.util.occurrences.OccurrenceManager;
 import com.intellij.util.IncorrectOperationException;
@@ -373,7 +374,7 @@
         PsiStatement assignment = createAssignment(field, initializerExpression, body.getLastChild(), parentClass);
         assignment = (PsiStatement) body.add(assignment);
         ChangeContextUtil.decodeContextInfo(assignment, field.getContainingClass(),
-                                            RefactoringUtil.createThisExpression(field.getManager(), null));
+                                            RefactoringChangeUtil.createThisExpression(field.getManager(), null));
         added = true;
       }
       if (!added && enclosingConstructor == null) {
@@ -383,7 +384,7 @@
         PsiStatement assignment = createAssignment(field, initializerExpression, body.getLastChild(), parentClass);
         assignment = (PsiStatement) body.add(assignment);
         ChangeContextUtil.decodeContextInfo(assignment, field.getContainingClass(),
-                                            RefactoringUtil.createThisExpression(field.getManager(), null));
+                                            RefactoringChangeUtil.createThisExpression(field.getManager(), null));
       }
     }
     catch (IncorrectOperationException e) {
@@ -444,7 +445,7 @@
       return null;
     }
   }
-  
+
   protected abstract boolean accept(ElementToWorkOn elementToWorkOn);
 
   protected ElementToWorkOn.ElementsProcessor<ElementToWorkOn> getElementProcessor(final Project project, final Editor editor) {
@@ -707,7 +708,7 @@
         }
 
         initializer = IntroduceVariableBase.replaceExplicitWithDiamondWhenApplicable(initializer, myType);
-        
+
         final PsiMethod enclosingConstructor = getEnclosingConstructor(myParentClass, myAnchorElement);
         PsiClass destClass = mySettings.getDestinationClass() == null ? myParentClass : mySettings.getDestinationClass();
 
@@ -861,7 +862,7 @@
       }
       return true;
     }
-    
+
     static PsiField appendField(final PsiExpression initializer,
                                 InitializationPlace initializerPlace, final PsiClass destClass,
                                 final PsiClass parentClass,
@@ -877,13 +878,13 @@
                                        final PsiField forwardReference) {
       final PsiClass parentClass = PsiTreeUtil.getParentOfType(anchorMember, PsiClass.class);
 
-      if (anchorMember instanceof PsiField && 
+      if (anchorMember instanceof PsiField &&
           anchorMember.getParent() == parentClass &&
           destClass == parentClass &&
           ((PsiField)anchorMember).hasModifierProperty(PsiModifier.STATIC) == psiField.hasModifierProperty(PsiModifier.STATIC)) {
         return (PsiField)destClass.addBefore(psiField, anchorMember);
       }
-      else if (anchorMember instanceof PsiClassInitializer && 
+      else if (anchorMember instanceof PsiClassInitializer &&
                anchorMember.getParent() == parentClass &&
                destClass == parentClass) {
         PsiField field = (PsiField)destClass.addBefore(psiField, anchorMember);
diff --git a/java/java-impl/src/com/intellij/refactoring/introduceParameter/AbstractJavaInplaceIntroducer.java b/java/java-impl/src/com/intellij/refactoring/introduceParameter/AbstractJavaInplaceIntroducer.java
index 3a02fbb..223a180 100644
--- a/java/java-impl/src/com/intellij/refactoring/introduceParameter/AbstractJavaInplaceIntroducer.java
+++ b/java/java-impl/src/com/intellij/refactoring/introduceParameter/AbstractJavaInplaceIntroducer.java
@@ -162,7 +162,15 @@
         return null;
       }
     }
-    return expression != null && expression.isValid() && expression.getText().equals(exprText) ? expression : null;
+    if (expression != null && expression.isValid() && expression.getText().equals(exprText)) {
+      return expression;
+    }
+
+    if (refVariableElementParent instanceof PsiExpression && refVariableElementParent.getText().equals(exprText)) {
+      return (PsiExpression)refVariableElementParent;
+    }
+
+    return null;
   }
 
    public static Expression createExpression(final TypeExpression expression, final String defaultType) {
diff --git a/java/java-impl/src/com/intellij/refactoring/makeStatic/MakeClassStaticProcessor.java b/java/java-impl/src/com/intellij/refactoring/makeStatic/MakeClassStaticProcessor.java
index 288bab4..5672203 100644
--- a/java/java-impl/src/com/intellij/refactoring/makeStatic/MakeClassStaticProcessor.java
+++ b/java/java-impl/src/com/intellij/refactoring/makeStatic/MakeClassStaticProcessor.java
@@ -15,7 +15,6 @@
  */
 package com.intellij.refactoring.makeStatic;
 
-import com.intellij.codeInsight.intention.impl.BaseMoveInitializerToMethodAction;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.project.Project;
 import com.intellij.psi.*;
@@ -29,6 +28,7 @@
 import com.intellij.psi.util.PsiUtil;
 import com.intellij.refactoring.RefactoringBundle;
 import com.intellij.refactoring.move.MoveInstanceMembersUtil;
+import com.intellij.refactoring.util.RefactoringChangeUtil;
 import com.intellij.refactoring.util.RefactoringUIUtil;
 import com.intellij.refactoring.util.RefactoringUtil;
 import com.intellij.refactoring.util.javadoc.MethodJavaDocHelper;
@@ -262,7 +262,7 @@
     PsiElement newQualifier;
 
     if (instanceRef == null || instanceRef instanceof PsiSuperExpression) {
-      final PsiClass thisClass = RefactoringUtil.getThisClass(element);
+      final PsiClass thisClass = RefactoringChangeUtil.getThisClass(element);
       @NonNls String thisText;
       if (thisClass.getManager().areElementsEquivalent(thisClass, myMember.getContainingClass())) {
         thisText = "this";
diff --git a/java/java-impl/src/com/intellij/refactoring/memberPullUp/PullUpHelper.java b/java/java-impl/src/com/intellij/refactoring/memberPullUp/PullUpHelper.java
index fc67f71..0f7b115 100644
--- a/java/java-impl/src/com/intellij/refactoring/memberPullUp/PullUpHelper.java
+++ b/java/java-impl/src/com/intellij/refactoring/memberPullUp/PullUpHelper.java
@@ -48,10 +48,7 @@
 import com.intellij.refactoring.RefactoringBundle;
 import com.intellij.refactoring.listeners.JavaRefactoringListenerManager;
 import com.intellij.refactoring.listeners.impl.JavaRefactoringListenerManagerImpl;
-import com.intellij.refactoring.util.DocCommentPolicy;
-import com.intellij.refactoring.util.RefactoringHierarchyUtil;
-import com.intellij.refactoring.util.RefactoringUIUtil;
-import com.intellij.refactoring.util.RefactoringUtil;
+import com.intellij.refactoring.util.*;
 import com.intellij.refactoring.util.classMembers.ClassMemberReferencesVisitor;
 import com.intellij.refactoring.util.classMembers.MemberInfo;
 import com.intellij.refactoring.util.duplicates.MethodDuplicatesHandler;
@@ -485,7 +482,7 @@
       PsiStatement assignmentStatement = (PsiStatement)constructor.getBody().add(initializer.initializer);
 
       ChangeContextUtil.decodeContextInfo(assignmentStatement,
-                                          myTargetSuperClass, RefactoringUtil.createThisExpression(myManager, null));
+                                          myTargetSuperClass, RefactoringChangeUtil.createThisExpression(myManager, null));
       for (PsiElement psiElement : initializer.statementsToRemove) {
         psiElement.delete();
       }
diff --git a/java/java-impl/src/com/intellij/refactoring/move/moveInner/MoveInnerProcessor.java b/java/java-impl/src/com/intellij/refactoring/move/moveInner/MoveInnerProcessor.java
index 8b55498..57936c6 100644
--- a/java/java-impl/src/com/intellij/refactoring/move/moveInner/MoveInnerProcessor.java
+++ b/java/java-impl/src/com/intellij/refactoring/move/moveInner/MoveInnerProcessor.java
@@ -36,10 +36,7 @@
 import com.intellij.refactoring.move.MoveCallback;
 import com.intellij.refactoring.move.moveClassesOrPackages.MoveClassesOrPackagesUtil;
 import com.intellij.refactoring.rename.RenameUtil;
-import com.intellij.refactoring.util.ConflictsUtil;
-import com.intellij.refactoring.util.NonCodeUsageInfo;
-import com.intellij.refactoring.util.RefactoringUIUtil;
-import com.intellij.refactoring.util.RefactoringUtil;
+import com.intellij.refactoring.util.*;
 import com.intellij.usageView.UsageInfo;
 import com.intellij.usageView.UsageViewDescriptor;
 import com.intellij.usageView.UsageViewUtil;
@@ -231,12 +228,12 @@
             if (argList != null) { // can happen in incomplete code
               if (newExpr.getQualifier() == null) {
                 PsiThisExpression thisExpr;
-                PsiClass parentClass = RefactoringUtil.getThisClass(newExpr);
+                PsiClass parentClass = RefactoringChangeUtil.getThisClass(newExpr);
                 if (myOuterClass.equals(parentClass)) {
-                  thisExpr = RefactoringUtil.createThisExpression(manager, null);
+                  thisExpr = RefactoringChangeUtil.createThisExpression(manager, null);
                 }
                 else {
-                  thisExpr = RefactoringUtil.createThisExpression(manager, myOuterClass);
+                  thisExpr = RefactoringChangeUtil.createThisExpression(manager, myOuterClass);
                 }
                 argList.addAfter(thisExpr, null);
               }
diff --git a/java/java-impl/src/com/intellij/refactoring/move/moveInstanceMethod/MoveInstanceMethodProcessor.java b/java/java-impl/src/com/intellij/refactoring/move/moveInstanceMethod/MoveInstanceMethodProcessor.java
index 068fe4f..5784665 100644
--- a/java/java-impl/src/com/intellij/refactoring/move/moveInstanceMethod/MoveInstanceMethodProcessor.java
+++ b/java/java-impl/src/com/intellij/refactoring/move/moveInstanceMethod/MoveInstanceMethodProcessor.java
@@ -425,7 +425,14 @@
                 return;
               }
               if (myTargetVariable.equals(resolved)) {
-                PsiThisExpression thisExpression = RefactoringUtil.createThisExpression(manager, PsiTreeUtil.isAncestor(myMethod, PsiTreeUtil.getParentOfType(expression, PsiClass.class), true) ? myTargetClass : null);
+                PsiThisExpression thisExpression = RefactoringChangeUtil.createThisExpression(manager, PsiTreeUtil.isAncestor(myMethod,
+                                                                                                                              PsiTreeUtil
+                                                                                                                                .getParentOfType(
+                                                                                                                                  expression,
+                                                                                                                                  PsiClass.class),
+                                                                                                                              true)
+                                                                                                       ? myTargetClass
+                                                                                                       : null);
                 replaceMap.put(expression, thisExpression);
                 return;
               }
diff --git a/java/java-impl/src/com/intellij/refactoring/rename/BeanPropertyRenameHandler.java b/java/java-impl/src/com/intellij/refactoring/rename/BeanPropertyRenameHandler.java
index 4c41a43..785c5da 100644
--- a/java/java-impl/src/com/intellij/refactoring/rename/BeanPropertyRenameHandler.java
+++ b/java/java-impl/src/com/intellij/refactoring/rename/BeanPropertyRenameHandler.java
@@ -56,9 +56,10 @@
     new PropertyRenameDialog(property, editor).show();
   }
 
-  public static void doRename(@NotNull final BeanProperty property, final String newName, final boolean searchInComments) {
+  public static void doRename(@NotNull final BeanProperty property, final String newName, final boolean searchInComments, boolean isPreview) {
     final PsiElement psiElement = property.getPsiElement();
     final RenameRefactoring rename = new JavaRenameRefactoringImpl(psiElement.getProject(), psiElement, newName, searchInComments, false);
+    rename.setPreviewUsages(isPreview);
 
     final PsiMethod setter = property.getSetter();
     if (setter != null) {
@@ -90,7 +91,7 @@
     protected void doAction() {
       final String newName = getNewName();
       final boolean searchInComments = isSearchInComments();
-      doRename(myProperty, newName, searchInComments);
+      doRename(myProperty, newName, searchInComments, isPreviewUsages());
       close(DialogWrapper.OK_EXIT_CODE);
     }
   }
diff --git a/java/java-impl/src/com/intellij/refactoring/util/FieldConflictsResolver.java b/java/java-impl/src/com/intellij/refactoring/util/FieldConflictsResolver.java
index 488cac4..38a194a 100644
--- a/java/java-impl/src/com/intellij/refactoring/util/FieldConflictsResolver.java
+++ b/java/java-impl/src/com/intellij/refactoring/util/FieldConflictsResolver.java
@@ -15,16 +15,11 @@
  */
 package com.intellij.refactoring.util;
 
-import com.intellij.codeInsight.daemon.impl.analysis.HighlightUtil;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.psi.*;
-import com.intellij.psi.codeStyle.CodeStyleManager;
 import com.intellij.psi.search.LocalSearchScope;
 import com.intellij.psi.search.searches.ReferencesSearch;
-import com.intellij.psi.util.InheritanceUtil;
-import com.intellij.psi.util.PsiTreeUtil;
 import com.intellij.util.IncorrectOperationException;
-import org.jetbrains.annotations.Nullable;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -84,7 +79,7 @@
           final PsiElement result = expression.resolve();
           if (expression.getManager().areElementsEquivalent(result, myField)) {
             try {
-              replacedRef[0] = qualifyReference(expression, myField, myQualifyingClass);
+              replacedRef[0] = RefactoringChangeUtil.qualifyReference(expression, myField, myQualifyingClass);
             }
             catch (IncorrectOperationException e) {
               LOG.error(e);
@@ -104,46 +99,8 @@
       if (!referenceExpression.isValid()) continue;
       final PsiElement newlyResolved = referenceExpression.resolve();
       if (!manager.areElementsEquivalent(newlyResolved, myField)) {
-        qualifyReference(referenceExpression, myField, myQualifyingClass);
+        RefactoringChangeUtil.qualifyReference(referenceExpression, myField, myQualifyingClass);
       }
     }
   }
-
-
-  public static PsiReferenceExpression qualifyReference(PsiReferenceExpression referenceExpression,
-                                                        final PsiMember member,
-                                                        @Nullable final PsiClass qualifyingClass) throws IncorrectOperationException {
-    PsiManager manager = referenceExpression.getManager();
-    PsiMethodCallExpression methodCallExpression = PsiTreeUtil.getParentOfType(referenceExpression, PsiMethodCallExpression.class, true);
-    while (methodCallExpression != null) {
-      if (HighlightUtil.isSuperOrThisMethodCall(methodCallExpression)) {
-        return referenceExpression;
-      }
-      methodCallExpression = PsiTreeUtil.getParentOfType(methodCallExpression, PsiMethodCallExpression.class, true);
-    }
-    PsiReferenceExpression expressionFromText;
-    final PsiElementFactory factory = JavaPsiFacade.getInstance(manager.getProject()).getElementFactory();
-    if (qualifyingClass == null) {
-      PsiClass parentClass = PsiTreeUtil.getParentOfType(referenceExpression, PsiClass.class);
-      final PsiClass containingClass = member.getContainingClass();
-      if (parentClass != null && !InheritanceUtil.isInheritorOrSelf(parentClass, containingClass, true)) {
-        while (parentClass != null && !InheritanceUtil.isInheritorOrSelf(parentClass, containingClass, true)) {
-          parentClass = PsiTreeUtil.getParentOfType(parentClass, PsiClass.class, true);
-        }
-        LOG.assertTrue(parentClass != null);
-        expressionFromText = (PsiReferenceExpression)factory.createExpressionFromText("A.this." + member.getName(), null);
-        ((PsiThisExpression)expressionFromText.getQualifierExpression()).getQualifier().replace(factory.createClassReferenceElement(parentClass));
-      }
-      else {
-        expressionFromText = (PsiReferenceExpression)factory.createExpressionFromText("this." + member.getName(), null);
-      }
-    }
-    else {
-      expressionFromText = (PsiReferenceExpression)factory.createExpressionFromText("A." + member.getName(), null);
-      expressionFromText.setQualifierExpression(factory.createReferenceExpression(qualifyingClass));
-    }
-    CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(manager.getProject());
-    expressionFromText = (PsiReferenceExpression)codeStyleManager.reformat(expressionFromText);
-    return (PsiReferenceExpression)referenceExpression.replace(expressionFromText);
-  }
 }
diff --git a/java/java-impl/src/com/intellij/refactoring/util/InlineUtil.java b/java/java-impl/src/com/intellij/refactoring/util/InlineUtil.java
index db3e95b..c02644f 100644
--- a/java/java-impl/src/com/intellij/refactoring/util/InlineUtil.java
+++ b/java/java-impl/src/com/intellij/refactoring/util/InlineUtil.java
@@ -47,8 +47,8 @@
     throws IncorrectOperationException {
     PsiManager manager = initializer.getManager();
 
-    PsiClass thisClass = RefactoringUtil.getThisClass(initializer);
-    PsiClass refParent = RefactoringUtil.getThisClass(ref);
+    PsiClass thisClass = RefactoringChangeUtil.getThisClass(initializer);
+    PsiClass refParent = RefactoringChangeUtil.getThisClass(ref);
     boolean insertCastWhenUnchecked = ref.getParent() instanceof PsiForeachStatement;
     final PsiType varType = variable.getType();
     initializer = RefactoringUtil.convertInitializerToNormalExpression(initializer, varType);
@@ -57,7 +57,7 @@
     PsiExpression expr = (PsiExpression)replaceDiamondWithInferredTypesIfNeeded(initializer, ref);
     PsiType exprType = expr.getType();
     if (exprType != null && (!varType.equals(exprType) && (varType instanceof PsiPrimitiveType || exprType instanceof PsiPrimitiveType)
-                             || !TypeConversionUtil.isAssignable(varType, exprType) 
+                             || !TypeConversionUtil.isAssignable(varType, exprType)
                              || insertCastWhenUnchecked && GenericsHighlightUtil.isRawToGeneric(varType, exprType))) {
       boolean matchedTypes = false;
       //try explicit type arguments
@@ -174,14 +174,14 @@
     if (Comparing.equal(thisClass, refParent))
 
     {
-      thisAccessExpr = RefactoringUtil.createThisExpression(manager, null);
+      thisAccessExpr = RefactoringChangeUtil.createThisExpression(manager, null);
     }
 
     else
 
     {
       if (!(thisClass instanceof PsiAnonymousClass)) {
-        thisAccessExpr = RefactoringUtil.createThisExpression(manager, thisClass);
+        thisAccessExpr = RefactoringChangeUtil.createThisExpression(manager, thisClass);
       }
     }
     return thisAccessExpr;
diff --git a/java/java-impl/src/com/intellij/refactoring/util/RefactoringUtil.java b/java/java-impl/src/com/intellij/refactoring/util/RefactoringUtil.java
index 6b7b44e..b30b63c 100644
--- a/java/java-impl/src/com/intellij/refactoring/util/RefactoringUtil.java
+++ b/java/java-impl/src/com/intellij/refactoring/util/RefactoringUtil.java
@@ -373,22 +373,6 @@
     return null;
   }
 
-  public static PsiClass getThisClass(PsiElement place) {
-    PsiElement parent = place.getContext();
-    if (parent == null) return null;
-    PsiElement prev = null;
-    while (true) {
-      if (parent instanceof PsiClass) {
-        if (!(parent instanceof PsiAnonymousClass && ((PsiAnonymousClass)parent).getArgumentList() == prev)) {
-          return (PsiClass)parent;
-        }
-      }
-      prev = parent;
-      parent = parent.getContext();
-      if (parent == null) return null;
-    }
-  }
-
   public static PsiClass getThisResolveClass(final PsiReferenceExpression place) {
     final JavaResolveResult resolveResult = place.advancedResolve(false);
     final PsiElement scope = resolveResult.getCurrentFileResolveScope();
@@ -434,29 +418,6 @@
     return !isReassigned;
   }
 
-  public static PsiThisExpression createThisExpression(PsiManager manager, PsiClass qualifierClass) throws IncorrectOperationException {
-    return RefactoringUtil.<PsiThisExpression>createQualifiedExpression(manager, qualifierClass, "this");
-  }
-
-  public static PsiSuperExpression createSuperExpression(PsiManager manager, PsiClass qualifierClass) throws IncorrectOperationException {
-    return RefactoringUtil.<PsiSuperExpression>createQualifiedExpression(manager, qualifierClass, "super");
-  }
-
-  private static <T extends PsiQualifiedExpression> T createQualifiedExpression(PsiManager manager, PsiClass qualifierClass, String qName) throws IncorrectOperationException {
-     PsiElementFactory factory = JavaPsiFacade.getInstance(manager.getProject()).getElementFactory();
-     if (qualifierClass != null) {
-       T qualifiedThis = (T)factory.createExpressionFromText("q." + qName, null);
-       qualifiedThis = (T)CodeStyleManager.getInstance(manager.getProject()).reformat(qualifiedThis);
-       PsiJavaCodeReferenceElement thisQualifier = qualifiedThis.getQualifier();
-       LOG.assertTrue(thisQualifier != null);
-       thisQualifier.bindToElement(qualifierClass);
-       return qualifiedThis;
-     }
-     else {
-       return (T)factory.createExpressionFromText(qName, null);
-     }
-   }
-
   /**
    * removes a reference to the specified class from the reference list given
    *
diff --git a/java/java-impl/src/com/intellij/refactoring/util/duplicates/DuplicatesFinder.java b/java/java-impl/src/com/intellij/refactoring/util/duplicates/DuplicatesFinder.java
index f6929a3..b6d8a55 100644
--- a/java/java-impl/src/com/intellij/refactoring/util/duplicates/DuplicatesFinder.java
+++ b/java/java-impl/src/com/intellij/refactoring/util/duplicates/DuplicatesFinder.java
@@ -27,7 +27,7 @@
 import com.intellij.psi.tree.IElementType;
 import com.intellij.psi.util.*;
 import com.intellij.refactoring.extractMethod.InputVariables;
-import com.intellij.refactoring.util.RefactoringUtil;
+import com.intellij.refactoring.util.RefactoringChangeUtil;
 import com.intellij.util.ArrayUtil;
 import com.intellij.util.IncorrectOperationException;
 import com.intellij.util.containers.IntArrayList;
@@ -349,11 +349,11 @@
         return false;
       }
       PsiElement qualifier1 = ((PsiJavaCodeReferenceElement)pattern).getQualifier();
-      if (qualifier1 instanceof PsiReferenceExpression && qualifier2 instanceof PsiReferenceExpression && 
+      if (qualifier1 instanceof PsiReferenceExpression && qualifier2 instanceof PsiReferenceExpression &&
           !match.areCorrespond(((PsiReferenceExpression)qualifier1).resolve(), ((PsiReferenceExpression)qualifier2).resolve())) {
         return false;
       }
-      
+
     }
 
     if (pattern instanceof PsiTypeCastExpression) {
@@ -424,16 +424,17 @@
               final Pair<PsiVariable, PsiType> parameter = patternQualifier.getUserData(PARAMETER);
 
               if (parameter != null) {
-                final PsiClass thisClass = RefactoringUtil.getThisClass(parameter.first);
+                final PsiClass thisClass = RefactoringChangeUtil.getThisClass(parameter.first);
 
                 if (contextClass != null && InheritanceUtil.isInheritorOrSelf(thisClass, contextClass, true)) {
                   contextClass = thisClass;
                 }
-                final PsiClass thisCandidate = RefactoringUtil.getThisClass(candidate);
+                final PsiClass thisCandidate = RefactoringChangeUtil.getThisClass(candidate);
                 if (thisCandidate != null && InheritanceUtil.isInheritorOrSelf(thisCandidate, contextClass, true)) {
                   contextClass = thisCandidate;
                 }
-                return contextClass != null && match.putParameter(parameter, RefactoringUtil.createThisExpression(patternQualifier.getManager(), contextClass));
+                return contextClass != null && match.putParameter(parameter, RefactoringChangeUtil
+                  .createThisExpression(patternQualifier.getManager(), contextClass));
               } else if (patternQualifier instanceof PsiReferenceExpression) {
                 final PsiElement resolved = ((PsiReferenceExpression)patternQualifier).resolve();
                 if (resolved instanceof PsiClass) {
diff --git a/java/java-impl/src/com/intellij/refactoring/util/duplicates/MethodDuplicatesMatchProvider.java b/java/java-impl/src/com/intellij/refactoring/util/duplicates/MethodDuplicatesMatchProvider.java
index 553b708..6476aa4 100644
--- a/java/java-impl/src/com/intellij/refactoring/util/duplicates/MethodDuplicatesMatchProvider.java
+++ b/java/java-impl/src/com/intellij/refactoring/util/duplicates/MethodDuplicatesMatchProvider.java
@@ -23,6 +23,7 @@
 import com.intellij.psi.util.PsiTypesUtil;
 import com.intellij.psi.util.PsiUtil;
 import com.intellij.refactoring.RefactoringBundle;
+import com.intellij.refactoring.util.RefactoringChangeUtil;
 import com.intellij.refactoring.util.RefactoringUtil;
 import com.intellij.util.IncorrectOperationException;
 import com.intellij.util.VisibilityUtil;
@@ -83,9 +84,9 @@
       } else {
         final PsiClass psiClass = PsiTreeUtil.getParentOfType(match.getMatchStart(), PsiClass.class);
         if (psiClass != null && psiClass.isInheritor(containingClass, true)) {
-          qualifierExpression.replace(RefactoringUtil.createSuperExpression(containingClass.getManager(), null));
+          qualifierExpression.replace(RefactoringChangeUtil.createSuperExpression(containingClass.getManager(), null));
         } else {
-          qualifierExpression.replace(RefactoringUtil.createThisExpression(containingClass.getManager(), containingClass));
+          qualifierExpression.replace(RefactoringChangeUtil.createThisExpression(containingClass.getManager(), containingClass));
         }
       }
     }
diff --git a/java/java-psi-api/java-psi-api.iml b/java/java-psi-api/java-psi-api.iml
index caff682..4256838 100644
--- a/java/java-psi-api/java-psi-api.iml
+++ b/java/java-psi-api/java-psi-api.iml
@@ -8,6 +8,7 @@
     <orderEntry type="inheritedJdk" />
     <orderEntry type="sourceFolder" forTests="false" />
     <orderEntry type="module" module-name="core-api" exported="" />
+    <orderEntry type="module" module-name="projectModel-api" />
   </component>
 </module>
 
diff --git a/java/java-psi-api/src/com/intellij/openapi/module/EffectiveLanguageLevelUtil.java b/java/java-psi-api/src/com/intellij/openapi/module/EffectiveLanguageLevelUtil.java
new file mode 100644
index 0000000..9a0fb12
--- /dev/null
+++ b/java/java-psi-api/src/com/intellij/openapi/module/EffectiveLanguageLevelUtil.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2000-2013 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.openapi.module;
+
+import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.roots.LanguageLevelModuleExtension;
+import com.intellij.openapi.roots.LanguageLevelProjectExtension;
+import com.intellij.pom.java.LanguageLevel;
+import org.jetbrains.annotations.NotNull;
+
+public class EffectiveLanguageLevelUtil {
+  @NotNull
+  public static LanguageLevel getEffectiveLanguageLevel(@NotNull final Module module) {
+    ApplicationManager.getApplication().assertReadAccessAllowed();
+    LanguageLevel level = LanguageLevelModuleExtension.getInstance(module).getLanguageLevel();
+    if (level != null) return level;
+    return LanguageLevelProjectExtension.getInstance(module.getProject()).getLanguageLevel();
+  }
+}
diff --git a/java/java-psi-api/src/com/intellij/openapi/projectRoots/JdkVersionUtil.java b/java/java-psi-api/src/com/intellij/openapi/projectRoots/JdkVersionUtil.java
new file mode 100644
index 0000000..d26b1ca
--- /dev/null
+++ b/java/java-psi-api/src/com/intellij/openapi/projectRoots/JdkVersionUtil.java
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2000-2013 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.openapi.projectRoots;
+
+import org.jetbrains.annotations.NotNull;
+
+import java.util.EnumMap;
+import java.util.Map;
+
+public class JdkVersionUtil {
+  private static final Map<JavaSdkVersion, String[]> VERSION_STRINGS = new EnumMap<JavaSdkVersion, String[]>(JavaSdkVersion.class);
+
+  static {
+    VERSION_STRINGS.put(JavaSdkVersion.JDK_1_0, new String[]{"1.0"});
+    VERSION_STRINGS.put(JavaSdkVersion.JDK_1_1, new String[]{"1.1"});
+    VERSION_STRINGS.put(JavaSdkVersion.JDK_1_2, new String[]{"1.2"});
+    VERSION_STRINGS.put(JavaSdkVersion.JDK_1_3, new String[]{"1.3"});
+    VERSION_STRINGS.put(JavaSdkVersion.JDK_1_4, new String[]{"1.4"});
+    VERSION_STRINGS.put(JavaSdkVersion.JDK_1_5, new String[]{"1.5", "5.0"});
+    VERSION_STRINGS.put(JavaSdkVersion.JDK_1_6, new String[]{"1.6", "6.0"});
+    VERSION_STRINGS.put(JavaSdkVersion.JDK_1_7, new String[]{"1.7", "7.0"});
+    VERSION_STRINGS.put(JavaSdkVersion.JDK_1_8, new String[]{"1.8", "8.0"});
+  }
+
+  public static JavaSdkVersion getVersion(@NotNull String versionString) {
+    for (Map.Entry<JavaSdkVersion, String[]> entry : VERSION_STRINGS.entrySet()) {
+      for (String s : entry.getValue()) {
+        if (versionString.contains(s)) {
+          return entry.getKey();
+        }
+      }
+    }
+    return null;
+  }
+}
diff --git a/java/openapi/src/com/intellij/openapi/roots/LanguageLevelModuleExtension.java b/java/java-psi-api/src/com/intellij/openapi/roots/LanguageLevelModuleExtension.java
similarity index 99%
rename from java/openapi/src/com/intellij/openapi/roots/LanguageLevelModuleExtension.java
rename to java/java-psi-api/src/com/intellij/openapi/roots/LanguageLevelModuleExtension.java
index e6db187..5ede20d 100644
--- a/java/openapi/src/com/intellij/openapi/roots/LanguageLevelModuleExtension.java
+++ b/java/java-psi-api/src/com/intellij/openapi/roots/LanguageLevelModuleExtension.java
@@ -119,4 +119,4 @@
     myModule = null;
     myLanguageLevel = null;
   }
-}
\ No newline at end of file
+}
diff --git a/java/java-psi-api/src/com/intellij/psi/GenericsUtil.java b/java/java-psi-api/src/com/intellij/psi/GenericsUtil.java
index 06d4037..f2a6236 100644
--- a/java/java-psi-api/src/com/intellij/psi/GenericsUtil.java
+++ b/java/java-psi-api/src/com/intellij/psi/GenericsUtil.java
@@ -385,6 +385,8 @@
       final PsiType bound = ((PsiWildcardType)type).getBound();
       return bound != null ? bound 
                            : ((PsiWildcardType)type).getExtendsBound();//object
+    } else if (type instanceof PsiCapturedWildcardType && !eliminateInTypeArguments) {
+      return eliminateWildcards(((PsiCapturedWildcardType)type).getWildcard(), eliminateInTypeArguments);
     }
     return type;
   }
diff --git a/java/openapi/src/com/intellij/psi/util/RedundantCastUtil.java b/java/java-psi-api/src/com/intellij/psi/util/RedundantCastUtil.java
similarity index 100%
rename from java/openapi/src/com/intellij/psi/util/RedundantCastUtil.java
rename to java/java-psi-api/src/com/intellij/psi/util/RedundantCastUtil.java
diff --git a/java/java-impl/src/com/intellij/codeInsight/ChangeContextUtil.java b/java/java-psi-impl/src/com/intellij/codeInsight/ChangeContextUtil.java
similarity index 96%
rename from java/java-impl/src/com/intellij/codeInsight/ChangeContextUtil.java
rename to java/java-psi-impl/src/com/intellij/codeInsight/ChangeContextUtil.java
index df3ccb7..b93057f 100644
--- a/java/java-impl/src/com/intellij/codeInsight/ChangeContextUtil.java
+++ b/java/java-psi-impl/src/com/intellij/codeInsight/ChangeContextUtil.java
@@ -20,8 +20,7 @@
 import com.intellij.psi.*;
 import com.intellij.psi.util.InheritanceUtil;
 import com.intellij.psi.util.PsiTreeUtil;
-import com.intellij.refactoring.util.FieldConflictsResolver;
-import com.intellij.refactoring.util.RefactoringUtil;
+import com.intellij.refactoring.util.RefactoringChangeUtil;
 import com.intellij.util.ArrayUtil;
 import com.intellij.util.IncorrectOperationException;
 import org.jetbrains.annotations.NotNull;
@@ -57,7 +56,7 @@
       PsiThisExpression thisExpr = (PsiThisExpression)scope;
       final PsiJavaCodeReferenceElement qualifier = thisExpr.getQualifier();
       if (qualifier == null){
-        PsiClass thisClass = RefactoringUtil.getThisClass(thisExpr);
+        PsiClass thisClass = RefactoringChangeUtil.getThisClass(thisExpr);
         if (thisClass != null && !(thisClass instanceof PsiAnonymousClass)){
           thisExpr.putCopyableUserData(THIS_QUALIFIER_CLASS_KEY, thisClass);
         }
@@ -187,7 +186,7 @@
     return thisExpr;
   }
 
-  private static PsiReferenceExpression decodeReferenceExpression(PsiReferenceExpression refExpr,
+  private static PsiReferenceExpression decodeReferenceExpression(@NotNull PsiReferenceExpression refExpr,
                                                                   PsiExpression thisAccessExpr,
                                                                   PsiClass thisClass) throws IncorrectOperationException {
     PsiManager manager = refExpr.getManager();
@@ -225,7 +224,7 @@
                   PsiJavaCodeReferenceElement thisQualifier = ((PsiThisExpression)thisAccessExpr).getQualifier();
                   PsiClass thisExprClass = thisQualifier != null
                                            ? (PsiClass)thisQualifier.resolve()
-                                           : RefactoringUtil.getThisClass(refExpr);
+                                           : RefactoringChangeUtil.getThisClass(refExpr);
                   if (currentClass.equals(thisExprClass) || thisExprClass.isInheritor(realParentClass, true)){ // qualifier is not necessary
                     needQualifier = false;
                   }
@@ -240,7 +239,7 @@
           else if (thisClass != null && realParentClass != null && PsiTreeUtil.isAncestor(realParentClass, thisClass, true)) {
             PsiElement refElement = refExpr.resolve();
             if (refElement != null && !manager.areElementsEquivalent(refMember, refElement)) {
-              refExpr = FieldConflictsResolver.qualifyReference(refExpr, refMember, null);
+              refExpr = RefactoringChangeUtil.qualifyReference(refExpr, refMember, null);
             }
           }
         }
@@ -302,7 +301,7 @@
         return refElement.equals(newRefElement);
       }
       else if (refExpr instanceof PsiMethodReferenceExpression) {
-        return false;        
+        return false;
       }
       else {
         PsiReferenceExpression newRefExpr = (PsiReferenceExpression)factory.createExpressionFromText(
@@ -322,7 +321,7 @@
       PsiThisExpression thisExpr = (PsiThisExpression)scope;
       if (thisExpr.getQualifier() == null){
         if (thisClass instanceof PsiAnonymousClass) return null;
-        PsiThisExpression qualifiedThis = RefactoringUtil.createThisExpression(thisClass.getManager(), thisClass);
+        PsiThisExpression qualifiedThis = RefactoringChangeUtil.createThisExpression(thisClass.getManager(), thisClass);
         if (thisExpr.getParent() != null) {
           return thisExpr.replace(qualifiedThis);
         } else {
diff --git a/java/java-psi-impl/src/com/intellij/codeInsight/intention/AddAnnotationPsiFix.java b/java/java-psi-impl/src/com/intellij/codeInsight/intention/AddAnnotationPsiFix.java
new file mode 100644
index 0000000..d803b32
--- /dev/null
+++ b/java/java-psi-impl/src/com/intellij/codeInsight/intention/AddAnnotationPsiFix.java
@@ -0,0 +1,146 @@
+/*
+ * Copyright 2000-2013 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.codeInsight.intention;
+
+import com.intellij.codeInsight.AnnotationUtil;
+import com.intellij.codeInsight.CodeInsightBundle;
+import com.intellij.codeInsight.ExternalAnnotationsManager;
+import com.intellij.codeInsight.FileModificationService;
+import com.intellij.codeInspection.LocalQuickFixOnPsiElement;
+import com.intellij.lang.findUsages.FindUsagesProvider;
+import com.intellij.lang.findUsages.LanguageFindUsages;
+import com.intellij.openapi.command.undo.UndoUtil;
+import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.project.Project;
+import com.intellij.psi.*;
+import com.intellij.psi.codeStyle.JavaCodeStyleManager;
+import com.intellij.psi.util.PsiTreeUtil;
+import com.intellij.psi.util.PsiUtil;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+public class AddAnnotationPsiFix extends LocalQuickFixOnPsiElement {
+  private static final Logger LOG = Logger.getInstance("#com.intellij.codeInsight.intention.AddAnnotationPsiFix");
+  protected final String myAnnotation;
+  protected final String[] myAnnotationsToRemove;
+  protected final PsiNameValuePair[] myPairs; // not used when registering local quick fix
+  protected final String myText;
+
+  public AddAnnotationPsiFix(@NotNull String fqn,
+                            @NotNull PsiModifierListOwner modifierListOwner,
+                            @NotNull PsiNameValuePair[] values,
+                            @NotNull String... annotationsToRemove) {
+    super(modifierListOwner);
+    myAnnotation = fqn;
+    myPairs = values;
+    myAnnotationsToRemove = annotationsToRemove;
+    myText = calcText(modifierListOwner, myAnnotation);
+  }
+
+  public static String calcText(PsiModifierListOwner modifierListOwner, @NotNull String annotation) {
+    final String shortName = annotation.substring(annotation.lastIndexOf('.') + 1);
+    if (modifierListOwner instanceof PsiNamedElement) {
+      final String name = ((PsiNamedElement)modifierListOwner).getName();
+      if (name != null) {
+        FindUsagesProvider provider = LanguageFindUsages.INSTANCE.forLanguage(modifierListOwner.getLanguage());
+        return CodeInsightBundle
+          .message("inspection.i18n.quickfix.annotate.element.as", provider.getType(modifierListOwner), name, shortName);
+      }
+    }
+    return CodeInsightBundle.message("inspection.i18n.quickfix.annotate.as", shortName);
+  }
+
+  @Nullable
+  public static PsiModifierListOwner getContainer(final PsiElement element) {
+    PsiModifierListOwner listOwner = PsiTreeUtil.getParentOfType(element, PsiParameter.class, false);
+    if (listOwner == null) {
+      final PsiIdentifier psiIdentifier = PsiTreeUtil.getParentOfType(element, PsiIdentifier.class, false);
+      if (psiIdentifier != null && psiIdentifier.getParent() instanceof PsiModifierListOwner) {
+        listOwner = (PsiModifierListOwner)psiIdentifier.getParent();
+      }
+    }
+    return listOwner;
+  }
+
+  @Override
+  @NotNull
+  public String getText() {
+    return myText;
+  }
+
+  @Override
+  @NotNull
+  public String getFamilyName() {
+    return CodeInsightBundle.message("intention.add.annotation.family");
+  }
+
+  @Override
+  public boolean isAvailable(@NotNull Project project,
+                             @NotNull PsiFile file,
+                             @NotNull PsiElement startElement,
+                             @NotNull PsiElement endElement) {
+    if (!startElement.isValid()) return false;
+    if (!PsiUtil.isLanguageLevel5OrHigher(startElement)) return false;
+    final PsiModifierListOwner myModifierListOwner = (PsiModifierListOwner)startElement;
+
+    return !AnnotationUtil.isAnnotated(myModifierListOwner, myAnnotation, false, false);
+  }
+
+  @Override
+  public void invoke(@NotNull Project project,
+                     @NotNull PsiFile file,
+                     @NotNull PsiElement startElement,
+                     @NotNull PsiElement endElement) {
+    final PsiModifierListOwner myModifierListOwner = (PsiModifierListOwner)startElement;
+
+    final ExternalAnnotationsManager annotationsManager = ExternalAnnotationsManager.getInstance(project);
+    final PsiModifierList modifierList = myModifierListOwner.getModifierList();
+    LOG.assertTrue(modifierList != null);
+    if (modifierList.findAnnotation(myAnnotation) != null) return;
+    final ExternalAnnotationsManager.AnnotationPlace annotationAnnotationPlace = annotationsManager.chooseAnnotationsPlace(myModifierListOwner);
+    if (annotationAnnotationPlace == ExternalAnnotationsManager.AnnotationPlace.NOWHERE) return;
+    if (annotationAnnotationPlace == ExternalAnnotationsManager.AnnotationPlace.EXTERNAL) {
+      for (String fqn : myAnnotationsToRemove) {
+        annotationsManager.deannotate(myModifierListOwner, fqn);
+      }
+      annotationsManager.annotateExternally(myModifierListOwner, myAnnotation, file, myPairs);
+    }
+    else {
+      final PsiFile containingFile = myModifierListOwner.getContainingFile();
+      if (!FileModificationService.getInstance().preparePsiElementForWrite(containingFile)) return;
+      for (String fqn : myAnnotationsToRemove) {
+        PsiAnnotation annotation = AnnotationUtil.findAnnotation(myModifierListOwner, fqn);
+        if (annotation != null) {
+          annotation.delete();
+        }
+      }
+
+      PsiAnnotation inserted = modifierList.addAnnotation(myAnnotation);
+      for (PsiNameValuePair pair : myPairs) {
+        inserted.setDeclaredAttributeValue(pair.getName(), pair.getValue());
+      }
+      JavaCodeStyleManager.getInstance(project).shortenClassReferences(inserted);
+      if (containingFile != file) {
+        UndoUtil.markPsiFileForUndo(file);
+      }
+    }
+  }
+
+  @NotNull
+  public String[] getAnnotationsToRemove() {
+    return myAnnotationsToRemove;
+  }
+}
diff --git a/java/java-psi-impl/src/com/intellij/externalSystem/JavaProjectDataService.java b/java/java-psi-impl/src/com/intellij/externalSystem/JavaProjectDataService.java
index cc9ff3b..626763a 100644
--- a/java/java-psi-impl/src/com/intellij/externalSystem/JavaProjectDataService.java
+++ b/java/java-psi-impl/src/com/intellij/externalSystem/JavaProjectDataService.java
@@ -38,7 +38,7 @@
  * @author Denis Zhdanov
  * @since 4/15/13 12:09 PM
  */
-public class JavaProjectDataService implements ProjectDataService<JavaProjectData> {
+public class JavaProjectDataService implements ProjectDataService<JavaProjectData, Project> {
 
   @NotNull
   @Override
@@ -95,9 +95,9 @@
     }
     return candidate;
   }
-  
+
   @Override
-  public void removeData(@NotNull Collection<DataNode<JavaProjectData>> toRemove, @NotNull Project project, boolean synchronous) {
+  public void removeData(@NotNull Collection<? extends Project> toRemove, @NotNull Project project, boolean synchronous) {
   }
 
   @SuppressWarnings("MethodMayBeStatic")
diff --git a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/JavaResolveUtil.java b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/JavaResolveUtil.java
index b60524d..9fc420f 100644
--- a/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/JavaResolveUtil.java
+++ b/java/java-psi-impl/src/com/intellij/psi/impl/source/resolve/JavaResolveUtil.java
@@ -183,7 +183,7 @@
     PsiClass lastClass = null;
     Boolean isAtLeast17 = null;
     for (PsiElement placeParent = place; placeParent != null; placeParent = placeParent.getContext()) {
-      if (placeParent instanceof PsiClass && !(placeParent instanceof PsiAnonymousClass)) {
+      if (placeParent instanceof PsiClass) {
         final boolean isTypeParameter = placeParent instanceof PsiTypeParameter;
         if (isTypeParameter && isAtLeast17 == null) {
           isAtLeast17 = JavaVersionService.getInstance().isAtLeast(place, JavaSdkVersion.JDK_1_7);
diff --git a/java/java-psi-impl/src/com/intellij/refactoring/util/RefactoringChangeUtil.java b/java/java-psi-impl/src/com/intellij/refactoring/util/RefactoringChangeUtil.java
new file mode 100644
index 0000000..b23e347
--- /dev/null
+++ b/java/java-psi-impl/src/com/intellij/refactoring/util/RefactoringChangeUtil.java
@@ -0,0 +1,124 @@
+/*
+ * Copyright 2000-2013 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.refactoring.util;
+
+import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.psi.*;
+import com.intellij.psi.codeStyle.CodeStyleManager;
+import com.intellij.psi.util.InheritanceUtil;
+import com.intellij.psi.util.PsiTreeUtil;
+import com.intellij.util.IncorrectOperationException;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+public class RefactoringChangeUtil {
+  private static final Logger LOG = Logger.getInstance("#com.intellij.refactoring.util.ChangeUtil");
+
+  @Nullable
+  private static String getMethodExpressionName(@Nullable PsiElement element) {
+    if (!(element instanceof PsiMethodCallExpression)) return null;
+    PsiReferenceExpression methodExpression = ((PsiMethodCallExpression)element).getMethodExpression();
+    return methodExpression.getReferenceName();
+  }
+
+  public static boolean isSuperOrThisMethodCall(@Nullable PsiElement element) {
+    String name = getMethodExpressionName(element);
+    return PsiKeyword.SUPER.equals(name) || PsiKeyword.THIS.equals(name);
+  }
+
+  public static boolean isSuperMethodCall(@Nullable PsiElement element) {
+    String name = getMethodExpressionName(element);
+    return PsiKeyword.SUPER.equals(name);
+  }
+
+  public static PsiReferenceExpression qualifyReference(@NotNull PsiReferenceExpression referenceExpression,
+                                                        @NotNull PsiMember member,
+                                                        @Nullable final PsiClass qualifyingClass) throws IncorrectOperationException {
+    PsiManager manager = referenceExpression.getManager();
+    PsiMethodCallExpression methodCallExpression = PsiTreeUtil.getParentOfType(referenceExpression, PsiMethodCallExpression.class, true);
+    while (methodCallExpression != null) {
+      if (isSuperOrThisMethodCall(methodCallExpression)) {
+        return referenceExpression;
+      }
+      methodCallExpression = PsiTreeUtil.getParentOfType(methodCallExpression, PsiMethodCallExpression.class, true);
+    }
+    PsiReferenceExpression expressionFromText;
+    final PsiElementFactory factory = JavaPsiFacade.getInstance(manager.getProject()).getElementFactory();
+    if (qualifyingClass == null) {
+      PsiClass parentClass = PsiTreeUtil.getParentOfType(referenceExpression, PsiClass.class);
+      final PsiClass containingClass = member.getContainingClass();
+      if (parentClass != null && !InheritanceUtil.isInheritorOrSelf(parentClass, containingClass, true)) {
+        while (parentClass != null && !InheritanceUtil.isInheritorOrSelf(parentClass, containingClass, true)) {
+          parentClass = PsiTreeUtil.getParentOfType(parentClass, PsiClass.class, true);
+        }
+        LOG.assertTrue(parentClass != null);
+        expressionFromText = (PsiReferenceExpression)factory.createExpressionFromText("A.this." + member.getName(), null);
+        ((PsiThisExpression)expressionFromText.getQualifierExpression()).getQualifier().replace(factory.createClassReferenceElement(parentClass));
+      }
+      else {
+        expressionFromText = (PsiReferenceExpression)factory.createExpressionFromText("this." + member.getName(), null);
+      }
+    }
+    else {
+      expressionFromText = (PsiReferenceExpression)factory.createExpressionFromText("A." + member.getName(), null);
+      expressionFromText.setQualifierExpression(factory.createReferenceExpression(qualifyingClass));
+    }
+    CodeStyleManager codeStyleManager = CodeStyleManager.getInstance(manager.getProject());
+    expressionFromText = (PsiReferenceExpression)codeStyleManager.reformat(expressionFromText);
+    return (PsiReferenceExpression)referenceExpression.replace(expressionFromText);
+  }
+
+  public static PsiClass getThisClass(@NotNull PsiElement place) {
+    PsiElement parent = place.getContext();
+    if (parent == null) return null;
+    PsiElement prev = null;
+    while (true) {
+      if (parent instanceof PsiClass) {
+        if (!(parent instanceof PsiAnonymousClass && ((PsiAnonymousClass)parent).getArgumentList() == prev)) {
+          return (PsiClass)parent;
+        }
+      }
+      prev = parent;
+      parent = parent.getContext();
+      if (parent == null) return null;
+    }
+  }
+
+  static <T extends PsiQualifiedExpression> T createQualifiedExpression(@NotNull PsiManager manager,
+                                                                        PsiClass qualifierClass,
+                                                                        @NotNull String qName) throws IncorrectOperationException {
+     PsiElementFactory factory = JavaPsiFacade.getInstance(manager.getProject()).getElementFactory();
+     if (qualifierClass != null) {
+       T qualifiedThis = (T)factory.createExpressionFromText("q." + qName, null);
+       qualifiedThis = (T)CodeStyleManager.getInstance(manager.getProject()).reformat(qualifiedThis);
+       PsiJavaCodeReferenceElement thisQualifier = qualifiedThis.getQualifier();
+       LOG.assertTrue(thisQualifier != null);
+       thisQualifier.bindToElement(qualifierClass);
+       return qualifiedThis;
+     }
+     else {
+       return (T)factory.createExpressionFromText(qName, null);
+     }
+   }
+
+  public static PsiThisExpression createThisExpression(PsiManager manager, PsiClass qualifierClass) throws IncorrectOperationException {
+    return RefactoringChangeUtil.<PsiThisExpression>createQualifiedExpression(manager, qualifierClass, "this");
+  }
+
+  public static PsiSuperExpression createSuperExpression(PsiManager manager, PsiClass qualifierClass) throws IncorrectOperationException {
+    return RefactoringChangeUtil.<PsiSuperExpression>createQualifiedExpression(manager, qualifierClass, "super");
+  }
+}
diff --git a/java/java-tests/testData/codeInsight/completeStatement/FieldBeforeAnnotation.java b/java/java-tests/testData/codeInsight/completeStatement/FieldBeforeAnnotation.java
index 60897ad..c09cfc1 100644
--- a/java/java-tests/testData/codeInsight/completeStatement/FieldBeforeAnnotation.java
+++ b/java/java-tests/testData/codeInsight/completeStatement/FieldBeforeAnnotation.java
@@ -1,5 +1,6 @@
 public class Test {
-    private String s
+
+    private String s<caret>
 
     @Deprecated private String foo;
 }
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/completeStatement/FieldBeforeAnnotation_after.java b/java/java-tests/testData/codeInsight/completeStatement/FieldBeforeAnnotation_after.java
index 904bae9..47664ef 100644
--- a/java/java-tests/testData/codeInsight/completeStatement/FieldBeforeAnnotation_after.java
+++ b/java/java-tests/testData/codeInsight/completeStatement/FieldBeforeAnnotation_after.java
@@ -1,4 +1,5 @@
 public class Test {
+
     private String s;<caret>
 
     @Deprecated private String foo;
diff --git a/java/java-tests/testData/codeInsight/completeStatement/MethodBeforeAnnotation.java b/java/java-tests/testData/codeInsight/completeStatement/MethodBeforeAnnotation.java
index af7100e..0cec1a5 100644
--- a/java/java-tests/testData/codeInsight/completeStatement/MethodBeforeAnnotation.java
+++ b/java/java-tests/testData/codeInsight/completeStatement/MethodBeforeAnnotation.java
@@ -1,5 +1,6 @@
 public class Test {
-    private String s()
+
+    private String s()<caret>
 
     @Deprecated private String foo;
 }
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/completeStatement/MethodBeforeAnnotation_after.java b/java/java-tests/testData/codeInsight/completeStatement/MethodBeforeAnnotation_after.java
index 6abd1bb..5a5583f 100644
--- a/java/java-tests/testData/codeInsight/completeStatement/MethodBeforeAnnotation_after.java
+++ b/java/java-tests/testData/codeInsight/completeStatement/MethodBeforeAnnotation_after.java
@@ -1,4 +1,5 @@
 public class Test {
+
     private String s() {
         <caret>
     }
diff --git a/java/java-tests/testData/codeInsight/completion/normal/ClassNameAnonymous_after.java b/java/java-tests/testData/codeInsight/completion/normal/ClassNameAnonymous_after.java
index 3b36448..4fcd91f 100644
--- a/java/java-tests/testData/codeInsight/completion/normal/ClassNameAnonymous_after.java
+++ b/java/java-tests/testData/codeInsight/completion/normal/ClassNameAnonymous_after.java
@@ -3,6 +3,7 @@
     Zzoo l = new Zzoo() {
         @Override
         public void run() {
+            <caret>
         }
     }
   }
diff --git a/java/java-tests/testData/codeInsight/completion/normal/ClassNameWithInner_after.java b/java/java-tests/testData/codeInsight/completion/normal/ClassNameWithInner_after.java
index 4f77648..aa1a866 100644
--- a/java/java-tests/testData/codeInsight/completion/normal/ClassNameWithInner_after.java
+++ b/java/java-tests/testData/codeInsight/completion/normal/ClassNameWithInner_after.java
@@ -3,6 +3,7 @@
     Zzoo l = new Zzoo() {
         @Override
         public void run() {
+            <caret>
         }
     }
   }
diff --git a/java/java-tests/testData/codeInsight/completion/normal/ImplementViaCompletion_after.java b/java/java-tests/testData/codeInsight/completion/normal/ImplementViaCompletion_after.java
index c8e336a..82ba62f 100644
--- a/java/java-tests/testData/codeInsight/completion/normal/ImplementViaCompletion_after.java
+++ b/java/java-tests/testData/codeInsight/completion/normal/ImplementViaCompletion_after.java
@@ -5,5 +5,6 @@
 public class A implements Foo<String> {
     @Override
     public void run(String s, int myInt) {
+        <caret>
     }
 }
diff --git a/java/java-tests/testData/codeInsight/completion/smartType/AnonymousNoPairBracket-out.java b/java/java-tests/testData/codeInsight/completion/smartType/AnonymousNoPairBracket-out.java
index 7271ebe..22dd5a3 100644
--- a/java/java-tests/testData/codeInsight/completion/smartType/AnonymousNoPairBracket-out.java
+++ b/java/java-tests/testData/codeInsight/completion/smartType/AnonymousNoPairBracket-out.java
@@ -3,6 +3,7 @@
         new Thread(new Runnable() {
             @Override
             public void run() {
+                <caret>
             }
         })
     }
diff --git a/java/java-tests/testData/codeInsight/completion/smartType/InsertOverride-out.java b/java/java-tests/testData/codeInsight/completion/smartType/InsertOverride-out.java
index d8946b1..72d4839 100644
--- a/java/java-tests/testData/codeInsight/completion/smartType/InsertOverride-out.java
+++ b/java/java-tests/testData/codeInsight/completion/smartType/InsertOverride-out.java
@@ -3,6 +3,7 @@
         Runnable r = new Runnable() {
             @Override
             public void run() {
+                <caret>
             }
         };
     }
diff --git a/java/java-tests/testData/codeInsight/completion/smartType/NewAbstractClassWithConstructorArgs-out.java b/java/java-tests/testData/codeInsight/completion/smartType/NewAbstractClassWithConstructorArgs-out.java
index 4f5e397..d59022f 100644
--- a/java/java-tests/testData/codeInsight/completion/smartType/NewAbstractClassWithConstructorArgs-out.java
+++ b/java/java-tests/testData/codeInsight/completion/smartType/NewAbstractClassWithConstructorArgs-out.java
@@ -4,6 +4,7 @@
     Bar b = new Bar() {
         @Override
         void update() {
+            <caret>
         }
     };
   }
diff --git a/java/java-tests/testData/codeInsight/completion/smartType/NewAbstractInsideAnonymous-out.java b/java/java-tests/testData/codeInsight/completion/smartType/NewAbstractInsideAnonymous-out.java
index f9d6519..207a0f1 100644
--- a/java/java-tests/testData/codeInsight/completion/smartType/NewAbstractInsideAnonymous-out.java
+++ b/java/java-tests/testData/codeInsight/completion/smartType/NewAbstractInsideAnonymous-out.java
@@ -6,6 +6,7 @@
         Goo<String> g = new Goo<String>() {
             @Override
             void foo() {
+                <caret>
             }
         };
       }
diff --git a/java/java-tests/testData/codeInsight/createSubclass/innerClassImplement/after/Test.java b/java/java-tests/testData/codeInsight/createSubclass/innerClassImplement/after/Test.java
index 4e97010..3802498 100644
--- a/java/java-tests/testData/codeInsight/createSubclass/innerClassImplement/after/Test.java
+++ b/java/java-tests/testData/codeInsight/createSubclass/innerClassImplement/after/Test.java
@@ -11,6 +11,7 @@
 
         @Override
         void bar() {
+
         }
     }
 }
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/IDEA78916.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/IDEA78916.java
new file mode 100644
index 0000000..214a3ae
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/advHighlighting7/IDEA78916.java
@@ -0,0 +1,38 @@
+enum EnumPrivateMethodTest {
+    FIRST {
+        @Override
+        public void execute() {
+            this.<error descr="'firstMethod()' has private access in 'EnumPrivateMethodTest'">firstMethod</error>();
+        }
+    };
+
+    public abstract void execute();
+
+    private void firstMethod() {}
+}
+
+abstract class EnumPrivateMethodTest1 {
+    EnumPrivateMethodTest1 FIRST = new EnumPrivateMethodTest1() {
+        @Override
+        public void execute() {
+            this.<error descr="'firstMethod()' has private access in 'EnumPrivateMethodTest1'">firstMethod</error>();
+        }
+    };
+
+    public abstract void execute();
+
+    private void firstMethod() {}
+}
+
+abstract class EnumPrivateMethodTest2 {
+    EnumPrivateMethodTest2 FIRST = new EnumPrivateMethodTest2() {
+        @Override
+        public void execute() {
+            firstMethod();
+        }
+    };
+
+    public abstract void execute();
+
+    private void firstMethod() {}
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA57259.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA57259.java
new file mode 100644
index 0000000..fbf2bd1
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IDEA57259.java
@@ -0,0 +1,8 @@
+class A<T extends A.B> {
+    class B extends A<B> {}
+}
+
+class C<T> {
+    class D extends C<T> {}
+    <T extends C<String>.D> void foo(){}
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IllegalForwardReferenceInTypeParameterDefinition.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IllegalForwardReferenceInTypeParameterDefinition.java
new file mode 100644
index 0000000..cbc96ad
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/IllegalForwardReferenceInTypeParameterDefinition.java
@@ -0,0 +1,2 @@
+class A<T extends <error descr="Illegal forward reference">S</error>, S> {
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/InheritedWithDifferentArgsInTypeParams.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/InheritedWithDifferentArgsInTypeParams.java
new file mode 100644
index 0000000..2adff2f
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/InheritedWithDifferentArgsInTypeParams.java
@@ -0,0 +1,24 @@
+interface IA<T> {}
+interface IB<T> extends IA<T> {}
+
+class A {
+    <<error descr="'IA' cannot be inherited with different type arguments: 'java.lang.Integer' and 'java.lang.String'"></error>T extends IA<Integer> & IB<String>> void foo(){}
+}
+
+
+
+interface IA1<T> {}
+interface IB1<T> extends IA1<T> {}
+
+class A1 {
+    <<error descr="'IA1' cannot be inherited with different type arguments: 'java.lang.Object' and 'capture<?>'"></error>T extends IA1<Object> & IB1<?>> void foo(){}
+}
+
+interface IA2<T> {}
+interface IB2<T> extends IA2<T[]> {}
+
+class A2 {
+    <T extends IA2<Object[]> & IB2<?>> void foo(){}
+}
+
+
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/TypeArgumentsOnRawType.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/TypeArgumentsOnRawType.java
new file mode 100644
index 0000000..bbb565f
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/TypeArgumentsOnRawType.java
@@ -0,0 +1,43 @@
+interface I{
+    <T extends Iterable<String>> void foo();
+}
+
+abstract class A<S> implements I {
+    public abstract <T extends Iterable<String>> void foo();
+    <T extends A> void bar(T x){
+        A a = null;
+        a.<Iterable<String>> foo();
+        x.<Iterable<String>> foo();
+    }
+}
+
+abstract class B<S> {
+    public abstract <T extends Iterable<String>> void foo();
+    <T extends B> void bar(T x){
+        B a = null;
+        a.<error descr="Type arguments given on a raw method"><Iterable<String>></error> foo();
+        x.<error descr="Type arguments given on a raw method"><Iterable<String>></error> foo();
+    }
+}
+
+abstract class C<S> {
+    public abstract <T extends Iterable<String>> void foo();
+    <T extends C & I> void bar(T x){
+        x.<Iterable<String>> foo();
+    }
+}
+
+//---------------------------------------------------------------
+interface I1 {
+    void foo();
+}
+
+
+abstract class B1<S> {
+    public abstract <T extends Iterable<String>> void foo();
+    <T extends B1 & I1> void bar(T x){
+        B1 a = null;
+        a.<error descr="Type arguments given on a raw method"><Iterable<String>></error> foo();
+        x.<error descr="Type arguments given on a raw method"><Iterable<String>></error> foo();
+    }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/TypeArgumentsOnRawType17.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/TypeArgumentsOnRawType17.java
new file mode 100644
index 0000000..f586b18
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/genericsHighlighting/TypeArgumentsOnRawType17.java
@@ -0,0 +1,43 @@
+interface I{
+    <T extends Iterable<String>> void foo();
+}
+
+abstract class A<S> implements I {
+    public abstract <T extends Iterable<String>> void foo();
+    <T extends A> void bar(T x){
+        A a = null;
+        a.<Iterable<String>> foo();
+        x.<Iterable<String>> foo();
+    }
+}
+
+abstract class B<S> {
+    public abstract <T extends Iterable<String>> void foo();
+    <T extends B> void bar(T x){
+        B a = null;
+        a.<error descr="Type arguments given on a raw method"><Iterable<String>></error> foo();
+        x.<Iterable<String>> foo();
+    }
+}
+
+abstract class C<S> {
+    public abstract <T extends Iterable<String>> void foo();
+    <T extends C & I> void bar(T x){
+        x.<Iterable<String>> foo();
+    }
+}
+
+//---------------------------------------------------------------
+interface I1 {
+    void foo();
+}
+
+
+abstract class B1<S> {
+    public abstract <T extends Iterable<String>> void foo();
+    <T extends B1 & I1> void bar(T x){
+        B1 a = null;
+        a.<error descr="Type arguments given on a raw method"><Iterable<String>></error> foo();
+        x.<Iterable<String>> foo();
+    }
+}
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/changeParameterClass/after1.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/changeParameterClass/after1.java
index 9caf9c8..4b05309 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/changeParameterClass/after1.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/changeParameterClass/after1.java
@@ -5,6 +5,7 @@
     }
 
     public void run() {
+        <caret>
     }
 }
 
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/changeParameterClass/after6.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/changeParameterClass/after6.java
index a0f5015..06604cb 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/changeParameterClass/after6.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/changeParameterClass/after6.java
@@ -5,6 +5,7 @@
     }
 
     public void g(b<String> t) {
+        <caret>
     }
 }
 interface b<T> {
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/overrideMethod/afterAbstractMethod.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/overrideMethod/afterAbstractMethod.java
index 2b5d7f2..df358cd 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/overrideMethod/afterAbstractMethod.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/overrideMethod/afterAbstractMethod.java
@@ -6,5 +6,6 @@
 class TImple extends Test {
     @Override
     void foo() {
+        <caret>
     }
 }
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/overrideMethod/afterSkipUnresolvedNullable.java b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/overrideMethod/afterSkipUnresolvedNullable.java
index 94c8226..2d99857 100644
--- a/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/overrideMethod/afterSkipUnresolvedNullable.java
+++ b/java/java-tests/testData/codeInsight/daemonCodeAnalyzer/quickFix/overrideMethod/afterSkipUnresolvedNullable.java
@@ -8,5 +8,6 @@
 class TImple extends Test {
     @Override
     public void foo(@Nullable String a) {
+        <caret>
     }
 }
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/invertIfCondition/afterContinue3.java b/java/java-tests/testData/codeInsight/invertIfCondition/afterContinue3.java
new file mode 100644
index 0000000..be835ee
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/invertIfCondition/afterContinue3.java
@@ -0,0 +1,20 @@
+// "Invert If Condition" "true"
+class B {
+    public static void foo() {
+        for (int i = 0; i < 10; i++) {
+            if (i % 2 == 0) {
+                if (i != 0) {
+
+                    System.out.println("!= 0");
+                    continue;
+                }
+                else {
+                    System.out.println("== 0");
+                    continue;
+                }
+            }
+
+            System.out.println("i = " + i);
+        }
+    }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/invertIfCondition/afterContinue4.java b/java/java-tests/testData/codeInsight/invertIfCondition/afterContinue4.java
new file mode 100644
index 0000000..461672c
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/invertIfCondition/afterContinue4.java
@@ -0,0 +1,16 @@
+// "Invert If Condition" "true"
+class B {
+    public static void foo() {
+        for (int i = 0; i < 10; i++) {
+            if (i % 2 == 0) {
+                if (i != 0) {
+
+                    System.out.println("!= 0");
+                }
+                else {
+                    System.out.println("== 0");
+                }
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/invertIfCondition/beforeContinue3.java b/java/java-tests/testData/codeInsight/invertIfCondition/beforeContinue3.java
new file mode 100644
index 0000000..339b3de
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/invertIfCondition/beforeContinue3.java
@@ -0,0 +1,18 @@
+// "Invert If Condition" "true"
+class B {
+    public static void foo() {
+        for (int i = 0; i < 10; i++) {
+            if (i % 2 == 0) {
+                <caret>if (i == 0) {
+                    System.out.println("== 0");
+                    continue;
+                }
+
+                System.out.println("!= 0");
+                continue;
+            }
+
+            System.out.println("i = " + i);
+        }
+    }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/invertIfCondition/beforeContinue4.java b/java/java-tests/testData/codeInsight/invertIfCondition/beforeContinue4.java
new file mode 100644
index 0000000..d2c904a
--- /dev/null
+++ b/java/java-tests/testData/codeInsight/invertIfCondition/beforeContinue4.java
@@ -0,0 +1,15 @@
+// "Invert If Condition" "true"
+class B {
+    public static void foo() {
+        for (int i = 0; i < 10; i++) {
+            if (i % 2 == 0) {
+                <caret>if (i == 0) {
+                    System.out.println("== 0");
+                    continue;
+                }
+
+                System.out.println("!= 0");
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/overrideImplement/afterDoNotImplementExtensionMethods.java b/java/java-tests/testData/codeInsight/overrideImplement/afterDoNotImplementExtensionMethods.java
index d4c43d9..58c96a0 100644
--- a/java/java-tests/testData/codeInsight/overrideImplement/afterDoNotImplementExtensionMethods.java
+++ b/java/java-tests/testData/codeInsight/overrideImplement/afterDoNotImplementExtensionMethods.java
@@ -10,5 +10,6 @@
 class MyClass<T> implements B<T> {
     @Override
     public void m2() {
+        <caret>
     }
 }
diff --git a/java/java-tests/testData/codeInsight/overrideImplement/afterEnumConstant.java b/java/java-tests/testData/codeInsight/overrideImplement/afterEnumConstant.java
index 8efbedc..e01e890 100644
--- a/java/java-tests/testData/codeInsight/overrideImplement/afterEnumConstant.java
+++ b/java/java-tests/testData/codeInsight/overrideImplement/afterEnumConstant.java
@@ -17,6 +17,7 @@
   E1 {
       @Override
       public void foo() {
+          <caret>
       }
   };
   public abstract void foo();
diff --git a/java/java-tests/testData/codeInsight/overrideImplement/afterImplementExtensionMethods.java b/java/java-tests/testData/codeInsight/overrideImplement/afterImplementExtensionMethods.java
index 0d3c412..93b1bc2 100644
--- a/java/java-tests/testData/codeInsight/overrideImplement/afterImplementExtensionMethods.java
+++ b/java/java-tests/testData/codeInsight/overrideImplement/afterImplementExtensionMethods.java
@@ -5,5 +5,6 @@
 class MyClass<T> implements A<T> {
     @Override
     public void m(T t) {
+        <caret>
     }
 }
diff --git a/java/java-tests/testData/codeInsight/overrideImplement/afterIncomplete.java b/java/java-tests/testData/codeInsight/overrideImplement/afterIncomplete.java
index d80beee..6b2edbc 100644
--- a/java/java-tests/testData/codeInsight/overrideImplement/afterIncomplete.java
+++ b/java/java-tests/testData/codeInsight/overrideImplement/afterIncomplete.java
@@ -1,4 +1,5 @@
 class S implements Runnable {
     public void run() {
+        <caret>
     }
 }
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/overrideImplement/afterLongFinalParameterList.java b/java/java-tests/testData/codeInsight/overrideImplement/afterLongFinalParameterList.java
index 512e937..df1d664 100644
--- a/java/java-tests/testData/codeInsight/overrideImplement/afterLongFinalParameterList.java
+++ b/java/java-tests/testData/codeInsight/overrideImplement/afterLongFinalParameterList.java
@@ -11,5 +11,6 @@
                     final String pppppppppppp6,
                     final String pppppppppppp7,
                     final String pppppppppppp8) {
+        <caret>
     }
 }
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/overrideImplement/afterLongParameterList.java b/java/java-tests/testData/codeInsight/overrideImplement/afterLongParameterList.java
index 43775c7..3c68f49 100644
--- a/java/java-tests/testData/codeInsight/overrideImplement/afterLongParameterList.java
+++ b/java/java-tests/testData/codeInsight/overrideImplement/afterLongParameterList.java
@@ -10,5 +10,6 @@
                     String p5,
                     String p6,
                     String p7) {
+        <caret>
     }
 }
\ No newline at end of file
diff --git a/java/java-tests/testData/codeInsight/overrideImplement/afterOverrideExtensionMethods.java b/java/java-tests/testData/codeInsight/overrideImplement/afterOverrideExtensionMethods.java
index aaf31a5..43c9a16 100644
--- a/java/java-tests/testData/codeInsight/overrideImplement/afterOverrideExtensionMethods.java
+++ b/java/java-tests/testData/codeInsight/overrideImplement/afterOverrideExtensionMethods.java
@@ -5,6 +5,7 @@
 class MyClass<T> implements A<T> {
     @Override
     public void m(T t) {
+        <caret>
     }
 
     public MyClass() {
diff --git a/java/java-tests/testData/codeInsight/overrideImplement/afterRawSuper.java b/java/java-tests/testData/codeInsight/overrideImplement/afterRawSuper.java
index fb2c61e..d850e4a 100644
--- a/java/java-tests/testData/codeInsight/overrideImplement/afterRawSuper.java
+++ b/java/java-tests/testData/codeInsight/overrideImplement/afterRawSuper.java
@@ -20,5 +20,6 @@
     class B implements A
     {
         public void foo() {
+            <caret>
         }
     }
diff --git a/java/java-tests/testData/codeInsight/overrideImplement/afterResolveTypeParamConflict.java b/java/java-tests/testData/codeInsight/overrideImplement/afterResolveTypeParamConflict.java
index ead6e41..6dae27e 100644
--- a/java/java-tests/testData/codeInsight/overrideImplement/afterResolveTypeParamConflict.java
+++ b/java/java-tests/testData/codeInsight/overrideImplement/afterResolveTypeParamConflict.java
@@ -5,5 +5,6 @@
 class B1<T> extends A1<T>{
     @Override
     <T1> void foo(T1 t1, T t) {
+        <caret>
     }
 }
diff --git a/java/java-tests/testData/codeInsight/overrideImplement/afterSubstituteBoundInMethodTypeParam.java b/java/java-tests/testData/codeInsight/overrideImplement/afterSubstituteBoundInMethodTypeParam.java
index fa1102c..4460d52 100644
--- a/java/java-tests/testData/codeInsight/overrideImplement/afterSubstituteBoundInMethodTypeParam.java
+++ b/java/java-tests/testData/codeInsight/overrideImplement/afterSubstituteBoundInMethodTypeParam.java
@@ -21,5 +21,6 @@
 
         @Override
         <S extends Throwable> void foo(S s) {
+            <caret>
         }
     }
diff --git a/java/java-tests/testData/codeInsight/overrideImplement/afterSubstitutionInTypeParametersList.java b/java/java-tests/testData/codeInsight/overrideImplement/afterSubstitutionInTypeParametersList.java
index ae7841a..71f4145 100644
--- a/java/java-tests/testData/codeInsight/overrideImplement/afterSubstitutionInTypeParametersList.java
+++ b/java/java-tests/testData/codeInsight/overrideImplement/afterSubstitutionInTypeParametersList.java
@@ -5,5 +5,6 @@
 class XXC<S> extends IX<Throwable> {
     @Override
     <S extends Throwable> void foo() {
+        <caret>
     }
 }
diff --git a/java/java-tests/testData/codeInsight/overrideImplement/afterTypeParam.java b/java/java-tests/testData/codeInsight/overrideImplement/afterTypeParam.java
index ff91250..007c4e4 100644
--- a/java/java-tests/testData/codeInsight/overrideImplement/afterTypeParam.java
+++ b/java/java-tests/testData/codeInsight/overrideImplement/afterTypeParam.java
@@ -4,5 +4,6 @@
 
 class Bar extends Function<String>{
     public void fun(Function<String> function) {
+        <caret>
     }
 }
\ No newline at end of file
diff --git a/java/java-tests/testData/inspection/defaultFileTemplateUsage/defaultFile/expected.xml b/java/java-tests/testData/inspection/defaultFileTemplateUsage/defaultFile/expected.xml
index 8a0d3d3..46addf6 100644
--- a/java/java-tests/testData/inspection/defaultFileTemplateUsage/defaultFile/expected.xml
+++ b/java/java-tests/testData/inspection/defaultFileTemplateUsage/defaultFile/expected.xml
@@ -14,105 +14,4 @@
     <problem_class>Default File Template Usage</problem_class>
     <description>Default File template</description>
   </problem>
-
-  <problem>
-  <file>X.java</file>
-  <line>17</line>
-  <package>x</package>
-  <class>
-    <name>X</name>
-    <display_name>X</display_name>
-  </class>
-  <problem_class>Default File Template Usage</problem_class>
-  <description>Default File template</description>
-</problem>
-
-<problem>
-  <file>X.java</file>
-  <line>22</line>
-  <package>x</package>
-  <class>
-    <name>X</name>
-    <display_name>X</display_name>
-  </class>
-  <problem_class>Default File Template Usage</problem_class>
-  <description>Default File template</description>
-</problem>
-
-<problem>
-  <file>X.java</file>
-  <line>31</line>
-  <method>
-    <name>int hashCode()</name>
-    <display_name>hashCode()</display_name>
-    <package>x</package>
-    <class>
-      <name>X</name>
-      <display_name>X</display_name>
-    </class>
-  </method>
-  <problem_class>Default File Template Usage</problem_class>
-  <description>Default File template</description>
-</problem>
-
-<problem>
-  <file>X.java</file>
-  <line>27</line>
-  <method>
-    <name>void g()</name>
-    <display_name>g()</display_name>
-    <package>x</package>
-    <class>
-      <name>X</name>
-      <display_name>X</display_name>
-    </class>
-  </method>
-  <problem_class>Default File Template Usage</problem_class>
-  <description>Default File template</description>
-</problem>
-
-<problem>
-  <file>X.java</file>
-  <line>35</line>
-  <method>
-    <name>String toString()</name>
-    <display_name>toString()</display_name>
-    <package>x</package>
-    <class>
-      <name>X</name>
-      <display_name>X</display_name>
-    </class>
-  </method>
-  <problem_class>Default File Template Usage</problem_class>
-  <description>Default File template</description>
-</problem>
-
-<problem>
-  <file>X.java</file>
-  <line>39</line>
-  <method>
-    <name>void run()</name>
-    <display_name>run()</display_name>
-    <package>x</package>
-    <class>
-      <name>X</name>
-      <display_name>X</display_name>
-    </class>
-  </method>
-  <problem_class>Default File Template Usage</problem_class>
-  <description>Default File template</description>
-</problem>
-
-  <problem>
-    <file>X.java</file>
-    <line>63</line>
-    <package>x</package>
-    <class>
-      <name>X</name>
-      <display_name>X</display_name>
-    </class>
-    <problem_class>Default File Template Usage</problem_class>
-    <description>Default File template</description>
-  </problem>
-
 </problems>
\ No newline at end of file
diff --git a/java/java-tests/testData/inspection/defaultFileTemplateUsage/defaultFile/src/x/X.java b/java/java-tests/testData/inspection/defaultFileTemplateUsage/defaultFile/src/x/X.java
index bcd930a..c77b8f3 100644
--- a/java/java-tests/testData/inspection/defaultFileTemplateUsage/defaultFile/src/x/X.java
+++ b/java/java-tests/testData/inspection/defaultFileTemplateUsage/defaultFile/src/x/X.java
@@ -2,11 +2,7 @@
 import java.io.*;
 
 /**
- * Created with IntelliJ IDEA.
- * User: Alexey
- * Date: 02.12.2005
- * Time: 0:24:14
- * To change this template use File | Settings | File Templates.
+ * Created by Alexey on 02.12.2005.
  */
 public class X implements Runnable{
     File f; //kkj lkkl jjkuufdffffjkkjjh kjh kjhj kkjh kjh  i k kj kj klj lkj lkj lkjl kj klkl kl
@@ -14,12 +10,12 @@
         try {
             f=null;
         } catch (Exception e) {
-            e.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+            e.printStackTrace();
         }
         try {
             g();
         } catch (Exception ex) {
-            ex.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+            ex.printStackTrace();
         }
     }
 
@@ -28,11 +24,11 @@
     }
 
     public int hashCode() {
-        return super.hashCode();    //To change body of overridden methods use File | Settings | File Templates.
+        return super.hashCode();
     }
         
     public String toString() {
-     return super.toString();            //To change body of overridden methods use File | Settings | File Templates.
+     return super.toString();
     }
 
     public void run() {
@@ -60,7 +56,7 @@
         try {
             g();
         } catch (EOFException | FileNotFoundException ex) {
-            ex.printStackTrace();  //To change body of catch statement use File | Settings | File Templates.
+            ex.printStackTrace();
         }
     }
 }
diff --git a/java/java-tests/testData/inspection/defaultFileTemplateUsage/defaultFile/src/x/X2.java b/java/java-tests/testData/inspection/defaultFileTemplateUsage/defaultFile/src/x/X2.java
index 2c43737..89efeb8 100644
--- a/java/java-tests/testData/inspection/defaultFileTemplateUsage/defaultFile/src/x/X2.java
+++ b/java/java-tests/testData/inspection/defaultFileTemplateUsage/defaultFile/src/x/X2.java
@@ -2,11 +2,7 @@
 import java.io.*;
 
 /**
- * Created with IntelliJ IDEA.
- * User: Alexey
- * Date: 02.12.2005
- * Time: 0:24:14
- * To change this template use File | Settings | File Templates.
+ * Created by Alexey on 02.12.2005.
  */
 public class X2 {
 }
diff --git a/java/java-tests/testData/refactoring/inplaceIntroduceConstant/replaceAllFromLiteral.java b/java/java-tests/testData/refactoring/inplaceIntroduceConstant/replaceAllFromLiteral.java
new file mode 100644
index 0000000..1516ee3
--- /dev/null
+++ b/java/java-tests/testData/refactoring/inplaceIntroduceConstant/replaceAllFromLiteral.java
@@ -0,0 +1,6 @@
+class B {
+    public static void foo(boolean f) {
+        Object[] objs = new Object[0];
+        System.out.println(objs[<caret>9] != null ? Integer.valueOf(objs[9].toString()) : null);
+    }
+}
\ No newline at end of file
diff --git a/java/java-tests/testData/refactoring/inplaceIntroduceConstant/replaceAllFromLiteral_after.java b/java/java-tests/testData/refactoring/inplaceIntroduceConstant/replaceAllFromLiteral_after.java
new file mode 100644
index 0000000..0694e9b
--- /dev/null
+++ b/java/java-tests/testData/refactoring/inplaceIntroduceConstant/replaceAllFromLiteral_after.java
@@ -0,0 +1,9 @@
+class B {
+
+    public static final int NINE = 9;
+
+    public static void foo(boolean f) {
+        Object[] objs = new Object[0];
+        System.out.println(objs[NINE] != null ? Integer.valueOf(objs[NINE].toString()) : null);
+    }
+}
\ No newline at end of file
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/AddAnnotationFixTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/AddAnnotationFixTest.java
index 0af361a..a988c80 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/AddAnnotationFixTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/AddAnnotationFixTest.java
@@ -4,7 +4,7 @@
  */
 package com.intellij.codeInsight;
 
-import com.intellij.codeInsight.intention.AddAnnotationFix;
+import com.intellij.codeInsight.intention.AddAnnotationPsiFix;
 import com.intellij.codeInsight.intention.IntentionAction;
 import com.intellij.codeInsight.intention.impl.DeannotateIntentionAction;
 import com.intellij.openapi.application.ApplicationManager;
@@ -110,7 +110,7 @@
     int position = caretModel.getOffset();
     PsiElement element = myFixture.getFile().findElementAt(position);
     assert element != null;
-    PsiModifierListOwner container = AddAnnotationFix.getContainer(element);
+    PsiModifierListOwner container = AddAnnotationPsiFix.getContainer(element);
     assert container != null;
     return container;
   }
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/CompleteStatementTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/CompleteStatementTest.java
index 2e40ced..f1afadd 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/CompleteStatementTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/CompleteStatementTest.java
@@ -140,7 +140,7 @@
   public void testFieldWithInitializer() throws Exception { doTest(); }
 
   public void testFieldBeforeAnnotation() throws Exception { doTest(); }
-  public void _testMethodBeforeAnnotation() throws Exception { doTest(); }
+  public void testMethodBeforeAnnotation() throws Exception { doTest(); }
 
   public void testParenthesized() throws Exception { doTest(); }
 
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java
index afc3d15..ca4c17a 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/GenericsHighlightingTest.java
@@ -235,6 +235,9 @@
   public void testIDEA20573() throws Exception { doTest5(false);}
   public void testIDEA20244() throws Exception { doTest5(false);}
   public void testIDEA22005() throws Exception { doTest5(false);}
+  public void testIDEA57259() throws Exception { doTest5(false);}
+  public void testInheritedWithDifferentArgsInTypeParams() throws Exception { doTest5(false);}
+  public void testIllegalForwardReferenceInTypeParameterDefinition() throws Exception { doTest5(false);}
 
   public void testIDEA57877() throws Exception { doTest5(false);}
   public void testTypeParamsCyclicInference() throws Exception { doTest5(false);}
@@ -243,6 +246,8 @@
 
   public void testIDEA27185(){ doTest(LanguageLevel.JDK_1_6, JavaSdkVersion.JDK_1_6, false); }
   public void testIDEA67571(){ doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); }
+  public void testTypeArgumentsOnRawType(){ doTest(LanguageLevel.JDK_1_6, JavaSdkVersion.JDK_1_6, false); }
+  public void testTypeArgumentsOnRawType17(){ doTest(LanguageLevel.JDK_1_7, JavaSdkVersion.JDK_1_7, false); }
 
   public void testWildcardsOnRawTypes() { doTest5(false); }
   public void testDisableWithinBoundsCheckForSuperWildcards() {
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk7Test.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk7Test.java
index fb4fede..278de8c 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk7Test.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/LightAdvHighlightingJdk7Test.java
@@ -179,4 +179,5 @@
   public void testIDEA70890() { doTest(false, false); }
   public void testIDEA63731() { doTest(false, false); }
   public void testIDEA62056() { doTest(false, false); }
+  public void testIDEA78916() { doTest(false, false); }
 }
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Lambda2MethodReferenceInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Lambda2MethodReferenceInspectionTest.java
index af915d6..50de135 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Lambda2MethodReferenceInspectionTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/Lambda2MethodReferenceInspectionTest.java
@@ -15,7 +15,7 @@
  */
 package com.intellij.codeInsight.daemon.quickFix;
 
-import com.intellij.codeInspection.LambdaCanBeMethReferenceInspection;
+import com.intellij.codeInspection.LambdaCanBeMethodReferenceInspection;
 import com.intellij.codeInspection.LocalInspectionTool;
 import org.jetbrains.annotations.NotNull;
 
@@ -25,7 +25,7 @@
   @Override
   protected LocalInspectionTool[] configureLocalInspectionTools() {
     return new LocalInspectionTool[]{
-      new LambdaCanBeMethReferenceInspection(),
+      new LambdaCanBeMethodReferenceInspection(),
     };
   }
 
diff --git a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/SuppressLocalInspectionTest.java b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/SuppressLocalInspectionTest.java
index 4f3a1bb..a69ef8c 100644
--- a/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/SuppressLocalInspectionTest.java
+++ b/java/java-tests/testSrc/com/intellij/codeInsight/daemon/quickFix/SuppressLocalInspectionTest.java
@@ -7,9 +7,7 @@
 import com.intellij.pom.java.LanguageLevel;
 import org.jetbrains.annotations.NotNull;
 
-
 public class SuppressLocalInspectionTest extends LightQuickFixTestCase {
-
   @Override
   protected void setUp() throws Exception {
     super.setUp();
@@ -22,11 +20,6 @@
     return new LocalInspectionTool[]{new LocalCanBeFinal()};
   }
 
-  @Override
-  protected void tearDown() throws Exception {
-    super.tearDown();
-  }
-
   public void test() throws Exception { doAllTests(); }
 
   @Override
diff --git a/java/java-tests/testSrc/com/intellij/refactoring/InplaceIntroduceConstantTest.java b/java/java-tests/testSrc/com/intellij/refactoring/InplaceIntroduceConstantTest.java
index 958df7a..14a53f4 100644
--- a/java/java-tests/testSrc/com/intellij/refactoring/InplaceIntroduceConstantTest.java
+++ b/java/java-tests/testSrc/com/intellij/refactoring/InplaceIntroduceConstantTest.java
@@ -65,6 +65,17 @@
     });
   }
 
+  public void testReplaceAllFromLiteral() throws Exception {
+
+    doTest(new Pass<AbstractInplaceIntroducer>() {
+      @Override
+      public void pass(AbstractInplaceIntroducer inplaceIntroduceFieldPopup) {
+        type("NINE");
+        inplaceIntroduceFieldPopup.setReplaceAllOccurrences(true);
+      }
+    });
+  }
+
   public void testConflictingConstantName() throws Exception {
 
     doTest(new Pass<AbstractInplaceIntroducer>() {
diff --git a/java/openapi/openapi.iml b/java/openapi/openapi.iml
index 0f0db7c..e83bce3 100644
--- a/java/openapi/openapi.iml
+++ b/java/openapi/openapi.iml
@@ -26,6 +26,7 @@
     <orderEntry type="module" module-name="resources-en" exported="" />
     <orderEntry type="module" module-name="java-psi-api" exported="" />
     <orderEntry type="module" module-name="java-indexing-api" exported="" />
+    <orderEntry type="module" module-name="java-analysis-api" exported="" />
   </component>
   <component name="copyright">
     <option name="body" value="/*&#10; * Copyright (c) $today.year Your Corporation. All Rights Reserved.&#10; */" />
diff --git a/java/openapi/src/com/intellij/codeInspection/BaseJavaLocalInspectionTool.java b/java/openapi/src/com/intellij/codeInspection/BaseJavaLocalInspectionTool.java
index 898efb5..129dc58 100644
--- a/java/openapi/src/com/intellij/codeInspection/BaseJavaLocalInspectionTool.java
+++ b/java/openapi/src/com/intellij/codeInspection/BaseJavaLocalInspectionTool.java
@@ -16,10 +16,8 @@
 package com.intellij.codeInspection;
 
 import com.intellij.codeInsight.daemon.HighlightDisplayKey;
-import com.intellij.psi.*;
-import com.intellij.psi.util.PsiTreeUtil;
+import com.intellij.psi.PsiElement;
 import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
 
 /**
  * Implement this abstract class in order to provide new inspection tool functionality. The major API limitation here is
@@ -30,94 +28,7 @@
  *
  * @see GlobalInspectionTool
  */
-public abstract class BaseJavaLocalInspectionTool extends LocalInspectionTool  implements CustomSuppressableInspectionTool {
-  /**
-   * Override this to report problems at method level.
-   *
-   * @param method     to check.
-   * @param manager    InspectionManager to ask for ProblemDescriptors from.
-   * @param isOnTheFly true if called during on the fly editor highlighting. Called from Inspect Code action otherwise.
-   * @return <code>null</code> if no problems found or not applicable at method level.
-   */
-  @Nullable
-  public ProblemDescriptor[] checkMethod(@NotNull PsiMethod method, @NotNull InspectionManager manager, boolean isOnTheFly) {
-    return null;
-  }
-
-  /**
-   * Override this to report problems at class level.
-   *
-   * @param aClass     to check.
-   * @param manager    InspectionManager to ask for ProblemDescriptors from.
-   * @param isOnTheFly true if called during on the fly editor highlighting. Called from Inspect Code action otherwise.
-   * @return <code>null</code> if no problems found or not applicable at class level.
-   */
-  @Nullable
-  public ProblemDescriptor[] checkClass(@NotNull PsiClass aClass, @NotNull InspectionManager manager, boolean isOnTheFly) {
-    return null;
-  }
-
-  /**
-   * Override this to report problems at field level.
-   *
-   * @param field      to check.
-   * @param manager    InspectionManager to ask for ProblemDescriptors from.
-   * @param isOnTheFly true if called during on the fly editor highlighting. Called from Inspect Code action otherwise.
-   * @return <code>null</code> if no problems found or not applicable at field level.
-   */
-  @Nullable
-  public ProblemDescriptor[] checkField(@NotNull PsiField field, @NotNull InspectionManager manager, boolean isOnTheFly) {
-    return null;
-  }
-
-  /**
-     * Override this to report problems at file level.
-     *
-     * @param file       to check.
-     * @param manager    InspectionManager to ask for ProblemDescriptors from.
-     * @param isOnTheFly true if called during on the fly editor highlighting. Called from Inspect Code action otherwise.
-     * @return <code>null</code> if no problems found or not applicable at file level.
-     */
-  @Override
-  @Nullable
-  public ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly) {
-    return null;
-  }
-
-  @Override
-  @NotNull
-  public PsiElementVisitor buildVisitor(@NotNull final ProblemsHolder holder, final boolean isOnTheFly) {
-    return new JavaElementVisitor() {
-      @Override public void visitMethod(PsiMethod method) {
-        addDescriptors(checkMethod(method, holder.getManager(), isOnTheFly));
-      }
-
-      @Override public void visitClass(PsiClass aClass) {
-        addDescriptors(checkClass(aClass, holder.getManager(), isOnTheFly));
-      }
-
-      @Override public void visitField(PsiField field) {
-        addDescriptors(checkField(field, holder.getManager(), isOnTheFly));
-      }
-
-      @Override public void visitFile(PsiFile file) {
-        addDescriptors(checkFile(file, holder.getManager(), isOnTheFly));
-      }
-      private void addDescriptors(final ProblemDescriptor[] descriptors) {
-        if (descriptors != null) {
-          for (ProblemDescriptor descriptor : descriptors) {
-            holder.registerProblem(descriptor);
-          }
-        }
-      }
-    };
-  }
-
-  @Override
-  public PsiNamedElement getProblemElement(final PsiElement psiElement) {
-    return PsiTreeUtil.getNonStrictParentOfType(psiElement, PsiFile.class, PsiClass.class, PsiMethod.class, PsiField.class);
-  }
-
+public abstract class BaseJavaLocalInspectionTool extends AbstractBaseJavaLocalInspectionTool implements CustomSuppressableInspectionTool {
   @Override
   public SuppressIntentionAction[] getSuppressActions(final PsiElement element) {
     return SuppressManager.getInstance().createSuppressActions(HighlightDisplayKey.find(getShortName()));
@@ -129,12 +40,6 @@
   }
 
   public static boolean isSuppressedFor(@NotNull PsiElement element, @NotNull LocalInspectionTool tool) {
-    final SuppressManager manager = SuppressManager.getInstance();
-    String alternativeId;
-    String id;
-    return manager.isSuppressedFor(element, id = tool.getID()) ||
-           (alternativeId = tool.getAlternativeID()) != null &&
-             !alternativeId.equals(id) &&
-             manager.isSuppressedFor(element, alternativeId);
+    return BaseJavaBatchLocalInspectionTool.isSuppressedFor(element, tool);
   }
 }
diff --git a/java/openapi/src/com/intellij/codeInspection/SuppressManager.java b/java/openapi/src/com/intellij/codeInspection/SuppressManager.java
index 8b60d46..df9cfdd 100644
--- a/java/openapi/src/com/intellij/codeInspection/SuppressManager.java
+++ b/java/openapi/src/com/intellij/codeInspection/SuppressManager.java
@@ -22,48 +22,31 @@
 
 import com.intellij.codeInsight.daemon.HighlightDisplayKey;
 import com.intellij.openapi.components.ServiceManager;
-import com.intellij.psi.*;
+import com.intellij.psi.PsiAnnotation;
+import com.intellij.psi.PsiCodeBlock;
+import com.intellij.psi.PsiField;
+import com.intellij.psi.PsiLiteralExpression;
 import com.intellij.psi.util.PsiTreeUtil;
 import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
 
-import java.util.Collection;
-
-public abstract class SuppressManager {
+public abstract class SuppressManager implements BatchSuppressManager {
   public static final String SUPPRESS_INSPECTIONS_ANNOTATION_NAME = "java.lang.SuppressWarnings";
 
   public static SuppressManager getInstance() {
     return ServiceManager.getService(SuppressManager.class);
   }
 
-  @NotNull
-  public abstract SuppressIntentionAction[] createSuppressActions(@NotNull HighlightDisplayKey key);
-
-  public abstract boolean isSuppressedFor(@NotNull PsiElement element, final String toolId);
-
-  public abstract PsiElement getElementMemberSuppressedIn(@NotNull PsiDocCommentOwner owner, final String inspectionToolID);
-
-  @Nullable
-  public abstract PsiElement getAnnotationMemberSuppressedIn(@NotNull PsiModifierListOwner owner, String inspectionToolID);
-
-  @Nullable
-  public abstract PsiElement getDocCommentToolSuppressedIn(@NotNull PsiDocCommentOwner owner, String inspectionToolID);
-
-  @NotNull
-  public abstract Collection<String> getInspectionIdsSuppressedInAnnotation(@NotNull PsiModifierListOwner owner);
-
-  @Nullable
-  public abstract String getSuppressedInspectionIdsIn(@NotNull PsiElement element);
-
-  @Nullable
-  public abstract PsiElement getElementToolSuppressedIn(@NotNull PsiElement place, String toolId);
-
-  public abstract boolean canHave15Suppressions(@NotNull PsiElement file);
-
-  public abstract boolean alreadyHas14Suppressions(@NotNull PsiDocCommentOwner commentOwner);
-
   public static boolean isSuppressedInspectionName(PsiLiteralExpression expression) {
     PsiAnnotation annotation = PsiTreeUtil.getParentOfType(expression, PsiAnnotation.class, true, PsiCodeBlock.class, PsiField.class);
     return annotation != null && SUPPRESS_INSPECTIONS_ANNOTATION_NAME.equals(annotation.getQualifiedName());
   }
+
+  @NotNull
+  @Override
+  public SuppressQuickFix[] createBatchSuppressActions(@NotNull HighlightDisplayKey key) {
+    return BatchSuppressManager.SERVICE.getInstance().createBatchSuppressActions(key);
+  }
+
+  @NotNull
+  public abstract SuppressIntentionAction[] createSuppressActions(@NotNull HighlightDisplayKey key);
 }
\ No newline at end of file
diff --git a/java/openapi/src/com/intellij/openapi/module/LanguageLevelUtil.java b/java/openapi/src/com/intellij/openapi/module/LanguageLevelUtil.java
index 0ee5397..1fa919b 100644
--- a/java/openapi/src/com/intellij/openapi/module/LanguageLevelUtil.java
+++ b/java/openapi/src/com/intellij/openapi/module/LanguageLevelUtil.java
@@ -15,11 +15,8 @@
  */
 package com.intellij.openapi.module;
 
-import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.projectRoots.JavaSdk;
 import com.intellij.openapi.projectRoots.JavaSdkVersion;
-import com.intellij.openapi.roots.LanguageLevelModuleExtension;
-import com.intellij.openapi.roots.LanguageLevelProjectExtension;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.pom.java.LanguageLevel;
 import org.jetbrains.annotations.NotNull;
@@ -27,19 +24,11 @@
 /**
  * @author yole
  */
-public class LanguageLevelUtil {
+public class LanguageLevelUtil extends EffectiveLanguageLevelUtil {
   private LanguageLevelUtil() {
   }
 
   @NotNull
-  public static LanguageLevel getEffectiveLanguageLevel(@NotNull final Module module) {
-    ApplicationManager.getApplication().assertReadAccessAllowed();
-    LanguageLevel level = LanguageLevelModuleExtension.getInstance(module).getLanguageLevel();
-    if (level != null) return level;
-    return LanguageLevelProjectExtension.getInstance(module.getProject()).getLanguageLevel();
-  }
-
-  @NotNull
   public static LanguageLevel getLanguageLevelForFile(final VirtualFile file) {
     if (file == null) return LanguageLevel.HIGHEST;
 
diff --git a/platform/analysis-api/src/com/intellij/ToolExtensionPoints.java b/platform/analysis-api/src/com/intellij/ToolExtensionPoints.java
new file mode 100644
index 0000000..e589cef
--- /dev/null
+++ b/platform/analysis-api/src/com/intellij/ToolExtensionPoints.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright 2000-2013 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij;
+
+import org.jetbrains.annotations.NonNls;
+
+public interface ToolExtensionPoints {
+  @NonNls String INVALID_PROPERTY_KEY_INSPECTION_TOOL = "com.intellij.invalidPropertyKeyInspectionTool";
+  @NonNls String I18N_INSPECTION_TOOL = "com.intellij.i18nInspectionTool";
+  @NonNls String JAVA15_INSPECTION_TOOL = "com.intellij.java15InspectionTool";
+}
diff --git a/platform/lang-api/src/com/intellij/codeInsight/intention/HighPriorityAction.java b/platform/analysis-api/src/com/intellij/codeInsight/intention/HighPriorityAction.java
similarity index 100%
rename from platform/lang-api/src/com/intellij/codeInsight/intention/HighPriorityAction.java
rename to platform/analysis-api/src/com/intellij/codeInsight/intention/HighPriorityAction.java
diff --git a/platform/analysis-api/src/com/intellij/codeInspection/BatchSuppressableTool.java b/platform/analysis-api/src/com/intellij/codeInspection/BatchSuppressableTool.java
new file mode 100644
index 0000000..9a08f3a
--- /dev/null
+++ b/platform/analysis-api/src/com/intellij/codeInspection/BatchSuppressableTool.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2000-2013 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.codeInspection;
+
+import com.intellij.psi.PsiElement;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+public interface BatchSuppressableTool {
+  /**
+   * Checks if the inspection is suppressed for the specified element.
+   *
+   * @param element the element to check
+   * @return true if the inspection is suppressed, false otherwise.
+   */
+  boolean isSuppressedFor(@NotNull PsiElement element);
+
+
+  /**
+   * Returns the list of suppression actions for the specified element.
+   *
+   * @param element the element on which Alt-Enter is pressed, or null if getting the list of available suppression actions in
+   *                Inspections tool window
+   * @return the list of suppression actions.
+   */
+  @NotNull
+  SuppressQuickFix[] getBatchSuppressActions(@Nullable final PsiElement element);
+
+}
diff --git a/platform/lang-api/src/com/intellij/codeInspection/FileCheckingInspection.java b/platform/analysis-api/src/com/intellij/codeInspection/FileCheckingInspection.java
similarity index 95%
rename from platform/lang-api/src/com/intellij/codeInspection/FileCheckingInspection.java
rename to platform/analysis-api/src/com/intellij/codeInspection/FileCheckingInspection.java
index c9d9936..9ac1fdb 100644
--- a/platform/lang-api/src/com/intellij/codeInspection/FileCheckingInspection.java
+++ b/platform/analysis-api/src/com/intellij/codeInspection/FileCheckingInspection.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
diff --git a/platform/analysis-api/src/com/intellij/codeInspection/LocalQuickFixOnPsiElement.java b/platform/analysis-api/src/com/intellij/codeInspection/LocalQuickFixOnPsiElement.java
new file mode 100644
index 0000000..404dc23
--- /dev/null
+++ b/platform/analysis-api/src/com/intellij/codeInspection/LocalQuickFixOnPsiElement.java
@@ -0,0 +1,110 @@
+/*
+ * Copyright 2000-2013 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.codeInspection;
+
+import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.project.Project;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiFile;
+import com.intellij.psi.SmartPointerManager;
+import com.intellij.psi.SmartPsiElementPointer;
+import org.jetbrains.annotations.NotNull;
+
+public abstract class LocalQuickFixOnPsiElement implements LocalQuickFix {
+  protected static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.LocalQuickFixAndIntentionAction");
+  protected final SmartPsiElementPointer<PsiElement> myStartElement;
+  protected final SmartPsiElementPointer<PsiElement> myEndElement;
+
+  protected LocalQuickFixOnPsiElement(@NotNull PsiElement element) {
+    this(element, element);
+  }
+
+  public LocalQuickFixOnPsiElement(PsiElement startElement, PsiElement endElement) {
+    if (startElement == null || endElement == null) {
+      myStartElement = myEndElement = null;
+      return;
+    }
+    LOG.assertTrue(startElement.isValid());
+    PsiFile startContainingFile = startElement.getContainingFile();
+    PsiFile endContainingFile = startElement == endElement ? startContainingFile : endElement.getContainingFile();
+    if (startElement != endElement) {
+      LOG.assertTrue(endElement.isValid());
+      LOG.assertTrue(startContainingFile == endContainingFile, "Both elements must be from the same file");
+    }
+    Project project = startContainingFile == null ? startElement.getProject() : startContainingFile.getProject(); // containingFile can be null for a directory
+    myStartElement = SmartPointerManager.getInstance(project).createSmartPsiElementPointer(startElement, startContainingFile);
+    myEndElement = endElement == startElement ? null : SmartPointerManager.getInstance(project).createSmartPsiElementPointer(endElement, endContainingFile);
+  }
+
+  @NotNull
+  @Override
+  public final String getName() {
+    return getText();
+  }
+
+  public boolean isAvailable(@NotNull Project project,
+                             @NotNull PsiFile file,
+                             @NotNull PsiElement startElement,
+                             @NotNull PsiElement endElement) {
+    return true;
+  }
+
+  protected boolean isAvailable() {
+    if (myStartElement == null) return false;
+    final PsiElement startElement = myStartElement.getElement();
+    final PsiElement endElement = myEndElement == null ? startElement : myEndElement.getElement();
+    PsiFile file = myStartElement.getContainingFile();
+    Project project = myStartElement.getProject();
+    return startElement != null &&
+           endElement != null &&
+           startElement.isValid() &&
+           (endElement == startElement || endElement.isValid()) &&
+           file != null &&
+           isAvailable(project, file, startElement, endElement);
+  }
+
+  public PsiElement getStartElement() {
+    return myStartElement == null ? null : myStartElement.getElement();
+  }
+
+  public PsiElement getEndElement() {
+    return myEndElement == null ? null : myEndElement.getElement();
+  }
+
+  @NotNull
+  public abstract String getText();
+
+  @Override
+  public final void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
+    applyFix();
+  }
+
+  public void applyFix() {
+    if (myStartElement == null) return;
+    final PsiElement startElement = myStartElement.getElement();
+    final PsiElement endElement = myEndElement == null ? startElement : myEndElement.getElement();
+    if (startElement == null || endElement == null) return;
+    PsiFile file = startElement.getContainingFile();
+    if (file == null) return;
+    invoke(file.getProject(), file, startElement, endElement);
+  }
+
+  public abstract void invoke(@NotNull Project project,
+                              @NotNull PsiFile file,
+                              @NotNull PsiElement startElement,
+                              @NotNull PsiElement endElement);
+
+}
diff --git a/platform/lang-api/src/com/intellij/codeInspection/FileCheckingInspection.java b/platform/analysis-api/src/com/intellij/codeInspection/SuppressQuickFix.java
similarity index 65%
copy from platform/lang-api/src/com/intellij/codeInspection/FileCheckingInspection.java
copy to platform/analysis-api/src/com/intellij/codeInspection/SuppressQuickFix.java
index c9d9936..e0fff38 100644
--- a/platform/lang-api/src/com/intellij/codeInspection/FileCheckingInspection.java
+++ b/platform/analysis-api/src/com/intellij/codeInspection/SuppressQuickFix.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -13,17 +13,13 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package com.intellij.codeInspection;
 
-import com.intellij.psi.PsiFile;
+import com.intellij.openapi.project.Project;
+import com.intellij.psi.PsiElement;
 import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
 
-/**
- * @author yole
- */
-public interface FileCheckingInspection {
-  @Nullable
-  ProblemDescriptor[] checkFile(@NotNull PsiFile file, @NotNull InspectionManager manager, boolean isOnTheFly);
+public interface SuppressQuickFix extends LocalQuickFix {
+  SuppressQuickFix[] EMPTY_ARRAY = new SuppressQuickFix[0];
+  boolean isAvailable(@NotNull final Project project, @NotNull final PsiElement context);
 }
diff --git a/platform/lang-api/src/com/intellij/codeInspection/ui/MultipleCheckboxOptionsPanel.java b/platform/analysis-api/src/com/intellij/codeInspection/ui/MultipleCheckboxOptionsPanel.java
similarity index 100%
rename from platform/lang-api/src/com/intellij/codeInspection/ui/MultipleCheckboxOptionsPanel.java
rename to platform/analysis-api/src/com/intellij/codeInspection/ui/MultipleCheckboxOptionsPanel.java
diff --git a/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/actions/AbstractBatchSuppressByNoInspectionCommentFix.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/actions/AbstractBatchSuppressByNoInspectionCommentFix.java
new file mode 100644
index 0000000..7a8c3e3
--- /dev/null
+++ b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/actions/AbstractBatchSuppressByNoInspectionCommentFix.java
@@ -0,0 +1,166 @@
+/*
+ * Copyright 2000-2013 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.intellij.codeInsight.daemon.impl.actions;
+
+import com.intellij.codeInsight.FileModificationService;
+import com.intellij.codeInspection.InspectionsBundle;
+import com.intellij.codeInspection.ProblemDescriptor;
+import com.intellij.codeInspection.SuppressQuickFix;
+import com.intellij.codeInspection.SuppressionUtil;
+import com.intellij.icons.AllIcons;
+import com.intellij.lang.Language;
+import com.intellij.openapi.command.undo.UndoUtil;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.Iconable;
+import com.intellij.psi.PsiComment;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiManager;
+import com.intellij.psi.PsiWhiteSpace;
+import com.intellij.psi.util.PsiTreeUtil;
+import com.intellij.util.IncorrectOperationException;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import javax.swing.*;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * @author Roman.Chernyatchik
+ * @date Aug 13, 2009
+ */
+public abstract class AbstractBatchSuppressByNoInspectionCommentFix implements SuppressQuickFix, Iconable {
+  @NotNull protected final String myID;
+  private final boolean myReplaceOtherSuppressionIds;
+
+  @Nullable
+  public abstract PsiElement getContainer(final PsiElement context);
+
+  /**
+   * @param ID                         Inspection ID
+   * @param replaceOtherSuppressionIds Merge suppression policy. If false new tool id will be append to the end
+   *                                   otherwise replace other ids
+   */
+  public AbstractBatchSuppressByNoInspectionCommentFix(@NotNull String ID, final boolean replaceOtherSuppressionIds) {
+    myID = ID;
+    myReplaceOtherSuppressionIds = replaceOtherSuppressionIds;
+  }
+
+  @NotNull
+  @Override
+  public String getName() {
+    return getText();
+  }
+
+  @Override
+  public Icon getIcon(int flags) {
+    return AllIcons.General.InspectionsOff;
+  }
+
+  private String myText = "";
+  @NotNull
+  public String getText() {
+    return myText;
+  }
+
+  protected void setText(@NotNull String text) {
+    myText = text;
+  }
+
+  public boolean startInWriteAction() {
+    return true;
+  }
+
+  @Override
+  public String toString() {
+    return getText();
+  }
+
+  @Override
+  public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
+    PsiElement element = descriptor.getStartElement();
+    if (element == null) return;
+    invoke(project, element);
+  }
+
+  protected final void replaceSuppressionComment(@NotNull final PsiElement comment) {
+    SuppressionUtil.replaceSuppressionComment(comment, myID, myReplaceOtherSuppressionIds, getCommentLanguage(comment));
+  }
+
+  protected void createSuppression(@NotNull Project project,
+                                   @NotNull PsiElement element,
+                                   @NotNull PsiElement container) throws IncorrectOperationException {
+    SuppressionUtil.createSuppression(project, container, myID, getCommentLanguage(element));
+  }
+
+  /**
+   * @param element quickfix target or existing comment element
+   * @return language that will be used for comment creating.
+   * In common case language will be the same as language of quickfix target
+   */
+  @NotNull
+  protected Language getCommentLanguage(@NotNull PsiElement element) {
+    return element.getLanguage();
+  }
+
+  @Override
+  public boolean isAvailable(@NotNull final Project project, @NotNull final PsiElement context) {
+    return context.isValid() && PsiManager.getInstance(project).isInProject(context) && getContainer(context) != null;
+  }
+
+  public void invoke(@NotNull final Project project, @NotNull final PsiElement element) throws IncorrectOperationException {
+    if (!isAvailable(project, element)) return;
+    PsiElement container = getContainer(element);
+    if (container == null) return;
+
+    if (!FileModificationService.getInstance().preparePsiElementForWrite(container)) return;
+
+    if (replaceSuppressionComments(container)) return;
+
+    createSuppression(project, element, container);
+    UndoUtil.markPsiFileForUndo(element.getContainingFile());
+  }
+
+  protected boolean replaceSuppressionComments(PsiElement container) {
+    final List<? extends PsiElement> comments = getCommentsFor(container);
+    if (comments != null) {
+      for (PsiElement comment : comments) {
+        if (comment instanceof PsiComment && SuppressionUtil.isSuppressionComment(comment)) {
+          replaceSuppressionComment(comment);
+          return true;
+        }
+      }
+    }
+    return false;
+  }
+
+  @Nullable
+  protected List<? extends PsiElement> getCommentsFor(@NotNull final PsiElement container) {
+    final PsiElement prev = PsiTreeUtil.skipSiblingsBackward(container, PsiWhiteSpace.class);
+    if (prev == null) {
+      return null;
+    }
+    return Collections.singletonList(prev);
+  }
+
+
+  @Override
+  @NotNull
+  public String getFamilyName() {
+    return InspectionsBundle.message("suppress.inspection.family");
+  }
+}
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/actions/SuppressByCommentFix.java b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/actions/SuppressByCommentFix.java
similarity index 91%
rename from platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/actions/SuppressByCommentFix.java
rename to platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/actions/SuppressByCommentFix.java
index a174928..bcc8fd6 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/actions/SuppressByCommentFix.java
+++ b/platform/analysis-impl/src/com/intellij/codeInsight/daemon/impl/actions/SuppressByCommentFix.java
@@ -26,7 +26,7 @@
 /**
  * @author ven
  */
-public class SuppressByCommentFix extends AbstractSuppressByNoInspectionCommentFix {
+public class SuppressByCommentFix extends AbstractBatchSuppressByNoInspectionCommentFix {
   protected Class<? extends PsiElement> mySuppressionHolderClass;
 
   public SuppressByCommentFix(@NotNull HighlightDisplayKey key, @NotNull Class<? extends PsiElement> suppressionHolderClass) {
@@ -46,7 +46,7 @@
 
   @Override
   @Nullable
-  protected PsiElement getContainer(PsiElement context) {
+  public PsiElement getContainer(PsiElement context) {
     return PsiTreeUtil.getParentOfType(context, mySuppressionHolderClass);
   }
 }
diff --git a/platform/analysis-impl/src/com/intellij/codeInspection/SuppressionUtil.java b/platform/analysis-impl/src/com/intellij/codeInspection/SuppressionUtil.java
new file mode 100644
index 0000000..e98bcc3
--- /dev/null
+++ b/platform/analysis-impl/src/com/intellij/codeInspection/SuppressionUtil.java
@@ -0,0 +1,185 @@
+/*
+ * Copyright 2000-2013 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.intellij.codeInspection;
+
+import com.intellij.lang.Commenter;
+import com.intellij.lang.Language;
+import com.intellij.lang.LanguageCommenters;
+import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.NullableComputable;
+import com.intellij.openapi.util.Pair;
+import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.psi.PsiComment;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiParserFacade;
+import com.intellij.psi.PsiWhiteSpace;
+import com.intellij.psi.util.PsiTreeUtil;
+import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * @author yole
+ */
+public class SuppressionUtil {
+  @NonNls public static final String SUPPRESS_INSPECTIONS_TAG_NAME = "noinspection";
+
+  /**
+   * Common part of regexp for suppressing in line comments for different languages.
+   * Comment start prefix isn't included, e.g. add '//' for Java/C/JS or '#' for Ruby
+   */
+  @NonNls
+  public static final String COMMON_SUPPRESS_REGEXP = "\\s*" + SUPPRESS_INSPECTIONS_TAG_NAME +
+                                                      "\\s+(" + LocalInspectionTool.VALID_ID_PATTERN +
+                                                      "(\\s*,\\s*" + LocalInspectionTool.VALID_ID_PATTERN + ")*)\\s*\\w*";
+
+  @NonNls
+  public static final Pattern SUPPRESS_IN_LINE_COMMENT_PATTERN = Pattern.compile("//" + COMMON_SUPPRESS_REGEXP);  // for Java, C, JS line comments
+
+  @NonNls
+  public static final String ALL = "ALL";
+
+  private SuppressionUtil() {
+  }
+
+  public static boolean isInspectionToolIdMentioned(@NotNull String inspectionsList, String inspectionToolID) {
+    Iterable<String> ids = StringUtil.tokenize(inspectionsList, "[, ]");
+
+    for (@NonNls String id : ids) {
+      @NonNls String trim = id.trim();
+      if (trim.equals(inspectionToolID) || trim.equalsIgnoreCase(ALL)) return true;
+    }
+    return false;
+  }
+
+  @Nullable
+  public static PsiElement getStatementToolSuppressedIn(final PsiElement place,
+                                                        final String toolId,
+                                                        final Class<? extends PsiElement> statementClass) {
+    return getStatementToolSuppressedIn(place, toolId, statementClass, SUPPRESS_IN_LINE_COMMENT_PATTERN);
+  }
+
+  @Nullable
+  public static PsiElement getStatementToolSuppressedIn(final PsiElement place,
+                                                        final String toolId,
+                                                        final Class<? extends PsiElement> statementClass,
+                                                        final Pattern suppressInLineCommentPattern) {
+    PsiElement statement = PsiTreeUtil.getNonStrictParentOfType(place, statementClass);
+    if (statement != null) {
+      PsiElement prev = PsiTreeUtil.skipSiblingsBackward(statement, PsiWhiteSpace.class);
+      if (prev instanceof PsiComment) {
+        String text = prev.getText();
+        Matcher matcher = suppressInLineCommentPattern.matcher(text);
+        if (matcher.matches() && isInspectionToolIdMentioned(matcher.group(1), toolId)) {
+          return prev;
+        }
+      }
+    }
+    return null;
+  }
+
+  public static boolean isSuppressedInStatement(final PsiElement place,
+                                                final String toolId,
+                                                final Class<? extends PsiElement> statementClass) {
+    return ApplicationManager.getApplication().runReadAction(new NullableComputable<PsiElement>() {
+      @Override
+      public PsiElement compute() {
+        return getStatementToolSuppressedIn(place, toolId, statementClass);
+      }
+    }) != null;
+  }
+
+  @NotNull
+  public static PsiComment createComment(@NotNull Project project,
+                                         @NotNull String commentText,
+                                         @NotNull Language language) {
+    final PsiParserFacade parserFacade = PsiParserFacade.SERVICE.getInstance(project);
+    return parserFacade.createLineOrBlockCommentFromText(language, commentText);
+  }
+
+  @Nullable
+  public static Pair<String, String> getBlockPrefixSuffixPair(PsiElement comment) {
+    final Commenter commenter = LanguageCommenters.INSTANCE.forLanguage(comment.getLanguage());
+    if (commenter != null) {
+      final String prefix = commenter.getBlockCommentPrefix();
+      final String suffix = commenter.getBlockCommentSuffix();
+      if (prefix != null || suffix != null) {
+        return Pair.create(StringUtil.notNullize(prefix), StringUtil.notNullize(suffix));
+      }
+    }
+    return null;
+  }
+
+  @Nullable
+  public static String getLineCommentPrefix(@NotNull final PsiElement comment) {
+    final Commenter commenter = LanguageCommenters.INSTANCE.forLanguage(comment.getLanguage());
+    return commenter == null ? null : commenter.getLineCommentPrefix();
+  }
+
+  public static boolean isSuppressionComment(@NotNull PsiElement comment) {
+    final String prefix = getLineCommentPrefix(comment);
+    final String commentText = comment.getText();
+    if (prefix != null) {
+      return commentText.startsWith(prefix + SUPPRESS_INSPECTIONS_TAG_NAME);
+    }
+    final Pair<String, String> prefixSuffixPair = getBlockPrefixSuffixPair(comment);
+    return prefixSuffixPair != null
+           && commentText.startsWith(prefixSuffixPair.first + SUPPRESS_INSPECTIONS_TAG_NAME)
+           && commentText.endsWith(prefixSuffixPair.second);
+  }
+
+  public static void replaceSuppressionComment(@NotNull PsiElement comment, @NotNull String id,
+                                               boolean replaceOtherSuppressionIds, @NotNull Language commentLanguage) {
+    final String oldSuppressionCommentText = comment.getText();
+    final String lineCommentPrefix = getLineCommentPrefix(comment);
+    Pair<String, String> blockPrefixSuffix = null;
+    if (lineCommentPrefix == null) {
+      blockPrefixSuffix = getBlockPrefixSuffixPair(comment);
+    }
+    assert blockPrefixSuffix != null
+           && oldSuppressionCommentText.startsWith(blockPrefixSuffix.first)
+           && oldSuppressionCommentText.endsWith(blockPrefixSuffix.second)
+           || lineCommentPrefix != null && oldSuppressionCommentText.startsWith(lineCommentPrefix)
+      : "Unexpected suppression comment " + oldSuppressionCommentText;
+
+    // append new suppression tool id or replace
+    final String newText;
+    if(replaceOtherSuppressionIds) {
+      newText = SUPPRESS_INSPECTIONS_TAG_NAME + " " + id;
+    }
+    else if (lineCommentPrefix == null) {
+      newText = oldSuppressionCommentText.substring(blockPrefixSuffix.first.length(),
+                                                    oldSuppressionCommentText.length() - blockPrefixSuffix.second.length()) + "," + id;
+    }
+    else {
+      newText = oldSuppressionCommentText.substring(lineCommentPrefix.length()) + "," + id;
+    }
+    comment.replace(createComment(comment.getProject(), newText, commentLanguage));
+  }
+
+  public static void createSuppression(@NotNull Project project,
+                                       @NotNull PsiElement container,
+                                       @NotNull String id, @NotNull Language commentLanguage) {
+    final String text = SUPPRESS_INSPECTIONS_TAG_NAME + " " + id;
+    PsiComment comment = createComment(project, text, commentLanguage);
+    container.getParent().addBefore(comment, container);
+  }
+}
diff --git a/platform/lang-api/src/com/intellij/openapi/command/undo/UndoUtil.java b/platform/core-api/src/com/intellij/openapi/command/undo/UndoUtil.java
similarity index 99%
rename from platform/lang-api/src/com/intellij/openapi/command/undo/UndoUtil.java
rename to platform/core-api/src/com/intellij/openapi/command/undo/UndoUtil.java
index b5d149b..e42d56c 100644
--- a/platform/lang-api/src/com/intellij/openapi/command/undo/UndoUtil.java
+++ b/platform/core-api/src/com/intellij/openapi/command/undo/UndoUtil.java
@@ -49,4 +49,4 @@
   public static void markVirtualFileForUndo(@NotNull Project project, @NotNull VirtualFile file) {
     CommandProcessor.getInstance().addAffectedFiles(project, file);
   }
-}
\ No newline at end of file
+}
diff --git a/platform/core-api/src/com/intellij/openapi/progress/EmptyProgressIndicator.java b/platform/core-api/src/com/intellij/openapi/progress/EmptyProgressIndicator.java
index 9cae8fc..82abd36 100644
--- a/platform/core-api/src/com/intellij/openapi/progress/EmptyProgressIndicator.java
+++ b/platform/core-api/src/com/intellij/openapi/progress/EmptyProgressIndicator.java
@@ -23,79 +23,100 @@
   private boolean myIsRunning = false;
   private volatile boolean myIsCanceled = false;
 
+  @Override
   public void start() {
     myIsRunning = true;
     myIsCanceled = false;
   }
 
+  @Override
   public void stop() {
     myIsRunning = false;
   }
 
+  @Override
   public boolean isRunning() {
     return myIsRunning;
   }
 
+  @Override
   public void cancel() {
     myIsCanceled = true;
   }
 
+  @Override
   public boolean isCanceled() {
     return myIsCanceled;
   }
 
+  @Override
   public void setText(String text) {
   }
 
+  @Override
   public String getText() {
     return "";
   }
 
+  @Override
   public void setText2(String text) {
   }
 
+  @Override
   public String getText2() {
     return "";
   }
 
+  @Override
   public double getFraction() {
     return 1;
   }
 
+  @Override
   public void setFraction(double fraction) {
   }
 
+  @Override
   public void pushState() {
   }
 
+  @Override
   public void popState() {
   }
 
+  @Override
   public void startNonCancelableSection() {
   }
 
+  @Override
   public void finishNonCancelableSection() {
   }
 
+  @Override
   public boolean isModal() {
     return false;
   }
 
+  @Override
   @NotNull
   public ModalityState getModalityState() {
     return ModalityState.NON_MODAL;
   }
 
+  @Override
   public void setModalityProgress(ProgressIndicator modalityProgress) {
   }
 
+  @Override
   public boolean isIndeterminate() {
     return false;
   }
 
+  @Override
   public void setIndeterminate(boolean indeterminate) {
   }
 
+  @Override
   public void checkCanceled() {
     if (myIsCanceled) {
       throw new ProcessCanceledException();
diff --git a/platform/external-system-api/resources/i18n/ExternalSystemBundle.properties b/platform/external-system-api/resources/i18n/ExternalSystemBundle.properties
index bcc54db..c4ab791 100644
--- a/platform/external-system-api/resources/i18n/ExternalSystemBundle.properties
+++ b/platform/external-system-api/resources/i18n/ExternalSystemBundle.properties
@@ -1,3 +1,7 @@
+# Import.
+import.title=Import {0} Projects
+orphan.modules.text=<html>The modules below have been removed from {0} structure.<br/>Check those to be removed from the project too:
+
 # Settings.
 setting.type.location.deduced={0} location is deduced
 setting.type.location.unknown={0} location is unknown
@@ -10,8 +14,8 @@
 settings.title.system.settings=Global {0} settings
 
 # Progress.
-progress.import.text=Building {0} project info
-progress.refresh.text=Refreshing {0} project
+progress.import.text=Building ''{0}'' {1} project info
+progress.refresh.text=Refreshing ''{0}'' {1} project
 progress.resolve.libraries=Resolving {0} libraries
 progress.update.text={0}: {1}
 
diff --git a/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/DataNode.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/DataNode.java
index 951e648..65891f2 100644
--- a/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/DataNode.java
+++ b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/DataNode.java
@@ -66,30 +66,69 @@
     return myKey;
   }
 
-  @SuppressWarnings({"unchecked", "IOResourceOpenedButNotSafelyClosed"})
   @NotNull
   public T getData() {
     if (myData == null) {
-      assert myRawData != null;
-      ObjectInputStream oIn = null;
-      try {
-        oIn = new ObjectInputStream(new ByteArrayInputStream(myRawData));
-        myData = (T)oIn.readObject();
-      }
-      catch (IOException e) {
-        throw new IllegalStateException("Can't deserialize target data of key " + myKey);
-      }
-      catch (ClassNotFoundException e) {
-        throw new IllegalStateException("Can't deserialize target data of key " + myKey);
-      }
-      finally {
-        StreamUtil.closeStream(oIn);
-      }
+      prepareData(getClass().getClassLoader(), Thread.currentThread().getContextClassLoader());
     }
     return myData;
   }
 
   /**
+   * This class is a generic holder for any kind of project data. That project data might originate from different locations, e.g.
+   * core ide plugins, non-core ide plugins, third-party plugins etc. That means that when a service from a core plugin needs to
+   * unmarshall {@link DataNode} object, its content should not be unmarshalled as well because its class might be unavailable here.
+   * <p/>
+   * That's why the content is delivered as a raw byte array and this method allows to build actual java object from it using
+   * the right class loader.
+   * <p/>
+   * This method is a no-op if the content is already built.
+   *  
+   * @param loaders  class loaders which are assumed to be able to build object of the target content class
+   */
+  @SuppressWarnings({"unchecked", "IOResourceOpenedButNotSafelyClosed"})
+  public void prepareData(@NotNull final ClassLoader ... loaders) {
+    if (myData != null) {
+      return;
+    }
+    ObjectInputStream oIn = null;
+    try {
+      oIn = new ObjectInputStream(new ByteArrayInputStream(myRawData)) {
+        @Override
+        protected Class<?> resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException {
+          String name = desc.getName();
+          for (ClassLoader loader : loaders) {
+            try {
+              return loader.loadClass(name);
+            }
+            catch (ClassNotFoundException e) {
+              // Ignore
+            }
+          }
+          return super.resolveClass(desc);
+        }
+      };
+      myData = (T)oIn.readObject();
+      myRawData = null;
+    }
+    catch (IOException e) {
+      throw new IllegalStateException(
+        String.format("Can't deserialize target data of key '%s'. Given class loaders: %s", myKey, Arrays.toString(loaders)),
+        e
+      );
+    }
+    catch (ClassNotFoundException e) {
+      throw new IllegalStateException(
+        String.format("Can't deserialize target data of key '%s'. Given class loaders: %s", myKey, Arrays.toString(loaders)),
+        e
+      );
+    }
+    finally {
+      StreamUtil.closeStream(oIn);
+    }
+  }
+
+  /**
    * Allows to retrieve data stored for the given key at the current node or any of its parents.
    *
    * @param key  target data's key
diff --git a/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/Key.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/Key.java
index 2d5344d..b065741 100644
--- a/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/Key.java
+++ b/platform/external-system-api/src/com/intellij/openapi/externalSystem/model/Key.java
@@ -20,7 +20,12 @@
 import java.io.Serializable;
 
 /**
- * // TODO den add doc
+ * The basic design of external system integration assumes that target project info if represented as a generic graph
+ * of {@link DataNode} objects where every {@link DataNode} content type is identified by an instance of this class.
+ * <p/>
+ * That makes it possible to register custom {@link DataNode} processor per-{@link Key}
+ * <p/>
+ * Thread-safe.
  * 
  * @author Denis Zhdanov
  * @since 4/12/13 11:49 AM
@@ -30,20 +35,15 @@
 
   private static final long serialVersionUID = 1L;
   
-  @NotNull private final Class<T> myDataClass;
+  @NotNull private final String myDataClass;
 
-  public Key(@NotNull Class<T> dataClass) {
+  public Key(@NotNull String dataClass) {
     myDataClass = dataClass;
   }
 
   @NotNull
   public static <T> Key<T> create(@NotNull Class<T> dataClass) {
-    return new Key<T>(dataClass);
-  }
-
-  @NotNull
-  public Class<T> getDataClass() {
-    return myDataClass;
+    return new Key<T>(dataClass.getName());
   }
 
   @Override
@@ -65,6 +65,6 @@
 
   @Override
   public String toString() {
-    return myDataClass.getSimpleName();
+    return myDataClass;
   }
 }
diff --git a/platform/external-system-api/src/com/intellij/openapi/externalSystem/service/project/manage/ProjectDataService.java b/platform/external-system-api/src/com/intellij/openapi/externalSystem/service/project/manage/ProjectDataService.java
index 1a67a1f..c047e16 100644
--- a/platform/external-system-api/src/com/intellij/openapi/externalSystem/service/project/manage/ProjectDataService.java
+++ b/platform/external-system-api/src/com/intellij/openapi/externalSystem/service/project/manage/ProjectDataService.java
@@ -45,17 +45,18 @@
  * 
  * @author Denis Zhdanov
  * @since 4/12/13 3:59 PM
- * @param <T>  target project data type
+ * @param <E>  target external project data type
+ * @param <I>  target ide project data type
  */
-public interface ProjectDataService<T> {
+public interface ProjectDataService<E, I> {
 
-  ExtensionPointName<ProjectDataService<?>> EP_NAME = ExtensionPointName.create("com.intellij.externalProjectDataService");
+  ExtensionPointName<ProjectDataService<?, ?>> EP_NAME = ExtensionPointName.create("com.intellij.externalProjectDataService");
 
   /**
    * @return key of project data supported by the current manager
    */
   @NotNull
-  Key<T> getTargetDataKey();
+  Key<E> getTargetDataKey();
 
   /**
    * It's assumed that given data nodes present at the ide when this method returns. I.e. the method should behave as below for
@@ -76,7 +77,18 @@
    * @param project
    * @param synchronous
    */
-  void importData(@NotNull Collection<DataNode<T>> toImport, @NotNull Project project, boolean synchronous);
+  void importData(@NotNull Collection<DataNode<E>> toImport, @NotNull Project project, boolean synchronous);
 
-  void removeData(@NotNull Collection<DataNode<T>> toRemove, @NotNull Project project, boolean synchronous);
+  /**
+   * Asks to remove all given ide project entities.
+   * <p/>
+   * <b>Note:</b> as more than one {@link ProjectDataService} might be configured for a target entity type, there is a possible case
+   * that the entities have already been removed when this method is called. Then it's necessary to cleanup auxiliary data (if any)
+   * or just return otherwise.
+   * 
+   * @param toRemove     project entities to remove
+   * @param project      target project
+   * @param synchronous  flag which defines if entities removal should be synchronous
+   */
+  void removeData(@NotNull Collection<? extends I> toRemove, @NotNull Project project, boolean synchronous);
 }
diff --git a/platform/external-system-impl/external-system-impl.iml b/platform/external-system-impl/external-system-impl.iml
index bbc5026..6f10fb8 100644
--- a/platform/external-system-impl/external-system-impl.iml
+++ b/platform/external-system-impl/external-system-impl.iml
@@ -4,7 +4,6 @@
     <exclude-output />
     <content url="file://$MODULE_DIR$">
       <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
-      <sourceFolder url="file://$MODULE_DIR$/resources" isTestSource="false" />
     </content>
     <orderEntry type="inheritedJdk" />
     <orderEntry type="sourceFolder" forTests="false" />
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/AbstractDependencyDataService.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/AbstractDependencyDataService.java
index c0e9df6..ef42cab 100644
--- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/AbstractDependencyDataService.java
+++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/AbstractDependencyDataService.java
@@ -24,45 +24,20 @@
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.roots.*;
 import com.intellij.util.Consumer;
+import com.intellij.util.containers.ContainerUtilRt;
 import org.jetbrains.annotations.NotNull;
 
 import java.util.Collection;
+import java.util.Map;
 
 /**
  * @author Denis Zhdanov
  * @since 4/14/13 11:21 PM
  */
 @Order(ExternalSystemConstants.BUILTIN_SERVICE_ORDER)
-public abstract class AbstractDependencyDataService<T extends AbstractDependencyData<?>> implements ProjectDataService<T> {
-
-  public void removeData(@NotNull Collection<ExportableOrderEntry> toRemove, @NotNull final Module module, boolean synchronous) {
-    if (toRemove.isEmpty()) {
-      return;
-    }
-    for (final ExportableOrderEntry dependency : toRemove) {
-      ExternalSystemApiUtil.executeProjectChangeAction(module.getProject(), ProjectSystemId.IDE, toRemove, synchronous, new Runnable() {
-        @Override
-        public void run() {
-          ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);
-          final ModifiableRootModel moduleRootModel = moduleRootManager.getModifiableModel();
-          try {
-            // The thing is that intellij created order entry objects every time new modifiable model is created,
-            // that's why we can't use target dependency object as is but need to get a reference to the current
-            // entry object from the model instead.
-            for (OrderEntry entry : moduleRootModel.getOrderEntries()) {
-              if (entry.getPresentableName().equals(dependency.getPresentableName())) {
-                moduleRootModel.removeOrderEntry(entry);
-                break;
-              }
-            }
-          }
-          finally {
-            moduleRootModel.commit();
-          }
-        }
-      });
-    }
-  }
+public abstract class AbstractDependencyDataService<E extends AbstractDependencyData<?>, I extends ExportableOrderEntry>
+  implements ProjectDataService<E, I>
+{
 
   public void setScope(@NotNull final DependencyScope scope, @NotNull final ExportableOrderEntry dependency, boolean synchronous) {
     Project project = dependency.getOwnerModule().getProject();
@@ -113,4 +88,58 @@
       moduleRootModel.commit();
     }
   }
+
+  @Override
+  public void removeData(@NotNull Collection<? extends I> toRemove, @NotNull Project project, boolean synchronous) {
+    if (toRemove.isEmpty()) {
+      return;
+    }
+
+    Map<Module, Collection<ExportableOrderEntry>> byModule = groupByModule(toRemove);
+    for (Map.Entry<Module, Collection<ExportableOrderEntry>> entry : byModule.entrySet()) {
+      removeData(entry.getValue(), entry.getKey(), synchronous);
+    }
+  }
+
+  @NotNull
+  private static Map<Module, Collection<ExportableOrderEntry>> groupByModule(@NotNull Collection<? extends ExportableOrderEntry> data) {
+    Map<Module, Collection<ExportableOrderEntry>> result = ContainerUtilRt.newHashMap();
+    for (ExportableOrderEntry entry : data) {
+      Collection<ExportableOrderEntry> entries = result.get(entry.getOwnerModule());
+      if (entries == null) {
+        result.put(entry.getOwnerModule(), entries = ContainerUtilRt.newArrayList());
+      }
+      entries.add(entry);
+    }
+    return result;
+  }
+  
+  public void removeData(@NotNull Collection<? extends ExportableOrderEntry> toRemove, @NotNull final Module module, boolean synchronous) {
+    if (toRemove.isEmpty()) {
+      return;
+    }
+    for (final ExportableOrderEntry dependency : toRemove) {
+      ExternalSystemApiUtil.executeProjectChangeAction(module.getProject(), ProjectSystemId.IDE, toRemove, synchronous, new Runnable() {
+        @Override
+        public void run() {
+          ModuleRootManager moduleRootManager = ModuleRootManager.getInstance(module);
+          final ModifiableRootModel moduleRootModel = moduleRootManager.getModifiableModel();
+          try {
+            // The thing is that intellij created order entry objects every time new modifiable model is created,
+            // that's why we can't use target dependency object as is but need to get a reference to the current
+            // entry object from the model instead.
+            for (OrderEntry entry : moduleRootModel.getOrderEntries()) {
+              if (entry.getPresentableName().equals(dependency.getPresentableName())) {
+                moduleRootModel.removeOrderEntry(entry);
+                break;
+              }
+            }
+          }
+          finally {
+            moduleRootModel.commit();
+          }
+        }
+      });
+    }
+  }
 }
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ContentRootDataService.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ContentRootDataService.java
index cd9177d..e0b67ac 100644
--- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ContentRootDataService.java
+++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ContentRootDataService.java
@@ -22,7 +22,6 @@
 import org.jetbrains.annotations.NotNull;
 
 import java.util.Collection;
-import java.util.List;
 import java.util.Map;
 
 /**
@@ -32,7 +31,7 @@
  * @since 2/7/12 3:20 PM
  */
 @Order(ExternalSystemConstants.BUILTIN_SERVICE_ORDER)
-public class ContentRootDataService implements ProjectDataService<ContentRootData> {
+public class ContentRootDataService implements ProjectDataService<ContentRootData, ModuleAwareContentRoot> {
 
   private static final Logger LOG = Logger.getInstance("#" + ContentRootDataService.class.getName());
 
@@ -192,29 +191,17 @@
   }
 
   @Override
-  public void removeData(@NotNull Collection<DataNode<ContentRootData>> toRemove, @NotNull Project project, boolean synchronous) {
-    if (toRemove.isEmpty()) {
-      return;
+  public void removeData(@NotNull Collection<? extends ModuleAwareContentRoot> toRemove, @NotNull Project project, boolean synchronous) {
+    Map<Module, Collection<ModuleAwareContentRoot>> byModule = ContainerUtilRt.newHashMap();
+    for (ModuleAwareContentRoot root : toRemove) {
+      Collection<ModuleAwareContentRoot> roots = byModule.get(root.getModule());
+      if (roots == null) {
+        byModule.put(root.getModule(), roots = ContainerUtilRt.newArrayList());
+      }
+      roots.add(root);
     }
-    Map<DataNode<ModuleData>,Collection<DataNode<ContentRootData>>> byModule
-      = ExternalSystemApiUtil.groupBy(toRemove, ProjectKeys.MODULE);
-    for (Map.Entry<DataNode<ModuleData>, Collection<DataNode<ContentRootData>>> entry : byModule.entrySet()) {
-      final Module module = myProjectStructureHelper.findIdeModule(entry.getKey().getData(), project);
-      if (module == null) {
-        LOG.warn(String.format(
-          "Can't import content roots. Reason: target module (%s) is not found at the ide. Content roots: %s",
-          entry.getKey(), entry.getValue()
-        ));
-        continue;
-      }
-      List<ModuleAwareContentRoot> contentRoots = ContainerUtilRt.newArrayList();
-      for (DataNode<ContentRootData> holder : entry.getValue()) {
-        ModuleAwareContentRoot contentRoot = myProjectStructureHelper.findIdeContentRoot(holder, project);
-        if (contentRoot != null) {
-          contentRoots.add(contentRoot);
-        }
-      }
-      doRemoveData(contentRoots, project, synchronous);
+    for (Map.Entry<Module, Collection<ModuleAwareContentRoot>> entry : byModule.entrySet()) {
+      doRemoveData(entry.getValue(), project, synchronous);
     }
   }
 
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/LibraryDataService.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/LibraryDataService.java
index 4b7bbbf..3bf137f 100644
--- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/LibraryDataService.java
+++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/LibraryDataService.java
@@ -12,7 +12,6 @@
 import com.intellij.openapi.externalSystem.service.project.ProjectStructureHelper;
 import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
 import com.intellij.openapi.externalSystem.util.ExternalSystemConstants;
-import com.intellij.openapi.externalSystem.util.ExternalSystemUtil;
 import com.intellij.openapi.externalSystem.util.Order;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.roots.OrderRootType;
@@ -27,14 +26,16 @@
 import org.jetbrains.annotations.NotNull;
 
 import java.io.File;
-import java.util.*;
+import java.util.Collection;
+import java.util.Map;
+import java.util.Set;
 
 /**
  * @author Denis Zhdanov
  * @since 2/15/12 11:32 AM
  */
 @Order(ExternalSystemConstants.BUILTIN_SERVICE_ORDER)
-public class LibraryDataService implements ProjectDataService<LibraryData> {
+public class LibraryDataService implements ProjectDataService<LibraryData, Library> {
 
   private static final Logger LOG = Logger.getInstance("#" + LibraryDataService.class.getName());
   @NotNull public static final NotNullFunction<String, File> PATH_TO_FILE = new NotNullFunction<String, File>() {
@@ -151,19 +152,7 @@
     }
   }
 
-  @Override
-  public void removeData(@NotNull Collection<DataNode<LibraryData>> toRemove, @NotNull Project project, boolean synchronous) {
-    Collection<Library> libraries = ContainerUtilRt.newArrayList();
-    for (DataNode<LibraryData> node : toRemove) {
-      Library library = myProjectStructureHelper.findIdeLibrary(node.getData(), project);
-      if (library != null) {
-        libraries.add(library);
-      }
-    }
-    removeLibraries(libraries, project, synchronous);
-  }
-
-  public void removeLibraries(@NotNull final Collection<Library> libraries, @NotNull final Project project, boolean synchronous) {
+  public void removeData(@NotNull final Collection<? extends Library> libraries, @NotNull final Project project, boolean synchronous) {
     if (libraries.isEmpty()) {
       return;
     }
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/LibraryDependencyDataService.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/LibraryDependencyDataService.java
index 4b246a4..1e00304 100644
--- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/LibraryDependencyDataService.java
+++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/LibraryDependencyDataService.java
@@ -54,7 +54,7 @@
  * @since 4/12/13 6:19 PM
  */
 @Order(ExternalSystemConstants.BUILTIN_SERVICE_ORDER)
-public class LibraryDependencyDataService extends AbstractDependencyDataService<LibraryDependencyData> {
+public class LibraryDependencyDataService extends AbstractDependencyDataService<LibraryDependencyData, LibraryOrderEntry> {
 
   private static final Logger LOG = Logger.getInstance("#" + LibraryDependencyDataService.class.getName());
 
@@ -168,27 +168,4 @@
       }
     });
   }
-
-  @Override
-  public void removeData(@NotNull Collection<DataNode<LibraryDependencyData>> toRemove, @NotNull Project project, boolean synchronous) {
-    if (toRemove.isEmpty()) {
-      return;
-    }
-    Map<DataNode<ModuleData>, Collection<DataNode<LibraryDependencyData>>> byModule = ExternalSystemApiUtil.groupBy(toRemove, MODULE);
-    for (Map.Entry<DataNode<ModuleData>, Collection<DataNode<LibraryDependencyData>>> entry : byModule.entrySet()) {
-      Module module = myProjectStructureHelper.findIdeModule(entry.getKey().getData(), project);
-      if (module == null) {
-        continue;
-      }
-      List<ExportableOrderEntry> dependencies = ContainerUtilRt.newArrayList();
-      for (DataNode<LibraryDependencyData> node : entry.getValue()) {
-        LibraryOrderEntry dependency
-          = myProjectStructureHelper.findIdeLibraryDependency(module.getName(), node.getData().getName(), project);
-        if (dependency != null) {
-          dependencies.add(dependency);
-        }
-      }
-      removeData(dependencies, module, synchronous);
-    }
-  }
 }
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ModuleDataService.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ModuleDataService.java
index 1f6cc95..8584535 100644
--- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ModuleDataService.java
+++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ModuleDataService.java
@@ -27,7 +27,6 @@
 import java.io.File;
 import java.io.IOException;
 import java.util.Collection;
-import java.util.Iterator;
 import java.util.Map;
 import java.util.concurrent.TimeUnit;
 
@@ -38,7 +37,7 @@
  * @since 2/7/12 2:49 PM
  */
 @Order(ExternalSystemConstants.BUILTIN_SERVICE_ORDER)
-public class ModuleDataService implements ProjectDataService<ModuleData> {
+public class ModuleDataService implements ProjectDataService<ModuleData, Module> {
 
   private static final Logger LOG = Logger.getInstance("#" + ModuleDataService.class.getName());
 
@@ -147,7 +146,7 @@
       UIUtil.invokeLaterIfNeeded(task);
     }
   }
-
+  
   @NotNull
   private Collection<DataNode<ModuleData>> filterExistingModules(@NotNull Collection<DataNode<ModuleData>> modules,
                                                                  @NotNull Project project)
@@ -187,23 +186,10 @@
   }
 
   @Override
-  public void removeData(@NotNull Collection<DataNode<ModuleData>> toRemove, @NotNull Project project, boolean synchronous) {
-     Collection<Module> modules = ContainerUtilRt.newArrayList();
-    for (DataNode<ModuleData> node : toRemove) {
-      Module module = myProjectStructureHelper.findIdeModule(node.getData(), project);
-      if (module != null) {
-        modules.add(module);
-      }
-    }
-    removeData(modules, synchronous);
-  }
-
-  @SuppressWarnings("MethodMayBeStatic")
-  public void removeData(@NotNull final Collection<? extends Module> modules, boolean synchronous) {
+  public void removeData(@NotNull final Collection<? extends Module> modules, @NotNull Project project, boolean synchronous) {
     if (modules.isEmpty()) {
       return;
     }
-    Project project = modules.iterator().next().getProject();
     ExternalSystemApiUtil.executeProjectChangeAction(project, ProjectSystemId.IDE, modules, synchronous, new Runnable() {
       @Override
       public void run() {
@@ -222,6 +208,11 @@
       }
     });
   }
+
+  public static void unlinkModuleFromExternalSystem(@NotNull Module module) {
+    module.clearOption(ExternalSystemConstants.EXTERNAL_SYSTEM_ID_KEY);
+    module.clearOption(ExternalSystemConstants.LINKED_PROJECT_PATH_KEY);
+  }
   
   private class ImportModulesTask implements Runnable {
 
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ModuleDependencyDataService.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ModuleDependencyDataService.java
index c2a680a..654bea0 100644
--- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ModuleDependencyDataService.java
+++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ModuleDependencyDataService.java
@@ -29,17 +29,14 @@
 import com.intellij.openapi.externalSystem.util.Order;
 import com.intellij.openapi.module.Module;
 import com.intellij.openapi.project.Project;
-import com.intellij.openapi.roots.ExportableOrderEntry;
 import com.intellij.openapi.roots.ModifiableRootModel;
 import com.intellij.openapi.roots.ModuleOrderEntry;
 import com.intellij.openapi.roots.ModuleRootManager;
 import com.intellij.util.BooleanFunction;
-import com.intellij.util.containers.ContainerUtilRt;
 import org.jetbrains.annotations.NotNull;
 
 import java.util.Collection;
 import java.util.Collections;
-import java.util.List;
 import java.util.Map;
 
 import static com.intellij.openapi.externalSystem.model.ProjectKeys.MODULE;
@@ -49,7 +46,7 @@
  * @since 4/15/13 8:37 AM
  */
 @Order(ExternalSystemConstants.BUILTIN_SERVICE_ORDER)
-public class ModuleDependencyDataService extends AbstractDependencyDataService<ModuleDependencyData> {
+public class ModuleDependencyDataService extends AbstractDependencyDataService<ModuleDependencyData, ModuleOrderEntry> {
 
   private static final Logger LOG = Logger.getInstance("#" + ModuleDependencyDataService.class.getName());
 
@@ -142,26 +139,4 @@
       }
     });
   }
-
-  @Override
-  public void removeData(@NotNull Collection<DataNode<ModuleDependencyData>> toRemove, @NotNull Project project, boolean synchronous) {
-    if (toRemove.isEmpty()) {
-      return;
-    }
-    Map<DataNode<ModuleData>, Collection<DataNode<ModuleDependencyData>>> byModule = ExternalSystemApiUtil.groupBy(toRemove, MODULE);
-    for (Map.Entry<DataNode<ModuleData>, Collection<DataNode<ModuleDependencyData>>> entry : byModule.entrySet()) {
-      Module module = myProjectStructureHelper.findIdeModule(entry.getKey().getData(), project);
-      if (module == null) {
-        continue;
-      }
-      List<ExportableOrderEntry> dependencies = ContainerUtilRt.newArrayList();
-      for (DataNode<ModuleDependencyData> node : entry.getValue()) {
-        ModuleOrderEntry dependency = myProjectStructureHelper.findIdeModuleDependency(module.getName(), node.getData().getName(), project);
-        if (dependency != null) {
-          dependencies.add(dependency);
-        }
-      }
-      removeData(dependencies, module, synchronous);
-    } 
-  }
 }
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ProjectDataManager.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ProjectDataManager.java
index bf97f97..cd267e1 100644
--- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ProjectDataManager.java
+++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ProjectDataManager.java
@@ -21,7 +21,9 @@
 import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.NotNullLazyValue;
+import com.intellij.util.containers.ContainerUtil;
 import com.intellij.util.containers.ContainerUtilRt;
+import com.intellij.util.containers.Stack;
 import org.jetbrains.annotations.NotNull;
 
 import java.util.Collection;
@@ -38,21 +40,21 @@
 
   private static final Logger LOG = Logger.getInstance("#" + ProjectDataManager.class.getName());
 
-  @NotNull private final NotNullLazyValue<Map<Key<?>, List<ProjectDataService<?>>>> myServices =
-    new NotNullLazyValue<Map<Key<?>, List<ProjectDataService<?>>>>() {
+  @NotNull private final NotNullLazyValue<Map<Key<?>, List<ProjectDataService<?, ?>>>> myServices =
+    new NotNullLazyValue<Map<Key<?>, List<ProjectDataService<?, ?>>>>() {
       @NotNull
       @Override
-      protected Map<Key<?>, List<ProjectDataService<?>>> compute() {
-        Map<Key<?>, List<ProjectDataService<?>>> result = ContainerUtilRt.newHashMap();
-        for (ProjectDataService<?> service : ProjectDataService.EP_NAME.getExtensions()) {
-          List<ProjectDataService<?>> services = result.get(service.getTargetDataKey());
+      protected Map<Key<?>, List<ProjectDataService<?, ?>>> compute() {
+        Map<Key<?>, List<ProjectDataService<?, ?>>> result = ContainerUtilRt.newHashMap();
+        for (ProjectDataService<?, ?> service : ProjectDataService.EP_NAME.getExtensions()) {
+          List<ProjectDataService<?, ?>> services = result.get(service.getTargetDataKey());
           if (services == null) {
             result.put(service.getTargetDataKey(), services = ContainerUtilRt.newArrayList());
           }
           services.add(service);
         }
 
-        for (List<ProjectDataService<?>> services : result.values()) {
+        for (List<ProjectDataService<?, ?>> services : result.values()) {
           ExternalSystemApiUtil.orderAwareSort(services);
         }
 
@@ -75,7 +77,8 @@
 
   @SuppressWarnings("unchecked")
   public <T> void importData(@NotNull Key<T> key, @NotNull Collection<DataNode<T>> nodes, @NotNull Project project, boolean synchronous) {
-    List<ProjectDataService<?>> services = myServices.getValue().get(key);
+    ensureTheDataIsReadyToUse(nodes);
+    List<ProjectDataService<?, ?>> services = myServices.getValue().get(key);
     if (services == null) {
       LOG.warn(String.format(
         "Can't import data nodes '%s'. Reason: no service is registered for key %s. Available services for %s",
@@ -83,8 +86,8 @@
       ));
     }
     else {
-      for (ProjectDataService<?> service : services) {
-        ((ProjectDataService<T>)service).importData(nodes, project, synchronous);
+      for (ProjectDataService<?, ?> service : services) {
+        ((ProjectDataService<T, ?>)service).importData(nodes, project, synchronous);
       }
     }
 
@@ -94,4 +97,31 @@
     }
     importData(children, project, synchronous);
   }
+
+  @SuppressWarnings("unchecked")
+  private <T> void ensureTheDataIsReadyToUse(@NotNull Collection<DataNode<T>> nodes) {
+    Map<Key<?>, List<ProjectDataService<?, ?>>> servicesByKey = myServices.getValue();
+    Stack<DataNode<T>> toProcess = ContainerUtil.newStack(nodes);
+    while (!toProcess.isEmpty()) {
+      DataNode<T> node = toProcess.pop();
+      List<ProjectDataService<?, ?>> services = servicesByKey.get(node.getKey());
+      if (services != null) {
+        for (ProjectDataService<?, ?> service : services) {
+          node.prepareData(service.getClass().getClassLoader());
+        }
+      }
+
+      for (DataNode<?> dataNode : node.getChildren()) {
+        toProcess.push((DataNode<T>)dataNode);
+      }
+    }
+  }
+
+  @SuppressWarnings("unchecked")
+  public <T> void removeData(@NotNull Key<?> key, @NotNull Collection<T> toRemove, @NotNull Project project, boolean synchronous) {
+    List<ProjectDataService<?, ?>> services = myServices.getValue().get(key);
+    for (ProjectDataService<?, ?> service : services) {
+      ((ProjectDataService<?, T>)service).removeData(toRemove, project, synchronous);
+    }
+  }
 }
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ProjectDataServiceImpl.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ProjectDataServiceImpl.java
index 3ba386b..2ac35ab 100644
--- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ProjectDataServiceImpl.java
+++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/service/project/manage/ProjectDataServiceImpl.java
@@ -34,7 +34,7 @@
  * @since 2/21/13 2:40 PM
  */
 @Order(ExternalSystemConstants.BUILTIN_SERVICE_ORDER)
-public class ProjectDataServiceImpl implements ProjectDataService<ProjectData> {
+public class ProjectDataServiceImpl implements ProjectDataService<ProjectData, Project> {
 
   @NotNull
   @Override
@@ -57,7 +57,7 @@
   }
 
   @Override
-  public void removeData(@NotNull Collection<DataNode<ProjectData>> toRemove, @NotNull Project project, boolean synchronous) {
+  public void removeData(@NotNull Collection<? extends Project> toRemove, @NotNull Project project, boolean synchronous) {
   }
 
   @SuppressWarnings("MethodMayBeStatic")
diff --git a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/util/ExternalSystemUtil.java b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/util/ExternalSystemUtil.java
index 30f0d69..abf7666 100644
--- a/platform/external-system-impl/src/com/intellij/openapi/externalSystem/util/ExternalSystemUtil.java
+++ b/platform/external-system-impl/src/com/intellij/openapi/externalSystem/util/ExternalSystemUtil.java
@@ -31,6 +31,7 @@
 import com.intellij.openapi.externalSystem.model.task.ExternalSystemResolveProjectTask;
 import com.intellij.openapi.externalSystem.service.project.ExternalProjectRefreshCallback;
 import com.intellij.openapi.externalSystem.service.project.PlatformFacade;
+import com.intellij.openapi.externalSystem.service.project.manage.ModuleDataService;
 import com.intellij.openapi.externalSystem.service.project.manage.ProjectDataManager;
 import com.intellij.openapi.externalSystem.settings.AbstractExternalSystemSettings;
 import com.intellij.openapi.externalSystem.settings.ExternalProjectSettings;
@@ -39,17 +40,23 @@
 import com.intellij.openapi.progress.ProgressManager;
 import com.intellij.openapi.progress.Task;
 import com.intellij.openapi.project.Project;
+import com.intellij.openapi.ui.DialogWrapper;
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.openapi.wm.ToolWindow;
 import com.intellij.openapi.wm.ToolWindowManager;
+import com.intellij.ui.CheckBoxList;
+import com.intellij.ui.components.JBScrollPane;
 import com.intellij.ui.content.Content;
 import com.intellij.ui.content.ContentManager;
+import com.intellij.util.Function;
 import com.intellij.util.containers.ContainerUtilRt;
 import com.intellij.util.ui.UIUtil;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
 import javax.swing.*;
+import java.awt.*;
+import java.io.File;
 import java.io.PrintWriter;
 import java.io.StringWriter;
 import java.util.Collection;
@@ -159,20 +166,25 @@
    * @param project           target ide project
    * @param externalSystemId  target external system which projects should be refreshed
    */
-  public static void refreshProjects(@NotNull final Project project, @NotNull ProjectSystemId externalSystemId) {
+  public static void refreshProjects(@NotNull final Project project, @NotNull final ProjectSystemId externalSystemId) {
     ExternalSystemManager<?,?,?,?,?> manager = ExternalSystemApiUtil.getManager(externalSystemId);
     if (manager == null) {
       return;
     }
     AbstractExternalSystemSettings<?, ?> settings = manager.getSettingsProvider().fun(project);
-    Collection<? extends ExternalProjectSettings> projectsSettings = settings.getLinkedProjectsSettings();
+    final Collection<? extends ExternalProjectSettings> projectsSettings = settings.getLinkedProjectsSettings();
     if (projectsSettings.isEmpty()) {
       return;
     }
 
     final ProjectDataManager projectDataManager = ServiceManager.getService(ProjectDataManager.class);
-    final Set<String> externalModuleNames = ContainerUtilRt.newHashSet();
+    
     ExternalProjectRefreshCallback callback = new ExternalProjectRefreshCallback() {
+
+      @NotNull
+      private final Set<String> myExternalModuleNames = ContainerUtilRt.newHashSet();
+      private int myCounter = projectsSettings.size();
+      
       @Override
       public void onSuccess(@Nullable DataNode<ProjectData> externalProject) {
         if (externalProject == null) {
@@ -180,29 +192,103 @@
         }
         Collection<DataNode<ModuleData>> moduleNodes = ExternalSystemApiUtil.findAll(externalProject, ProjectKeys.MODULE);
         for (DataNode<ModuleData> node : moduleNodes) {
-          externalModuleNames.add(node.getData().getName());
+          myExternalModuleNames.add(node.getData().getName());
         }
         projectDataManager.importData(externalProject.getKey(), Collections.singleton(externalProject), project, false);
+        if (--myCounter <= 0) {
+          processOrphanModules();
+        }
       }
 
       @Override
       public void onFailure(@NotNull String errorMessage, @Nullable String errorDetails) {
+        if (--myCounter <= 0) {
+          processOrphanModules();
+        }
+      }
+
+      private void processOrphanModules() {
+        PlatformFacade platformFacade = ServiceManager.getService(PlatformFacade.class);
+        List<Module> orphanIdeModules = ContainerUtilRt.newArrayList();
+        String externalSystemIdAsString = externalSystemId.toString();
+
+        for (Module module : platformFacade.getModules(project)) {
+          String s = module.getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_ID_KEY);
+          if (externalSystemIdAsString.equals(s) && !myExternalModuleNames.contains(module.getName())) {
+            orphanIdeModules.add(module);
+          }
+        }
+        
+        if (!orphanIdeModules.isEmpty()) {
+          ruleOrphanModules(orphanIdeModules, project, externalSystemId);
+        }
       }
     };
     for (ExternalProjectSettings setting : projectsSettings) {
       refreshProject(project, externalSystemId, setting.getExternalProjectPath(), callback, true, false);
     }
-    PlatformFacade platformFacade = ServiceManager.getService(PlatformFacade.class);
-    List<Module> orphanIdeModules = ContainerUtilRt.newArrayList();
-    String externalSystemIdAsString = externalSystemId.toString();
-    for (Module module : platformFacade.getModules(project)) {
-      String s = module.getOptionValue(ExternalSystemConstants.EXTERNAL_SYSTEM_ID_KEY);
-      if (externalSystemIdAsString.equals(s) && !externalModuleNames.contains(module.getName())) {
-        orphanIdeModules.add(module);
+  }
+
+  private static void ruleOrphanModules(@NotNull final List<Module> orphanModules,
+                                        @NotNull final Project project,
+                                        @NotNull final ProjectSystemId externalSystemId)
+  {
+    UIUtil.invokeLaterIfNeeded(new Runnable() {
+      @Override
+      public void run() {
+        final String externalSystem = ExternalSystemApiUtil.toReadableName(externalSystemId);
+        
+        final JPanel content = new JPanel(new GridBagLayout());
+        content.add(new JLabel(ExternalSystemBundle.message("orphan.modules.text", externalSystem)),
+                    ExternalSystemUiUtil.getFillLineConstraints(0));
+        
+        final CheckBoxList<Module> orphanModulesList = new CheckBoxList<Module>();
+        orphanModulesList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
+        orphanModulesList.setItems(orphanModules, new Function<Module, String>() {
+          @Override
+          public String fun(Module module) {
+            return module.getName();
+          }
+        });
+        for (Module module : orphanModules) {
+          orphanModulesList.setItemSelected(module, true);
+        }
+        content.add(orphanModulesList, ExternalSystemUiUtil.getFillLineConstraints(0));
+        
+        DialogWrapper dialog = new DialogWrapper(project) {
+
+          {
+            setTitle(ExternalSystemBundle.message("import.title", externalSystem));
+            init();
+          }
+          
+          @Nullable
+          @Override
+          protected JComponent createCenterPanel() {
+            return new JBScrollPane(content);
+          }
+        };
+        boolean ok = dialog.showAndGet();
+        if (!ok) {
+          return;
+        }
+        
+        List<Module> toRemove = ContainerUtilRt.newArrayList();
+        for (int i = 0; i < orphanModules.size(); i++) {
+          Module module = orphanModules.get(i);
+          if (orphanModulesList.isItemSelected(i)) {
+            toRemove.add(module);
+          }
+          else {
+            ModuleDataService.unlinkModuleFromExternalSystem(module);
+          }
+        }
+
+        if (!toRemove.isEmpty()) {
+          ServiceManager.getService(ProjectDataManager.class).removeData(ProjectKeys.MODULE, toRemove, project, true);
+        }
       }
-    }
-    
-    // TODO den offer to remove orphan modules here
+    });
   }
 
   @SuppressWarnings("ThrowableResultOfMethodCallIgnored")
@@ -267,8 +353,11 @@
     UIUtil.invokeAndWaitIfNeeded(new Runnable() {
       @Override
       public void run() {
+        final String projectName = new File(externalProjectPath).getParentFile().getName();
         if (modal) {
-          String title = ExternalSystemBundle.message("progress.import.text", ExternalSystemApiUtil.toReadableName(externalSystemId));
+          String title = ExternalSystemBundle.message("progress.import.text",
+                                                      projectName,
+                                                      ExternalSystemApiUtil.toReadableName(externalSystemId));
           ProgressManager.getInstance().run(new Task.Modal(project, title, false) {
             @Override
             public void run(@NotNull ProgressIndicator indicator) {
@@ -280,7 +369,8 @@
           });
         }
         else {
-          String title = ExternalSystemBundle.message("progress.refresh.text", ExternalSystemApiUtil.toReadableName(externalSystemId));
+          String title = ExternalSystemBundle.message("progress.refresh.text",
+                                                      projectName, ExternalSystemApiUtil.toReadableName(externalSystemId));
           ProgressManager.getInstance().run(new Task.Backgroundable(project, title) {
             @Override
             public void run(@NotNull ProgressIndicator indicator) {
diff --git a/platform/lang-api/src/com/intellij/codeInspection/LocalQuickFixAndIntentionActionOnPsiElement.java b/platform/lang-api/src/com/intellij/codeInspection/LocalQuickFixAndIntentionActionOnPsiElement.java
index f021380..78bed6f 100644
--- a/platform/lang-api/src/com/intellij/codeInspection/LocalQuickFixAndIntentionActionOnPsiElement.java
+++ b/platform/lang-api/src/com/intellij/codeInspection/LocalQuickFixAndIntentionActionOnPsiElement.java
@@ -16,46 +16,20 @@
 package com.intellij.codeInspection;
 
 import com.intellij.codeInsight.intention.IntentionAction;
-import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.project.Project;
 import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiFile;
-import com.intellij.psi.SmartPointerManager;
-import com.intellij.psi.SmartPsiElementPointer;
 import com.intellij.util.IncorrectOperationException;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
-public abstract class LocalQuickFixAndIntentionActionOnPsiElement implements LocalQuickFix, IntentionAction {
-  private static final Logger LOG = Logger.getInstance("#com.intellij.codeInspection.LocalQuickFixAndIntentionAction");
-  private final SmartPsiElementPointer<PsiElement> myStartElement;
-  private final SmartPsiElementPointer<PsiElement> myEndElement;
-
+public abstract class LocalQuickFixAndIntentionActionOnPsiElement extends LocalQuickFixOnPsiElement implements IntentionAction {
   protected LocalQuickFixAndIntentionActionOnPsiElement(@Nullable PsiElement element) {
     this(element, element);
   }
   protected LocalQuickFixAndIntentionActionOnPsiElement(@Nullable PsiElement startElement, @Nullable PsiElement endElement) {
-    if (startElement == null || endElement == null) {
-      myStartElement = myEndElement = null;
-      return;
-    }
-    LOG.assertTrue(startElement.isValid());
-    PsiFile startContainingFile = startElement.getContainingFile();
-    PsiFile endContainingFile = startElement == endElement ? startContainingFile : endElement.getContainingFile();
-    if (startElement != endElement) {
-      LOG.assertTrue(endElement.isValid());
-      LOG.assertTrue(startContainingFile == endContainingFile, "Both elements must be from the same file");
-    }
-    Project project = startContainingFile == null ? startElement.getProject() : startContainingFile.getProject(); // containingFile can be null for a directory
-    myStartElement = SmartPointerManager.getInstance(project).createSmartPsiElementPointer(startElement, startContainingFile);
-    myEndElement = endElement == startElement ? null : SmartPointerManager.getInstance(project).createSmartPsiElementPointer(endElement, endContainingFile);
-  }
-
-  @NotNull
-  @Override
-  public final String getName() {
-    return getText();
+    super(startElement, endElement);
   }
 
   @Override
@@ -68,17 +42,6 @@
   }
 
   @Override
-  public final void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
-    if (myStartElement == null) return;
-    final PsiElement startElement = myStartElement.getElement();
-    final PsiElement endElement = myEndElement == null ? startElement : myEndElement.getElement();
-    if (startElement == null || endElement == null) return;
-    PsiFile file = startElement.getContainingFile();
-    if (file == null) return;
-    invoke(project, file, null, startElement, endElement);
-  }
-
-  @Override
   public final boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
     if (myStartElement == null) return false;
     final PsiElement startElement = myStartElement.getElement();
@@ -91,17 +54,6 @@
            isAvailable(project, file, startElement, endElement);
   }
 
-  public boolean isAvailable(@NotNull Project project,
-                             @NotNull PsiFile file,
-                             @NotNull PsiElement startElement,
-                             @NotNull PsiElement endElement) {
-    return true;
-  }
-
-  public PsiElement getStartElement() {
-    return myStartElement == null ? null : myStartElement.getElement();
-  }
-
   public abstract void invoke(@NotNull Project project,
                               @NotNull PsiFile file,
                               @Nullable("is null when called from inspection") Editor editor,
@@ -109,6 +61,11 @@
                               @NotNull PsiElement endElement);
 
   @Override
+  public void invoke(@NotNull Project project, @NotNull PsiFile file, @NotNull PsiElement startElement, @NotNull PsiElement endElement) {
+    invoke(project, file, null, startElement, endElement);
+  }
+
+  @Override
   public boolean startInWriteAction() {
     return true;
   }
diff --git a/platform/lang-api/src/com/intellij/codeInspection/LocalQuickFixAsIntentionAdapter.java b/platform/lang-api/src/com/intellij/codeInspection/LocalQuickFixAsIntentionAdapter.java
new file mode 100644
index 0000000..42763f9
--- /dev/null
+++ b/platform/lang-api/src/com/intellij/codeInspection/LocalQuickFixAsIntentionAdapter.java
@@ -0,0 +1,61 @@
+/*
+ * Copyright 2000-2013 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.codeInspection;
+
+import com.intellij.codeInsight.intention.IntentionAction;
+import com.intellij.openapi.editor.Editor;
+import com.intellij.openapi.project.Project;
+import com.intellij.psi.PsiFile;
+import com.intellij.util.IncorrectOperationException;
+import org.jetbrains.annotations.NotNull;
+
+public class LocalQuickFixAsIntentionAdapter implements IntentionAction {
+  private final LocalQuickFix myFix;
+  @NotNull private final ProblemDescriptor myProblemDescriptor;
+
+  public LocalQuickFixAsIntentionAdapter(@NotNull LocalQuickFix fix, @NotNull ProblemDescriptor problemDescriptor) {
+    myFix = fix;
+    myProblemDescriptor = problemDescriptor;
+  }
+
+  @NotNull
+  @Override
+  public String getText() {
+    return myFix.getName();
+  }
+
+  @NotNull
+  @Override
+  public String getFamilyName() {
+    return myFix.getFamilyName();
+  }
+
+  @Override
+  public boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
+    return myProblemDescriptor.getStartElement() != null;
+  }
+
+  @Override
+  public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
+    myFix.applyFix(project, myProblemDescriptor);
+  }
+
+  @Override
+  public boolean startInWriteAction() {
+    return true;
+  }
+}
+
diff --git a/platform/lang-api/src/com/intellij/codeInspection/SuppressIntentionAction.java b/platform/lang-api/src/com/intellij/codeInspection/SuppressIntentionAction.java
index a216766..204b9f3 100644
--- a/platform/lang-api/src/com/intellij/codeInspection/SuppressIntentionAction.java
+++ b/platform/lang-api/src/com/intellij/codeInspection/SuppressIntentionAction.java
@@ -20,16 +20,95 @@
  */
 package com.intellij.codeInspection;
 
-import com.intellij.codeInsight.intention.PsiElementBaseIntentionAction;
+import com.intellij.codeInsight.intention.IntentionAction;
 import com.intellij.icons.AllIcons;
+import com.intellij.openapi.editor.CaretModel;
+import com.intellij.openapi.editor.Editor;
+import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.Iconable;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.PsiFile;
+import com.intellij.psi.PsiManager;
+import com.intellij.util.IncorrectOperationException;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
 
 import javax.swing.*;
 
-public abstract class SuppressIntentionAction extends PsiElementBaseIntentionAction implements Iconable {
+public abstract class SuppressIntentionAction implements Iconable, IntentionAction {
+  private String myText = "";
   public static SuppressIntentionAction[] EMPTY_ARRAY = new SuppressIntentionAction[0];
+
   @Override
   public Icon getIcon(int flags) {
     return AllIcons.General.InspectionsOff;
   }
+
+  @Override
+  @NotNull
+  public String getText() {
+    return myText;
+  }
+
+  protected void setText(@NotNull String text) {
+    myText = text;
+  }
+
+  @Override
+  public boolean startInWriteAction() {
+    return true;
+  }
+
+  @Override
+  public String toString() {
+    return getText();
+  }
+
+  @Override
+  public final void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
+    if (!file.getManager().isInProject(file)) return;
+    final PsiElement element = getElement(editor, file);
+    if (element != null) {
+      invoke(project, editor, element);
+    }
+  }
+
+  /**
+   * Invokes intention action for the element under caret.
+   *
+   * @param project the project in which the file is opened.
+   * @param editor  the editor for the file.
+   * @param element the element under cursor.
+   * @throws com.intellij.util.IncorrectOperationException
+   *
+   */
+  public abstract void invoke(@NotNull Project project, Editor editor, @NotNull PsiElement element) throws IncorrectOperationException;
+
+  @Override
+  public final boolean isAvailable(@NotNull Project project, Editor editor, PsiFile file) {
+    if (file == null) return false;
+    final PsiManager manager = file.getManager();
+    if (manager == null) return false;
+    if (!manager.isInProject(file)) return false;
+    final PsiElement element = getElement(editor, file);
+    return element != null && isAvailable(project, editor, element);
+  }
+
+  /**
+   * Checks whether this intention is available at a caret offset in file.
+   * If this method returns true, a light bulb for this intention is shown.
+   *
+   * @param project the project in which the availability is checked.
+   * @param editor  the editor in which the intention will be invoked.
+   * @param element the element under caret.
+   * @return true if the intention is available, false otherwise.
+   */
+  public abstract boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement element);
+
+  @Nullable
+  private static PsiElement getElement(@NotNull Editor editor, @NotNull PsiFile file) {
+    CaretModel caretModel = editor.getCaretModel();
+    int position = caretModel.getOffset();
+    return file.findElementAt(position);
+  }
 }
diff --git a/platform/lang-api/src/com/intellij/ide/util/projectWizard/WizardContext.java b/platform/lang-api/src/com/intellij/ide/util/projectWizard/WizardContext.java
index 9322cc6..71347be 100644
--- a/platform/lang-api/src/com/intellij/ide/util/projectWizard/WizardContext.java
+++ b/platform/lang-api/src/com/intellij/ide/util/projectWizard/WizardContext.java
@@ -23,7 +23,7 @@
 import com.intellij.openapi.projectRoots.Sdk;
 import com.intellij.openapi.roots.ProjectRootManager;
 import com.intellij.openapi.util.IconLoader;
-import com.intellij.openapi.util.NotNullLazyValue;
+import com.intellij.openapi.util.UserDataHolderBase;
 import com.intellij.util.SystemProperties;
 import com.intellij.util.containers.ContainerUtil;
 import org.jetbrains.annotations.NotNull;
@@ -33,7 +33,7 @@
 import java.io.File;
 import java.util.List;
 
-public class WizardContext {
+public class WizardContext extends UserDataHolderBase {
   private static final Icon NEW_PROJECT_ICON = IconLoader.getIcon("/newprojectwizard.png");
   private static final Icon NEW_MODULE_ICON = IconLoader.getIcon("/addmodulewizard.png");
   /**
@@ -49,17 +49,6 @@
   private final List<Listener> myListeners = ContainerUtil.createLockFreeCopyOnWriteList();
   private StorageScheme myProjectStorageFormat = StorageScheme.DIRECTORY_BASED;
 
-  private final NotNullLazyValue<ModuleBuilder[]> myAllBuilders = new NotNullLazyValue<ModuleBuilder[]>() {
-    @NotNull
-    @Override
-    protected ModuleBuilder[] compute() {
-      List<ModuleBuilder> builders = ModuleBuilder.getAllBuilders();
-      return builders.toArray(new ModuleBuilder[builders.size()]);
-    }
-  };
-
-  private ModuleWizardStep myProjectSdkStep;
-
   public void setProjectStorageFormat(StorageScheme format) {
     myProjectStorageFormat = format;
   }
@@ -81,14 +70,6 @@
     return myProject;
   }
 
-  public ModuleWizardStep getProjectSdkStep() {
-    return myProjectSdkStep;
-  }
-
-  public void setProjectSdkStep(ModuleWizardStep projectSdkStep) {
-    myProjectSdkStep = projectSdkStep;
-  }
-
   @NotNull
   public String getProjectFileDirectory() {
     if (myProjectFileDirectory != null) {
@@ -180,8 +161,4 @@
   public StorageScheme getProjectStorageFormat() {
     return myProjectStorageFormat;
   }
-
-  public ModuleBuilder[] getAllBuilders() {
-    return myAllBuilders.getValue();
-  }
 }
diff --git a/platform/lang-api/src/com/intellij/lang/annotation/Annotation.java b/platform/lang-api/src/com/intellij/lang/annotation/Annotation.java
index ceaf70e..33e28f9 100644
--- a/platform/lang-api/src/com/intellij/lang/annotation/Annotation.java
+++ b/platform/lang-api/src/com/intellij/lang/annotation/Annotation.java
@@ -17,8 +17,7 @@
 
 import com.intellij.codeInsight.daemon.HighlightDisplayKey;
 import com.intellij.codeInsight.intention.IntentionAction;
-import com.intellij.codeInspection.LocalQuickFix;
-import com.intellij.codeInspection.ProblemHighlightType;
+import com.intellij.codeInspection.*;
 import com.intellij.openapi.editor.HighlighterColors;
 import com.intellij.openapi.editor.colors.CodeInsightColors;
 import com.intellij.openapi.editor.colors.TextAttributesKey;
@@ -75,7 +74,7 @@
       this.options = options;
     }
 
-    public QuickFixInfo(final IntentionAction fix, final TextRange range, @Nullable final HighlightDisplayKey key) {
+    public QuickFixInfo(@NotNull IntentionAction fix, final TextRange range, @Nullable final HighlightDisplayKey key) {
       this.key = key;
       quickFix = fix;
       textRange = range;
@@ -123,6 +122,16 @@
     registerFix(fix,range, null);
   }
 
+  public void registerFix(@NotNull LocalQuickFix fix, TextRange range, HighlightDisplayKey key, @NotNull ProblemDescriptor problemDescriptor) {
+    if (range == null) {
+      range = new TextRange(myStartOffset, myEndOffset);
+    }
+    if (myQuickFixes == null) {
+      myQuickFixes = new ArrayList<QuickFixInfo>();
+    }
+    myQuickFixes.add(new QuickFixInfo(new LocalQuickFixAsIntentionAdapter(fix, problemDescriptor), range, key));
+  }
+
   /**
    * Registers a quick fix for the annotation which is only available on a particular range of text
    * within the annotation.
@@ -159,8 +168,8 @@
   }
 
   /**
-   * Registers a quickfix which would be available during batch mode only, 
-   * in particular during com.intellij.codeInspection.DefaultHighlightVisitorBasedInspection run 
+   * Registers a quickfix which would be available during batch mode only,
+   * in particular during com.intellij.codeInspection.DefaultHighlightVisitorBasedInspection run
    */
   public <T extends IntentionAction & LocalQuickFix> void registerBatchFix(@NotNull T fix, @Nullable TextRange range, @Nullable final HighlightDisplayKey key) {
     if (range == null) {
@@ -302,7 +311,7 @@
   public List<QuickFixInfo> getQuickFixes() {
     return myQuickFixes;
   }
-  
+
   @Nullable
   public List<QuickFixInfo> getBatchFixes() {
     return myBatchFixes;
diff --git a/platform/lang-impl/src/com/intellij/application/options/editor/EditorOptionsPanel.form b/platform/lang-impl/src/com/intellij/application/options/editor/EditorOptionsPanel.form
index 4beef3e..79d4149 100644
--- a/platform/lang-impl/src/com/intellij/application/options/editor/EditorOptionsPanel.form
+++ b/platform/lang-impl/src/com/intellij/application/options/editor/EditorOptionsPanel.form
@@ -304,7 +304,7 @@
                   </component>
                 </children>
               </grid>
-              <grid id="7f3f5" layout-manager="GridLayoutManager" row-count="4" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
+              <grid id="7f3f5" layout-manager="GridLayoutManager" row-count="5" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
                 <margin top="0" left="0" bottom="0" right="0"/>
                 <constraints>
                   <grid row="4" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
@@ -339,7 +339,7 @@
                   </component>
                   <component id="ce8e2" class="com.intellij.ui.components.JBCheckBox" binding="myCbShowQuickDocOnMouseMove">
                     <constraints>
-                      <grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
+                      <grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
                     </constraints>
                     <properties>
                       <text value="Show quick doc on mouse move"/>
@@ -366,9 +366,17 @@
                   </component>
                   <vspacer id="612dd">
                     <constraints>
-                      <grid row="3" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
+                      <grid row="4" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
                     </constraints>
                   </vspacer>
+                  <component id="2de1c" class="com.intellij.ui.components.JBCheckBox" binding="myCbShowIntentionBulb">
+                    <constraints>
+                      <grid row="3" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
+                    </constraints>
+                    <properties>
+                      <text value="Show intention bulb"/>
+                    </properties>
+                  </component>
                 </children>
               </grid>
               <grid id="5df80" binding="myHighlightSettingsPanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
diff --git a/platform/lang-impl/src/com/intellij/application/options/editor/EditorOptionsPanel.java b/platform/lang-impl/src/com/intellij/application/options/editor/EditorOptionsPanel.java
index 6d78682..a925251 100644
--- a/platform/lang-impl/src/com/intellij/application/options/editor/EditorOptionsPanel.java
+++ b/platform/lang-impl/src/com/intellij/application/options/editor/EditorOptionsPanel.java
@@ -91,6 +91,7 @@
   private JBCheckBox   myCbShowQuickDocOnMouseMove;
   private JBLabel      myQuickDocDelayLabel;
   private JTextField   myQuickDocDelayTextField;
+  private JBCheckBox   myCbShowIntentionBulb;
 
   private final ErrorHighlightingPanel myErrorHighlightingPanel = new ErrorHighlightingPanel();
   private final MyConfigurable myConfigurable;
@@ -169,6 +170,7 @@
     myQuickDocDelayTextField.setText(Long.toString(editorSettings.getQuickDocOnMouseOverElementDelayMillis()));
     myQuickDocDelayTextField.setEnabled(editorSettings.isShowQuickDocOnMouseOverElement());
     myQuickDocDelayLabel.setEnabled(editorSettings.isShowQuickDocOnMouseOverElement());
+    myCbShowIntentionBulb.setSelected(editorSettings.isShowIntentionBulb());
 
     // Advanced mouse
     myCbEnableDnD.setSelected(editorSettings.isDndEnabled());
@@ -258,6 +260,8 @@
     if (quickDocDelay != null) {
       editorSettings.setQuickDocOnMouseOverElementDelayMillis(quickDocDelay);
     }
+    
+    editorSettings.setShowIntentionBulb(myCbShowIntentionBulb.isSelected());
 
     editorSettings.setDndEnabled(myCbEnableDnD.isSelected());
 
@@ -389,6 +393,8 @@
       return true;
     }
 
+    isModified |= isModified(myCbShowIntentionBulb, editorSettings.isShowIntentionBulb());
+
     // advanced mouse
     isModified |= isModified(myCbEnableDnD, editorSettings.isDndEnabled());
     isModified |= isModified(myCbEnableWheelFontChange, editorSettings.isWheelFontChangeEnabled());
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java
index 9c6db05..33a8cee 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/DaemonCodeAnalyzerImpl.java
@@ -667,6 +667,9 @@
                             @NotNull Editor editor,
                             @NotNull ShowIntentionsPass.IntentionsInfo intentions,
                             boolean hasToRecreate) {
+    if (!editor.getSettings().isShowIntentionBulb()) {
+      return;
+    }
     ApplicationManager.getApplication().assertIsDispatchThread();
     hideLastIntentionHint();
     IntentionHintComponent hintComponent = IntentionHintComponent.showIntentionHint(project, file, editor, intentions, false);
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfo.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfo.java
index 6d11839..a938b73 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfo.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/HighlightInfo.java
@@ -22,9 +22,7 @@
 import com.intellij.codeInsight.intention.IntentionManager;
 import com.intellij.codeInspection.*;
 import com.intellij.codeInspection.actions.CleanupInspectionIntention;
-import com.intellij.codeInspection.ex.GlobalInspectionToolWrapper;
-import com.intellij.codeInspection.ex.LocalInspectionToolWrapper;
-import com.intellij.codeInspection.ex.QuickFixWrapper;
+import com.intellij.codeInspection.ex.*;
 import com.intellij.lang.ASTNode;
 import com.intellij.lang.annotation.Annotation;
 import com.intellij.lang.annotation.HighlightSeverity;
@@ -48,6 +46,7 @@
 import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiFile;
 import com.intellij.util.ArrayUtilRt;
+import com.intellij.util.Function;
 import com.intellij.util.containers.ContainerUtil;
 import com.intellij.xml.util.XmlStringUtil;
 import org.intellij.lang.annotations.MagicConstant;
@@ -727,11 +726,18 @@
       this(action, null, null, icon);
     }
 
-    public IntentionActionDescriptor(@NotNull IntentionAction action, @Nullable final List<IntentionAction> options, @Nullable final String displayName, @Nullable Icon icon) {
+    public IntentionActionDescriptor(@NotNull IntentionAction action,
+                                     @Nullable final List<IntentionAction> options,
+                                     @Nullable final String displayName,
+                                     @Nullable Icon icon) {
       this(action, options, displayName, icon, null);
     }
 
-    public IntentionActionDescriptor(@NotNull IntentionAction action, @Nullable final List<IntentionAction> options, @Nullable final String displayName, @Nullable Icon icon, @Nullable HighlightDisplayKey key) {
+    public IntentionActionDescriptor(@NotNull IntentionAction action,
+                                     @Nullable final List<IntentionAction> options,
+                                     @Nullable final String displayName,
+                                     @Nullable Icon icon,
+                                     @Nullable HighlightDisplayKey key) {
       myAction = action;
       myOptions = options;
       myDisplayName = displayName;
@@ -788,6 +794,15 @@
           ContainerUtil.addAll(newOptions, suppressActions);
         }
       }
+      if (wrappedTool instanceof BatchSuppressableTool) {
+        final SuppressQuickFix[] suppressActions = ((BatchSuppressableTool)wrappedTool).getBatchSuppressActions(element);
+        ContainerUtil.addAll(newOptions, ContainerUtil.map(suppressActions, new Function<SuppressQuickFix, IntentionAction>() {
+          @Override
+          public IntentionAction fun(SuppressQuickFix fix) {
+            return InspectionManagerEx.convertBatchToSuppressIntentionAction(fix);
+          }
+        }));
+      }
 
       synchronized (this) {
         options = myOptions;
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/actions/AbstractSuppressByNoInspectionCommentFix.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/actions/AbstractSuppressByNoInspectionCommentFix.java
index 89ab516..214c3ca 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/actions/AbstractSuppressByNoInspectionCommentFix.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/impl/actions/AbstractSuppressByNoInspectionCommentFix.java
@@ -16,20 +16,18 @@
 
 package com.intellij.codeInsight.daemon.impl.actions;
 
-import com.google.common.base.Strings;
 import com.intellij.codeInsight.FileModificationService;
 import com.intellij.codeInspection.InspectionsBundle;
 import com.intellij.codeInspection.SuppressIntentionAction;
 import com.intellij.codeInspection.SuppressionUtil;
-import com.intellij.lang.Commenter;
-import com.intellij.lang.LanguageCommenters;
+import com.intellij.lang.Language;
+import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.command.undo.UndoUtil;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.Pair;
+import com.intellij.openapi.ui.Messages;
 import com.intellij.psi.PsiComment;
 import com.intellij.psi.PsiElement;
-import com.intellij.psi.PsiParserFacade;
 import com.intellij.psi.PsiWhiteSpace;
 import com.intellij.psi.util.PsiTreeUtil;
 import com.intellij.util.IncorrectOperationException;
@@ -44,7 +42,7 @@
  * @date Aug 13, 2009
  */
 public abstract class AbstractSuppressByNoInspectionCommentFix extends SuppressIntentionAction {
-  protected final String myID;
+  @NotNull protected final String myID;
   private final boolean myReplaceOtherSuppressionIds;
 
   @Nullable
@@ -55,71 +53,29 @@
    * @param replaceOtherSuppressionIds Merge suppression policy. If false new tool id will be append to the end
    *                                   otherwise replace other ids
    */
-  public AbstractSuppressByNoInspectionCommentFix(final String ID, final boolean replaceOtherSuppressionIds) {
+  public AbstractSuppressByNoInspectionCommentFix(@NotNull String ID, final boolean replaceOtherSuppressionIds) {
     myID = ID;
     myReplaceOtherSuppressionIds = replaceOtherSuppressionIds;
   }
 
   protected final void replaceSuppressionComment(@NotNull final PsiElement comment) {
-    final String oldSuppressionCommentText = comment.getText();
-    final String lineCommentPrefix = getLineCommentPrefix(comment);
-    Pair<String, String> blockPrefixSuffix = null;
-    if (lineCommentPrefix == null) {
-      blockPrefixSuffix = getBlockPrefixSuffixPair(comment);
-    }
-    assert (blockPrefixSuffix != null && oldSuppressionCommentText.startsWith(blockPrefixSuffix.first)) && oldSuppressionCommentText.endsWith(blockPrefixSuffix.second)
-           || (lineCommentPrefix != null && oldSuppressionCommentText.startsWith(lineCommentPrefix))
-      : "Unexpected suppression comment " + oldSuppressionCommentText;
-
-    // append new suppression tool id or replace
-    final String newText;
-    if(myReplaceOtherSuppressionIds) {
-      newText = SuppressionUtil.SUPPRESS_INSPECTIONS_TAG_NAME + " " + myID;
-    } else {
-      if (lineCommentPrefix != null) {
-        newText = oldSuppressionCommentText.substring(lineCommentPrefix.length()) + "," + myID;
-      } else {
-        newText = oldSuppressionCommentText.substring(blockPrefixSuffix.first.length(),
-                                                      oldSuppressionCommentText.length() - blockPrefixSuffix.second.length()) + "," + myID;
-      }
-    }
-
-    PsiElement parent = comment.getParent();
-    comment.replace(createComment(comment.getProject(), parent != null ? parent : comment, newText));
+    SuppressionUtil.replaceSuppressionComment(comment, myID, myReplaceOtherSuppressionIds, getCommentLanguage(comment));
   }
 
-  @Nullable
-  private static String getLineCommentPrefix(@NotNull final PsiElement comment) {
-    final Commenter commenter = LanguageCommenters.INSTANCE.forLanguage(comment.getLanguage());
-    return commenter == null ? null : commenter.getLineCommentPrefix();
+  protected void createSuppression(@NotNull Project project,
+                                   @NotNull PsiElement element,
+                                   @NotNull PsiElement container) throws IncorrectOperationException {
+    SuppressionUtil.createSuppression(project, container, myID, getCommentLanguage(element));
   }
 
-  @Nullable
-  private static Pair<String, String> getBlockPrefixSuffixPair(PsiElement comment) {
-    final Commenter commenter = LanguageCommenters.INSTANCE.forLanguage(comment.getLanguage());
-    if (commenter != null) {
-      final String prefix = commenter.getBlockCommentPrefix();
-      final String suffix = commenter.getBlockCommentSuffix();
-      if (prefix != null || suffix != null) {
-        return Pair.create(Strings.nullToEmpty(prefix), Strings.nullToEmpty(suffix));
-      }
-    }
-    return null;
-  }
-
-  protected void createSuppression(final Project project,
-                                 final Editor editor,
-                                 final PsiElement element,
-                                 final PsiElement container) throws IncorrectOperationException {
-    final String text = SuppressionUtil.SUPPRESS_INSPECTIONS_TAG_NAME + " " + myID;
-    PsiComment comment = createComment(project, element, text);
-    container.getParent().addBefore(comment, container);
-  }
-
+  /**
+   * @param element quickfix target or existing comment element
+   * @return language that will be used for comment creating.
+   * In common case language will be the same as language of quickfix target
+   */
   @NotNull
-  protected PsiComment createComment(Project project, PsiElement element, String commentText) {
-    final PsiParserFacade parserFacade = PsiParserFacade.SERVICE.getInstance(project);
-    return parserFacade.createLineOrBlockCommentFromText(element.getLanguage(), commentText);
+  protected Language getCommentLanguage(@NotNull PsiElement element) {
+    return element.getLanguage();
   }
 
   @Override
@@ -137,7 +93,7 @@
     final List<? extends PsiElement> comments = getCommentsFor(container);
     if (comments != null) {
       for (PsiElement comment : comments) {
-        if (comment instanceof PsiComment && isSuppressionComment(comment)) {
+        if (comment instanceof PsiComment && SuppressionUtil.isSuppressionComment(comment)) {
           replaceSuppressionComment(comment);
           return;
         }
@@ -145,7 +101,15 @@
     }
 
     boolean caretWasBeforeStatement = editor != null && editor.getCaretModel().getOffset() == container.getTextRange().getStartOffset();
-    createSuppression(project, editor, element, container);
+    try {
+      createSuppression(project, element, container);
+    }
+    catch (IncorrectOperationException e) {
+      if (!ApplicationManager.getApplication().isUnitTestMode() && editor != null) {
+        Messages.showErrorDialog(editor.getComponent(),
+                                 InspectionsBundle.message("suppress.inspection.annotation.syntax.error", e.getMessage()));
+      }
+    }
 
     if (caretWasBeforeStatement) {
       editor.getCaretModel().moveToOffset(container.getTextRange().getStartOffset());
@@ -153,18 +117,6 @@
     UndoUtil.markPsiFileForUndo(element.getContainingFile());
   }
 
-  public static boolean isSuppressionComment(PsiElement comment) {
-    final String prefix = getLineCommentPrefix(comment);
-    final String commentText = comment.getText();
-    if (prefix != null) {
-      return commentText.startsWith(prefix + SuppressionUtil.SUPPRESS_INSPECTIONS_TAG_NAME);
-    }
-    final Pair<String, String> prefixSuffixPair = getBlockPrefixSuffixPair(comment);
-    return prefixSuffixPair != null
-           && commentText.startsWith(prefixSuffixPair.first + SuppressionUtil.SUPPRESS_INSPECTIONS_TAG_NAME)
-           && commentText.endsWith(prefixSuffixPair.second);
-  }
-
   @Nullable
   protected List<? extends PsiElement> getCommentsFor(@NotNull final PsiElement container) {
     final PsiElement prev = PsiTreeUtil.skipSiblingsBackward(container, PsiWhiteSpace.class);
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/quickFix/CreateFileFix.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/quickFix/CreateFileFix.java
index 964103a..4b78d86 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/quickFix/CreateFileFix.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/quickFix/CreateFileFix.java
@@ -51,7 +51,7 @@
   private final boolean myIsDirectory;
   private final String myNewFileName;
   private final String myText;
-  @NotNull private String myKey;
+  @NotNull private final String myKey;
   private boolean myIsAvailable;
   private long myIsAvailableTimeStamp;
   private static final int REFRESH_INTERVAL = 1000;
@@ -71,14 +71,11 @@
     myIsAvailableTimeStamp = System.currentTimeMillis();
   }
 
-  public CreateFileFix(final String newFileName,
-                                   @NotNull PsiDirectory directory, String text) {
-    this(false,newFileName,directory, text, "create.file.text" );
+  public CreateFileFix(@NotNull String newFileName, @NotNull PsiDirectory directory, String text) {
+    this(false,newFileName,directory, text, "create.file.text");
   }
 
-  public CreateFileFix(final boolean isDirectory,
-                                   final String newFileName,
-                                   @NotNull PsiDirectory directory) {
+  public CreateFileFix(final boolean isDirectory, @NotNull String newFileName, @NotNull PsiDirectory directory) {
     this(isDirectory,newFileName,directory,null, isDirectory ? "create.directory.text":"create.file.text" );
   }
 
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/daemon/quickFix/FileReferenceQuickFixProvider.java b/platform/lang-impl/src/com/intellij/codeInsight/daemon/quickFix/FileReferenceQuickFixProvider.java
index 58a3830..dfb53b4 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/daemon/quickFix/FileReferenceQuickFixProvider.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/daemon/quickFix/FileReferenceQuickFixProvider.java
@@ -105,7 +105,7 @@
 
     final VirtualFile virtualFile = context.getVirtualFile();
     if (virtualFile == null) return Collections.emptyList();
-    
+
     final PsiDirectory directory = context.getManager().findDirectory(virtualFile);
     if (directory == null) return Collections.emptyList();
 
@@ -147,25 +147,7 @@
       isdirectory = false;
     }
 
-    final CreateFileFix action = new CreateFileFix(isdirectory, newFileName, directory) {
-      @Override
-      protected String getFileText() {
-        if (!isdirectory) {
-          String templateName = reference.getNewFileTemplateName();
-          if (templateName != null) {
-            FileTemplate template = FileTemplateManager.getInstance().getTemplate(templateName);
-            if (template != null) {
-              try {
-                return template.getText(FileTemplateManager.getInstance().getDefaultProperties(directory.getProject()));
-              } catch (IOException ex) {
-                throw new RuntimeException(ex);
-              }
-            }
-          }
-        }
-        return super.getFileText();
-      }
-    };
+    final CreateFileFix action = new MyCreateFileFix(isdirectory, newFileName, directory, reference);
     QuickFixAction.registerQuickFixAction(info, action);
     return Arrays.asList(action);
   }
@@ -176,4 +158,35 @@
     VirtualFile file = context.getVirtualFile();
     return file != null ? ModuleUtil.findModuleForFile(file, context.getProject()) : null;
   }
+
+  private static class MyCreateFileFix extends CreateFileFix {
+    private final boolean isDirectory;
+    private final PsiDirectory myDirectory;
+    private final FileReference myReference;
+
+    public MyCreateFileFix(boolean isdirectory, String newFileName, PsiDirectory directory, FileReference reference) {
+      super(isdirectory, newFileName, directory);
+      isDirectory = isdirectory;
+      myDirectory = directory;
+      myReference = reference;
+    }
+
+    @Override
+    protected String getFileText() {
+      if (!isDirectory) {
+        String templateName = myReference.getNewFileTemplateName();
+        if (templateName != null) {
+          FileTemplate template = FileTemplateManager.getInstance().getTemplate(templateName);
+          if (template != null) {
+            try {
+              return template.getText(FileTemplateManager.getInstance().getDefaultProperties(myDirectory.getProject()));
+            } catch (IOException ex) {
+              throw new RuntimeException(ex);
+            }
+          }
+        }
+      }
+      return super.getFileText();
+    }
+  }
 }
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/SuppressionUtil.java b/platform/lang-impl/src/com/intellij/codeInspection/SuppressionUtil.java
deleted file mode 100644
index 9135d45..0000000
--- a/platform/lang-impl/src/com/intellij/codeInspection/SuppressionUtil.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright 2000-2009 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.intellij.codeInspection;
-
-import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.util.NullableComputable;
-import com.intellij.openapi.util.text.StringUtil;
-import com.intellij.psi.PsiComment;
-import com.intellij.psi.PsiElement;
-import com.intellij.psi.PsiWhiteSpace;
-import com.intellij.psi.util.PsiTreeUtil;
-import org.jetbrains.annotations.NonNls;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-/**
- * @author yole
- */
-public class SuppressionUtil {
-  @NonNls public static final String SUPPRESS_INSPECTIONS_TAG_NAME = "noinspection";
-
-  /**
-   * Common part of regexp for suppressing in line comments for different languages.
-   * Comment start prefix isn't included, e.g. add '//' for Java/C/JS or '#' for Ruby
-   */
-  @NonNls
-  public static final String COMMON_SUPPRESS_REGEXP = "\\s*" + SUPPRESS_INSPECTIONS_TAG_NAME +
-                                                      "\\s+(" + LocalInspectionTool.VALID_ID_PATTERN +
-                                                      "(\\s*,\\s*" + LocalInspectionTool.VALID_ID_PATTERN + ")*)\\s*\\w*";
-
-  @NonNls
-  public static final Pattern SUPPRESS_IN_LINE_COMMENT_PATTERN = Pattern.compile("//" + COMMON_SUPPRESS_REGEXP);  // for Java, C, JS line comments
-
-  @NonNls
-  public static final String ALL = "ALL";
-
-  private SuppressionUtil() {
-  }
-
-  public static boolean isInspectionToolIdMentioned(@NotNull String inspectionsList, String inspectionToolID) {
-    Iterable<String> ids = StringUtil.tokenize(inspectionsList, "[, ]");
-
-    for (@NonNls String id : ids) {
-      @NonNls String trim = id.trim();
-      if (trim.equals(inspectionToolID) || trim.equalsIgnoreCase(ALL)) return true;
-    }
-    return false;
-  }
-
-  @Nullable
-  public static PsiElement getStatementToolSuppressedIn(final PsiElement place,
-                                                        final String toolId,
-                                                        final Class<? extends PsiElement> statementClass) {
-    return getStatementToolSuppressedIn(place, toolId, statementClass, SUPPRESS_IN_LINE_COMMENT_PATTERN);
-  }
-
-  @Nullable
-  public static PsiElement getStatementToolSuppressedIn(final PsiElement place,
-                                                        final String toolId,
-                                                        final Class<? extends PsiElement> statementClass,
-                                                        final Pattern suppressInLineCommentPattern) {
-    PsiElement statement = PsiTreeUtil.getNonStrictParentOfType(place, statementClass);
-    if (statement != null) {
-      PsiElement prev = PsiTreeUtil.skipSiblingsBackward(statement, PsiWhiteSpace.class);
-      if (prev instanceof PsiComment) {
-        String text = prev.getText();
-        Matcher matcher = suppressInLineCommentPattern.matcher(text);
-        if (matcher.matches() && isInspectionToolIdMentioned(matcher.group(1), toolId)) {
-          return prev;
-        }
-      }
-    }
-    return null;
-  }
-
-  public static boolean isSuppressedInStatement(final PsiElement place,
-                                                final String toolId,
-                                                final Class<? extends PsiElement> statementClass) {
-    return ApplicationManager.getApplication().runReadAction(new NullableComputable<PsiElement>() {
-      @Override
-      public PsiElement compute() {
-        return getStatementToolSuppressedIn(place, toolId, statementClass);
-      }
-    }) != null;
-  }
-}
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionManagerEx.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionManagerEx.java
index 6615e3d..d559e8f 100644
--- a/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionManagerEx.java
+++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionManagerEx.java
@@ -22,13 +22,16 @@
 
 package com.intellij.codeInspection.ex;
 
+import com.intellij.codeInsight.daemon.impl.actions.AbstractBatchSuppressByNoInspectionCommentFix;
 import com.intellij.codeInspection.*;
 import com.intellij.codeInspection.lang.InspectionExtensionsFactory;
 import com.intellij.icons.AllIcons;
 import com.intellij.ide.impl.ContentManagerWatcher;
 import com.intellij.openapi.application.ApplicationManager;
+import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.extensions.Extensions;
 import com.intellij.openapi.project.Project;
+import com.intellij.openapi.ui.Messages;
 import com.intellij.openapi.util.NotNullLazyValue;
 import com.intellij.openapi.wm.ToolWindow;
 import com.intellij.openapi.wm.ToolWindowAnchor;
@@ -40,6 +43,7 @@
 import com.intellij.ui.content.ContentFactory;
 import com.intellij.ui.content.ContentManager;
 import com.intellij.ui.content.TabbedPaneContentUI;
+import com.intellij.util.IncorrectOperationException;
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
@@ -82,6 +86,53 @@
     }
   }
 
+  @NotNull
+  public static SuppressIntentionAction convertBatchToSuppressIntentionAction(@NotNull final SuppressQuickFix fix) {
+    return new SuppressIntentionAction() {
+      @Override
+      public void invoke(@NotNull Project project, Editor editor, @NotNull PsiElement element) throws IncorrectOperationException {
+        PsiElement container = fix instanceof AbstractBatchSuppressByNoInspectionCommentFix
+                               ? ((AbstractBatchSuppressByNoInspectionCommentFix )fix).getContainer(element) : null;
+        boolean caretWasBeforeStatement = editor != null && container != null && editor.getCaretModel().getOffset() == container.getTextRange().getStartOffset();
+        try {
+          ProblemDescriptor descriptor =
+            new ProblemDescriptorImpl(element, element, "", null, ProblemHighlightType.GENERIC_ERROR_OR_WARNING, false, null, false);
+          fix.applyFix(project, descriptor);
+        }
+        catch (IncorrectOperationException e) {
+          if (!ApplicationManager.getApplication().isUnitTestMode() && editor != null) {
+            Messages.showErrorDialog(editor.getComponent(),
+                                     InspectionsBundle.message("suppress.inspection.annotation.syntax.error", e.getMessage()));
+          }
+          else {
+            throw e;
+          }
+        }
+
+        if (caretWasBeforeStatement) {
+          editor.getCaretModel().moveToOffset(container.getTextRange().getStartOffset());
+        }
+      }
+
+      @Override
+      public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement element) {
+        return fix.isAvailable(project, element);
+      }
+
+      @NotNull
+      @Override
+      public String getText() {
+        return fix.getName();
+      }
+
+      @NotNull
+      @Override
+      public String getFamilyName() {
+        return fix.getFamilyName();
+      }
+    };
+  }
+
 
   @NotNull
   public ProblemDescriptor createProblemDescriptor(@NotNull final PsiElement psiElement,
@@ -133,6 +184,9 @@
     if (tool instanceof CustomSuppressableInspectionTool) {
       return ((CustomSuppressableInspectionTool)tool).isSuppressedFor(place);
     }
+    if (tool instanceof BatchSuppressableTool) {
+      return ((BatchSuppressableTool)tool).isSuppressedFor(place);
+    }
     String alternativeId;
     String id;
 
diff --git a/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionToolWrapper.java b/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionToolWrapper.java
index 7c4f325..36443ce 100644
--- a/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionToolWrapper.java
+++ b/platform/lang-impl/src/com/intellij/codeInspection/ex/InspectionToolWrapper.java
@@ -16,15 +16,14 @@
 package com.intellij.codeInspection.ex;
 
 import com.intellij.codeHighlighting.HighlightDisplayLevel;
-import com.intellij.codeInspection.CustomSuppressableInspectionTool;
-import com.intellij.codeInspection.InspectionEP;
-import com.intellij.codeInspection.InspectionProfileEntry;
-import com.intellij.codeInspection.SuppressIntentionAction;
+import com.intellij.codeInspection.*;
 import com.intellij.openapi.application.Application;
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.InvalidDataException;
 import com.intellij.openapi.util.WriteExternalException;
+import com.intellij.util.Function;
+import com.intellij.util.containers.ContainerUtil;
 import org.jdom.Element;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
@@ -185,14 +184,23 @@
       return super.getDescriptionUrl();
     }
     String fileName = getDescriptionFileName();
-    if (fileName == null) return null;
     return myEP.getLoaderForClass().getResource("/inspectionDescriptions/" + fileName);
   }
 
   @Override
   public SuppressIntentionAction[] getSuppressActions() {
-    if (getTool() instanceof CustomSuppressableInspectionTool) {
-      return ((CustomSuppressableInspectionTool)getTool()).getSuppressActions(null);
+    T tool = getTool();
+    if (tool instanceof CustomSuppressableInspectionTool) {
+      return ((CustomSuppressableInspectionTool)tool).getSuppressActions(null);
+    }
+    if (tool instanceof BatchSuppressableTool) {
+      LocalQuickFix[] actions = ((BatchSuppressableTool)tool).getBatchSuppressActions(null);
+      return ContainerUtil.map2Array(actions, SuppressIntentionAction.class, new Function<LocalQuickFix, SuppressIntentionAction>() {
+        @Override
+        public SuppressIntentionAction fun(final LocalQuickFix fix) {
+          return InspectionManagerEx.convertBatchToSuppressIntentionAction((SuppressQuickFix)fix);
+        }
+      });
     }
     return super.getSuppressActions();
   }
diff --git a/platform/lang-impl/src/com/intellij/ide/hierarchy/actions/BrowseHierarchyActionBase.java b/platform/lang-impl/src/com/intellij/ide/hierarchy/actions/BrowseHierarchyActionBase.java
index d5f3b6a..8d6401a 100644
--- a/platform/lang-impl/src/com/intellij/ide/hierarchy/actions/BrowseHierarchyActionBase.java
+++ b/platform/lang-impl/src/com/intellij/ide/hierarchy/actions/BrowseHierarchyActionBase.java
@@ -120,8 +120,9 @@
 
   @Nullable
   public static HierarchyProvider findBestHierarchyProvider(final LanguageExtension<HierarchyProvider> extension,
-                                                            PsiElement element,
+                                                            @Nullable PsiElement element,
                                                             DataContext dataContext) {
+    if (element == null) return null;
     List<HierarchyProvider> providers = extension.allForLanguage(element.getLanguage());
     for (HierarchyProvider provider : providers) {
       PsiElement target = provider.getTarget(dataContext);
diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/impl/DirectoryIndexImpl.java b/platform/lang-impl/src/com/intellij/openapi/roots/impl/DirectoryIndexImpl.java
index 12acdca..6b65e62 100644
--- a/platform/lang-impl/src/com/intellij/openapi/roots/impl/DirectoryIndexImpl.java
+++ b/platform/lang-impl/src/com/intellij/openapi/roots/impl/DirectoryIndexImpl.java
@@ -1284,7 +1284,9 @@
 
       copy.multiDirPackages.clear();
       for (int[] dirs : multiDirPackages) {
-        if (dirs == null) continue;
+        if (dirs == null) {
+          dirs = ArrayUtil.EMPTY_INT_ARRAY;
+        }
         int[] filtered = ContainerUtil.filter(dirs, new TIntProcedure() {
           @Override
           public boolean execute(int id) {
diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/impl/ModuleRootManagerComponent.java b/platform/lang-impl/src/com/intellij/openapi/roots/impl/ModuleRootManagerComponent.java
index 0acd89e..c9211cc 100644
--- a/platform/lang-impl/src/com/intellij/openapi/roots/impl/ModuleRootManagerComponent.java
+++ b/platform/lang-impl/src/com/intellij/openapi/roots/impl/ModuleRootManagerComponent.java
@@ -17,6 +17,7 @@
 
 import com.intellij.openapi.components.*;
 import com.intellij.openapi.module.Module;
+import com.intellij.openapi.roots.impl.storage.ClassPathStorageUtil;
 import com.intellij.openapi.roots.impl.storage.ClasspathStorage;
 import com.intellij.openapi.vfs.pointers.VirtualFilePointerManager;
 
@@ -27,7 +28,7 @@
   name = "NewModuleRootManager",
   storages = {
     @Storage(
-      id = ClasspathStorage.DEFAULT_STORAGE,
+      id = ClassPathStorageUtil.DEFAULT_STORAGE,
       file = "$MODULE_FILE$"
     ),
 
@@ -50,8 +51,8 @@
   public static class StorageChooser implements StateStorageChooser<ModuleRootManagerImpl> {
     @Override
     public Storage[] selectStorages(Storage[] storages, ModuleRootManagerImpl moduleRootManager, final StateStorageOperation operation) {
-      final String storageType = ClasspathStorage.getStorageType(moduleRootManager.getModule());
-      final String id = storageType.equals(ClasspathStorage.DEFAULT_STORAGE)? ClasspathStorage.DEFAULT_STORAGE: ClasspathStorage.SPECIAL_STORAGE;
+      final boolean isDefaultStorageType = ClassPathStorageUtil.isDefaultStorage(moduleRootManager.getModule());
+      final String id = isDefaultStorageType ? ClassPathStorageUtil.DEFAULT_STORAGE: ClasspathStorage.SPECIAL_STORAGE;
       for (Storage storage : storages) {
         if (storage.id().equals(id)) return new Storage[]{storage};
       }
diff --git a/platform/lang-impl/src/com/intellij/openapi/roots/impl/storage/ClasspathStorage.java b/platform/lang-impl/src/com/intellij/openapi/roots/impl/storage/ClasspathStorage.java
index f3f3fa8..047a5ab 100644
--- a/platform/lang-impl/src/com/intellij/openapi/roots/impl/storage/ClasspathStorage.java
+++ b/platform/lang-impl/src/com/intellij/openapi/roots/impl/storage/ClasspathStorage.java
@@ -62,12 +62,10 @@
 public class ClasspathStorage implements StateStorage {
   private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.roots.impl.storage.ClasspathStorage");
 
-  @NonNls public static final String DEFAULT_STORAGE = "default";
   @NonNls public static final String SPECIAL_STORAGE = "special";
 
   public static final String DEFAULT_STORAGE_DESCR = ProjectBundle.message("project.roots.classpath.format.default.descr");
 
-  @NonNls public static final String CLASSPATH_OPTION = JpsProjectLoader.CLASSPATH_ATTRIBUTE;
   @NonNls public static final String CLASSPATH_DIR_OPTION = JpsProjectLoader.CLASSPATH_DIR_ATTRIBUTE;
 
   @NonNls private static final String COMPONENT_TAG = "component";
@@ -76,7 +74,7 @@
 
 
   public ClasspathStorage(Module module) {
-    myConverter = getProvider(getStorageType(module)).createConverter(module);
+    myConverter = getProvider(ClassPathStorageUtil.getStorageType(module)).createConverter(module);
     final MessageBus messageBus = module.getMessageBus();
     final VirtualFileTracker virtualFileTracker =
       (VirtualFileTracker)module.getPicoContainer().getComponentInstanceOfType(VirtualFileTracker.class);
@@ -185,7 +183,7 @@
 
   @Override
   @NotNull
-  public SaveSession startSave(final ExternalizationSession externalizationSession) {
+  public SaveSession startSave(@NotNull final ExternalizationSession externalizationSession) {
     assert mySession == externalizationSession;
 
     final SaveSession session = new MySaveSession();
@@ -202,7 +200,7 @@
   }
 
   @Override
-  public void finishSave(final SaveSession saveSession) {
+  public void finishSave(@NotNull final SaveSession saveSession) {
     try {
       LOG.assertTrue(mySession == saveSession);
     }
@@ -212,7 +210,7 @@
   }
 
   @Override
-  public void reload(final Set<String> changedComponents) throws StateStorageException {
+  public void reload(@NotNull final Set<String> changedComponents) throws StateStorageException {
   }
 
   public boolean needsSave() throws StateStorageException {
@@ -238,7 +236,8 @@
     }
   }
 
-  public static ClasspathStorageProvider getProvider(final String type) {
+  @NotNull
+  public static ClasspathStorageProvider getProvider(@NotNull String type) {
     for (ClasspathStorageProvider provider : getProviders()) {
       if (type.equals(provider.getID())) {
         return provider;
@@ -247,6 +246,7 @@
     return new UnsupportedStorageProvider(type);
   }
 
+  @NotNull
   public static List<ClasspathStorageProvider> getProviders() {
     final List<ClasspathStorageProvider> list = new ArrayList<ClasspathStorageProvider>();
     list.add(new DefaultStorageProvider());
@@ -255,12 +255,7 @@
   }
 
   @NotNull
-  public static String getStorageType(final Module module) {
-    final String id = module.getOptionValue(CLASSPATH_OPTION);
-    return id != null ? id : DEFAULT_STORAGE;
-  }
-
-  public static String getModuleDir(final Module module) {
+  public static String getModuleDir(@NotNull Module module) {
     return new File(module.getModuleFilePath()).getParent();
   }
 
@@ -278,38 +273,38 @@
     }
   }
 
-  public static void setStorageType(final ModuleRootModel model, final String storageID) {
+  public static void setStorageType(@NotNull ModuleRootModel model, @NotNull String storageID) {
     final Module module = model.getModule();
-    final String oldStorageType = getStorageType(module);
+    final String oldStorageType = ClassPathStorageUtil.getStorageType(module);
     if (oldStorageType.equals(storageID)) {
       return;
     }
 
     getProvider(oldStorageType).detach(module);
 
-    if (storageID.equals(DEFAULT_STORAGE)) {
-      module.clearOption(CLASSPATH_OPTION);
+    if (storageID.equals(ClassPathStorageUtil.DEFAULT_STORAGE)) {
+      module.clearOption(ClassPathStorageUtil.CLASSPATH_OPTION);
       module.clearOption(CLASSPATH_DIR_OPTION);
     }
     else {
-      module.setOption(CLASSPATH_OPTION, storageID);
+      module.setOption(ClassPathStorageUtil.CLASSPATH_OPTION, storageID);
       module.setOption(CLASSPATH_DIR_OPTION, getProvider(storageID).getContentRoot(model));
     }
   }
 
   public static void moduleRenamed(Module module, String newName) {
-    getProvider(getStorageType(module)).moduleRenamed(module, newName);
+    getProvider(ClassPathStorageUtil.getStorageType(module)).moduleRenamed(module, newName);
   }
 
   public static void modulePathChanged(Module module, String path) {
-    getProvider(getStorageType(module)).modulePathChanged(module, path);
+    getProvider(ClassPathStorageUtil.getStorageType(module)).modulePathChanged(module, path);
   }
 
   private static class DefaultStorageProvider implements ClasspathStorageProvider {
     @Override
     @NonNls
     public String getID() {
-      return DEFAULT_STORAGE;
+      return ClassPathStorageUtil.DEFAULT_STORAGE;
     }
 
     @Override
diff --git a/platform/platform-api/src/com/intellij/ExtensionPoints.java b/platform/platform-api/src/com/intellij/ExtensionPoints.java
index ed40003..d36cfb9 100644
--- a/platform/platform-api/src/com/intellij/ExtensionPoints.java
+++ b/platform/platform-api/src/com/intellij/ExtensionPoints.java
@@ -22,7 +22,7 @@
 /**
  * Extension points provided by IDEA core are listed here.
  */
-public interface ExtensionPoints {
+public interface ExtensionPoints extends ToolExtensionPoints {
   /**
    * This extension point should be used instead of former application-components, project-components, module-components.
    * Extension declaration sample is as follows:
@@ -64,8 +64,7 @@
    * </pre>
    * my.plugin.package.MyJUnitPatcher class must implement {@link com.intellij.execution.JUnitPatcher} abstract class.
    */
-
-  @NonNls String JUNIT_PATCHER = "com.intellij.junitPatcher";
+  @SuppressWarnings("JavadocReference") @NonNls String JUNIT_PATCHER = "com.intellij.junitPatcher";
 
   /**
    * This extensions allows to run custom [command-line] application based on IDEA platform
@@ -78,10 +77,6 @@
    */
   @NonNls String APPLICATION_STARTER = "com.intellij.appStarter";
 
-  @NonNls String INVALID_PROPERTY_KEY_INSPECTION_TOOL = "com.intellij.invalidPropertyKeyInspectionTool";
-  @NonNls String I18N_INSPECTION_TOOL = "com.intellij.i18nInspectionTool";
-  @NonNls String JAVA15_INSPECTION_TOOL = "com.intellij.java15InspectionTool";
-
   @NonNls String INSPECTIONS_GRAPH_ANNOTATOR = "com.intellij.refGraphAnnotator";
 
   @NonNls String DEAD_CODE_TOOL = "com.intellij.deadCode";
diff --git a/platform/platform-api/src/com/intellij/ide/ui/UISettings.java b/platform/platform-api/src/com/intellij/ide/ui/UISettings.java
index 879df0a..e2e3d73 100644
--- a/platform/platform-api/src/com/intellij/ide/ui/UISettings.java
+++ b/platform/platform-api/src/com/intellij/ide/ui/UISettings.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -99,9 +99,7 @@
   public boolean FILE_COLORS_IN_PROJECT_VIEW = false;
   public boolean DEFAULT_AUTOSCROLL_TO_SOURCE = false;
   public boolean PRESENTATION_MODE = false;
-  public boolean PRESENTATION_MODE_ALLOW_LINE_NUMBER = false;
-  public boolean PRESENTATION_MODE_ALLOW_STATUS_BAR = false;
-  public boolean PRESENTATION_MODE_ALLOW_ANNOTATIONS = false;
+  public int PRESENTATION_MODE_FONT_SIZE = 24;
 
   /**
    * Defines whether asterisk is shown on modified editor tab or not
diff --git a/platform/platform-api/src/com/intellij/openapi/editor/EditorSettings.java b/platform/platform-api/src/com/intellij/openapi/editor/EditorSettings.java
index 5a1c694..565748e 100644
--- a/platform/platform-api/src/com/intellij/openapi/editor/EditorSettings.java
+++ b/platform/platform-api/src/com/intellij/openapi/editor/EditorSettings.java
@@ -116,4 +116,6 @@
   boolean isPreselectRename();
   void setPreselectRename(final boolean val);
 
+  boolean isShowIntentionBulb();
+  void setShowIntentionBulb(boolean show);
 }
diff --git a/platform/platform-api/src/com/intellij/openapi/editor/colors/FontPreferences.java b/platform/platform-api/src/com/intellij/openapi/editor/colors/FontPreferences.java
index 2d88151..3ea825a 100644
--- a/platform/platform-api/src/com/intellij/openapi/editor/colors/FontPreferences.java
+++ b/platform/platform-api/src/com/intellij/openapi/editor/colors/FontPreferences.java
@@ -15,6 +15,7 @@
  */
 package com.intellij.openapi.editor.colors;
 
+import com.intellij.ide.ui.UISettings;
 import com.intellij.openapi.options.FontSize;
 import com.intellij.openapi.util.SystemInfo;
 import com.intellij.util.containers.ContainerUtilRt;
@@ -56,6 +57,11 @@
     myChangeListener = changeListener;
   }
 
+  @Nullable
+  public Runnable getChangeListener() {
+    return myChangeListener;
+  }
+
   public void clear() {
     myEffectiveFontFamilies.clear();
     myRealFontFamilies.clear();
@@ -78,6 +84,9 @@
   }
 
   public int getSize(@NotNull String fontFamily) {
+    if (UISettings.getInstance().PRESENTATION_MODE) {
+      return UISettings.getInstance().PRESENTATION_MODE_FONT_SIZE;
+    }
     int result = myFontSizes.get(fontFamily);
     if (result <= 0) {
       result = myTemplateFontSize;
diff --git a/platform/platform-api/src/com/intellij/openapi/editor/markup/GutterIconRenderer.java b/platform/platform-api/src/com/intellij/openapi/editor/markup/GutterIconRenderer.java
index 1eb2772..fb96c13 100644
--- a/platform/platform-api/src/com/intellij/openapi/editor/markup/GutterIconRenderer.java
+++ b/platform/platform-api/src/com/intellij/openapi/editor/markup/GutterIconRenderer.java
@@ -82,6 +82,11 @@
     return null;
   }
 
+  @Nullable
+  public AnAction getRightButtonClickAction() {
+    return null;
+  }
+
   /**
    * Returns the value indicating whether the hand cursor should be displayed when the mouse
    * is hovering over the icon.
diff --git a/platform/platform-api/src/com/intellij/openapi/util/AsyncResult.java b/platform/platform-api/src/com/intellij/openapi/util/AsyncResult.java
index 5d801da..d6be804 100644
--- a/platform/platform-api/src/com/intellij/openapi/util/AsyncResult.java
+++ b/platform/platform-api/src/com/intellij/openapi/util/AsyncResult.java
@@ -19,6 +19,7 @@
 import com.intellij.util.Consumer;
 import com.intellij.util.Function;
 import com.intellij.util.PairConsumer;
+import com.intellij.util.concurrency.Semaphore;
 import org.jetbrains.annotations.NotNull;
 
 public class AsyncResult<T> extends ActionCallback {
@@ -113,6 +114,37 @@
     return myResult;
   }
 
+  public T getResultSync() {
+    return getResultSync(-1);
+  }
+
+  public T getResultSync(long msTimeout) {
+    if (isProcessed()) {
+      return myResult;
+    }
+
+    final Semaphore semaphore = new Semaphore();
+    semaphore.down();
+    doWhenProcessed(new Runnable() {
+      @Override
+      public void run() {
+        semaphore.up();
+      }
+    });
+    try {
+      if (msTimeout == -1) {
+        semaphore.waitForUnsafe();
+      }
+      else if (!semaphore.waitForUnsafe(msTimeout)) {
+        reject("Time limit exceeded");
+      }
+    }
+    catch (InterruptedException e) {
+      reject(e.getMessage());
+    }
+    return myResult;
+  }
+
   public interface Handler<T> {
     void run(T t);
   }
diff --git a/platform/platform-api/src/com/intellij/ui/DoubleClickListener.java b/platform/platform-api/src/com/intellij/ui/DoubleClickListener.java
index 54d66c3..048ab41 100644
--- a/platform/platform-api/src/com/intellij/ui/DoubleClickListener.java
+++ b/platform/platform-api/src/com/intellij/ui/DoubleClickListener.java
@@ -19,40 +19,13 @@
  */
 package com.intellij.ui;
 
-import javax.swing.*;
-import javax.swing.plaf.basic.BasicTreeUI;
-import javax.swing.tree.TreePath;
 import java.awt.event.MouseEvent;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
 
 public abstract class DoubleClickListener extends ClickListener {
   @Override
   public final boolean onClick(MouseEvent event, int clickCount) {
     if (clickCount == 2 && event.getButton() == MouseEvent.BUTTON1) {
-      return isExpandIconClick(event) ? false : onDoubleClick(event);
-    }
-    return false;
-  }
-
-  private static boolean isExpandIconClick(MouseEvent event) {
-    if (event.getComponent() instanceof JTree) {
-      JTree tree = (JTree)event.getComponent();
-      TreePath treePath = tree.getClosestPathForLocation(event.getX(), event.getY());
-      if (treePath == null || !(tree.getUI() instanceof BasicTreeUI)) return false;
-      BasicTreeUI ui = (BasicTreeUI)tree.getUI();
-      try {
-        Method method = BasicTreeUI.class.getDeclaredMethod("isLocationInExpandControl", TreePath.class, Integer.TYPE, Integer.TYPE);
-        method.setAccessible(true);
-        Object result = method.invoke(ui, treePath, event.getX(), event.getY());
-        if (result instanceof Boolean && result.equals(Boolean.TRUE)) return true;
-      }
-      catch (NoSuchMethodException e) {
-      }
-      catch (InvocationTargetException e) {
-      }
-      catch (IllegalAccessException e) {
-      }
+      return onDoubleClick(event);
     }
     return false;
   }
diff --git a/platform/platform-api/src/com/intellij/ui/treeStructure/Tree.java b/platform/platform-api/src/com/intellij/ui/treeStructure/Tree.java
index 29a9f28..0d2bf4c 100644
--- a/platform/platform-api/src/com/intellij/ui/treeStructure/Tree.java
+++ b/platform/platform-api/src/com/intellij/ui/treeStructure/Tree.java
@@ -683,6 +683,39 @@
         }
       }
     }
+
+    @Override
+    public void mouseReleased(MouseEvent e) {
+      if (e.getButton() == MouseEvent.BUTTON1 && e.getClickCount() == 2 && isLocationInExpandControl(getClosestPathForLocation(e.getX(), e.getY()), e.getX())) {
+        e.consume();
+      }
+    }
+    /**
+     * Returns true if <code>mouseX</code> falls
+     * in the area of row that is used to expand/collapse the node and
+     * the node at <code>row</code> does not represent a leaf.
+     */
+  }
+
+  protected boolean isLocationInExpandControl(@Nullable TreePath path, int mouseX) {
+    if (path == null) return false;
+    TreeUI ui = getUI();
+    if (!(ui instanceof BasicTreeUI)) return false;
+    BasicTreeUI treeUI = (BasicTreeUI)ui;
+    if (!treeModel.isLeaf(path.getLastPathComponent())) {
+      Insets insets = Tree.this.getInsets();
+      int boxWidth = treeUI.getExpandedIcon() != null ? treeUI.getExpandedIcon().getIconWidth() : 8;
+      int boxLeftX = treeUI.getLeftChildIndent() + treeUI.getRightChildIndent() * (path.getPathCount() - 1);
+      if (getComponentOrientation().isLeftToRight()) {
+        boxLeftX = boxLeftX + insets.left - treeUI.getRightChildIndent() + 1;
+      }
+      else {
+        boxLeftX = getWidth() - boxLeftX - insets.right + treeUI.getRightChildIndent() - 1;
+      }
+      boxLeftX -= (getComponentOrientation().isLeftToRight() ? (int)Math.ceil(boxWidth / 2.0) : (int)Math.floor(boxWidth / 2.0));
+      return (mouseX >= boxLeftX && mouseX < (boxLeftX + boxWidth));
+    }
+    return false;
   }
 
   /**
diff --git a/platform/platform-impl/src/com/intellij/ide/actions/TogglePresentationModeAction.java b/platform/platform-impl/src/com/intellij/ide/actions/TogglePresentationModeAction.java
index 304f8af..e5ff49a 100644
--- a/platform/platform-impl/src/com/intellij/ide/actions/TogglePresentationModeAction.java
+++ b/platform/platform-impl/src/com/intellij/ide/actions/TogglePresentationModeAction.java
@@ -1,8 +1,25 @@
+/*
+ * Copyright 2000-2013 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
 package com.intellij.ide.actions;
 
 import com.intellij.ide.ui.UISettings;
+import com.intellij.ide.util.PropertiesComponent;
 import com.intellij.openapi.actionSystem.AnAction;
 import com.intellij.openapi.actionSystem.AnActionEvent;
+import com.intellij.openapi.editor.ex.util.EditorUtil;
 import com.intellij.openapi.project.DumbAware;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.wm.impl.IdeFrameImpl;
@@ -34,8 +51,17 @@
     if (project != null) {
       Window frame = IdeFrameImpl.getActiveFrame();
       if (frame instanceof IdeFrameImpl) {
-        ((IdeFrameImpl)frame).toggleFullScreen(true);
+        final PropertiesComponent propertiesComponent = PropertiesComponent.getInstance(project);
+        if (settings.PRESENTATION_MODE) {
+          propertiesComponent.setValue("full.screen.before.presentation.mode", String.valueOf(((IdeFrameImpl)frame).isInFullScreen()));
+          ((IdeFrameImpl)frame).toggleFullScreen(true);
+        } else {
+          final String value = propertiesComponent.getValue("full.screen.before.presentation.mode");
+          ((IdeFrameImpl)frame).toggleFullScreen("true".equalsIgnoreCase(value));
+        }
       }
     }
+
+    EditorUtil.reinitSettings();
   }
 }
diff --git a/platform/platform-impl/src/com/intellij/ide/plugins/PluginManager.java b/platform/platform-impl/src/com/intellij/ide/plugins/PluginManager.java
index e110b29..d34e594 100644
--- a/platform/platform-impl/src/com/intellij/ide/plugins/PluginManager.java
+++ b/platform/platform-impl/src/com/intellij/ide/plugins/PluginManager.java
@@ -220,7 +220,8 @@
 
     final IdeaPluginDescriptorImpl[] pluginDescriptors = loadDescriptors(progress);
 
-    final Class callerClass = ReflectionUtil.getCallerClass(1);
+    final Class callerClass = ReflectionUtil.findCallerClass(1);
+    assert callerClass != null;
     final ClassLoader parentLoader = callerClass.getClassLoader();
 
     final List<IdeaPluginDescriptorImpl> result = new ArrayList<IdeaPluginDescriptorImpl>();
diff --git a/platform/platform-impl/src/com/intellij/ide/ui/AppearanceConfigurable.java b/platform/platform-impl/src/com/intellij/ide/ui/AppearanceConfigurable.java
index fe1705b..608856a 100644
--- a/platform/platform-impl/src/com/intellij/ide/ui/AppearanceConfigurable.java
+++ b/platform/platform-impl/src/com/intellij/ide/ui/AppearanceConfigurable.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -17,6 +17,7 @@
 
 import com.intellij.ide.IdeBundle;
 import com.intellij.ide.ui.laf.darcula.DarculaInstaller;
+import com.intellij.openapi.editor.ex.util.EditorUtil;
 import com.intellij.openapi.options.BaseConfigurable;
 import com.intellij.openapi.options.SearchableConfigurable;
 import com.intellij.openapi.ui.ComboBox;
@@ -62,7 +63,9 @@
     DefaultComboBoxModel aModel = new DefaultComboBoxModel(UIUtil.getValidFontNames(false));
     myComponent.myFontCombo.setModel(aModel);
     myComponent.myFontSizeCombo.setModel(new DefaultComboBoxModel(UIUtil.getStandardFontSizes()));
+    myComponent.myPresentationModeFontSize.setModel(new DefaultComboBoxModel(UIUtil.getStandardFontSizes()));
     myComponent.myFontSizeCombo.setEditable(true);
+    myComponent.myPresentationModeFontSize.setEditable(true);
 
     myComponent.myLafComboBox.setModel(new DefaultComboBoxModel(LafManager.getInstance().getInstalledLookAndFeels()));
     myComponent.myLafComboBox.setRenderer(new LafComboBoxRenderer());
@@ -116,21 +119,8 @@
   public void apply() {
     initComponent();
     UISettings settings = UISettings.getInstance();
-    String temp = (String)myComponent.myFontSizeCombo.getEditor().getItem();
-    int _fontSize = -1;
-    if (temp != null && temp.trim().length() > 0) {
-      try {
-        _fontSize = Integer.parseInt(temp);
-      }
-      catch (NumberFormatException ignore) {
-      }
-      if (_fontSize <= 0) {
-        _fontSize = settings.FONT_SIZE;
-      }
-    }
-    else {
-      _fontSize = settings.FONT_SIZE;
-    }
+    int _fontSize = getIntValue(myComponent.myFontSizeCombo, settings.FONT_SIZE);
+    int _presentationFontSize = getIntValue(myComponent.myPresentationModeFontSize, settings.PRESENTATION_MODE_FONT_SIZE);
     boolean shouldUpdateUI = false;
     String _fontFace = (String)myComponent.myFontCombo.getSelectedItem();
     LafManager lafManager = LafManager.getInstance();
@@ -139,6 +129,12 @@
       settings.FONT_FACE = _fontFace;
       shouldUpdateUI = true;
     }
+
+    if (_presentationFontSize != settings.PRESENTATION_MODE_FONT_SIZE) {
+      settings.PRESENTATION_MODE_FONT_SIZE = _presentationFontSize;
+      shouldUpdateUI = true;
+    }
+
     settings.ANIMATE_WINDOWS = myComponent.myAnimateWindowsCheckBox.isSelected();
     boolean update = settings.SHOW_TOOL_WINDOW_NUMBERS != myComponent.myWindowShortcutsCheckBox.isSelected();
     settings.SHOW_TOOL_WINDOW_NUMBERS = myComponent.myWindowShortcutsCheckBox.isSelected();
@@ -171,15 +167,6 @@
     update |= settings.SHOW_ICONS_IN_QUICK_NAVIGATION != myComponent.myHideIconsInQuickNavigation.isSelected();
     settings.SHOW_ICONS_IN_QUICK_NAVIGATION = myComponent.myHideIconsInQuickNavigation.isSelected();
 
-    update |= settings.PRESENTATION_MODE_ALLOW_STATUS_BAR != myComponent.myAllowStatusBar.isSelected();
-    settings.PRESENTATION_MODE_ALLOW_STATUS_BAR = myComponent.myAllowStatusBar.isSelected();
-
-    update |= settings.PRESENTATION_MODE_ALLOW_LINE_NUMBER != myComponent.myAllowLineNumbers.isSelected();
-    settings.PRESENTATION_MODE_ALLOW_LINE_NUMBER = myComponent.myAllowLineNumbers.isSelected();
-
-    update |= settings.PRESENTATION_MODE_ALLOW_ANNOTATIONS != myComponent.myAllowAnnotations.isSelected();
-    settings.PRESENTATION_MODE_ALLOW_ANNOTATIONS = myComponent.myAllowAnnotations.isSelected();
-
     if (!Comparing.equal(myComponent.myLafComboBox.getSelectedItem(), lafManager.getCurrentLookAndFeel())) {
       final UIManager.LookAndFeelInfo lafInfo = (UIManager.LookAndFeelInfo)myComponent.myLafComboBox.getSelectedItem();
       if (lafManager.checkLookAndFeel(lafInfo)) {
@@ -230,6 +217,27 @@
       settings.fireUISettingsChanged();
     }
     myComponent.updateCombo();
+
+    EditorUtil.reinitSettings();
+  }
+
+  private static int getIntValue(JComboBox combo, int defaultValue) {
+    String temp = (String)combo.getEditor().getItem();
+    int value = -1;
+    if (temp != null && temp.trim().length() > 0) {
+      try {
+        value = Integer.parseInt(temp);
+      }
+      catch (NumberFormatException ignore) {
+      }
+      if (value <= 0) {
+        value = defaultValue;
+      }
+    }
+    else {
+      value = defaultValue;
+    }
+    return value;
   }
 
   public void reset() {
@@ -238,6 +246,7 @@
 
     myComponent.myFontCombo.setSelectedItem(settings.FONT_FACE);
     myComponent.myFontSizeCombo.setSelectedItem(Integer.toString(settings.FONT_SIZE));
+    myComponent.myPresentationModeFontSize.setSelectedItem(Integer.toString(settings.PRESENTATION_MODE_FONT_SIZE));
     myComponent.myAnimateWindowsCheckBox.setSelected(settings.ANIMATE_WINDOWS);
     myComponent.myWindowShortcutsCheckBox.setSelected(settings.SHOW_TOOL_WINDOW_NUMBERS);
     myComponent.myShowToolStripesCheckBox.setSelected(!settings.HIDE_TOOL_STRIPES);
@@ -246,10 +255,6 @@
     myComponent.myAllowMergeButtons.setSelected(settings.ALLOW_MERGE_BUTTONS);
     myComponent.myCycleScrollingCheckBox.setSelected(settings.CYCLE_SCROLLING);
 
-    myComponent.myAllowStatusBar.setSelected(settings.PRESENTATION_MODE_ALLOW_STATUS_BAR);
-    myComponent.myAllowLineNumbers.setSelected(settings.PRESENTATION_MODE_ALLOW_LINE_NUMBER);
-    myComponent.myAllowAnnotations.setSelected(settings.PRESENTATION_MODE_ALLOW_ANNOTATIONS);
-
     myComponent.myHideIconsInQuickNavigation.setSelected(settings.SHOW_ICONS_IN_QUICK_NAVIGATION);
     myComponent.myMoveMouseOnDefaultButtonCheckBox.setSelected(settings.MOVE_MOUSE_ON_DEFAULT_BUTTON);
     myComponent.myHideNavigationPopupsCheckBox.setSelected(settings.HIDE_NAVIGATION_ON_FOCUS_LOSS);
@@ -301,9 +306,7 @@
 
     isModified |= myComponent.myHideIconsInQuickNavigation.isSelected() != settings.SHOW_ICONS_IN_QUICK_NAVIGATION;
 
-    isModified |= settings.PRESENTATION_MODE_ALLOW_STATUS_BAR != myComponent.myAllowStatusBar.isSelected();
-    isModified |= settings.PRESENTATION_MODE_ALLOW_LINE_NUMBER != myComponent.myAllowLineNumbers.isSelected();
-    isModified |= settings.PRESENTATION_MODE_ALLOW_ANNOTATIONS != myComponent.myAllowAnnotations.isSelected();
+    isModified |= !Comparing.equal(myComponent.myPresentationModeFontSize.getEditor().getItem(), Integer.toString(settings.PRESENTATION_MODE_FONT_SIZE));
 
     isModified |= myComponent.myMoveMouseOnDefaultButtonCheckBox.isSelected() != settings.MOVE_MOUSE_ON_DEFAULT_BUTTON;
     isModified |= myComponent.myHideNavigationPopupsCheckBox.isSelected() != settings.HIDE_NAVIGATION_ON_FOCUS_LOSS;
@@ -365,6 +368,7 @@
     private JCheckBox myAllowMergeButtons;
     private JBCheckBox myUseSmallLabelsOnTabs;
     private JSlider myInitialTooltipDelaySlider;
+    private ComboBox myPresentationModeFontSize;
     private JCheckBox myAllowStatusBar;
     private JCheckBox myAllowLineNumbers;
     private JCheckBox myAllowAnnotations;
@@ -388,6 +392,7 @@
 
     private void createUIComponents() {
       myFontSizeCombo = new ComboBox();
+      myPresentationModeFontSize = new ComboBox();
     }
   }
 
diff --git a/platform/platform-impl/src/com/intellij/ide/ui/AppearancePanel.form b/platform/platform-impl/src/com/intellij/ide/ui/AppearancePanel.form
index b3a70c2..d2fd0bb 100644
--- a/platform/platform-impl/src/com/intellij/ide/ui/AppearancePanel.form
+++ b/platform/platform-impl/src/com/intellij/ide/ui/AppearancePanel.form
@@ -3,7 +3,7 @@
   <grid id="41bd3" binding="myPanel" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
     <margin top="0" left="0" bottom="0" right="0"/>
     <constraints>
-      <xy x="81" y="44" width="507" height="713"/>
+      <xy x="81" y="44" width="507" height="731"/>
     </constraints>
     <properties/>
     <border type="none"/>
@@ -354,7 +354,7 @@
               </component>
             </children>
           </grid>
-          <grid id="e3cc0" layout-manager="GridLayoutManager" row-count="4" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
+          <grid id="e3cc0" layout-manager="GridLayoutManager" row-count="2" column-count="3" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
             <margin top="0" left="0" bottom="0" right="0"/>
             <constraints>
               <grid row="3" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
@@ -365,39 +365,29 @@
             </clientProperties>
             <border type="etched" title-resource-bundle="messages/IdeBundle" title-key="group.presentation.mode"/>
             <children>
-              <component id="4b1be" class="javax.swing.JCheckBox" binding="myAllowStatusBar">
-                <constraints>
-                  <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
-                </constraints>
-                <properties>
-                  <text resource-bundle="messages/IdeBundle" key="checkbox.allow.status.bar"/>
-                </properties>
-              </component>
               <hspacer id="6caf3">
                 <constraints>
-                  <grid row="0" column="1" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
+                  <grid row="0" column="2" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
                 </constraints>
               </hspacer>
               <vspacer id="4e6ce">
                 <constraints>
-                  <grid row="3" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
+                  <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
                 </constraints>
               </vspacer>
-              <component id="492d7" class="javax.swing.JCheckBox" binding="myAllowLineNumbers">
+              <component id="9190a" class="com.intellij.ui.components.JBLabel">
                 <constraints>
-                  <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
+                  <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
                 </constraints>
                 <properties>
-                  <text resource-bundle="messages/IdeBundle" key="checkbox.allow.line.numbers"/>
+                  <text resource-bundle="messages/IdeBundle" key="presentation.mode.fon.size"/>
                 </properties>
               </component>
-              <component id="c3ed4" class="javax.swing.JCheckBox" binding="myAllowAnnotations">
+              <component id="754ff" class="com.intellij.openapi.ui.ComboBox" binding="myPresentationModeFontSize" custom-create="true">
                 <constraints>
-                  <grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
+                  <grid row="0" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="2" anchor="0" fill="0" indent="0" use-parent-layout="false"/>
                 </constraints>
-                <properties>
-                  <text resource-bundle="messages/IdeBundle" key="checkbox.allow.vcs.annotations"/>
-                </properties>
+                <properties/>
               </component>
             </children>
           </grid>
diff --git a/platform/platform-impl/src/com/intellij/idea/IdeaApplication.java b/platform/platform-impl/src/com/intellij/idea/IdeaApplication.java
index 0f0effc..ad08610 100644
--- a/platform/platform-impl/src/com/intellij/idea/IdeaApplication.java
+++ b/platform/platform-impl/src/com/intellij/idea/IdeaApplication.java
@@ -43,7 +43,6 @@
 import com.intellij.openapi.wm.impl.X11UiUtil;
 import com.intellij.openapi.wm.impl.welcomeScreen.WelcomeFrame;
 import com.intellij.ui.Splash;
-import com.intellij.util.SystemProperties;
 import com.intellij.util.messages.MessageBus;
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.Nullable;
@@ -107,7 +106,7 @@
       RepaintManager.setCurrentManager(new IdeRepaintManager());
     }
 
-    if (SystemInfo.isXWindow && !SystemProperties.getBooleanProperty("idea.skip.wm.patching", false)) {
+    if (SystemInfo.isXWindow) {
       String wmName = X11UiUtil.getWmName();
       LOG.info("WM detected: " + wmName);
       if (wmName != null) {
diff --git a/platform/platform-impl/src/com/intellij/openapi/application/PluginPathManager.java b/platform/platform-impl/src/com/intellij/openapi/application/PluginPathManager.java
index a466335..1ab0500 100644
--- a/platform/platform-impl/src/com/intellij/openapi/application/PluginPathManager.java
+++ b/platform/platform-impl/src/com/intellij/openapi/application/PluginPathManager.java
@@ -18,8 +18,7 @@
 import com.intellij.openapi.util.io.FileUtil;
 
 import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.*;
 
 /**
  * @author yole
@@ -35,6 +34,12 @@
       List<File> result = new ArrayList<File>();
       File[] subdirs = new File(PathManager.getHomePath()).listFiles();
       if (subdirs == null) return result;
+      Arrays.sort(subdirs, new Comparator<File>() {
+        @Override
+        public int compare(File file, File file2) {
+          return FileUtil.compareFiles(file, file2);
+        }
+      });
       for (File subdir : subdirs) {
         if (new File(subdir, ".git").exists()) {
           File pluginsDir = new File(subdir, "plugins");
@@ -51,14 +56,21 @@
   }
 
   public static File getPluginHome(String pluginName) {
-    String homePath = PathManager.getHomePath();
+    File subrepo = findSubrepo(pluginName);
+    if (subrepo != null) {
+      return subrepo;
+    }
+    return new File(PathManager.getHomePath(), "plugins/" + pluginName);
+  }
+
+  private static File findSubrepo(String pluginName) {
     for (File subrepo : SubrepoHolder.subrepos) {
       File candidate = new File(subrepo, pluginName);
       if (candidate.isDirectory()) {
         return candidate;
       }
     }
-    return new File(homePath, "plugins/" + pluginName);
+    return null;
   }
 
   public static String getPluginHomePath(String pluginName) {
@@ -66,12 +78,10 @@
   }
 
   public static String getPluginHomePathRelative(String pluginName) {
-    String homePath = PathManager.getHomePath();
-    for (File subrepo : SubrepoHolder.subrepos) {
-      File candidate = new File(subrepo, pluginName);
-      if (candidate.isDirectory()) {
-        return "/" + FileUtil.getRelativePath(homePath, candidate.getPath(), '/');
-      }
+    File subrepo = findSubrepo(pluginName);
+    if (subrepo != null) {
+      String homePath = FileUtil.toSystemIndependentName(PathManager.getHomePath());
+      return "/" + FileUtil.getRelativePath(homePath, FileUtil.toSystemIndependentName(subrepo.getPath()), '/');
     }
     return "/plugins/" + pluginName;
   }
diff --git a/platform/platform-impl/src/com/intellij/openapi/application/ex/ApplicationEx.java b/platform/platform-impl/src/com/intellij/openapi/application/ex/ApplicationEx.java
index 9272391..e7e506c 100644
--- a/platform/platform-impl/src/com/intellij/openapi/application/ex/ApplicationEx.java
+++ b/platform/platform-impl/src/com/intellij/openapi/application/ex/ApplicationEx.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -29,6 +29,8 @@
  * @author max
  */
 public interface ApplicationEx extends Application {
+  String LOCATOR_FILE_NAME = ".home";
+
   /**
    * Loads the application configuration from the specified path
    *
diff --git a/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java b/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java
index 085ba75..272562d 100644
--- a/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/application/impl/ApplicationImpl.java
@@ -51,6 +51,7 @@
 import com.intellij.openapi.ui.DialogWrapper;
 import com.intellij.openapi.ui.Messages;
 import com.intellij.openapi.util.*;
+import com.intellij.openapi.util.io.FileUtil;
 import com.intellij.openapi.util.registry.Registry;
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.openapi.wm.IdeFrame;
@@ -73,6 +74,7 @@
 
 import javax.swing.*;
 import java.awt.*;
+import java.io.File;
 import java.io.IOException;
 import java.lang.reflect.Method;
 import java.util.List;
@@ -116,7 +118,7 @@
   private volatile boolean myDisposeInProgress = false;
 
   private final Disposable myLastDisposable = Disposer.newDisposable(); // will be disposed last
-  
+
   private boolean myHandlingInitComponentError;
 
   private final AtomicBoolean mySaveSettingsIsInProgress = new AtomicBoolean(false);
@@ -530,6 +532,7 @@
   public void load(String path) throws IOException, InvalidDataException {
     getStateStore().setOptionsPath(path);
     getStateStore().setConfigPath(PathManager.getConfigPath());
+
     myIsFiringLoadingEvent = true;
     try {
       fireBeforeApplicationLoaded();
@@ -551,6 +554,15 @@
       HeavyProcessLatch.INSTANCE.processFinished();
     }
     myLoaded = true;
+
+    File locatorFile = new File(PathManager.getSystemPath() + "/" + ApplicationEx.LOCATOR_FILE_NAME);
+    try {
+      byte[] data = PathManager.getHomePath().getBytes("UTF-8");
+      FileUtil.writeToFile(locatorFile, data);
+    }
+    catch (Exception e) {
+      LOG.warn("can't store a location in '" + locatorFile + "'", e);
+    }
   }
 
   @Override
@@ -1154,7 +1166,7 @@
       if (root != null) {
         component.putClientProperty(WAS_EVER_SHOWN, Boolean.TRUE);
         assertIsDispatchThread();
-      } 
+      }
     }
   }
 
diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/AbstractColorsScheme.java b/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/AbstractColorsScheme.java
index b446df3..ff0fa50 100644
--- a/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/AbstractColorsScheme.java
+++ b/platform/platform-impl/src/com/intellij/openapi/editor/colors/impl/AbstractColorsScheme.java
@@ -19,6 +19,7 @@
  */
 package com.intellij.openapi.editor.colors.impl;
 
+import com.intellij.ide.ui.UISettings;
 import com.intellij.openapi.editor.HighlighterColors;
 import com.intellij.openapi.editor.colors.*;
 import com.intellij.openapi.editor.colors.ex.DefaultColorSchemesManager;
@@ -172,6 +173,10 @@
 
   @Override
   public Font getFont(EditorFontType key) {
+    if (UISettings.getInstance().PRESENTATION_MODE) {
+      final Font font = myFonts.get(key);
+      return new Font(font.getName(), font.getStyle(), UISettings.getInstance().PRESENTATION_MODE_FONT_SIZE);
+    }
     return myFonts.get(key);
   }
 
diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/ex/EditorSettingsExternalizable.java b/platform/platform-impl/src/com/intellij/openapi/editor/ex/EditorSettingsExternalizable.java
index 92858fc..44ae129 100644
--- a/platform/platform-impl/src/com/intellij/openapi/editor/ex/EditorSettingsExternalizable.java
+++ b/platform/platform-impl/src/com/intellij/openapi/editor/ex/EditorSettingsExternalizable.java
@@ -53,6 +53,7 @@
     public boolean IS_ENSURE_NEWLINE_AT_EOF = false;
     public boolean SHOW_QUICK_DOC_ON_MOUSE_OVER_ELEMENT = false;
     public long QUICK_DOC_ON_MOUSE_OVER_DELAY_MS = 500;
+    public boolean SHOW_INTENTION_BULB = true;
     public boolean IS_CARET_BLINKING = true;
     public int CARET_BLINKING_PERIOD = 500;
     public boolean IS_RIGHT_MARGIN_SHOWN = true;
@@ -393,6 +394,14 @@
     myOptions.QUICK_DOC_ON_MOUSE_OVER_DELAY_MS = delay;
   }
 
+  public boolean isShowIntentionBulb() {
+    return myOptions.SHOW_INTENTION_BULB;
+  }
+
+  public void setShowIntentionBulb(boolean show) {
+    myOptions.SHOW_INTENTION_BULB = show;
+  }
+
   public boolean isRefrainFromScrolling() {
     return myOptions.REFRAIN_FROM_SCROLLING;
   }
diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/ex/util/EditorUtil.java b/platform/platform-impl/src/com/intellij/openapi/editor/ex/util/EditorUtil.java
index b663634..ede4d2b 100644
--- a/platform/platform-impl/src/com/intellij/openapi/editor/ex/util/EditorUtil.java
+++ b/platform/platform-impl/src/com/intellij/openapi/editor/ex/util/EditorUtil.java
@@ -760,6 +760,14 @@
   public static boolean inVirtualSpace(@NotNull Editor editor, @NotNull LogicalPosition logicalPosition) {
     return !editor.offsetToLogicalPosition(editor.logicalPositionToOffset(logicalPosition)).equals(logicalPosition);
   }
+
+  public static void reinitSettings() {
+    for (Editor editor : EditorFactory.getInstance().getAllEditors()) {
+      if (editor instanceof EditorEx) {
+        ((EditorEx)editor).reinitSettings();
+      }
+    }
+  }
 }
 
 
diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorGutterComponentImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorGutterComponentImpl.java
index 27aac0e..3d67e5c 100644
--- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorGutterComponentImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/EditorGutterComponentImpl.java
@@ -1414,6 +1414,14 @@
                                                                                         actionGroup);
           popupMenu.getComponent().show(this, e.getX(), e.getY());
           e.consume();
+        } else {
+          AnAction rightButtonAction = renderer.getRightButtonClickAction();
+          if (rightButtonAction != null) {
+            rightButtonAction.actionPerformed(new AnActionEvent(e, myEditor.getDataContext(), "ICON_NAVIGATION_SECONDARY_BUTTON", rightButtonAction.getTemplatePresentation(),
+                                                                ActionManager.getInstance(),
+                                                                e.getModifiers()));
+            e.consume();
+          }
         }
       }
       else {
diff --git a/platform/platform-impl/src/com/intellij/openapi/editor/impl/SettingsImpl.java b/platform/platform-impl/src/com/intellij/openapi/editor/impl/SettingsImpl.java
index d727d2b..237453d 100644
--- a/platform/platform-impl/src/com/intellij/openapi/editor/impl/SettingsImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/editor/impl/SettingsImpl.java
@@ -77,6 +77,7 @@
   private Integer myCustomSoftWrapIndent                  = null;
   private Boolean myRenamePreselect                       = null;
   private Boolean myWrapWhenTypingReachesRightMargin      = null;
+  private Boolean myShowIntentionBulb                     = null;
 
   public SettingsImpl(@Nullable EditorEx editor) {
     myEditor = editor;
@@ -531,4 +532,14 @@
   public void setPreselectRename(boolean val) {
     myRenamePreselect = val;
   }
+
+  @Override
+  public boolean isShowIntentionBulb() {
+    return myShowIntentionBulb == null ? EditorSettingsExternalizable.getInstance().isShowIntentionBulb() : myShowIntentionBulb;
+  }
+
+  @Override
+  public void setShowIntentionBulb(boolean show) {
+    myShowIntentionBulb = show; 
+  }
 }
diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/encoding/EncodingManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/vfs/encoding/EncodingManagerImpl.java
index c20143d..441fa53 100644
--- a/platform/platform-impl/src/com/intellij/openapi/vfs/encoding/EncodingManagerImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/vfs/encoding/EncodingManagerImpl.java
@@ -55,6 +55,7 @@
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
+import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
 import java.beans.PropertyChangeSupport;
 import java.lang.ref.Reference;
@@ -133,9 +134,9 @@
     });
   }
 
-  private void setCachedCharsetFromContent(Charset charset, Charset oldCached, Document document) {
+  private void setCachedCharsetFromContent(Charset charset, Charset oldCached, @NotNull Document document) {
     document.putUserData(CACHED_CHARSET_FROM_CONTENT, charset);
-    firePropertyChange(PROP_CACHED_ENCODING_CHANGED, oldCached, charset);
+    firePropertyChange(document, PROP_CACHED_ENCODING_CHANGED, oldCached, charset);
   }
 
   @Nullable("returns null if charset set cannot be determined from content")
@@ -312,7 +313,8 @@
   public void removePropertyChangeListener(@NotNull PropertyChangeListener listener){
     myPropertyChangeSupport.removePropertyChangeListener(listener);
   }
-  void firePropertyChange(final String propertyName, final Object oldValue, final Object newValue) {
-    myPropertyChangeSupport.firePropertyChange(propertyName, oldValue, newValue);
+  void firePropertyChange(@Nullable Document document, @NotNull String propertyName, final Object oldValue, final Object newValue) {
+    Object source = document == null ? this : document;
+    myPropertyChangeSupport.firePropertyChange(new PropertyChangeEvent(source, propertyName, oldValue, newValue));
   }
 }
diff --git a/platform/platform-impl/src/com/intellij/openapi/vfs/encoding/EncodingProjectManagerImpl.java b/platform/platform-impl/src/com/intellij/openapi/vfs/encoding/EncodingProjectManagerImpl.java
index 826028c..70f088b 100644
--- a/platform/platform-impl/src/com/intellij/openapi/vfs/encoding/EncodingProjectManagerImpl.java
+++ b/platform/platform-impl/src/com/intellij/openapi/vfs/encoding/EncodingProjectManagerImpl.java
@@ -312,10 +312,10 @@
 
     Set<VirtualFile> added = new HashSet<VirtualFile>(newMap.keySet());
     added.removeAll(oldMap.keySet());
-    
+
     Set<VirtualFile> removed = new HashSet<VirtualFile>(oldMap.keySet());
     removed.removeAll(newMap.keySet());
-    
+
     changed.addAll(added);
     changed.addAll(removed);
 
@@ -463,7 +463,7 @@
   public void setNative2AsciiForPropertiesFiles(final VirtualFile virtualFile, final boolean native2Ascii) {
     if (myNative2AsciiForPropertiesFiles != native2Ascii) {
       myNative2AsciiForPropertiesFiles = native2Ascii;
-      ((EncodingManagerImpl)EncodingManager.getInstance()).firePropertyChange(PROP_NATIVE2ASCII_SWITCH, !native2Ascii, native2Ascii);
+      ((EncodingManagerImpl)EncodingManager.getInstance()).firePropertyChange(null, PROP_NATIVE2ASCII_SWITCH, !native2Ascii, native2Ascii);
     }
   }
 
@@ -478,7 +478,7 @@
     Charset old = myDefaultCharsetForPropertiesFiles;
     if (!Comparing.equal(old, charset)) {
       myDefaultCharsetForPropertiesFiles = charset;
-      ((EncodingManagerImpl)EncodingManager.getInstance()).firePropertyChange(PROP_PROPERTIES_FILES_ENCODING, old, charset);
+      ((EncodingManagerImpl)EncodingManager.getInstance()).firePropertyChange(null, PROP_PROPERTIES_FILES_ENCODING, old, charset);
     }
   }
 
diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeRootPane.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeRootPane.java
index e81f206..b4105c5 100644
--- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeRootPane.java
+++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/IdeRootPane.java
@@ -316,7 +316,7 @@
   }
 
   private void updateStatusBarVisibility(){
-    myStatusBar.setVisible(myUISettings.SHOW_STATUS_BAR && (!myUISettings.PRESENTATION_MODE || myUISettings.PRESENTATION_MODE_ALLOW_STATUS_BAR));
+    myStatusBar.setVisible(myUISettings.SHOW_STATUS_BAR && !myUISettings.PRESENTATION_MODE);
   }
 
   public void installNorthComponents(final Project project) {
diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/SystemDock.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/SystemDock.java
index 5daa1e2..2252971 100644
--- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/SystemDock.java
+++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/SystemDock.java
@@ -15,6 +15,7 @@
  */
 package com.intellij.openapi.wm.impl;
 
+import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.util.SystemInfo;
 import com.intellij.ui.mac.MacDockImpl;
 
@@ -22,9 +23,17 @@
  * @author Denis Fokin
  */
 public class SystemDock {
+
+  private static final Logger LOG = Logger.getInstance("#com.intellij.openapi.wm.impl.SystemDock");
+
   synchronized public static void initialize() {
     if (SystemInfo.isMac) {
-      MacDockImpl.initialize();
+      try {
+        MacDockImpl.initialize();
+      }
+      catch (Exception e) {
+        LOG.error(e);
+      }
     }
   }
 }
diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/X11UiUtil.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/X11UiUtil.java
index 23b74c6..caa0487 100644
--- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/X11UiUtil.java
+++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/X11UiUtil.java
@@ -15,11 +15,12 @@
  */
 package com.intellij.openapi.wm.impl;
 
+import com.intellij.Patches;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.util.SystemInfo;
+import com.intellij.openapi.util.registry.Registry;
 import com.intellij.openapi.wm.IdeFrame;
 import com.intellij.openapi.wm.WindowManager;
-import com.intellij.util.SystemProperties;
 import org.jetbrains.annotations.Nullable;
 import sun.misc.Unsafe;
 
@@ -243,7 +244,7 @@
 
   @SuppressWarnings("SpellCheckingInspection")
   public static void patchDetectedWm(String wmName) {
-    if (X11 == null || SystemProperties.getBooleanProperty("idea.skip.wm.patching", false)) return;
+    if (X11 == null || Registry.is("idea.x11.skip.wm.patching")) return;
 
     try {
       if (wmName.startsWith("Mutter") || "Muffin".equals(wmName) || "GNOME Shell".equals(wmName)) {
@@ -293,7 +294,7 @@
   public static boolean isFullScreenSupported() {
     if (X11 == null) return false;
 
-    if (SystemInfo.isJavaVersionAtLeast("1.7")) {
+    if (Patches.SUN_BUG_ID_8013359) {
       String wmName = getWmName();
       if (wmName != null &&
           (wmName.startsWith("Mutter") || newHashSet("Metacity", "GNOME Shell", "Muffin", "Marco").contains(wmName))) {
diff --git a/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/EncodingPanel.java b/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/EncodingPanel.java
index 98a47ff..848141b 100644
--- a/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/EncodingPanel.java
+++ b/platform/platform-impl/src/com/intellij/openapi/wm/impl/status/EncodingPanel.java
@@ -27,9 +27,7 @@
 import com.intellij.openapi.editor.EditorFactory;
 import com.intellij.openapi.editor.event.DocumentAdapter;
 import com.intellij.openapi.editor.event.DocumentEvent;
-import com.intellij.openapi.fileEditor.FileDocumentManager;
-import com.intellij.openapi.fileEditor.FileEditorManager;
-import com.intellij.openapi.fileEditor.FileEditorManagerEvent;
+import com.intellij.openapi.fileEditor.*;
 import com.intellij.openapi.fileEditor.impl.LoadTextUtil;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.ui.popup.ListPopup;
@@ -59,6 +57,8 @@
 import java.awt.event.MouseEvent;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
+import java.lang.ref.Reference;
+import java.lang.ref.WeakReference;
 import java.nio.charset.Charset;
 
 /**
@@ -68,6 +68,7 @@
   private final TextPanel myComponent;
   private boolean actionEnabled;
   private final Alarm update;
+  private volatile Reference<Editor> myEditor = new WeakReference<Editor>(null); // store editor here to avoid expensive and EDT-only getSelectedEditor() retrievals
 
   public EncodingPanel(@NotNull final Project project) {
     super(project);
@@ -108,12 +109,20 @@
   @Override
   public void selectionChanged(@NotNull FileEditorManagerEvent event) {
     if (ApplicationManager.getApplication().isUnitTestMode()) return;
+    VirtualFile newFile = event.getNewFile();
+    fileChanged(newFile);
+  }
+
+  private void fileChanged(VirtualFile newFile) {
+    FileEditor fileEditor = newFile == null ? null : FileEditorManager.getInstance(getProject()).getSelectedEditor(newFile);
+    Editor editor = fileEditor instanceof TextEditor ? ((TextEditor)fileEditor).getEditor() : null;
+    myEditor = new WeakReference<Editor>(editor);
     update();
   }
 
   @Override
   public void fileOpened(@NotNull FileEditorManager source, @NotNull VirtualFile file) {
-    update();
+    fileChanged(file);
   }
 
   @Override
@@ -140,7 +149,8 @@
       @Override
       public void propertyChange(PropertyChangeEvent evt) {
         if (evt.getPropertyName().equals(EncodingManagerImpl.PROP_CACHED_ENCODING_CHANGED)) {
-          update();
+          Document document = evt.getSource() instanceof Document ? (Document)evt.getSource() : null;
+          updateForDocument(document);
         }
       }
     }, this);
@@ -148,7 +158,7 @@
       @Override
       public void propertyChanged(VirtualFilePropertyEvent event) {
         if (VirtualFile.PROP_ENCODING.equals(event.getPropertyName())) {
-          update();
+          updateForFile(event.getFile());
         }
       }
     }));
@@ -157,13 +167,26 @@
       @Override
       public void documentChanged(DocumentEvent e) {
         Document document = e.getDocument();
-        Editor selectedEditor = getEditor();
-        if (selectedEditor == null || selectedEditor.getDocument() != document) return;
-        update();
+        updateForDocument(document);
       }
     }, this);
   }
 
+  private void updateForDocument(@Nullable("null means update anyway") Document document) {
+    Editor selectedEditor = myEditor.get();
+    if (document != null && (selectedEditor == null || selectedEditor.getDocument() != document)) return;
+    update();
+  }
+
+  private void updateForFile(@Nullable("null means update anyway") VirtualFile file) {
+    if (file == null) {
+      update();
+    }
+    else {
+      updateForDocument(FileDocumentManager.getInstance().getCachedDocument(file));
+    }
+  }
+
   private void showPopup(MouseEvent e) {
     if (!actionEnabled) {
       return;
@@ -215,7 +238,7 @@
             charset = file.getCharset();
           }
 
-          actionEnabled = (check == null || check.second == null);
+          actionEnabled = check == null || check.second == null;
 
           if (!actionEnabled) {
             charset = check.first;
@@ -240,7 +263,7 @@
           myComponent.setTextAlignment(Component.LEFT_ALIGNMENT);
         }
         else {
-          String failReason = (check == null) ? "" : check.second;
+          String failReason = check == null ? "" : check.second;
           toolTipText = String.format("File encoding is disabled%n%s",
                                       failReason);
 
diff --git a/platform/platform-impl/src/com/intellij/ui/mac/MacDockImpl.java b/platform/platform-impl/src/com/intellij/ui/mac/MacDockImpl.java
index 1b8f9a0..25290db 100644
--- a/platform/platform-impl/src/com/intellij/ui/mac/MacDockImpl.java
+++ b/platform/platform-impl/src/com/intellij/ui/mac/MacDockImpl.java
@@ -20,13 +20,9 @@
 import com.intellij.ide.impl.ProjectUtil;
 import com.intellij.openapi.actionSystem.AnAction;
 import com.intellij.openapi.application.impl.LaterInvocator;
-import com.intellij.openapi.util.io.UniqueNameBuilder;
 import com.intellij.ui.mac.foundation.ID;
-import com.intellij.util.SystemProperties;
 import com.sun.jna.Callback;
 
-import java.io.File;
-
 import static com.intellij.ui.mac.foundation.Foundation.*;
 
 /**
@@ -82,8 +78,6 @@
 
         invoke(recentProjectsMenuWrapperItem, "setSubmenu:", recentProjectsMenu);
 
-        final UniqueNameBuilder<ReopenProjectAction> myPathShortener =
-          new UniqueNameBuilder<ReopenProjectAction>(SystemProperties.getUserHome(), File.separator, 40);
         for (AnAction action : recentProjectActions) {
           addItemToDockRecentProjectsMenu(recentProjectsMenu, (ReopenProjectAction)action);
         }
diff --git a/platform/platform-resources-en/src/messages/IdeBundle.properties b/platform/platform-resources-en/src/messages/IdeBundle.properties
index 05d0992..eb22ab1 100644
--- a/platform/platform-resources-en/src/messages/IdeBundle.properties
+++ b/platform/platform-resources-en/src/messages/IdeBundle.properties
@@ -1112,3 +1112,4 @@
 checkbox.allow.status.bar=Allow Status Bar
 checkbox.allow.line.numbers=Allow Line Numbers
 checkbox.allow.vcs.annotations=Allow VCS Annotations
+presentation.mode.fon.size=Font size\:
diff --git a/platform/platform-resources-en/src/misc/registry.properties b/platform/platform-resources-en/src/misc/registry.properties
index ce3816f..7f277a8 100644
--- a/platform/platform-resources-en/src/misc/registry.properties
+++ b/platform/platform-resources-en/src/misc/registry.properties
@@ -64,6 +64,8 @@
 # suppress inspection "UnusedProperty"
 idea.fix.mac.env.description=On Mac, use shell environment for external processes (effective on restart).
 
+idea.x11.skip.wm.patching=false
+
 ide.appIcon.progress=true
 ide.appIcon.badge=true
 ide.appIcon.requestAttention=true
@@ -129,6 +131,7 @@
 ide.mac.useNativeClipboard=false
 ide.mac.boldEditorTabs=false
 ide.mac.modalDialogsOnFullscreen=false
+# suppress inspection "UnusedProperty"
 ide.mac.modalDialogsOnFullscreen.description=New modality approach. All dialogs are DOCUMENT_MODAL expect ide-wide dialogs
 
 ide.mac.retina.disableDrawingFix=false
diff --git a/platform/platform-resources/src/META-INF/xdebugger.xml b/platform/platform-resources/src/META-INF/xdebugger.xml
index 3a47c11..013a4d8 100644
--- a/platform/platform-resources/src/META-INF/xdebugger.xml
+++ b/platform/platform-resources/src/META-INF/xdebugger.xml
@@ -23,8 +23,8 @@
 
     <projectService serviceImplementation="com.intellij.xdebugger.impl.evaluate.quick.common.ValueLookupManager"/>
 
-    <projectService serviceInterface="com.intellij.xdebugger.impl.breakpoints.ui.BreakpointsMasterDetailPopupFactory"
-                    serviceImplementation="com.intellij.xdebugger.impl.breakpoints.ui.BreakpointsMasterDetailPopupFactory"/>
+    <projectService serviceInterface="com.intellij.xdebugger.impl.breakpoints.ui.BreakpointsDialogFactory"
+                    serviceImplementation="com.intellij.xdebugger.impl.breakpoints.ui.BreakpointsDialogFactory"/>
 
     <projectService serviceInterface="com.intellij.xdebugger.impl.XDebuggerHistoryManager"
                     serviceImplementation="com.intellij.xdebugger.impl.XDebuggerHistoryManager"/>
diff --git a/platform/platform-tests/testSrc/com/intellij/ide/LocatorTest.java b/platform/platform-tests/testSrc/com/intellij/ide/LocatorTest.java
new file mode 100644
index 0000000..8c9f04d
--- /dev/null
+++ b/platform/platform-tests/testSrc/com/intellij/ide/LocatorTest.java
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2000-2013 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.ide;
+
+import com.intellij.openapi.application.PathManager;
+import com.intellij.openapi.application.ex.ApplicationEx;
+import com.intellij.openapi.util.io.FileUtil;
+import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.testFramework.PlatformLangTestCase;
+
+import java.io.File;
+
+public class LocatorTest extends PlatformLangTestCase {
+  public void test() throws Exception {
+    File locatorFile = new File(PathManager.getSystemPath() + "/" + ApplicationEx.LOCATOR_FILE_NAME);
+    assertTrue(locatorFile.getPath(), locatorFile.canRead());
+
+    String home = FileUtil.loadFile(locatorFile, "UTF-8");
+    assertTrue(home, StringUtil.isNotEmpty(home));
+
+    assertEquals(home, PathManager.getHomePath());
+  }
+}
diff --git a/platform/platform-tests/testSrc/com/intellij/psi/util/NameUtilMatchingTest.groovy b/platform/platform-tests/testSrc/com/intellij/psi/util/NameUtilMatchingTest.groovy
index d0d8494..ce1abaf 100644
--- a/platform/platform-tests/testSrc/com/intellij/psi/util/NameUtilMatchingTest.groovy
+++ b/platform/platform-tests/testSrc/com/intellij/psi/util/NameUtilMatchingTest.groovy
@@ -255,6 +255,7 @@
     assertDoesntMatch("*foc", "reformatCode");
     assertMatches("*forc", "reformatCode");
     assertDoesntMatch("*sTC", "LazyClassTypeConstructor");
+
     assertDoesntMatch("*Icon", "LEADING_CONSTRUCTOR");
     assertMatches("*I", "LEADING_CONSTRUCTOR");
     assertMatches("*i", "LEADING_CONSTRUCTOR");
@@ -262,6 +263,11 @@
     assertMatches("*ing", "LEADING_CONSTRUCTOR");
     assertDoesntMatch("*inc", "LEADING_CONSTRUCTOR");
     assertDoesntMatch("*ico", "drawLinePickedOut");
+
+    assertMatches("*l", "AppDelegate");
+    assertMatches("*le", "AppDelegate");
+    assertMatches("*leg", "AppDelegate");
+
   }
 
   public void testMiddleMatchingUnderscore() {
@@ -362,6 +368,9 @@
   }
 
   public void testFinalSpace() {
+    assertMatches("a ", "alpha + beta");
+    assertMatches("a ", "a ");
+    assertMatches("a ", "a");
     assertMatches("GrDebT ", "GroovyDebuggerTest");
     assertDoesntMatch("grdebT ", "GroovyDebuggerTest");
     assertDoesntMatch("grdebt ", "GroovyDebuggerTest");
@@ -446,10 +455,24 @@
                         TextRange.from(0, 4), TextRange.from(10, 1));
   }
 
-  public void "test plus in the pattern should allow to be space-surrounded"() {
+  public void "test plus/minus in the pattern should allow to be space-surrounded"() {
     assertMatches("a+b", "alpha+beta")
     assertMatches("a+b", "alpha_gamma+beta")
     assertMatches("a+b", "alpha + beta")
+    assertMatches("Foo+", "Foo+Bar.txt")
+    assertMatches("Foo+", "Foo + Bar.txt")
+    assertMatches("a", "alpha+beta");
+    assertMatches("*b", "alpha+beta");
+    assertMatches("a + b", "alpha+beta");
+    assertMatches("a+", "alpha+beta");
+    assertDoesntMatch("a ", "alpha+beta");
+    assertMatches("", "alpha+beta");
+    assertMatches("*+ b", "alpha+beta");
+    assertDoesntMatch("d+g", "alphaDelta+betaGamma");
+    assertMatches("*d+g", "alphaDelta+betaGamma");
+
+    assertMatches("a-b", "alpha-beta")
+    assertMatches("a-b", "alpha - beta")
   }
 
   public void testMatchingDegree() {
@@ -558,6 +581,11 @@
     assertDoesntMatch("URLCl", "UrlClassLoader");
   }
 
+  public void "test a capital after another capital may match a lowercase letter because shift was accidentally help too long"() {
+    assertMatches("USerDefa", "UserDefaults")
+    assertMatches("NSUSerDefa", "NSUserDefaults")
+  }
+
   public void testPerformance() {
     System.out.println("test start: " + System.currentTimeMillis());
     @NonNls final String longName = "ThisIsAQuiteLongNameWithParentheses().Dots.-Minuses-_UNDERSCORES_digits239:colons:/slashes\\AndOfCourseManyLetters";
diff --git a/platform/projectModel-api/src/com/intellij/openapi/roots/ModuleExtension.java b/platform/projectModel-api/src/com/intellij/openapi/roots/ModuleExtension.java
index 86af83c..d3fb969 100644
--- a/platform/projectModel-api/src/com/intellij/openapi/roots/ModuleExtension.java
+++ b/platform/projectModel-api/src/com/intellij/openapi/roots/ModuleExtension.java
@@ -24,6 +24,7 @@
 import com.intellij.openapi.extensions.ExtensionPointName;
 import com.intellij.openapi.util.JDOMExternalizable;
 import com.intellij.openapi.vfs.VirtualFile;
+import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
 public abstract class ModuleExtension<T extends ModuleExtension> implements JDOMExternalizable, Disposable, Comparable<ModuleExtension> {
@@ -47,7 +48,8 @@
     return null;
   }
 
-  public int compareTo(final ModuleExtension o) {
+  @Override
+  public int compareTo(@NotNull final ModuleExtension o) {
     return getClass().getName().compareTo(o.getClass().getName());
   }
 }
\ No newline at end of file
diff --git a/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/storage/ClassPathStorageUtil.java b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/storage/ClassPathStorageUtil.java
new file mode 100644
index 0000000..a2d9c75
--- /dev/null
+++ b/platform/projectModel-impl/src/com/intellij/openapi/roots/impl/storage/ClassPathStorageUtil.java
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2000-2013 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.openapi.roots.impl.storage;
+
+import com.intellij.openapi.module.Module;
+import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.jps.model.serialization.JpsProjectLoader;
+
+public class ClassPathStorageUtil {
+  @NonNls public static final String DEFAULT_STORAGE = "default";
+  @NonNls public static final String CLASSPATH_OPTION = JpsProjectLoader.CLASSPATH_ATTRIBUTE;
+
+  public static boolean isDefaultStorage(@NotNull Module module) {
+    final String storageType = getStorageType(module);
+    return storageType.equals(DEFAULT_STORAGE);
+  }
+
+  @NotNull
+  public static String getStorageType(@NotNull Module module) {
+    final String id = module.getOptionValue(CLASSPATH_OPTION);
+    return id == null ? DEFAULT_STORAGE : id;
+  }
+}
diff --git a/platform/util/src/com/intellij/Patches.java b/platform/util/src/com/intellij/Patches.java
index e697234..10dd40d 100644
--- a/platform/util/src/com/intellij/Patches.java
+++ b/platform/util/src/com/intellij/Patches.java
@@ -116,4 +116,12 @@
    * See http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=9000030.
    */
   public static final boolean SUN_BUG_ID_9000030 = SystemInfo.isXWindow && SystemInfo.isJavaVersionAtLeast("1.7");
+
+  /**
+   * On some WMs modal dialogs may show behind full screen window.
+   * See http://bugs.sun.com/view_bug.do?bug_id=8013359.
+   */
+  public static final boolean SUN_BUG_ID_8013359 =
+    SystemInfo.isXWindow && SystemInfo.isJavaVersionAtLeast("1.7") && !SystemInfo.isJavaVersionAtLeast("1.7.0.40");
+
 }
diff --git a/platform/platform-api/src/com/intellij/openapi/ui/VerticalFlowLayout.java b/platform/util/src/com/intellij/openapi/ui/VerticalFlowLayout.java
similarity index 100%
rename from platform/platform-api/src/com/intellij/openapi/ui/VerticalFlowLayout.java
rename to platform/util/src/com/intellij/openapi/ui/VerticalFlowLayout.java
diff --git a/platform/util/src/com/intellij/openapi/util/IconLoader.java b/platform/util/src/com/intellij/openapi/util/IconLoader.java
index 09c0bc2..799dbca 100644
--- a/platform/util/src/com/intellij/openapi/util/IconLoader.java
+++ b/platform/util/src/com/intellij/openapi/util/IconLoader.java
@@ -113,13 +113,14 @@
   @NotNull
   public static Icon getIcon(@NonNls @NotNull final String path) {
     int stackFrameCount = 2;
-    Class callerClass = ReflectionUtil.getCallerClass(stackFrameCount);
+    Class callerClass = ReflectionUtil.findCallerClass(stackFrameCount);
     while (callerClass != null && callerClass.getClassLoader() == null) { // looks like a system class
-      callerClass = ReflectionUtil.getCallerClass(++stackFrameCount);
+      callerClass = ReflectionUtil.findCallerClass(++stackFrameCount);
     }
     if (callerClass == null) {
-      callerClass = ReflectionUtil.getCallerClass(1);
+      callerClass = ReflectionUtil.findCallerClass(1);
     }
+    assert callerClass != null : path;
     return getIcon(path, callerClass);
   }
 
@@ -144,13 +145,14 @@
    */
   public static Icon findIcon(@NonNls @NotNull String path) {
     int stackFrameCount = 2;
-    Class callerClass = ReflectionUtil.getCallerClass(stackFrameCount);
+    Class callerClass = ReflectionUtil.findCallerClass(stackFrameCount);
     while (callerClass != null && callerClass.getClassLoader() == null) { // looks like a system class
-      callerClass = ReflectionUtil.getCallerClass(++stackFrameCount);
+      callerClass = ReflectionUtil.findCallerClass(++stackFrameCount);
     }
     if (callerClass == null) {
-      callerClass = ReflectionUtil.getCallerClass(1);
+      callerClass = ReflectionUtil.findCallerClass(1);
     }
+    if (callerClass == null) return null;
     return findIcon(path, callerClass);
   }
 
@@ -194,7 +196,8 @@
     return icon;
   }
 
-  private static String undeprecate(String path) {
+  @NotNull
+  private static String undeprecate(@NotNull String path) {
     String replacement = ourDeprecatedIconsReplacements.get(path);
     return replacement == null ? path : replacement;
   }
@@ -221,7 +224,7 @@
   public static Icon findIcon(@NotNull String path, final ClassLoader classLoader) {
     path = undeprecate(path);
     if (isReflectivePath(path)) return getReflectiveIcon(path, classLoader);
-    if (!path.startsWith("/")) return null;
+    if (!StringUtil.startsWithChar(path, '/')) return null;
 
     final URL url = classLoader.getResource(path.substring(1));
     return findIcon(url);
@@ -438,6 +441,7 @@
       return findIcon(url);
     }
 
+    @NonNls
     @Override
     public String toString() {
       return "icon path=" + myPath + " class=" + myCallerClass;
diff --git a/platform/util/src/com/intellij/openapi/util/JDOMExternalizableStringList.java b/platform/util/src/com/intellij/openapi/util/JDOMExternalizableStringList.java
index 6fdf557..869e2ed 100644
--- a/platform/util/src/com/intellij/openapi/util/JDOMExternalizableStringList.java
+++ b/platform/util/src/com/intellij/openapi/util/JDOMExternalizableStringList.java
@@ -48,10 +48,15 @@
   public void readExternal(Element element) throws InvalidDataException {
     clear();
 
+    Class callerClass = null;
     for (final Object o : element.getChildren()) {
       Element listElement = (Element)o;
       if (ATTR_LIST.equals(listElement.getName())) {
-        final ClassLoader classLoader = ReflectionUtil.getCallerClass(2).getClassLoader();
+        if (callerClass == null) {
+          callerClass = ReflectionUtil.findCallerClass(2);
+          assert callerClass != null;
+        }
+        final ClassLoader classLoader = callerClass.getClassLoader();
         for (final Object o1 : listElement.getChildren()) {
           Element listItemElement = (Element)o1;
           if (!ATTR_ITEM.equals(listItemElement.getName())) {
diff --git a/platform/util/src/com/intellij/openapi/util/io/win32/IdeaWin32.java b/platform/util/src/com/intellij/openapi/util/io/win32/IdeaWin32.java
index f06c699..4d89732 100644
--- a/platform/util/src/com/intellij/openapi/util/io/win32/IdeaWin32.java
+++ b/platform/util/src/com/intellij/openapi/util/io/win32/IdeaWin32.java
@@ -40,16 +40,19 @@
   static {
     boolean available = false;
     if (SystemInfo.isWin2kOrNewer) {
-      String libName = SystemInfo.is64Bit ? "IdeaWin64" : "IdeaWin32";
+      String libName = SystemInfo.is64Bit ? "IdeaWin64.dll" : "IdeaWin32.dll";
       try {
-        String path = PathManager.getBinPath() + "/" + libName + ".dll";
+        String path = PathManager.getBinPath() + "/" + libName;
         if (!new File(path).exists()) {
-          path = PathManager.getHomePath() + "/community/bin/win/" + libName + ".dll";
+          path = PathManager.getHomePath() + "/community/bin/win/" + libName;
           if (!new File(path).exists()) {
-            path = PathManager.getHomePath() + "/bin/win/" + libName + ".dll";
+            path = PathManager.getHomePath() + "/bin/win/" + libName;
             if (!new File(path).exists()) {
-              throw new FileNotFoundException("Native filesystem .dll is missing (path=" + PathManager.getBinPath() +
-                                              " content=" + Arrays.toString(new File(PathManager.getBinPath()).list()) + ")");
+              path = PathManager.getHomePathFor(IdeaWin32.class) + "/bin/" + libName;
+              if (!new File(path).exists()) {
+                throw new FileNotFoundException("Native filesystem .dll is missing (path=" + PathManager.getBinPath() +
+                                                " content=" + Arrays.toString(new File(PathManager.getBinPath()).list()) + ")");
+              }
             }
           }
         }
diff --git a/platform/util/src/com/intellij/psi/codeStyle/MinusculeMatcher.java b/platform/util/src/com/intellij/psi/codeStyle/MinusculeMatcher.java
index a97c13e..b92f73e 100644
--- a/platform/util/src/com/intellij/psi/codeStyle/MinusculeMatcher.java
+++ b/platform/util/src/com/intellij/psi/codeStyle/MinusculeMatcher.java
@@ -73,7 +73,7 @@
     }
     int i = 0;
     while (isWildcard(i)) i++;
-    myHasHumps = hasFlag(i + 1, isUpperCase) && hasFlag(i, isLowerCase) || pattern.contains("+");
+    myHasHumps = hasFlag(i + 1, isUpperCase) && hasFlag(i, isLowerCase);
     myHasSeparators = hasFlag(i, isWordSeparator);
     myHasDots = hasDots(i);
     myHasWildCards = hasWildCards();
@@ -83,6 +83,24 @@
     return Character.isWhitespace(c) || c == '_' || c == '-' || c == ':' || c == '+';
   }
 
+  private static boolean isWordStart(String text, int i) {
+    char c = text.charAt(i);
+    if (Character.isUpperCase(c)) {
+      if (i > 0 && Character.isUpperCase(text.charAt(i - 1))) {
+        // check that we're not in the middle of an all-caps word
+        return i + 1 < text.length() && Character.isLowerCase(text.charAt(i + 1));
+      }
+      return true;
+    }
+    if (Character.isDigit(c)) {
+      return true;
+    }
+    if (!Character.isLetter(c)) {
+      return false;
+    }
+    return i == 0 || !Character.isLetterOrDigit(text.charAt(i - 1));
+  }
+
   private boolean hasWildCards() {
     for (int i = 0; i < myPattern.length; i++) {
       if (isWildcard(i)) {
@@ -163,7 +181,7 @@
 
     int startIndex = first.getStartOffset();
     boolean afterSeparator = StringUtil.indexOfAny(name, HARD_SEPARATORS, 0, startIndex) >= 0;
-    boolean wordStart = startIndex == 0 || NameUtil.isWordStart(name, startIndex) && !NameUtil.isWordStart(name, startIndex - 1);
+    boolean wordStart = startIndex == 0 || isWordStart(name, startIndex) && !isWordStart(name, startIndex - 1);
 
     return (wordStart ? 1000 : 0) - integral * 10 + matchingCase + (afterSeparator ? 0 : 1);
   }
@@ -230,8 +248,12 @@
 
     if (patternIndex == myPattern.length) {
       boolean space = isPatternChar(patternIndex - 1, ' ');
-      // the trailing space should match if the pattern ends with the last name part, or only its first hump character
+      // the trailing space should match if the pattern ends with the last word part, or only its first hump character
       if (space && nameIndex != name.length() && (patternIndex < 2 || !NameUtil.isWordStart(myPattern[patternIndex - 2]))) {
+        int spaceIndex = name.indexOf(' ', nameIndex);
+        if (spaceIndex >= 0) {
+          return FList.<TextRange>emptyList().prepend(TextRange.from(spaceIndex, 1));
+        }
         return null;
       }
       return FList.emptyList();
@@ -275,7 +297,7 @@
       // uppercase should match either uppercase or a word start
       if (!isUpperCase[patternIndex] ||
           star && Character.isUpperCase(name.charAt(nextOccurrence)) ||
-          NameUtil.isWordStart(name, nextOccurrence)) {
+          isWordStart(name, nextOccurrence)) {
         FList<TextRange> ranges = matchFragment(name, patternIndex, nextOccurrence, matchingState);
         if (ranges != null) {
           return ranges;
@@ -320,7 +342,7 @@
 
     // middle matches have to be at least of length 3, to prevent too many irrelevant matches
     int minFragment = isPatternChar(patternIndex - 1, '*') && !isWildcard(patternIndex + 1) &&
-                      Character.isLetterOrDigit(name.charAt(nameIndex)) && !NameUtil.isWordStart(name, nameIndex)
+                      Character.isLetterOrDigit(name.charAt(nameIndex)) && !isWordStart(name, nameIndex)
                       ? 3 : 1;
     int i = 1;
     boolean ignoreCase = myOptions != NameUtil.MatchingCaseSensitivity.ALL;
@@ -340,7 +362,10 @@
           }
           // at least three consecutive uppercase letters shouldn't match lowercase
           if (myHasHumps && i > 1 && isUpperCase[patternIndex + i - 1] && isUpperCase[patternIndex + i - 2]) {
-            return null;
+            // but if there's a lowercase after them, it can match (in case shift was released a bit later)
+            if (nameIndex + i + 1 == name.length() || !isLowerCase[patternIndex + i + 1]) {
+              return null;
+            }
           }
         }
       }
diff --git a/platform/util/src/com/intellij/psi/codeStyle/NameUtil.java b/platform/util/src/com/intellij/psi/codeStyle/NameUtil.java
index 573cf29..2ab896e 100644
--- a/platform/util/src/com/intellij/psi/codeStyle/NameUtil.java
+++ b/platform/util/src/com/intellij/psi/codeStyle/NameUtil.java
@@ -326,24 +326,6 @@
     return suggestion;
   }
 
-  static boolean isWordStart(String text, int i) {
-    char c = text.charAt(i);
-    if (Character.isUpperCase(c)) {
-      if (i > 0 && Character.isUpperCase(text.charAt(i - 1))) {
-        // check that we're not in the middle of an all-caps word
-        return i + 1 < text.length() && Character.isLowerCase(text.charAt(i + 1));
-      }
-      return true;
-    }
-    if (Character.isDigit(c) || c == '+') {
-      return true;
-    }
-    if (!Character.isLetter(c)) {
-      return false;
-    }
-    return i == 0 || !Character.isLetterOrDigit(text.charAt(i - 1));
-  }
-
   static boolean isWordStart(char p) {
     return Character.isUpperCase(p) || Character.isDigit(p);
   }
diff --git a/platform/util/src/com/intellij/util/EnvironmentUtil.java b/platform/util/src/com/intellij/util/EnvironmentUtil.java
index 812cbc1..11ff535 100644
--- a/platform/util/src/com/intellij/util/EnvironmentUtil.java
+++ b/platform/util/src/com/intellij/util/EnvironmentUtil.java
@@ -163,6 +163,7 @@
         }
       }
       if (newEnv.size() < lines.size() - toIgnore.size()) {
+        // some lines weren't parsed - we're better to fall back to original environment than use possibly incomplete one
         throw new Exception("env:" + newEnv.size() + " lines:" + lines.size());
       }
 
diff --git a/platform/util/src/com/intellij/util/ImageLoader.java b/platform/util/src/com/intellij/util/ImageLoader.java
index 508768a..6dd70fc 100644
--- a/platform/util/src/com/intellij/util/ImageLoader.java
+++ b/platform/util/src/com/intellij/util/ImageLoader.java
@@ -26,7 +26,6 @@
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
-import sun.reflect.Reflection;
 
 import javax.swing.*;
 import java.awt.*;
@@ -84,20 +83,21 @@
   }
 
   @Nullable
-  public static Image loadFromResource(@NonNls String s) {
+  public static Image loadFromResource(@NonNls @NotNull String s) {
     int stackFrameCount = 2;
-    Class callerClass = ReflectionUtil.getCallerClass(stackFrameCount);
+    Class callerClass = ReflectionUtil.findCallerClass(stackFrameCount);
     while (callerClass != null && callerClass.getClassLoader() == null) { // looks like a system class
-      callerClass = ReflectionUtil.getCallerClass(++stackFrameCount);
+      callerClass = ReflectionUtil.findCallerClass(++stackFrameCount);
     }
     if (callerClass == null) {
-      callerClass = ReflectionUtil.getCallerClass(1);
+      callerClass = ReflectionUtil.findCallerClass(1);
     }
+    if (callerClass == null) return null;
     return loadFromResource(s, callerClass);
   }
 
   @Nullable
-  public static Image loadFromResource(String path, Class aClass) {
+  public static Image loadFromResource(@NonNls @NotNull String path, @NotNull Class aClass) {
     for (Pair<String, Integer> each : getFileNames(path)) {
       InputStream stream = aClass.getResourceAsStream(each.first);
       if (stream == null) continue;
diff --git a/platform/util/src/com/intellij/util/ReflectionUtil.java b/platform/util/src/com/intellij/util/ReflectionUtil.java
index 98a985e..cdd6e38 100644
--- a/platform/util/src/com/intellij/util/ReflectionUtil.java
+++ b/platform/util/src/com/intellij/util/ReflectionUtil.java
@@ -325,12 +325,13 @@
    */
   @SuppressWarnings("JavadocReference")
   @Nullable
-  public static Class getCallerClass(int framesToSkip) {
+  public static Class findCallerClass(int framesToSkip) {
+    assert framesToSkip > 0 : framesToSkip;
     int frames = framesToSkip;
 
     StackTraceElement[] stackTrace = new Throwable().getStackTrace();
     String className = null;
-    for (int i = 1; i<=frames; i++) {
+    for (int i = 1; i <= frames; i++) {
       if (i >= stackTrace.length) {
         break;
       }
diff --git a/platform/util/src/com/intellij/util/io/UnsyncByteArrayInputStream.java b/platform/util/src/com/intellij/util/io/UnsyncByteArrayInputStream.java
index 41af61e..830a7e0 100644
--- a/platform/util/src/com/intellij/util/io/UnsyncByteArrayInputStream.java
+++ b/platform/util/src/com/intellij/util/io/UnsyncByteArrayInputStream.java
@@ -15,32 +15,34 @@
  */
 package com.intellij.util.io;
 
+import org.jetbrains.annotations.NotNull;
+
 import java.io.InputStream;
 
 public class UnsyncByteArrayInputStream extends InputStream {
   protected byte[] myBuffer;
   private int myPosition;
-  private int myCount;
+  private final int myCount;
   private int myMarkedPosition;
 
-  public UnsyncByteArrayInputStream(byte buf[]) {
+  public UnsyncByteArrayInputStream(@NotNull byte[] buf) {
     this(buf, 0, buf.length);
   }
 
-  public UnsyncByteArrayInputStream(byte buf[], int offset, int length) {
-    this.myBuffer = buf;
-    this.myPosition = offset;
-    this.myCount = length;
+  public UnsyncByteArrayInputStream(byte[] buf, int offset, int length) {
+    myBuffer = buf;
+    myPosition = offset;
+    myCount = length;
   }
 
+  @Override
   public int read() {
-    return (myPosition < myCount) ? (myBuffer[myPosition++] & 0xff) : -1;
+    return myPosition < myCount ? myBuffer[myPosition++] & 0xff : -1;
   }
 
-  public int read(byte b[], int off, int len) {
-    if (b == null) {
-      throw new NullPointerException();
-    } else if (off < 0 || len < 0 || len > b.length - off) {
+  @Override
+  public int read(@NotNull byte[] b, int off, int len) {
+    if (off < 0 || len < 0 || len > b.length - off) {
       throw new IndexOutOfBoundsException();
     }
     if (myPosition >= myCount) {
@@ -57,6 +59,7 @@
     return len;
   }
 
+  @Override
   public long skip(long n) {
     if (myPosition + n > myCount) {
       n = myCount - myPosition;
@@ -68,6 +71,7 @@
     return n;
   }
 
+  @Override
   public int available() {
     return myCount - myPosition;
   }
@@ -82,6 +86,7 @@
     myMarkedPosition = myPosition;
   }
 
+  @Override
   public void reset() {
     myPosition = myMarkedPosition;
   }
diff --git a/platform/util/testSrc/com/intellij/openapi/util/io/FileAttributesReadingTest.java b/platform/util/testSrc/com/intellij/openapi/util/io/FileAttributesReadingTest.java
index bf0bbd5..b0524fa 100644
--- a/platform/util/testSrc/com/intellij/openapi/util/io/FileAttributesReadingTest.java
+++ b/platform/util/testSrc/com/intellij/openapi/util/io/FileAttributesReadingTest.java
@@ -284,6 +284,24 @@
   }
 
   @Test
+  public void notSoHiddenRoot() throws Exception {
+    if (SystemInfo.isWindows) {
+      File absRoot = new File("C:\\");
+      FileAttributes absAttributes = getAttributes(absRoot);
+      assertFalse(absAttributes.isHidden());
+
+      File relRoot = new File("C:");
+      FileAttributes relAttributes = getAttributes(relRoot);
+      assertFalse(relAttributes.isHidden());
+    }
+    else {
+      File absRoot = new File("/");
+      FileAttributes absAttributes = getAttributes(absRoot);
+      assertFalse(absAttributes.isHidden());
+    }
+  }
+
+  @Test
   public void wellHiddenFile() throws Exception {
     assumeTrue(SystemInfo.isWindows);
     final File file = new File("C:\\Documents and Settings\\desktop.ini");
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/VcsDirtyScopeManagerImpl.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/VcsDirtyScopeManagerImpl.java
index a5d4a01..70127c3 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/VcsDirtyScopeManagerImpl.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/changes/VcsDirtyScopeManagerImpl.java
@@ -105,7 +105,7 @@
     if ((! myProject.isOpen()) || myProject.isDisposed() || myVcsManager.getAllActiveVcss().length == 0) return;
 
     if (LOG.isDebugEnabled()) {
-      LOG.debug("everything dirty: " + ReflectionUtil.getCallerClass(1));
+      LOG.debug("everything dirty: " + ReflectionUtil.findCallerClass(1));
     }
 
     final LifeDrop lifeDrop = myLife.doIfAlive(new Runnable() {
@@ -169,7 +169,7 @@
       if (! haveStuff) return;
 
       if (LOG.isDebugEnabled()) {
-        LOG.debug("paths dirty: " + filesConverted + "; " + dirsConverted + "; " + ReflectionUtil.getCallerClass(2));
+        LOG.debug("paths dirty: " + filesConverted + "; " + dirsConverted + "; " + ReflectionUtil.findCallerClass(2));
       }
 
       takeDirt(new Consumer<DirtBuilder>() {
@@ -231,7 +231,7 @@
       if (! haveStuff) return;
 
       if (LOG.isDebugEnabled()) {
-        LOG.debug("files dirty: " + filesConverted + "; " + dirsConverted + "; " + ReflectionUtil.getCallerClass(2));
+        LOG.debug("files dirty: " + filesConverted + "; " + dirsConverted + "; " + ReflectionUtil.findCallerClass(2));
       }
 
       takeDirt(new Consumer<DirtBuilder>() {
@@ -257,7 +257,7 @@
       final AbstractVcs vcs = myGuess.getVcsForDirty(file);
       if (vcs == null) return;
       if (LOG.isDebugEnabled()) {
-        LOG.debug("file dirty: " + file + "; " + ReflectionUtil.getCallerClass(2));
+        LOG.debug("file dirty: " + file + "; " + ReflectionUtil.findCallerClass(2));
       }
       final VcsRoot root = new VcsRoot(vcs, file);
       takeDirt(new Consumer<DirtBuilder>() {
@@ -274,7 +274,7 @@
       final AbstractVcs vcs = myGuess.getVcsForDirty(file);
       if (vcs == null) return;
       if (LOG.isDebugEnabled()) {
-        LOG.debug("file dirty: " + file + "; " + ReflectionUtil.getCallerClass(1));
+        LOG.debug("file dirty: " + file + "; " + ReflectionUtil.findCallerClass(1));
       }
       final FilePathUnderVcs root = new FilePathUnderVcs(file, vcs);
       takeDirt(new Consumer<DirtBuilder>() {
@@ -295,7 +295,7 @@
       final AbstractVcs vcs = myGuess.getVcsForDirty(dir);
       if (vcs == null) return;
       if (LOG.isDebugEnabled()) {
-        LOG.debug("dir dirty recursively: " + dir + "; " + ReflectionUtil.getCallerClass(2));
+        LOG.debug("dir dirty recursively: " + dir + "; " + ReflectionUtil.findCallerClass(2));
       }
       final VcsRoot root = new VcsRoot(vcs, dir);
       takeDirt(new Consumer<DirtBuilder>() {
@@ -312,7 +312,7 @@
       final AbstractVcs vcs = myGuess.getVcsForDirty(path);
       if (vcs == null) return;
       if (LOG.isDebugEnabled()) {
-        LOG.debug("dir dirty recursively: " + path + "; " + ReflectionUtil.getCallerClass(2));
+        LOG.debug("dir dirty recursively: " + path + "; " + ReflectionUtil.findCallerClass(2));
       }
       final FilePathUnderVcs root = new FilePathUnderVcs(path, vcs);
       takeDirt(new Consumer<DirtBuilder>() {
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/update/AbstractCommonUpdateAction.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/update/AbstractCommonUpdateAction.java
index 9c621d0..d2c7b55 100644
--- a/platform/vcs-impl/src/com/intellij/openapi/vcs/update/AbstractCommonUpdateAction.java
+++ b/platform/vcs-impl/src/com/intellij/openapi/vcs/update/AbstractCommonUpdateAction.java
@@ -24,10 +24,7 @@
 import com.intellij.openapi.application.ApplicationManager;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.options.Configurable;
-import com.intellij.openapi.progress.ProcessCanceledException;
-import com.intellij.openapi.progress.ProgressIndicator;
-import com.intellij.openapi.progress.ProgressManager;
-import com.intellij.openapi.progress.Task;
+import com.intellij.openapi.progress.*;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.project.ex.ProjectManagerEx;
 import com.intellij.openapi.ui.MessageType;
@@ -110,7 +107,12 @@
           ApplicationManager.getApplication().saveAll();
         }
         Task.Backgroundable task = new Updater(project, roots, vcsToVirtualFiles);
-        ProgressManager.getInstance().run(task);
+        if (ApplicationManager.getApplication().isUnitTestMode()) {
+          task.run(new EmptyProgressIndicator());
+        }
+        else {
+          ProgressManager.getInstance().run(task);
+        }
       }
       catch (ProcessCanceledException e1) {
         //ignore
diff --git a/platform/xdebugger-api/src/com/intellij/xdebugger/breakpoints/ui/XBreakpointGroupingRule.java b/platform/xdebugger-api/src/com/intellij/xdebugger/breakpoints/ui/XBreakpointGroupingRule.java
index eb62e87..1038747 100644
--- a/platform/xdebugger-api/src/com/intellij/xdebugger/breakpoints/ui/XBreakpointGroupingRule.java
+++ b/platform/xdebugger-api/src/com/intellij/xdebugger/breakpoints/ui/XBreakpointGroupingRule.java
@@ -20,6 +20,7 @@
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
+import javax.swing.*;
 import java.util.Collection;
 
 /**
@@ -54,4 +55,9 @@
 
   @Nullable
   public abstract G getGroup(@NotNull B breakpoint, @NotNull Collection<G> groups);
+
+  @Nullable
+  public Icon getIcon() {
+    return null;
+  }
 }
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/EditBreakpointActionHandler.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/EditBreakpointActionHandler.java
index 2c396d9..5a53748 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/EditBreakpointActionHandler.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/EditBreakpointActionHandler.java
@@ -26,7 +26,7 @@
 import com.intellij.openapi.util.Pair;
 import com.intellij.xdebugger.impl.breakpoints.XBreakpointUtil;
 import com.intellij.xdebugger.impl.breakpoints.ui.BreakpointItem;
-import com.intellij.xdebugger.impl.breakpoints.ui.BreakpointsMasterDetailPopupFactory;
+import com.intellij.xdebugger.impl.breakpoints.ui.BreakpointsDialogFactory;
 import org.jetbrains.annotations.NotNull;
 
 import javax.swing.*;
@@ -52,7 +52,7 @@
   }
 
   public void editBreakpoint(@NotNull Project project, @NotNull Editor editor, @NotNull Object breakpoint, @NotNull GutterIconRenderer breakpointGutterRenderer) {
-    if (BreakpointsMasterDetailPopupFactory.getInstance(project).isBreakpointPopupShowing()) return;
+    if (BreakpointsDialogFactory.getInstance(project).isBreakpointPopupShowing()) return;
     EditorGutterComponentEx gutterComponent = ((EditorEx)editor).getGutterComponentEx();
     Point point = gutterComponent.getPoint(breakpointGutterRenderer);
     if (point == null) return;
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/ViewBreakpointsAction.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/ViewBreakpointsAction.java
index e5f9926..789b431 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/ViewBreakpointsAction.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/actions/ViewBreakpointsAction.java
@@ -25,9 +25,8 @@
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.project.DumbAware;
 import com.intellij.openapi.project.Project;
-import com.intellij.openapi.ui.popup.JBPopup;
 import com.intellij.xdebugger.impl.breakpoints.XBreakpointUtil;
-import com.intellij.xdebugger.impl.breakpoints.ui.BreakpointsMasterDetailPopupFactory;
+import com.intellij.xdebugger.impl.breakpoints.ui.BreakpointsDialogFactory;
 
 public class ViewBreakpointsAction extends AnAction implements AnAction.TransparentUpdate, DumbAware {
   private Object myInitialBreakpoint;
@@ -53,11 +52,7 @@
       }
     }
 
-    final JBPopup popup = BreakpointsMasterDetailPopupFactory.
-      getInstance(project).createPopup(myInitialBreakpoint);
-    if (popup != null) {
-      popup.showCenteredInCurrentWindow(project);
-    }
+    BreakpointsDialogFactory.getInstance(project).showDialog(myInitialBreakpoint);
     myInitialBreakpoint = null;
   }
 
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XBreakpointBase.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XBreakpointBase.java
index aff7d25..da0725c 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XBreakpointBase.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/XBreakpointBase.java
@@ -376,6 +376,12 @@
       return new ToggleBreakpointGutterIconAction(XBreakpointBase.this);
     }
 
+    @Nullable
+    @Override
+    public AnAction getRightButtonClickAction() {
+      return new EditBreakpointAction.ContextAction(this, XBreakpointBase.this, DebuggerSupport.getDebuggerSupport(XDebuggerSupport.class));
+    }
+
     @Override
     public Alignment getAlignment() {
       return Alignment.RIGHT;
@@ -383,25 +389,7 @@
 
     @Nullable
     public ActionGroup getPopupMenuActions() {
-      DefaultActionGroup group = new DefaultActionGroup();
-      final XDebuggerManager debuggerManager = XDebuggerManager.getInstance(getProject());
-
-
-      group.add(new EditBreakpointAction.ContextAction(this, XBreakpointBase.this, DebuggerSupport.getDebuggerSupport(XDebuggerSupport.class)));
-
-      group.add(new Separator());
-
-      if (!debuggerManager.getBreakpointManager().isDefaultBreakpoint(XBreakpointBase.this)) {
-        group.add(new RemoveBreakpointGutterIconAction(XBreakpointBase.this));
-      }
-      group.add(new ToggleBreakpointGutterIconAction(XBreakpointBase.this));
-      for (AnAction action : getAdditionalPopupMenuActions(debuggerManager.getCurrentSession())) {
-        group.add(action);
-      }
-      group.add(new Separator());
-
-      group.add(new ViewBreakpointsAction(ActionsBundle.actionText(XDebuggerActions.VIEW_BREAKPOINTS), XBreakpointBase.this));
-      return group;
+      return null;
     }
 
     @Nullable
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/BreakpointsDialog.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/BreakpointsDialog.java
new file mode 100644
index 0000000..2d1a30e
--- /dev/null
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/BreakpointsDialog.java
@@ -0,0 +1,356 @@
+/*
+ * Copyright 2000-2013 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.xdebugger.impl.breakpoints.ui;
+
+import com.intellij.ide.DataManager;
+import com.intellij.openapi.Disposable;
+import com.intellij.openapi.actionSystem.*;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.ui.DialogWrapper;
+import com.intellij.openapi.ui.popup.JBPopupFactory;
+import com.intellij.openapi.util.Condition;
+import com.intellij.openapi.util.Disposer;
+import com.intellij.ui.*;
+import com.intellij.ui.popup.util.DetailController;
+import com.intellij.ui.popup.util.DetailViewImpl;
+import com.intellij.ui.popup.util.ItemWrapper;
+import com.intellij.ui.popup.util.MasterController;
+import com.intellij.util.Function;
+import com.intellij.util.containers.*;
+import com.intellij.util.containers.HashSet;
+import com.intellij.util.ui.UIUtil;
+import com.intellij.xdebugger.XDebuggerManager;
+import com.intellij.xdebugger.breakpoints.ui.XBreakpointGroupingRule;
+import com.intellij.xdebugger.impl.breakpoints.XBreakpointManagerImpl;
+import com.intellij.xdebugger.impl.breakpoints.XBreakpointsDialogState;
+import com.intellij.xdebugger.impl.breakpoints.ui.tree.BreakpointItemsTreeController;
+import com.intellij.xdebugger.impl.breakpoints.ui.tree.BreakpointsCheckboxTree;
+
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.util.*;
+import java.util.List;
+
+public class BreakpointsDialog extends DialogWrapper {
+  @NotNull private Project myProject;
+
+  private Object myInitialBreakpoint;
+  private List<BreakpointPanelProvider> myBreakpointsPanelProviders;
+
+  private BreakpointItemsTreeController myTreeController;
+
+  JLabel temp = new JLabel();
+
+  private MasterController myMasterController = new MasterController() {
+    @Override
+    public ItemWrapper[] getSelectedItems() {
+      final List<BreakpointItem> res = myTreeController.getSelectedBreakpoints();
+      return res.toArray(new ItemWrapper[res.size()]);
+    }
+
+    @Override
+    public JLabel getPathLabel() {
+      return temp;
+    }
+  };
+
+  private final DetailController myDetailController = new DetailController(myMasterController);
+
+  private Collection<BreakpointItem> myBreakpointItems = new ArrayList<BreakpointItem>();
+
+  private final List<XBreakpointGroupingRule> myRulesAvailable = new ArrayList<XBreakpointGroupingRule>();
+
+  private Set<XBreakpointGroupingRule> myRulesEnabled = new TreeSet<XBreakpointGroupingRule>(new Comparator<XBreakpointGroupingRule>() {
+    @Override
+    public int compare(XBreakpointGroupingRule o1, XBreakpointGroupingRule o2) {
+      final int res = o2.getPriority() - o1.getPriority();
+      return res != 0 ? res : (o1.getId().compareTo(o2.getId()));
+    }
+  });
+  private Disposable myListenerDisposable = Disposer.newDisposable();
+  private List<ToggleActionButton> myToggleRuleActions = new ArrayList<ToggleActionButton>();
+
+  private XBreakpointManagerImpl getBreakpointManager() {
+    return (XBreakpointManagerImpl)XDebuggerManager.getInstance(myProject).getBreakpointManager();
+  }
+
+  protected BreakpointsDialog(@NotNull Project project, Object breakpoint, @NotNull List<BreakpointPanelProvider> providers) {
+    super(project);
+    myProject = project;
+    myBreakpointsPanelProviders = providers;
+    myInitialBreakpoint = breakpoint;
+
+    collectGroupingRules();
+
+    collectItems();
+
+    setTitle("Breakpoints");
+    setModal(false);
+    init();
+  }
+
+  private String getSplitterProportionKey() {
+    return getDimensionServiceKey() + ".splitter";
+  }
+
+  @Nullable
+  @Override
+  protected JComponent createCenterPanel() {
+    JPanel mainPanel = new JPanel(new BorderLayout());
+
+    JBSplitter splitPane = new JBSplitter(false, 0.3f);
+    splitPane.setSplitterProportionKey(getSplitterProportionKey());
+
+    splitPane.setFirstComponent(createMasterView());
+    splitPane.setSecondComponent(createDetailView());
+
+    mainPanel.add(splitPane, BorderLayout.CENTER);
+
+    return mainPanel;
+  }
+
+  private JComponent createDetailView() {
+    DetailViewImpl detailView = new DetailViewImpl(myProject);
+    myDetailController.setDetailView(detailView);
+
+    return detailView;
+  }
+
+  void collectItems() {
+    if (!myBreakpointsPanelProviders.isEmpty()) {
+      myBreakpointItems.clear();
+      for (BreakpointPanelProvider panelProvider : myBreakpointsPanelProviders) {
+        panelProvider.provideBreakpointItems(myProject, myBreakpointItems);
+      }
+    }
+  }
+
+  void initSelection(Collection<BreakpointItem> breakpoints) {
+    boolean found = false;
+    for (BreakpointItem breakpoint : breakpoints) {
+      if (breakpoint.getBreakpoint() == myInitialBreakpoint) {
+        myTreeController.selectBreakpointItem(breakpoint, null);
+        found = true;
+        break;
+      }
+    }
+
+    if (!found && !breakpoints.isEmpty()) {
+      myTreeController.selectFirstBreakpointItem();
+    }
+  }
+
+  @Nullable
+  @Override
+  protected String getDimensionServiceKey() {
+    return getClass().getName();
+  }
+
+  @NotNull
+  @Override
+  protected Action[] createActions() {
+    return new Action[]{getOKAction()};
+  }
+
+  private static Font smaller(Font f) {
+    return f.deriveFont(f.getStyle(), f.getSize() - 2);
+  }
+
+
+  private class ToggleBreakpointGroupingRuleEnabledAction extends ToggleActionButton {
+    private XBreakpointGroupingRule myRule;
+
+    public ToggleBreakpointGroupingRuleEnabledAction(XBreakpointGroupingRule rule) {
+      super(rule.getPresentableName(), rule.getIcon());
+      myRule = rule;
+      getTemplatePresentation().setText(rule.getPresentableName());
+    }
+
+    @Override
+    public boolean isSelected(AnActionEvent e) {
+      return myRulesEnabled.contains(myRule);
+    }
+
+    @Override
+    public void setSelected(AnActionEvent e, boolean state) {
+      if (state) {
+        myRulesEnabled.add(myRule);
+      }
+      else {
+        myRulesEnabled.remove(myRule);
+      }
+      myTreeController.setGroupingRules(myRulesEnabled);
+    }
+  }
+
+  private JComponent createMasterView() {
+    myTreeController = new BreakpointItemsTreeController(myRulesEnabled);
+    JTree tree = new BreakpointsCheckboxTree(myProject, myTreeController);
+
+    new AnAction("BreakpointDialog.GoToSource") {
+      @Override
+      public void actionPerformed(AnActionEvent e) {
+        navigate();
+        close(OK_EXIT_CODE);
+      }
+    }.registerCustomShortcutSet(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0)), tree);
+
+    new AnAction("BreakpointDialog.ShowSource") {
+      @Override
+      public void actionPerformed(AnActionEvent e) {
+        navigate();
+      }
+    }.registerCustomShortcutSet(ActionManager.getInstance().getAction(IdeActions.ACTION_EDIT_SOURCE).getShortcutSet(), tree);
+
+    tree.addMouseListener(new MouseAdapter() {
+      @Override
+      public void mouseClicked(MouseEvent event) {
+        if (event.getClickCount() == 2 && UIUtil.isActionClick(event, MouseEvent.MOUSE_CLICKED) && !UIUtil.isSelectionButtonDown(event) && !event.isConsumed()) {
+          navigate();
+          close(OK_EXIT_CODE);
+        }
+      }
+    });
+
+    final DefaultActionGroup breakpointTypes = new DefaultActionGroup();
+    for (BreakpointPanelProvider provider : myBreakpointsPanelProviders) {
+      breakpointTypes.addAll(provider.getAddBreakpointActions(myProject));
+    }
+
+    ToolbarDecorator decorator = ToolbarDecorator.createDecorator(tree).
+      setAddAction(new AnActionButtonRunnable() {
+        @Override
+        public void run(AnActionButton button) {
+          JBPopupFactory.getInstance()
+            .createActionGroupPopup(null, breakpointTypes, DataManager.getInstance().getDataContext(button.getContextComponent()),
+                                    JBPopupFactory.ActionSelectionAid.NUMBERING, false)
+            .show(button.getPreferredPopupPoint());
+        }
+      }).
+      setRemoveAction(new AnActionButtonRunnable() {
+        @Override
+        public void run(AnActionButton button) {
+          myTreeController.removeSelectedBreakpoints(myProject);
+        }
+      }).
+      setRemoveActionUpdater(new AnActionButtonUpdater() {
+        @Override
+        public boolean isEnabled(AnActionEvent e) {
+          boolean enabled = false;
+          final ItemWrapper[] items = myMasterController.getSelectedItems();
+          for (ItemWrapper item : items) {
+            if (item.allowedToRemove()) {
+              enabled = true;
+            }
+          }
+          return enabled;
+        }
+      });
+
+    for (ToggleActionButton action : myToggleRuleActions) {
+      decorator.addExtraAction(action);
+    }
+
+    JPanel decoratedTree = decorator.createPanel();
+    myTreeController.setTreeView(tree);
+
+    myDetailController.setTree(tree);
+
+    myTreeController.buildTree(myBreakpointItems);
+
+    initSelection(myBreakpointItems);
+
+    final BreakpointPanelProvider.BreakpointsListener listener = new BreakpointPanelProvider.BreakpointsListener() {
+      @Override
+      public void breakpointsChanged() {
+        collectItems();
+        myTreeController.rebuildTree(myBreakpointItems);
+      }
+    };
+
+    for (BreakpointPanelProvider provider : myBreakpointsPanelProviders) {
+      provider.addListener(listener, myProject, myListenerDisposable);
+    }
+
+    return decoratedTree;
+  }
+
+  private void navigate() {
+    List<BreakpointItem> breakpoints = myTreeController.getSelectedBreakpoints();
+    if (!breakpoints.isEmpty()) {
+      breakpoints.get(0).navigate(true);
+    }
+  }
+
+  @Nullable
+  @Override
+  public JComponent getPreferredFocusedComponent() {
+    return myTreeController.getTreeView();
+  }
+
+  private void collectGroupingRules() {
+    for (BreakpointPanelProvider provider : myBreakpointsPanelProviders) {
+      provider.createBreakpointsGroupingRules(myRulesAvailable);
+    }
+
+    myRulesEnabled.clear();
+    XBreakpointsDialogState settings = (getBreakpointManager()).getBreakpointsDialogSettings();
+
+    for (XBreakpointGroupingRule rule : myRulesAvailable) {
+      if (rule.isAlwaysEnabled() || (settings != null && settings.getSelectedGroupingRules().contains(rule.getId()) ) ) {
+        myRulesEnabled.add(rule);
+      }
+    }
+
+    for (XBreakpointGroupingRule rule : myRulesAvailable) {
+      if (!rule.isAlwaysEnabled()) {
+        myToggleRuleActions.add(new ToggleBreakpointGroupingRuleEnabledAction(rule));
+      }
+    }
+  }
+
+  private void saveBreakpointsDialogState() {
+    final XBreakpointsDialogState dialogState = new XBreakpointsDialogState();
+    final List<XBreakpointGroupingRule> rulesEnabled = ContainerUtil.filter(myRulesEnabled, new Condition<XBreakpointGroupingRule>() {
+      @Override
+      public boolean value(XBreakpointGroupingRule rule) {
+        return !rule.isAlwaysEnabled();
+      }
+    });
+
+    dialogState.setSelectedGroupingRules(new HashSet<String>(ContainerUtil.map(rulesEnabled, new Function<XBreakpointGroupingRule, String>() {
+      @Override
+      public String fun(XBreakpointGroupingRule rule) {
+        return rule.getId();
+      }
+    })));
+    getBreakpointManager().setBreakpointsDialogSettings(dialogState);
+  }
+
+
+  @Override
+  protected void dispose() {
+    Disposer.dispose(myListenerDisposable);
+    saveBreakpointsDialogState();
+    super.dispose();
+  }
+}
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/BreakpointsDialogFactory.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/BreakpointsDialogFactory.java
new file mode 100644
index 0000000..e635387
--- /dev/null
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/BreakpointsDialogFactory.java
@@ -0,0 +1,76 @@
+/*
+ * Copyright 2000-2012 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.xdebugger.impl.breakpoints.ui;
+
+import com.intellij.openapi.components.ServiceManager;
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.ui.popup.Balloon;
+import com.intellij.xdebugger.impl.breakpoints.XBreakpointUtil;
+import org.jetbrains.annotations.Nullable;
+
+public class BreakpointsDialogFactory {
+
+  private Project myProject;
+  private Balloon myBalloonToHide;
+  private Object myBreakpoint;
+  private BreakpointsDialog myDialogShowing;
+
+
+  public BreakpointsDialogFactory(Project project) {
+    myProject = project;
+  }
+
+  public void setBalloonToHide(Balloon balloonToHide, Object breakpoint) {
+    myBalloonToHide = balloonToHide;
+    myBreakpoint = breakpoint;
+  }
+
+  public static BreakpointsDialogFactory getInstance(Project project) {
+    return ServiceManager.getService(project, BreakpointsDialogFactory.class);
+  }
+
+  public boolean isBreakpointPopupShowing() {
+    return (myBalloonToHide != null && !myBalloonToHide.isDisposed()) || myDialogShowing != null;
+  }
+
+  public void showDialog(@Nullable Object initialBreakpoint) {
+    if (myDialogShowing != null) {
+      return;
+    }
+
+    final BreakpointsDialog dialog = new BreakpointsDialog(myProject, initialBreakpoint != null ? initialBreakpoint : myBreakpoint, XBreakpointUtil.collectPanelProviders()) {
+      @Override
+      protected void dispose() {
+        for (BreakpointPanelProvider provider : XBreakpointUtil.collectPanelProviders()) {
+          provider.onDialogClosed(myProject);
+        }
+        myDialogShowing = null;
+
+        super.dispose();
+      }
+    };
+
+    if (myBalloonToHide != null) {
+      if (!myBalloonToHide.isDisposed()) {
+        myBalloonToHide.hide();
+      }
+      myBalloonToHide = null;
+    }
+    myDialogShowing = dialog;
+
+    dialog.show();
+  }
+}
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/BreakpointsMasterDetailPopupFactory.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/BreakpointsMasterDetailPopupFactory.java
deleted file mode 100644
index 6e69335..0000000
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/BreakpointsMasterDetailPopupFactory.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * Copyright 2000-2012 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.xdebugger.impl.breakpoints.ui;
-
-import com.intellij.openapi.components.ServiceManager;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.ui.popup.Balloon;
-import com.intellij.openapi.ui.popup.JBPopup;
-import com.intellij.openapi.ui.popup.JBPopupListener;
-import com.intellij.openapi.ui.popup.LightweightWindowEvent;
-import com.intellij.xdebugger.impl.breakpoints.XBreakpointUtil;
-import com.intellij.xdebugger.impl.breakpoints.ui.tree.BreakpointMasterDetailPopupBuilder;
-import org.jetbrains.annotations.Nullable;
-
-public class BreakpointsMasterDetailPopupFactory {
-
-  private Project myProject;
-  private Balloon myBalloonToHide;
-  private Object myBreakpoint;
-  private JBPopup myPopupShowing;
-
-
-  public BreakpointsMasterDetailPopupFactory(Project project) {
-    myProject = project;
-  }
-
-  public void setBalloonToHide(Balloon balloonToHide, Object breakpoint) {
-    myBalloonToHide = balloonToHide;
-    myBreakpoint = breakpoint;
-  }
-
-  public static BreakpointsMasterDetailPopupFactory getInstance(Project project) {
-    return ServiceManager.getService(project, BreakpointsMasterDetailPopupFactory.class);
-  }
-
-  public boolean isBreakpointPopupShowing() {
-    return (myBalloonToHide != null && !myBalloonToHide.isDisposed()) || myPopupShowing != null;
-  }
-
-  @Nullable
-  public JBPopup createPopup(@Nullable Object initialBreakpoint) {
-    if (myPopupShowing != null) {
-      return null;
-    }
-    BreakpointMasterDetailPopupBuilder builder = new BreakpointMasterDetailPopupBuilder(myProject);
-    builder.setInitialBreakpoint(initialBreakpoint != null ? initialBreakpoint : myBreakpoint);
-    builder.setBreakpointsPanelProviders(XBreakpointUtil.collectPanelProviders());
-    builder.setCallback(new BreakpointMasterDetailPopupBuilder.BreakpointChosenCallback() {
-      @Override
-      public void breakpointChosen(Project project, BreakpointItem breakpointItem, JBPopup popup, boolean withEnterOrDoubleClick) {
-        if (withEnterOrDoubleClick && breakpointItem.canNavigate()) {
-          breakpointItem.navigate(true);
-          popup.cancel();
-        }
-      }
-    });
-    myBreakpoint = null;
-    final JBPopup popup = builder.createPopup();
-    popup.addListener(new JBPopupListener() {
-      @Override
-      public void beforeShown(LightweightWindowEvent event) {
-        if (myBalloonToHide != null) {
-          if (!myBalloonToHide.isDisposed()) {
-            myBalloonToHide.hide();
-          }
-          myBalloonToHide = null;
-        }
-        myPopupShowing = popup;
-      }
-
-      @Override
-      public void onClosed(LightweightWindowEvent event) {
-        for (BreakpointPanelProvider provider : XBreakpointUtil.collectPanelProviders()) {
-          provider.onDialogClosed(myProject);
-        }
-        myPopupShowing = null;
-      }
-    });
-    return popup;
-  }
-}
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XLightBreakpointPropertiesPanel.form b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XLightBreakpointPropertiesPanel.form
index ee2a6c0..a15e28b 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XLightBreakpointPropertiesPanel.form
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XLightBreakpointPropertiesPanel.form
@@ -1,29 +1,29 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.intellij.xdebugger.impl.breakpoints.ui.XLightBreakpointPropertiesPanel">
-  <grid id="27dc6" binding="myMainPanel" custom-create="true" layout-manager="GridLayoutManager" row-count="8" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
+  <grid id="27dc6" binding="myMainPanel" custom-create="true" layout-manager="GridLayoutManager" row-count="9" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
     <margin top="0" left="0" bottom="0" right="0"/>
     <constraints>
-      <xy x="20" y="20" width="500" height="400"/>
+      <xy x="20" y="20" width="500" height="453"/>
     </constraints>
     <properties/>
     <border type="none"/>
     <children>
       <vspacer id="71127">
         <constraints>
-          <grid row="7" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
+          <grid row="8" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
         </constraints>
       </vspacer>
       <grid id="8bb86" binding="myConditionPanel" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
         <margin top="0" left="0" bottom="0" right="0"/>
         <constraints>
-          <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
+          <grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
         </constraints>
         <properties/>
         <border type="none"/>
         <children>
           <component id="76b8d" class="javax.swing.JLabel">
             <constraints>
-              <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
+              <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="1" use-parent-layout="false"/>
             </constraints>
             <properties>
               <text value="Condition"/>
@@ -41,22 +41,22 @@
       </grid>
       <nested-form id="11152" form-file="com/intellij/xdebugger/impl/breakpoints/ui/XSuspendPolicyPanel.form" binding="mySuspendPolicyPanel">
         <constraints>
-          <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
+          <grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
         </constraints>
       </nested-form>
       <nested-form id="e13dc" form-file="com/intellij/xdebugger/impl/breakpoints/ui/XBreakpointActionsPanel.form" binding="myActionsPanel">
         <constraints>
-          <grid row="3" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
+          <grid row="4" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
         </constraints>
       </nested-form>
       <nested-form id="26e47" form-file="com/intellij/xdebugger/impl/breakpoints/ui/XMasterBreakpointPanel.form" binding="myMasterBreakpointPanel">
         <constraints>
-          <grid row="4" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
+          <grid row="5" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
         </constraints>
       </nested-form>
       <grid id="24056" binding="myCustomPropertiesPanelWrapper" layout-manager="BorderLayout" hgap="0" vgap="0">
         <constraints>
-          <grid row="5" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
+          <grid row="6" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
         </constraints>
         <properties/>
         <border type="none"/>
@@ -64,7 +64,7 @@
       </grid>
       <hspacer id="ab565">
         <constraints>
-          <grid row="6" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false">
+          <grid row="7" column="0" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false">
             <preferred-size width="400" height="-1"/>
           </grid>
         </constraints>
@@ -72,12 +72,21 @@
       <grid id="e59bd" binding="myCustomConditionsPanelWrapper" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
         <margin top="0" left="0" bottom="0" right="0"/>
         <constraints>
-          <grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
+          <grid row="3" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
         </constraints>
         <properties/>
         <border type="none"/>
         <children/>
       </grid>
+      <component id="90296" class="javax.swing.JCheckBox" binding="myEnabledCheckbox">
+        <constraints>
+          <grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
+        </constraints>
+        <properties>
+          <font size="11" style="1"/>
+          <text value="Enabled"/>
+        </properties>
+      </component>
     </children>
   </grid>
 </form>
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XLightBreakpointPropertiesPanel.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XLightBreakpointPropertiesPanel.java
index 94ec17e..c547c2e 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XLightBreakpointPropertiesPanel.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/XLightBreakpointPropertiesPanel.java
@@ -30,22 +30,15 @@
 
 import javax.swing.*;
 import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
 import java.awt.event.FocusAdapter;
 import java.awt.event.FocusEvent;
 import java.util.ArrayList;
 import java.util.List;
 
-/**
- * Created by IntelliJ IDEA.
- * User: zajac
- * Date: 16.06.11
- * Time: 15:46
- * To change this template use File | Settings | File Templates.
- */
 public class XLightBreakpointPropertiesPanel<B extends XBreakpoint<?>> implements XSuspendPolicyPanel.Delegate {
 
-  private DetailView myDetailView;
-
   public boolean showMoreOptions() {
     return myShowMoreOptions;
   }
@@ -94,6 +87,7 @@
   private XMasterBreakpointPanel<B> myMasterBreakpointPanel;
   private JPanel myCustomPropertiesPanelWrapper;
   private JPanel myCustomConditionsPanelWrapper;
+  private JCheckBox myEnabledCheckbox;
   private final List<XBreakpointCustomPropertiesPanel<B>> myCustomPanels;
 
   private List<XBreakpointPropertiesSubPanel<B>> mySubPanels = new ArrayList<XBreakpointPropertiesSubPanel<B>>();
@@ -103,7 +97,6 @@
   private B myBreakpoint;
 
   public void setDetailView(DetailView detailView) {
-    myDetailView = detailView;
     myMasterBreakpointPanel.setDetailView(detailView);
   }
 
@@ -158,7 +151,12 @@
         }
       }
     });
-
+    myEnabledCheckbox.addActionListener(new ActionListener() {
+      @Override
+      public void actionPerformed(ActionEvent event) {
+        myBreakpoint.setEnabled(myEnabledCheckbox.isSelected());
+      }
+    });
   }
 
   public void saveProperties() {
@@ -181,6 +179,7 @@
     if (!myCustomPanels.isEmpty()) {
       ((XBreakpointBase)myBreakpoint).fireBreakpointChanged();
     }
+    myBreakpoint.setEnabled(myEnabledCheckbox.isSelected());
   }
 
   public void loadProperties() {
@@ -196,6 +195,8 @@
     for (XBreakpointCustomPropertiesPanel<B> customPanel : myCustomPanels) {
       customPanel.loadFrom(myBreakpoint);
     }
+    myEnabledCheckbox.setSelected(myBreakpoint.isEnabled());
+    myEnabledCheckbox.setText(XBreakpointUtil.getShortText(myBreakpoint));
   }
 
   public JPanel getMainPanel() {
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/grouping/XBreakpointFileGroupingRule.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/grouping/XBreakpointFileGroupingRule.java
index 5255a33..b0b5998 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/grouping/XBreakpointFileGroupingRule.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/grouping/XBreakpointFileGroupingRule.java
@@ -15,6 +15,7 @@
  */
 package com.intellij.xdebugger.impl.breakpoints.ui.grouping;
 
+import com.intellij.icons.AllIcons;
 import com.intellij.openapi.vfs.VirtualFile;
 import com.intellij.xdebugger.XDebuggerBundle;
 import com.intellij.xdebugger.XSourcePosition;
@@ -22,7 +23,9 @@
 import com.intellij.xdebugger.breakpoints.ui.XBreakpointGroupingRule;
 import com.intellij.xdebugger.breakpoints.ui.XBreakpointsGroupingPriorities;
 import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
 
+import javax.swing.*;
 import java.util.Collection;
 
 /**
@@ -55,4 +58,10 @@
 
     return new XBreakpointFileGroup(file);
   }
+
+  @Nullable
+  @Override
+  public Icon getIcon() {
+    return AllIcons.FileTypes.Text;
+  }
 }
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/tree/BreakpointItemsTreeController.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/tree/BreakpointItemsTreeController.java
index 0757ce6..9ebdfea 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/tree/BreakpointItemsTreeController.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/tree/BreakpointItemsTreeController.java
@@ -52,6 +52,10 @@
     setGroupingRulesInternal(groupingRules);
   }
 
+  public JTree getTreeView() {
+    return myTreeView;
+  }
+
   public void setTreeView(JTree treeView) {
     myTreeView = treeView;
     if (treeView instanceof BreakpointsCheckboxTree) {
@@ -240,8 +244,4 @@
       return o1 instanceof BreakpointsGroupNode ? -1 : 1;
     }
   }
-
-  public interface BreakpointItemsTreeDelegate {
-    void execute(BreakpointItem item);
-  }
 }
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/tree/BreakpointMasterDetailPopupBuilder.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/tree/BreakpointMasterDetailPopupBuilder.java
deleted file mode 100644
index 47516e8..0000000
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/breakpoints/ui/tree/BreakpointMasterDetailPopupBuilder.java
+++ /dev/null
@@ -1,450 +0,0 @@
-/*
- * Copyright 2000-2012 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.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package com.intellij.xdebugger.impl.breakpoints.ui.tree;
-
-import com.intellij.openapi.Disposable;
-import com.intellij.openapi.actionSystem.*;
-import com.intellij.openapi.actionSystem.ex.CheckboxAction;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.ui.popup.JBPopup;
-import com.intellij.openapi.ui.popup.JBPopupFactory;
-import com.intellij.openapi.ui.popup.JBPopupListener;
-import com.intellij.openapi.ui.popup.LightweightWindowEvent;
-import com.intellij.openapi.util.Condition;
-import com.intellij.openapi.util.Disposer;
-import com.intellij.openapi.util.SystemInfo;
-import com.intellij.ui.popup.util.DetailView;
-import com.intellij.ui.popup.util.DetailViewImpl;
-import com.intellij.ui.popup.util.ItemWrapper;
-import com.intellij.ui.popup.util.MasterDetailPopupBuilder;
-import com.intellij.util.Function;
-import com.intellij.util.IconUtil;
-import com.intellij.util.PlatformIcons;
-import com.intellij.util.containers.ContainerUtil;
-import com.intellij.util.containers.HashSet;
-import com.intellij.xdebugger.XDebuggerManager;
-import com.intellij.xdebugger.breakpoints.XBreakpointManager;
-import com.intellij.xdebugger.breakpoints.ui.XBreakpointGroupingRule;
-import com.intellij.xdebugger.impl.breakpoints.XBreakpointManagerImpl;
-import com.intellij.xdebugger.impl.breakpoints.XBreakpointsDialogState;
-import com.intellij.xdebugger.impl.breakpoints.ui.BreakpointItem;
-import com.intellij.xdebugger.impl.breakpoints.ui.BreakpointPanelProvider;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-import javax.swing.*;
-import java.awt.*;
-import java.awt.event.KeyEvent;
-import java.util.*;
-import java.util.List;
-
-public class BreakpointMasterDetailPopupBuilder {
-
-  private Project myProject;
-  private MasterDetailPopupBuilder myPopupBuilder;
-  private Collection<BreakpointPanelProvider> myBreakpointsPanelProviders = Collections.emptyList();
-  private BreakpointItemsTreeController myTreeController;
-  private final List<XBreakpointGroupingRule> myRulesAvailable = new ArrayList<XBreakpointGroupingRule>();
-    
-  private Set<XBreakpointGroupingRule> myRulesEnabled = new TreeSet<XBreakpointGroupingRule>(new Comparator<XBreakpointGroupingRule>() {
-    @Override
-    public int compare(XBreakpointGroupingRule o1, XBreakpointGroupingRule o2) {
-      final int res = o2.getPriority() - o1.getPriority();
-      return res != 0 ? res : (o1.getId().compareTo(o2.getId()));
-    }
-  });
-
-  @Nullable private Object myInitialBreakpoint;
-
-  @Nullable private BreakpointChosenCallback myCallback = null;
-
-  private boolean myAddDetailViewToEast = true;
-
-  private DetailView myDetailView;
-
-  private boolean myIsViewer;
-
-  private boolean myPlainView = false;
-  private JBPopup myPopup;
-  private AddBreakpointAction myAddAction;
-
-  public boolean isPlainView() {
-    return myPlainView;
-  }
-
-  public void setPlainView(boolean plainView) {
-    myPlainView = plainView;
-  }
-
-  public Collection<BreakpointItem> getBreakpointItems() {
-    return myBreakpointItems;
-  }
-
-  public void setBreakpointItems(Collection<BreakpointItem> breakpointItems) {
-    myBreakpointItems = breakpointItems;
-  }
-
-  private Collection<BreakpointItem> myBreakpointItems = new ArrayList<BreakpointItem>();
-
-  public void setDetailView(DetailView detailView) {
-    myDetailView = detailView;
-  }
-
-  public void setAddDetailViewToEast(boolean addDetailViewToEast) {
-    myAddDetailViewToEast = addDetailViewToEast;
-  }
-
-  public void setCallback(BreakpointChosenCallback callback) {
-    myCallback = callback;
-  }
-
-  public void setIsViewer(boolean isViewer) {
-    myIsViewer = isViewer;
-  }
-
-  public interface BreakpointChosenCallback {
-    void breakpointChosen(Project project, BreakpointItem breakpointItem, JBPopup popup, boolean withEnterOrDoubleClick);
-  }
-
-  public void setInitialBreakpoint(@Nullable Object initialBreakpoint) {
-    myInitialBreakpoint = initialBreakpoint;
-  }
-
-  public BreakpointMasterDetailPopupBuilder(Project project) {
-    myProject = project;
-  }
-
-  public JBPopup createPopup() {
-    myPopupBuilder = new MasterDetailPopupBuilder(myProject);
-    if (!myPlainView) {
-      myPopupBuilder.setDimensionServiceKey(getClass().getName());
-      myPopupBuilder.setUseDimensionServiceForXYLocation(true);
-      myPopupBuilder.setCancelOnClickOutside(false);
-    }
-    myPopupBuilder.setCancelOnWindowDeactivation(false);
-
-    DetailViewImpl view = null;
-    if (myDetailView != null) {
-      myPopupBuilder.setDetailView(myDetailView);
-    } else {
-      view = new DetailViewImpl(myProject);
-
-      myPopupBuilder.setDetailView(view);
-    }
-    myPopupBuilder.setAddDetailViewToEast(myAddDetailViewToEast);
-
-    for (BreakpointPanelProvider provider : myBreakpointsPanelProviders) {
-      provider.createBreakpointsGroupingRules(myRulesAvailable);
-    }
-
-    if (!myIsViewer) {
-      getInitialGroupingRules(myRulesEnabled);
-    }
-
-    DefaultActionGroup actions = createActions();
-
-    myTreeController = new BreakpointItemsTreeController(myRulesEnabled);
-
-    JTree tree = myIsViewer ? new BreakpointsSimpleTree(myProject, myTreeController) : new BreakpointsCheckboxTree(myProject, myTreeController);
-
-    if (myPlainView) {
-      tree.putClientProperty("plainView", Boolean.TRUE);
-    }
-
-    myTreeController.setTreeView(tree);
-
-    collectItems();
-
-    myTreeController.buildTree(myBreakpointItems);
-
-
-    final BreakpointPanelProvider.BreakpointsListener listener = new BreakpointPanelProvider.BreakpointsListener() {
-      @Override
-      public void breakpointsChanged() {
-        collectItems();
-        myTreeController.rebuildTree(myBreakpointItems);
-      }
-    };
-
-    final Disposable listenerDisposable = Disposer.newDisposable();
-    for (BreakpointPanelProvider provider : myBreakpointsPanelProviders) {
-      provider.addListener(listener, myProject, listenerDisposable);
-    }
-
-    final MasterDetailPopupBuilder.Delegate delegate = new MasterDetailPopupBuilder.Delegate() {
-      @Nullable
-      @Override
-      public String getTitle() {
-        return "";
-      }
-
-      @Override
-      public void handleMnemonic(KeyEvent e, Project project, JBPopup popup) {
-        //To change body of implemented methods use File | Settings | File Templates.
-      }
-
-      public JComponent createAccessoryView(Project project) {
-        return new JCheckBox();
-      }
-
-      @Override
-      public Object[] getSelectedItemsInTree() {
-        final List<BreakpointItem> res = myTreeController.getSelectedBreakpoints();
-        return res.toArray(new Object[res.size()]);
-      }
-
-      @Override
-      public void itemChosen(ItemWrapper item, Project project, JBPopup popup, boolean withEnterOrDoubleClick) {
-        if (myCallback != null && item instanceof BreakpointItem) {
-          myCallback.breakpointChosen(myProject, (BreakpointItem)item,  popup, withEnterOrDoubleClick);
-        }
-      }
-
-      @Override
-      public void removeSelectedItemsInTree() {
-        myTreeController.removeSelectedBreakpoints(myProject);
-      }
-    };
-
-    myPopupBuilder.
-          setActionsGroup(actions).
-          setTree(tree).
-          setDelegate(delegate);
-
-    if (!myIsViewer) {
-      myPopupBuilder.setMinSize(new Dimension(-1, 700));
-    }
-
-    if (!myPlainView) {
-      myPopupBuilder.setDoneRunnable(new Runnable() {
-        @Override
-        public void run() {
-          myPopup.cancel();
-        }
-      });
-    }
-
-
-    myPopup = myPopupBuilder.setCloseOnEnter(false).createMasterDetailPopup();
-
-    initSelection(myBreakpointItems);
-
-    myPopup.addListener(new JBPopupListener() {
-      @Override
-      public void beforeShown(LightweightWindowEvent event) {
-        //To change body of implemented methods use File | Settings | File Templates.
-      }
-
-      @Override
-      public void onClosed(LightweightWindowEvent event) {
-        Disposer.dispose(listenerDisposable);
-        saveBreakpointsDialogState();
-      }
-    });
-
-    final ShortcutSet newShortcut = CommonShortcuts.getNew();
-    myAddAction.registerCustomShortcutSet(newShortcut, myPopup.getContent());
-
-    new GotoSourceAction();
-
-    return myPopup;
-  }
-
-  private void saveBreakpointsDialogState() {
-    final XBreakpointsDialogState dialogState = new XBreakpointsDialogState();
-    final List<XBreakpointGroupingRule> rulesEnabled = ContainerUtil.filter(myRulesEnabled, new Condition<XBreakpointGroupingRule>() {
-      @Override
-      public boolean value(XBreakpointGroupingRule rule) {
-        return !rule.isAlwaysEnabled();
-      }
-    });
-
-    dialogState.setSelectedGroupingRules(new HashSet<String>(ContainerUtil.map(rulesEnabled, new Function<XBreakpointGroupingRule, String>() {
-      @Override
-      public String fun(XBreakpointGroupingRule rule) {
-        return rule.getId();
-      }
-    })));
-    ((XBreakpointManagerImpl)getBreakpointManager()).setBreakpointsDialogSettings(dialogState);
-  }
-
-  private void getInitialGroupingRules(Collection<XBreakpointGroupingRule> rules) {
-    rules.clear();
-    XBreakpointsDialogState settings = ((XBreakpointManagerImpl)getBreakpointManager()).getBreakpointsDialogSettings();
-
-    for (XBreakpointGroupingRule rule : myRulesAvailable) {
-      if (rule.isAlwaysEnabled() || (settings != null && settings.getSelectedGroupingRules().contains(rule.getId()) ) ) {
-        rules.add(rule);
-      }
-    }
-  }
-
-  private XBreakpointManager getBreakpointManager() {
-    return XDebuggerManager.getInstance(myProject).getBreakpointManager();
-  }
-
-  void initSelection(Collection<BreakpointItem> breakpoints) {
-    boolean found = false;
-    for (BreakpointItem breakpoint : breakpoints) {
-      if (breakpoint.getBreakpoint() == myInitialBreakpoint) {
-        myTreeController.selectBreakpointItem(breakpoint, null);
-        found = true;
-        break;
-      }
-    }
-
-    if (!found && !breakpoints.isEmpty()) {
-      myTreeController.selectFirstBreakpointItem();
-    }
-  }
-
-  @Nullable
-  DefaultActionGroup createActions() {
-    if (myIsViewer) {
-      return null;
-    }
-    DefaultActionGroup actions = new DefaultActionGroup();
-    final DefaultActionGroup breakpointTypes = new DefaultActionGroup();
-    for (BreakpointPanelProvider provider : myBreakpointsPanelProviders) {
-      breakpointTypes.addAll(provider.getAddBreakpointActions(myProject));
-    }
-
-    myAddAction = new AddBreakpointAction(breakpointTypes);
-    actions.add(myAddAction);
-
-
-    actions.add(new AnAction("Remove Breakpoint", null, PlatformIcons.DELETE_ICON) {
-      @Override
-      public void update(AnActionEvent e) {
-        boolean enabled = false;
-        final ItemWrapper[] items = myPopupBuilder.getSelectedItems();
-        for (ItemWrapper item : items) {
-          if (item.allowedToRemove()) {
-            enabled = true;
-          }
-        }
-        e.getPresentation().setEnabled(enabled);
-      }
-
-      @Override
-      public void actionPerformed(AnActionEvent e) {
-        myPopupBuilder.removeSelectedItems(myProject);
-      }
-    });
-
-    for (XBreakpointGroupingRule rule : myRulesAvailable) {
-      if (!rule.isAlwaysEnabled()) {
-        actions.add(new ToggleBreakpointGroupingRuleEnabledAction(rule));
-      }
-    }
-
-    return actions;
-  }
-
-  void collectItems() {
-    if (!myBreakpointsPanelProviders.isEmpty()) {
-      myBreakpointItems.clear();
-      for (BreakpointPanelProvider panelProvider : myBreakpointsPanelProviders) {
-        panelProvider.provideBreakpointItems(myProject, myBreakpointItems);
-      }
-    }
-  }
-
-  public void setBreakpointsPanelProviders(@NotNull Collection<BreakpointPanelProvider> breakpointsPanelProviders) {
-    myBreakpointsPanelProviders = breakpointsPanelProviders;
-  }
-
-  private static Font smaller(Font f) {
-    return f.deriveFont(f.getStyle(), f.getSize() - 2);
-  }
-
-  private class ToggleBreakpointGroupingRuleEnabledAction extends CheckboxAction {
-    private XBreakpointGroupingRule myRule;
-
-    public ToggleBreakpointGroupingRuleEnabledAction(XBreakpointGroupingRule rule) {
-      super(rule.getPresentableName());
-      myRule = rule;
-      getTemplatePresentation().setText(rule.getPresentableName());
-    }
-
-
-
-    @Override
-    public JComponent createCustomComponent(Presentation presentation) {
-      JComponent component = super.createCustomComponent(presentation);
-      if (SystemInfo.isMac) {
-        component.setFont(smaller(component.getFont()));
-      }
-      return component;
-    }
-
-    @Override
-    public boolean isSelected(AnActionEvent e) {
-      return myRulesEnabled.contains(myRule);
-    }
-
-    @Override
-    public void setSelected(AnActionEvent e, boolean state) {
-      if (state) {
-        myRulesEnabled.add(myRule);
-      }
-      else {
-        myRulesEnabled.remove(myRule);
-      }
-      myTreeController.setGroupingRules(myRulesEnabled);
-    }
-  }
-
-  private class GotoSourceAction extends AnAction {
-
-    public GotoSourceAction() {
-      ShortcutSet shortcutSet = ActionManager.getInstance().getAction(IdeActions.ACTION_EDIT_SOURCE).getShortcutSet();
-      registerCustomShortcutSet(shortcutSet, myPopup.getContent());
-    }
-
-    @Override
-    public void update(AnActionEvent e) {
-      super.update(e);
-      e.getPresentation().setEnabled(!myTreeController.getSelectedBreakpoints().isEmpty());
-    }
-
-    @Override
-    public void actionPerformed(AnActionEvent e) {
-      final List<BreakpointItem> res = myTreeController.getSelectedBreakpoints();
-      if (!res.isEmpty()) {
-        myCallback.breakpointChosen(myProject, res.get(0), myPopup, true);
-      }
-    }
-  }
-
-  private class AddBreakpointAction extends AnAction {
-
-    private final DefaultActionGroup myBreakpointTypes;
-
-    public AddBreakpointAction(DefaultActionGroup breakpointTypes) {
-      super("Add Breakpoint", null, IconUtil.getAddIcon());
-      myBreakpointTypes = breakpointTypes;
-    }
-
-    @Override
-    public void actionPerformed(AnActionEvent e) {
-      final JComponent toolbarComponent = myPopupBuilder.getActionToolbar().getComponent();
-      JBPopupFactory.getInstance()
-        .createActionGroupPopup(null, myBreakpointTypes, e.getDataContext(), JBPopupFactory.ActionSelectionAid.NUMBERING, false)
-        .showUnderneathOf(toolbarComponent);
-    }
-  }
-}
diff --git a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/DebuggerUIUtil.java b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/DebuggerUIUtil.java
index 0d437c1..f9ca4ba 100644
--- a/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/DebuggerUIUtil.java
+++ b/platform/xdebugger-impl/src/com/intellij/xdebugger/impl/ui/DebuggerUIUtil.java
@@ -34,7 +34,7 @@
 import com.intellij.xdebugger.breakpoints.XBreakpointListener;
 import com.intellij.xdebugger.breakpoints.XBreakpointManager;
 import com.intellij.xdebugger.frame.XFullValueEvaluator;
-import com.intellij.xdebugger.impl.breakpoints.ui.BreakpointsMasterDetailPopupFactory;
+import com.intellij.xdebugger.impl.breakpoints.ui.BreakpointsDialogFactory;
 import com.intellij.xdebugger.impl.breakpoints.ui.XLightBreakpointPropertiesPanel;
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
@@ -199,11 +199,7 @@
       public void run() {
         propertiesPanel.saveProperties();
         //showXBreakpointEditorBalloon(project, point, component, true, breakpoint);
-        final JBPopup popup = BreakpointsMasterDetailPopupFactory.
-          getInstance(project).createPopup(breakpoint);
-        if (popup != null) {
-          popup.showCenteredInCurrentWindow(project);
-        }
+        BreakpointsDialogFactory.getInstance(project).showDialog(breakpoint);
       }
     };
 
@@ -308,7 +304,7 @@
       balloon.show(p, Balloon.Position.below);
     }
 
-    BreakpointsMasterDetailPopupFactory.getInstance(project).setBalloonToHide(balloon, breakpoint);
+    BreakpointsDialogFactory.getInstance(project).setBalloonToHide(balloon, breakpoint);
 
     return balloon;
   }
diff --git a/plugins/InspectionGadgets/src/com/siyeh/ig/internationalization/StringConcatenationInspection.java b/plugins/InspectionGadgets/src/com/siyeh/ig/internationalization/StringConcatenationInspection.java
index 3c3db60..9c99b76 100644
--- a/plugins/InspectionGadgets/src/com/siyeh/ig/internationalization/StringConcatenationInspection.java
+++ b/plugins/InspectionGadgets/src/com/siyeh/ig/internationalization/StringConcatenationInspection.java
@@ -16,13 +16,13 @@
 package com.siyeh.ig.internationalization;
 
 import com.intellij.codeInsight.AnnotationUtil;
-import com.intellij.codeInsight.daemon.impl.analysis.HighlightUtil;
 import com.intellij.codeInsight.intention.AddAnnotationFix;
 import com.intellij.codeInspection.ui.MultipleCheckboxOptionsPanel;
 import com.intellij.psi.*;
 import com.intellij.psi.tree.IElementType;
 import com.intellij.psi.util.InheritanceUtil;
 import com.intellij.psi.util.PsiTreeUtil;
+import com.intellij.refactoring.util.RefactoringChangeUtil;
 import com.siyeh.InspectionGadgetsBundle;
 import com.siyeh.ig.BaseInspection;
 import com.siyeh.ig.BaseInspectionVisitor;
@@ -209,7 +209,7 @@
         } else {
           final PsiMethodCallExpression methodCallExpression =
             PsiTreeUtil.getParentOfType(expression, PsiMethodCallExpression.class, true, PsiCodeBlock.class, PsiClass.class);
-          if (HighlightUtil.isSuperOrThisMethodCall(methodCallExpression)) {
+          if (RefactoringChangeUtil.isSuperOrThisMethodCall(methodCallExpression)) {
             return;
           }
         }
diff --git a/plugins/IntentionPowerPak/src/com/siyeh/ipp/types/ReplaceLambdaWithAnonymousIntention.java b/plugins/IntentionPowerPak/src/com/siyeh/ipp/types/ReplaceLambdaWithAnonymousIntention.java
index 55040e3..bd63923 100644
--- a/plugins/IntentionPowerPak/src/com/siyeh/ipp/types/ReplaceLambdaWithAnonymousIntention.java
+++ b/plugins/IntentionPowerPak/src/com/siyeh/ipp/types/ReplaceLambdaWithAnonymousIntention.java
@@ -24,7 +24,7 @@
 import com.intellij.psi.*;
 import com.intellij.psi.codeStyle.JavaCodeStyleManager;
 import com.intellij.psi.util.PsiTreeUtil;
-import com.intellij.refactoring.util.RefactoringUtil;
+import com.intellij.refactoring.util.RefactoringChangeUtil;
 import com.intellij.util.IncorrectOperationException;
 import com.intellij.util.containers.HashMap;
 import com.siyeh.ipp.base.Intention;
@@ -68,7 +68,8 @@
     final PsiClass thisClass = PsiTreeUtil.getParentOfType(lambdaExpression, PsiClass.class, true);
     final String thisClassName = thisClass.getName();
     if (thisClassName != null) {
-      final PsiThisExpression thisAccessExpr = thisClass instanceof PsiAnonymousClass ? null : RefactoringUtil.createThisExpression(lambdaExpression.getManager(), thisClass);
+      final PsiThisExpression thisAccessExpr = thisClass instanceof PsiAnonymousClass ? null : RefactoringChangeUtil
+        .createThisExpression(lambdaExpression.getManager(), thisClass);
       ChangeContextUtil.decodeContextInfo(blockFromText, thisClass, thisAccessExpr);
       final Map<PsiElement, PsiElement> replacements = new HashMap<PsiElement, PsiElement>();
       blockFromText.accept(new JavaRecursiveElementWalkingVisitor() {
@@ -79,7 +80,7 @@
             replacements.put(expression, psiElementFactory.createExpressionFromText(thisClassName + "." + expression.getText(), expression));
           }
         }
-  
+
       });
       for (PsiElement psiElement : replacements.keySet()) {
         psiElement.replace(replacements.get(psiElement));
@@ -148,9 +149,9 @@
           if (disabled[0]) return false;
         }
         final PsiType functionalInterfaceType = lambdaExpression.getFunctionalInterfaceType();
-        return functionalInterfaceType != null && 
-               LambdaUtil.getFunctionalInterfaceMethod(functionalInterfaceType) != null && 
-               LambdaUtil.isLambdaFullyInferred(lambdaExpression, functionalInterfaceType) && 
+        return functionalInterfaceType != null &&
+               LambdaUtil.getFunctionalInterfaceMethod(functionalInterfaceType) != null &&
+               LambdaUtil.isLambdaFullyInferred(lambdaExpression, functionalInterfaceType) &&
                LambdaHighlightingUtil.checkInterfaceFunctional(functionalInterfaceType) == null;
       }
       return false;
diff --git a/plugins/android-designer/src/com/intellij/android/designer/inspection/ErrorAnalyzer.java b/plugins/android-designer/src/com/intellij/android/designer/inspection/ErrorAnalyzer.java
index c427fcf..9bb633e 100644
--- a/plugins/android-designer/src/com/intellij/android/designer/inspection/ErrorAnalyzer.java
+++ b/plugins/android-designer/src/com/intellij/android/designer/inspection/ErrorAnalyzer.java
@@ -21,13 +21,17 @@
 import com.intellij.codeHighlighting.HighlightDisplayLevel;
 import com.intellij.codeInsight.daemon.HighlightDisplayKey;
 import com.intellij.codeInsight.intention.IntentionAction;
-import com.intellij.codeInspection.SuppressIntentionAction;
+import com.intellij.codeInspection.InspectionManager;
+import com.intellij.codeInspection.LocalQuickFix;
+import com.intellij.codeInspection.ProblemHighlightType;
+import com.intellij.codeInspection.SuppressQuickFix;
 import com.intellij.codeInspection.ex.DisableInspectionToolAction;
 import com.intellij.codeInspection.ex.EditInspectionToolsSettingsAction;
 import com.intellij.designer.model.*;
 import com.intellij.icons.AllIcons;
 import com.intellij.openapi.progress.ProgressIndicator;
 import com.intellij.openapi.project.Project;
+import com.intellij.openapi.util.Iconable;
 import com.intellij.openapi.util.Pair;
 import com.intellij.openapi.util.TextRange;
 import com.intellij.psi.PsiElement;
@@ -121,17 +125,17 @@
                   }
                 });
 
-              SuppressIntentionAction[] suppressActions = inspection.getSuppressActions(startElement);
+              SuppressQuickFix[] suppressActions = inspection.getBatchSuppressActions(startElement);
               if (suppressActions != null) {
-                for (final SuppressIntentionAction action : suppressActions) {
-                  if (action.isAvailable(xmlFile.getProject(), null, startElement)) {
-                    designerFixes.add(new QuickFix(action.getText(), action.getIcon(0)) {
-                      @Override
-                      public void run() {
-                        action.invoke(project, null, startElement);
-                      }
-                    });
-                  }
+                for (final SuppressQuickFix action : suppressActions) {
+                  Icon icon1 = action instanceof Iconable ? ((Iconable)action).getIcon(0) : null;
+                  designerFixes.add(new QuickFix(action.getName(), icon1) {
+                    @Override
+                    public void run() {
+                      action.applyFix(project, InspectionManager.getInstance(project).createProblemDescriptor(startElement,"", (LocalQuickFix)null,
+                                                                                                              ProblemHighlightType.GENERIC_ERROR_OR_WARNING,false));
+                    }
+                  });
                 }
               }
             }
diff --git a/plugins/android/src/org/jetbrains/android/inspections/lint/AndroidLintExternalAnnotator.java b/plugins/android/src/org/jetbrains/android/inspections/lint/AndroidLintExternalAnnotator.java
index 40f6961..1f88f84 100644
--- a/plugins/android/src/org/jetbrains/android/inspections/lint/AndroidLintExternalAnnotator.java
+++ b/plugins/android/src/org/jetbrains/android/inspections/lint/AndroidLintExternalAnnotator.java
@@ -4,12 +4,11 @@
 import com.android.tools.lint.client.api.LintDriver;
 import com.android.tools.lint.detector.api.Issue;
 import com.intellij.codeHighlighting.HighlightDisplayLevel;
-import com.intellij.codeInsight.CodeInsightUtilBase;
+import com.intellij.codeInsight.FileModificationService;
 import com.intellij.codeInsight.daemon.HighlightDisplayKey;
 import com.intellij.codeInsight.intention.HighPriorityAction;
 import com.intellij.codeInsight.intention.IntentionAction;
-import com.intellij.codeInspection.InspectionProfile;
-import com.intellij.codeInspection.SuppressIntentionAction;
+import com.intellij.codeInspection.*;
 import com.intellij.codeInspection.ex.CustomEditInspectionToolsSettingsAction;
 import com.intellij.codeInspection.ex.DisableInspectionToolAction;
 import com.intellij.lang.annotation.Annotation;
@@ -175,11 +174,10 @@
             annotation.registerFix(new MyDisableInspectionFix(key));
             annotation.registerFix(new MyEditInspectionToolsSettingsAction(key, inspection));
 
-            final SuppressIntentionAction[] suppressActions = inspection.getSuppressActions(startElement);
-            if (suppressActions != null) {
-              for (SuppressIntentionAction action : suppressActions) {
-                annotation.registerFix(action);
-              }
+            final SuppressQuickFix[] suppressActions = inspection.getBatchSuppressActions(startElement);
+            for (SuppressQuickFix action : suppressActions) {
+              ProblemHighlightType type = annotation.getHighlightType();
+              annotation.registerFix(action, null, key, InspectionManager.getInstance(project).createProblemDescriptor(startElement, endElement, message, type, true, LocalQuickFix.EMPTY_ARRAY));
             }
           }
         }
@@ -275,7 +273,7 @@
 
     @Override
     public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
-      CodeInsightUtilBase.getInstance().prepareFileForWrite(file);
+      FileModificationService.getInstance().prepareFileForWrite(file);
       myQuickFix.apply(myStartElement, myEndElement, AndroidQuickfixContexts.EditorContext.getInstance(editor));
     }
 
diff --git a/plugins/android/src/org/jetbrains/android/inspections/lint/AndroidLintInspectionBase.java b/plugins/android/src/org/jetbrains/android/inspections/lint/AndroidLintInspectionBase.java
index 55fe2fd..21aefe7 100644
--- a/plugins/android/src/org/jetbrains/android/inspections/lint/AndroidLintInspectionBase.java
+++ b/plugins/android/src/org/jetbrains/android/inspections/lint/AndroidLintInspectionBase.java
@@ -43,7 +43,7 @@
 /**
  * @author Eugene.Kudelevsky
  */
-public abstract class AndroidLintInspectionBase extends GlobalInspectionTool implements CustomSuppressableInspectionTool {
+public abstract class AndroidLintInspectionBase extends GlobalInspectionTool implements BatchSuppressableTool {
   private static final Logger LOG = Logger.getInstance("#org.jetbrains.android.inspections.lint.AndroidLintInspectionBase");
 
   private static volatile Map<Issue, String> ourIssue2InspectionShortName;
@@ -74,12 +74,12 @@
   public IntentionAction[] getIntentions(@NotNull PsiElement startElement, @NotNull PsiElement endElement) {
     return IntentionAction.EMPTY_ARRAY;
   }
-  
+
   @NotNull
   private LocalQuickFix[] getLocalQuickFixes(@NotNull PsiElement startElement, @NotNull PsiElement endElement, @NotNull String message) {
     final AndroidLintQuickFix[] fixes = getQuickFixes(message);
     final LocalQuickFix[] result = new LocalQuickFix[fixes.length];
-    
+
     for (int i = 0; i < fixes.length; i++) {
       if (fixes[i].isApplicable(startElement, endElement, AndroidQuickfixContexts.BatchContext.TYPE)) {
         result[i] = new MyLocalQuickFix(fixes[i]);
@@ -181,12 +181,12 @@
   }
 
   @Override
-  public SuppressIntentionAction[] getSuppressActions(@Nullable PsiElement element) {
-    final List<SuppressIntentionAction> result = new ArrayList<SuppressIntentionAction>();
-    result.addAll(Arrays.asList(SuppressManager.getInstance().createSuppressActions(HighlightDisplayKey.find(getShortName()))));
+  public SuppressQuickFix[] getBatchSuppressActions(@Nullable PsiElement element) {
+    final List<SuppressQuickFix> result = new ArrayList<SuppressQuickFix>();
+    result.addAll(Arrays.asList(BatchSuppressManager.SERVICE.getInstance().createBatchSuppressActions(HighlightDisplayKey.find(getShortName()))));
     result.addAll(Arrays.asList(new XmlSuppressableInspectionTool.SuppressTagStatic(getShortName()),
                                 new XmlSuppressableInspectionTool.SuppressForFile(getShortName())));
-    return result.toArray(new SuppressIntentionAction[result.size()]);
+    return result.toArray(new SuppressQuickFix[result.size()]);
   }
 
   @Override
diff --git a/plugins/ant/jps-plugin/src/org/jetbrains/jps/ant/build/AntArtifactBuildTaskProvider.java b/plugins/ant/jps-plugin/src/org/jetbrains/jps/ant/build/AntArtifactBuildTaskProvider.java
index dd5864a..19b9eb8 100644
--- a/plugins/ant/jps-plugin/src/org/jetbrains/jps/ant/build/AntArtifactBuildTaskProvider.java
+++ b/plugins/ant/jps-plugin/src/org/jetbrains/jps/ant/build/AntArtifactBuildTaskProvider.java
@@ -51,6 +51,7 @@
 import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 import java.util.concurrent.atomic.AtomicBoolean;
@@ -150,9 +151,10 @@
         }
       }
 
-
-      for (BuildFileProperty property : myExtension.getAntProperties()) {
-        programParams.add("-D" + property.getPropertyName() + "=" + property.getPropertyValue());
+      for (List<BuildFileProperty> properties : Arrays.asList(myExtension.getAntProperties(), options.getProperties())) {
+        for (BuildFileProperty property : properties) {
+          programParams.add("-D" + property.getPropertyName() + "=" + property.getPropertyValue());
+        }
       }
       programParams.add("-buildfile");
       final String buildFilePath = JpsPathUtil.urlToPath(myExtension.getFileUrl());
diff --git a/plugins/ant/jps-plugin/src/org/jetbrains/jps/ant/model/JpsAntBuildFileOptions.java b/plugins/ant/jps-plugin/src/org/jetbrains/jps/ant/model/JpsAntBuildFileOptions.java
index a6d3f26..7f0f94d 100644
--- a/plugins/ant/jps-plugin/src/org/jetbrains/jps/ant/model/JpsAntBuildFileOptions.java
+++ b/plugins/ant/jps-plugin/src/org/jetbrains/jps/ant/model/JpsAntBuildFileOptions.java
@@ -15,6 +15,8 @@
  */
 package org.jetbrains.jps.ant.model;
 
+import com.intellij.lang.ant.config.impl.BuildFileProperty;
+import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 
 import java.util.List;
@@ -36,5 +38,16 @@
 
   boolean isUseProjectDefaultAnt();
 
+  void setUseProjectDefaultAnt(boolean useProjectDefaultAnt);
+
   List<String> getAdditionalClasspath();
+
+  void addJarPath(@NotNull String path);
+
+  void addJarDirectory(@NotNull String directoryPath);
+
+  @NotNull
+  List<BuildFileProperty> getProperties();
+
+  void addProperty(@NotNull String name, @NotNull String value);
 }
diff --git a/plugins/ant/jps-plugin/src/org/jetbrains/jps/ant/model/JpsAntConfiguration.java b/plugins/ant/jps-plugin/src/org/jetbrains/jps/ant/model/JpsAntConfiguration.java
index 6c58f95..9355632 100644
--- a/plugins/ant/jps-plugin/src/org/jetbrains/jps/ant/model/JpsAntConfiguration.java
+++ b/plugins/ant/jps-plugin/src/org/jetbrains/jps/ant/model/JpsAntConfiguration.java
@@ -19,6 +19,8 @@
 import org.jetbrains.annotations.Nullable;
 import org.jetbrains.jps.model.JpsElement;
 
+import java.util.Collection;
+
 /**
  * @author nik
  */
@@ -28,4 +30,9 @@
 
   @Nullable
   String getProjectDefaultAntName();
+
+  void setProjectDefaultAntName(@Nullable String projectDefaultAntName);
+
+  @NotNull
+  Collection<JpsAntBuildFileOptions> getOptionsForAllBuildFiles();
 }
diff --git a/plugins/ant/jps-plugin/src/org/jetbrains/jps/ant/model/JpsAntExtensionService.java b/plugins/ant/jps-plugin/src/org/jetbrains/jps/ant/model/JpsAntExtensionService.java
index 61a7c99..6be70de 100644
--- a/plugins/ant/jps-plugin/src/org/jetbrains/jps/ant/model/JpsAntExtensionService.java
+++ b/plugins/ant/jps-plugin/src/org/jetbrains/jps/ant/model/JpsAntExtensionService.java
@@ -32,6 +32,7 @@
 
 import java.io.File;
 import java.util.Collections;
+import java.util.HashMap;
 
 /**
  * @author nik
@@ -68,6 +69,16 @@
     return project.getContainer().getChild(JpsAntConfigurationImpl.ROLE);
   }
 
+  @NotNull
+  public static JpsAntConfiguration getOrCreateAntConfiguration(@NotNull JpsProject project) {
+    JpsAntConfiguration configuration = getAntConfiguration(project);
+    if (configuration != null) {
+      return configuration;
+    }
+    JpsAntConfigurationImpl antConfiguration = new JpsAntConfigurationImpl(new HashMap<String, JpsAntBuildFileOptions>(), null);
+    return project.getContainer().setChild(JpsAntConfigurationImpl.ROLE, antConfiguration);
+  }
+
   @Nullable
   private static JpsAntInstallation getBundledAntInstallation() {
     String antPath = System.getProperty(BUNDLED_ANT_PATH_PROPERTY);
diff --git a/plugins/ant/jps-plugin/src/org/jetbrains/jps/ant/model/impl/JpsAntBuildFileOptionsImpl.java b/plugins/ant/jps-plugin/src/org/jetbrains/jps/ant/model/impl/JpsAntBuildFileOptionsImpl.java
index ddce091..4217ad6 100644
--- a/plugins/ant/jps-plugin/src/org/jetbrains/jps/ant/model/impl/JpsAntBuildFileOptionsImpl.java
+++ b/plugins/ant/jps-plugin/src/org/jetbrains/jps/ant/model/impl/JpsAntBuildFileOptionsImpl.java
@@ -15,6 +15,8 @@
  */
 package org.jetbrains.jps.ant.model.impl;
 
+import com.intellij.lang.ant.config.impl.BuildFileProperty;
+import org.jetbrains.annotations.NotNull;
 import org.jetbrains.jps.ant.model.JpsAntBuildFileOptions;
 
 import java.util.ArrayList;
@@ -30,8 +32,9 @@
   private String myCustomJdkName = "";
   private boolean myUseProjectDefaultAnt = true;
   private String myAntInstallationName;
-  private List<String> myClasspath = new ArrayList<String>();
-  private List<String> myJarDirectories = new ArrayList<String>();
+  private final List<String> myClasspath = new ArrayList<String>();
+  private final List<String> myJarDirectories = new ArrayList<String>();
+  private final List<BuildFileProperty> myProperties = new ArrayList<BuildFileProperty>();
 
   public void setMaxStackSize(int maxStackSize) {
     myMaxStackSize = maxStackSize;
@@ -42,6 +45,7 @@
     myAntCommandLineParameters = antCommandLineParameters;
   }
 
+  @Override
   public void setUseProjectDefaultAnt(boolean useProjectDefaultAnt) {
     myUseProjectDefaultAnt = useProjectDefaultAnt;
   }
@@ -55,11 +59,13 @@
     myAntInstallationName = antInstallationName;
   }
 
-  public void addJarPath(String path) {
+  @Override
+  public void addJarPath(@NotNull String path) {
     myClasspath.add(path);
   }
 
-  public void addJarDirectory(String directoryPath) {
+  @Override
+  public void addJarDirectory(@NotNull String directoryPath) {
     myJarDirectories.add(directoryPath);
   }
 
@@ -100,4 +106,15 @@
   public List<String> getAdditionalClasspath() {
     return JpsAntInstallationImpl.getClasspath(myClasspath, myJarDirectories);
   }
+
+  @Override
+  public void addProperty(@NotNull String name, @NotNull String value) {
+    myProperties.add(new BuildFileProperty(name, value));
+  }
+
+  @Override
+  @NotNull
+  public List<BuildFileProperty> getProperties() {
+    return myProperties;
+  }
 }
diff --git a/plugins/ant/jps-plugin/src/org/jetbrains/jps/ant/model/impl/JpsAntConfigurationImpl.java b/plugins/ant/jps-plugin/src/org/jetbrains/jps/ant/model/impl/JpsAntConfigurationImpl.java
index eb1c0c1..99f8646 100644
--- a/plugins/ant/jps-plugin/src/org/jetbrains/jps/ant/model/impl/JpsAntConfigurationImpl.java
+++ b/plugins/ant/jps-plugin/src/org/jetbrains/jps/ant/model/impl/JpsAntConfigurationImpl.java
@@ -24,6 +24,7 @@
 import org.jetbrains.jps.model.ex.JpsElementBase;
 import org.jetbrains.jps.model.ex.JpsElementChildRoleBase;
 
+import java.util.Collection;
 import java.util.Map;
 
 /**
@@ -31,8 +32,8 @@
  */
 public class JpsAntConfigurationImpl extends JpsElementBase<JpsAntConfigurationImpl> implements JpsAntConfiguration {
   public static final JpsElementChildRole<JpsAntConfiguration> ROLE = JpsElementChildRoleBase.create("ant configuration");
-  private final String myProjectDefaultAntName;
-  private Map<String, JpsAntBuildFileOptions> myOptionsMap = new HashMap<String, JpsAntBuildFileOptions>();
+  private String myProjectDefaultAntName;
+  private final Map<String, JpsAntBuildFileOptions> myOptionsMap = new HashMap<String, JpsAntBuildFileOptions>();
 
   public JpsAntConfigurationImpl(Map<String, JpsAntBuildFileOptions> options, String projectDefaultAntName) {
     myProjectDefaultAntName = projectDefaultAntName;
@@ -46,6 +47,11 @@
   }
 
   @Override
+  public void setProjectDefaultAntName(@Nullable String projectDefaultAntName) {
+    myProjectDefaultAntName = projectDefaultAntName;
+  }
+
+  @Override
   @Nullable
   public String getProjectDefaultAntName() {
     return myProjectDefaultAntName;
@@ -55,6 +61,12 @@
   public void applyChanges(@NotNull JpsAntConfigurationImpl modified) {
   }
 
+  @Override
+  @NotNull
+  public Collection<JpsAntBuildFileOptions> getOptionsForAllBuildFiles() {
+    return myOptionsMap.values();
+  }
+
   @NotNull
   @Override
   public JpsAntBuildFileOptions getOptions(@NotNull String buildFileUrl) {
diff --git a/plugins/ant/jps-plugin/src/org/jetbrains/jps/ant/model/impl/JpsAntModelSerializerExtension.java b/plugins/ant/jps-plugin/src/org/jetbrains/jps/ant/model/impl/JpsAntModelSerializerExtension.java
index b44a4e7..cbf7302 100644
--- a/plugins/ant/jps-plugin/src/org/jetbrains/jps/ant/model/impl/JpsAntModelSerializerExtension.java
+++ b/plugins/ant/jps-plugin/src/org/jetbrains/jps/ant/model/impl/JpsAntModelSerializerExtension.java
@@ -149,6 +149,13 @@
             options.addJarDirectory(JpsPathUtil.urlToPath(dirUrl));
           }
         }
+        for (Element propertyTag : JDOMUtil.getChildren(buildFileTag.getChild("properties"), "property")) {
+          String name = propertyTag.getAttributeValue("name");
+          String value = propertyTag.getAttributeValue("value");
+          if (name != null && value != null) {
+            options.addProperty(name, value);
+          }
+        }
         optionsMap.put(url, options);
       }
       Element defaultAnt = componentTag.getChild("defaultAnt");
diff --git a/plugins/ant/jps-plugin/testData/ant-project/.idea/ant.xml b/plugins/ant/jps-plugin/testData/ant-project/.idea/ant.xml
index 0ba2564..5ed7b64 100644
--- a/plugins/ant/jps-plugin/testData/ant-project/.idea/ant.xml
+++ b/plugins/ant/jps-plugin/testData/ant-project/.idea/ant.xml
@@ -11,7 +11,9 @@
       <customJdkName value="" />
       <maximumHeapSize value="128" />
       <maximumStackSize value="2" />
-      <properties />
+      <properties>
+        <property name="my.property" value="its value" />
+      </properties>
     </buildFile>
     <buildFile url="file://$PROJECT_DIR$/empty.xml">
       <additionalClassPath />
diff --git a/plugins/ant/jps-plugin/testSrc/org/jetbrains/jps/ant/JpsAntSerializationTest.java b/plugins/ant/jps-plugin/testSrc/org/jetbrains/jps/ant/JpsAntSerializationTest.java
index cb44d17..cf4bb7c 100644
--- a/plugins/ant/jps-plugin/testSrc/org/jetbrains/jps/ant/JpsAntSerializationTest.java
+++ b/plugins/ant/jps-plugin/testSrc/org/jetbrains/jps/ant/JpsAntSerializationTest.java
@@ -98,6 +98,9 @@
     assertContainsElements(toFiles(options.getAdditionalClasspath()),
                            new File(getAbsolutePath("lib/jdom.jar")),
                            new File(getAbsolutePath("ant-lib/a.jar")));
+    BuildFileProperty property = assertOneElement(options.getProperties());
+    assertEquals("my.property", property.getPropertyName());
+    assertEquals("its value", property.getPropertyValue());
 
     String emptyFileUrl = getUrl("empty.xml");
     JpsAntBuildFileOptions options2 = JpsAntExtensionService.getOptions(myProject, emptyFileUrl);
diff --git a/plugins/eclipse/src/org/jetbrains/idea/eclipse/config/EclipseClasspathStorageProvider.java b/plugins/eclipse/src/org/jetbrains/idea/eclipse/config/EclipseClasspathStorageProvider.java
index e458970..6787a9c 100644
--- a/plugins/eclipse/src/org/jetbrains/idea/eclipse/config/EclipseClasspathStorageProvider.java
+++ b/plugins/eclipse/src/org/jetbrains/idea/eclipse/config/EclipseClasspathStorageProvider.java
@@ -21,6 +21,7 @@
 import com.intellij.openapi.options.ConfigurationException;
 import com.intellij.openapi.roots.*;
 import com.intellij.openapi.roots.impl.RootModelImpl;
+import com.intellij.openapi.roots.impl.storage.ClassPathStorageUtil;
 import com.intellij.openapi.roots.impl.storage.ClasspathStorage;
 import com.intellij.openapi.roots.impl.storage.ClasspathStorageProvider;
 import com.intellij.openapi.roots.libraries.Library;
@@ -29,7 +30,7 @@
 import com.intellij.openapi.util.io.FileUtil;
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.openapi.vfs.LocalFileSystem;
-import com.intellij.openapi.vfs.VfsUtil;
+import com.intellij.openapi.vfs.VfsUtilCore;
 import com.intellij.openapi.vfs.VirtualFile;
 import org.jdom.Document;
 import org.jdom.Element;
@@ -55,16 +56,19 @@
 public class EclipseClasspathStorageProvider implements ClasspathStorageProvider {
   public static final String DESCR = EclipseBundle.message("eclipse.classpath.storage.description");
 
+  @Override
   @NonNls
   public String getID() {
     return JpsEclipseClasspathSerializer.CLASSPATH_STORAGE_ID;
   }
 
+  @Override
   @Nls
   public String getDescription() {
     return DESCR;
   }
 
+  @Override
   public void assertCompatible(final ModuleRootModel model) throws ConfigurationException {
     final String moduleName = model.getModule().getName();
     for (OrderEntry entry : model.getOrderEntries()) {
@@ -91,7 +95,7 @@
     final String output = model.getModuleExtension(CompilerModuleExtension.class).getCompilerOutputUrl();
     final String contentRoot = getContentRoot(model);
     if (output == null ||
-        !StringUtil.startsWith(VfsUtil.urlToPath(output), contentRoot) &&
+        !StringUtil.startsWith(VfsUtilCore.urlToPath(output), contentRoot) &&
         PathMacroManager.getInstance(model.getModule()).collapsePath(output).equals(output)) {
       throw new ConfigurationException("Module \'" +
                                        moduleName +
@@ -99,14 +103,17 @@
     }
   }
 
+  @Override
   public void detach(Module module) {
     EclipseModuleManagerImpl.getInstance(module).setDocumentSet(null);
   }
 
+  @Override
   public ClasspathConverter createConverter(Module module) {
     return new EclipseClasspathConverter(module);
   }
 
+  @Override
   public String getContentRoot(ModuleRootModel model) {
     final VirtualFile contentRoot = EPathUtil.getContentRoot(model);
     if (contentRoot != null) return contentRoot.getPath();
@@ -145,8 +152,9 @@
     return fileCache;
   }
 
+  @Override
   public void moduleRenamed(final Module module, String newName) {
-    if (ClasspathStorage.getStorageType(module).equals(JpsEclipseClasspathSerializer.CLASSPATH_STORAGE_ID)) {
+    if (ClassPathStorageUtil.getStorageType(module).equals(JpsEclipseClasspathSerializer.CLASSPATH_STORAGE_ID)) {
       try {
         final CachedXmlDocumentSet documentSet = getFileCache(module);
 
@@ -184,10 +192,12 @@
       this.module = module;
     }
 
+    @Override
     public CachedXmlDocumentSet getFileSet() {
       return getFileCache(module);
     }
 
+    @Override
     public Set<String> getClasspath(ModifiableRootModel model, final Element element) throws IOException, InvalidDataException {
       try {
         final HashSet<String> usedVariables = new HashSet<String>();
@@ -225,6 +235,7 @@
       }
     }
 
+    @Override
     public void setClasspath(final ModuleRootModel model) throws IOException, WriteExternalException {
       try {
         final Element classpathElement = new Element(EclipseXml.CLASSPATH_TAG);
diff --git a/plugins/eclipse/src/org/jetbrains/idea/eclipse/config/EclipseModuleManagerImpl.java b/plugins/eclipse/src/org/jetbrains/idea/eclipse/config/EclipseModuleManagerImpl.java
index 0450e37..30147f2 100644
--- a/plugins/eclipse/src/org/jetbrains/idea/eclipse/config/EclipseModuleManagerImpl.java
+++ b/plugins/eclipse/src/org/jetbrains/idea/eclipse/config/EclipseModuleManagerImpl.java
@@ -21,7 +21,7 @@
 import com.intellij.openapi.components.Storage;
 import com.intellij.openapi.module.Module;
 import com.intellij.openapi.module.ModuleServiceManager;
-import com.intellij.openapi.roots.impl.storage.ClasspathStorage;
+import com.intellij.openapi.roots.impl.storage.ClassPathStorageUtil;
 import com.intellij.openapi.util.text.StringUtil;
 import com.intellij.util.ArrayUtil;
 import org.jdom.Element;
@@ -174,7 +174,7 @@
 
   @Override
   public Element getState() {
-    if (!ClasspathStorage.getStorageType(myModule).equals(JpsEclipseClasspathSerializer.CLASSPATH_STORAGE_ID)) {
+    if (!ClassPathStorageUtil.getStorageType(myModule).equals(JpsEclipseClasspathSerializer.CLASSPATH_STORAGE_ID)) {
       if (!myEclipseUrls.isEmpty() || !myEclipseVariablePaths.isEmpty() || myForceConfigureJDK || !myUnknownCons.isEmpty()) {
         Element root = new Element("EclipseModuleSettings");
         for (String eclipseUrl : myEclipseUrls) {
diff --git a/plugins/eclipse/src/org/jetbrains/idea/eclipse/export/ExportEclipseProjectsAction.java b/plugins/eclipse/src/org/jetbrains/idea/eclipse/export/ExportEclipseProjectsAction.java
index b17cb12..a577d67 100644
--- a/plugins/eclipse/src/org/jetbrains/idea/eclipse/export/ExportEclipseProjectsAction.java
+++ b/plugins/eclipse/src/org/jetbrains/idea/eclipse/export/ExportEclipseProjectsAction.java
@@ -26,6 +26,7 @@
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.roots.ModuleRootManager;
 import com.intellij.openapi.roots.ModuleRootModel;
+import com.intellij.openapi.roots.impl.storage.ClassPathStorageUtil;
 import com.intellij.openapi.roots.impl.storage.ClasspathStorage;
 import com.intellij.openapi.ui.DialogWrapper;
 import com.intellij.openapi.ui.Messages;
@@ -65,7 +66,7 @@
     final List<Module> modules = new ArrayList<Module>();
     final List<Module> incompatibleModules = new ArrayList<Module>();
     for (Module module : ModuleManager.getInstance(project).getModules()) {
-      if (!JpsEclipseClasspathSerializer.CLASSPATH_STORAGE_ID.equals(ClasspathStorage.getStorageType(module))) {
+      if (!JpsEclipseClasspathSerializer.CLASSPATH_STORAGE_ID.equals(ClassPathStorageUtil.getStorageType(module))) {
         try {
           ClasspathStorage.getProvider(JpsEclipseClasspathSerializer.CLASSPATH_STORAGE_ID).assertCompatible(ModuleRootManager.getInstance(module));
           modules.add(module);
diff --git a/plugins/eclipse/src/org/jetbrains/idea/eclipse/importWizard/EclipseImportBuilder.java b/plugins/eclipse/src/org/jetbrains/idea/eclipse/importWizard/EclipseImportBuilder.java
index fdbea3c..93304b6 100644
--- a/plugins/eclipse/src/org/jetbrains/idea/eclipse/importWizard/EclipseImportBuilder.java
+++ b/plugins/eclipse/src/org/jetbrains/idea/eclipse/importWizard/EclipseImportBuilder.java
@@ -36,6 +36,7 @@
 import com.intellij.openapi.roots.ModifiableRootModel;
 import com.intellij.openapi.roots.ModuleRootManager;
 import com.intellij.openapi.roots.impl.ModifiableModelCommitter;
+import com.intellij.openapi.roots.impl.storage.ClassPathStorageUtil;
 import com.intellij.openapi.roots.impl.storage.ClasspathStorage;
 import com.intellij.openapi.roots.libraries.Library;
 import com.intellij.openapi.roots.libraries.LibraryTable;
@@ -173,7 +174,7 @@
   public boolean validate(final Project currentProject, final Project dstProject) {
     final Ref<Exception> refEx = new Ref<Exception>();
     final HashSet<String> variables = new HashSet<String>();
-    final Map<String, String> naturesNames = new HashMap<String, String>();  
+    final Map<String, String> naturesNames = new HashMap<String, String>();
     final List<String> projectsToConvert = getParameters().projectsToConvert;
     final boolean oneProjectToConvert = projectsToConvert.size() == 1;
     final String separator = oneProjectToConvert ? "<br>" : ", ";
@@ -333,7 +334,7 @@
           EclipseClasspathReader.setOutputUrl(rootModel, path + "/bin");
         }
         ClasspathStorage.setStorageType(rootModel,
-                                      getParameters().linkConverted ? JpsEclipseClasspathSerializer.CLASSPATH_STORAGE_ID : ClasspathStorage.DEFAULT_STORAGE);
+                                      getParameters().linkConverted ? JpsEclipseClasspathSerializer.CLASSPATH_STORAGE_ID : ClassPathStorageUtil.DEFAULT_STORAGE);
         if (model != null) {
           ApplicationManager.getApplication().runWriteAction(new Runnable() {
             public void run() {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/GroovySuppressableInspectionTool.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/GroovySuppressableInspectionTool.java
index 83de0a2..3f57fc0 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/GroovySuppressableInspectionTool.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/GroovySuppressableInspectionTool.java
@@ -44,22 +44,24 @@
 /**
  * @author peter
  */
-public abstract class GroovySuppressableInspectionTool extends LocalInspectionTool implements CustomSuppressableInspectionTool {
-  @Nullable
-  public SuppressIntentionAction[] getSuppressActions(final PsiElement element) {
+public abstract class GroovySuppressableInspectionTool extends LocalInspectionTool implements BatchSuppressableTool {
+  @NotNull
+  @Override
+  public SuppressQuickFix[] getBatchSuppressActions(@Nullable PsiElement element) {
     return getSuppressActions(getShortName());
 
   }
 
-  public static SuppressIntentionAction[] getSuppressActions(String name) {
+  public static SuppressQuickFix[] getSuppressActions(String name) {
     final HighlightDisplayKey displayKey = HighlightDisplayKey.find(name);
-    return new SuppressIntentionAction[]{
+    return new SuppressQuickFix[] {
       new SuppressByGroovyCommentFix(displayKey),
       new SuppressForMemberFix(displayKey, false),
       new SuppressForMemberFix(displayKey, true),
     };
   }
 
+  @Override
   public boolean isSuppressedFor(@NotNull final PsiElement element) {
     return isElementToolSuppressedIn(element, getID());
   }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/SuppressByGroovyCommentFix.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/SuppressByGroovyCommentFix.java
index 9f8a057..454dc55 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/SuppressByGroovyCommentFix.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/SuppressByGroovyCommentFix.java
@@ -31,8 +31,9 @@
     super(key, GrStatement.class);
   }
 
+  @Override
   @Nullable
-  protected PsiElement getContainer(PsiElement context) {
+  public PsiElement getContainer(PsiElement context) {
     return PsiUtil.findEnclosingStatement(context);
   }
 
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/SuppressForMemberFix.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/SuppressForMemberFix.java
index af27e20..0623187 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/SuppressForMemberFix.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/SuppressForMemberFix.java
@@ -16,13 +16,11 @@
 
 package org.jetbrains.plugins.groovy.codeInspection;
 
-import com.intellij.codeInsight.FileModificationService;
 import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
 import com.intellij.codeInsight.daemon.HighlightDisplayKey;
+import com.intellij.codeInsight.daemon.impl.actions.AbstractBatchSuppressByNoInspectionCommentFix;
 import com.intellij.codeInspection.InspectionsBundle;
-import com.intellij.codeInspection.SuppressIntentionAction;
 import com.intellij.codeInspection.SuppressManager;
-import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.project.Project;
 import com.intellij.psi.*;
 import com.intellij.psi.util.PsiTreeUtil;
@@ -43,18 +41,18 @@
 /**
  * @author peter
  */
-public class SuppressForMemberFix extends SuppressIntentionAction {
-  private final String myID;
+public class SuppressForMemberFix extends AbstractBatchSuppressByNoInspectionCommentFix {
   private String myKey;
   private final boolean myForClass;
 
-  public SuppressForMemberFix(HighlightDisplayKey key, boolean forClass) {
-    myID = key.getID();
+  public SuppressForMemberFix(@NotNull HighlightDisplayKey key, boolean forClass) {
+    super(key.getID(), false);
     myForClass = forClass;
   }
 
+  @Override
   @Nullable
-  protected GrDocCommentOwner getContainer(final PsiElement context) {
+  public GrDocCommentOwner getContainer(final PsiElement context) {
     if (context == null || context instanceof PsiFile) {
       return null;
     }
@@ -76,7 +74,7 @@
     if (myForClass) {
       while (container != null ) {
         final GrTypeDefinition parentClass = PsiTreeUtil.getParentOfType(container, GrTypeDefinition.class);
-        if ((parentClass == null) && container instanceof GrTypeDefinition){
+        if (parentClass == null && container instanceof GrTypeDefinition){
           return container;
         }
         container = parentClass;
@@ -85,28 +83,29 @@
     return container;
   }
 
+  @Override
   @NotNull
   public String getText() {
     return myKey != null ? InspectionsBundle.message(myKey) : "Suppress for member";
   }
 
 
-  @NotNull
-  public String getFamilyName() {
-    return InspectionsBundle.message("suppress.inspection.family");
-  }
-
-  public boolean isAvailable(@NotNull final Project project, final Editor editor, @NotNull final PsiElement context) {
+  @Override
+  public boolean isAvailable(@NotNull final Project project, @NotNull final PsiElement context) {
     final GrDocCommentOwner container = getContainer(context);
     myKey = container instanceof PsiClass ? "suppress.inspection.class" : container instanceof PsiMethod ? "suppress.inspection.method" : "suppress.inspection.field";
     return container != null && context.getManager().isInProject(context);
   }
 
-  public void invoke(@NotNull final Project project, final Editor editor, @NotNull final PsiElement element) throws IncorrectOperationException {
-    GrDocCommentOwner container = getContainer(element);
-    assert container != null;
-    if (!FileModificationService.getInstance().preparePsiElementForWrite(container)) return;
-    final GrModifierList modifierList = (GrModifierList)container.getModifierList();
+  @Override
+  protected boolean replaceSuppressionComments(PsiElement container) {
+    return false;
+  }
+
+  @Override
+  protected void createSuppression(@NotNull Project project, @NotNull PsiElement element, @NotNull PsiElement container)
+    throws IncorrectOperationException {
+    final GrModifierList modifierList = (GrModifierList)((PsiModifierListOwner)container).getModifierList();
     if (modifierList != null) {
       addSuppressAnnotation(project, modifierList, myID);
     }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/spellchecker/GroovySpellcheckingStrategy.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/spellchecker/GroovySpellcheckingStrategy.java
index 2e4f38e..f252ee8 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/spellchecker/GroovySpellcheckingStrategy.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeInspection/spellchecker/GroovySpellcheckingStrategy.java
@@ -15,7 +15,7 @@
  */
 package org.jetbrains.plugins.groovy.codeInspection.spellchecker;
 
-import com.intellij.codeInspection.SuppressIntentionAction;
+import com.intellij.codeInspection.SuppressQuickFix;
 import com.intellij.psi.PsiElement;
 import com.intellij.psi.javadoc.PsiDocComment;
 import com.intellij.spellchecker.inspections.PlainTextSplitter;
@@ -34,7 +34,7 @@
  */
 public class GroovySpellcheckingStrategy extends SuppressibleSpellcheckingStrategy {
   private final GrDocCommentTokenizer myDocCommentTokenizer = new GrDocCommentTokenizer();
-  private Tokenizer<PsiElement> myStringTokenizer = new Tokenizer<PsiElement>() {
+  private final Tokenizer<PsiElement> myStringTokenizer = new Tokenizer<PsiElement>() {
     @Override
     public void tokenize(@NotNull PsiElement literal, TokenConsumer consumer) {
       String text = GrStringUtil.removeQuotes(literal.getText());
@@ -73,7 +73,7 @@
   }
 
   @Override
-  public SuppressIntentionAction[] getSuppressActions(@NotNull PsiElement element, @NotNull String name) {
+  public SuppressQuickFix[] getSuppressActions(@NotNull PsiElement element, @NotNull String name) {
     return GroovySuppressableInspectionTool.getSuppressActions(name);
   }
 }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeStyle/GroovyCodeStyleSettings.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeStyle/GroovyCodeStyleSettings.java
index 12bdef1..d005e40 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeStyle/GroovyCodeStyleSettings.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeStyle/GroovyCodeStyleSettings.java
@@ -15,10 +15,7 @@
  */
 package org.jetbrains.plugins.groovy.codeStyle;
 
-import com.intellij.psi.codeStyle.CodeStyleSettings;
-import com.intellij.psi.codeStyle.CustomCodeStyleSettings;
-import com.intellij.psi.codeStyle.PackageEntry;
-import com.intellij.psi.codeStyle.PackageEntryTable;
+import com.intellij.psi.codeStyle.*;
 
 /**
  * @author Max Medvedev
@@ -62,6 +59,8 @@
   public final PackageEntryTable IMPORT_LAYOUT_TABLE = new PackageEntryTable();
   public boolean LAYOUT_STATIC_IMPORTS_SEPARATELY = true;
 
+  public int IMPORT_ANNOTATION_WRAP = CommonCodeStyleSettings.WRAP_ALWAYS;
+
   private void initImportsByDefault() {
     PACKAGES_TO_USE_IMPORT_ON_DEMAND.addEntry(new PackageEntry(false, "java.awt", false));
     PACKAGES_TO_USE_IMPORT_ON_DEMAND.addEntry(new PackageEntry(false, "javax.swing", false));
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeStyle/GroovyLanguageCodeStyleSettingsProvider.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeStyle/GroovyLanguageCodeStyleSettingsProvider.java
index 995ac82..ba9e519 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/codeStyle/GroovyLanguageCodeStyleSettingsProvider.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/codeStyle/GroovyLanguageCodeStyleSettingsProvider.java
@@ -141,9 +141,13 @@
         "VARIABLE_ANNOTATION_WRAP",
         "ENUM_CONSTANTS_WRAP"
       );
-      consumer.showCustomOption(GroovyCodeStyleSettings.class, "USE_FLYING_GEESE_BRACES",     "Use flying geese braces", CodeStyleSettingsCustomizable.WRAPPING_BRACES);
+      consumer.showCustomOption(GroovyCodeStyleSettings.class, "USE_FLYING_GEESE_BRACES", "Use flying geese braces",
+                                CodeStyleSettingsCustomizable.WRAPPING_BRACES);
       consumer.showCustomOption(GroovyCodeStyleSettings.class, "ALIGN_MULTILINE_LIST_OR_MAP", "Align when multiple",     "List and map literals");
       consumer.showCustomOption(GroovyCodeStyleSettings.class, "ALIGN_NAMED_ARGS_IN_MAP",     "Align multiline named arguments",   "List and map literals");
+      consumer.showCustomOption(GroovyCodeStyleSettings.class, "IMPORT_ANNOTATION_WRAP", "Import annotations", null,
+                                CodeStyleSettingsCustomizable.OptionAnchor.AFTER, "VARIABLE_ANNOTATION_WRAP",
+                                CodeStyleSettingsCustomizable.WRAP_OPTIONS, CodeStyleSettingsCustomizable.WRAP_VALUES);
       return;
     }
     if (settingsType == SettingsType.SPACING_SETTINGS) {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/ClosureBodyBlock.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/ClosureBodyBlock.java
index e1eae12..19d6bbd 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/ClosureBodyBlock.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/ClosureBodyBlock.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -20,10 +20,8 @@
 import com.intellij.formatting.Wrap;
 import com.intellij.lang.ASTNode;
 import com.intellij.openapi.util.TextRange;
-import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
-import org.jetbrains.plugins.groovy.codeStyle.GroovyCodeStyleSettings;
 
 import java.util.List;
 
@@ -36,10 +34,8 @@
   public ClosureBodyBlock(@NotNull ASTNode node,
                           @NotNull Indent indent,
                           @Nullable Wrap wrap,
-                          CommonCodeStyleSettings settings,
-                          GroovyCodeStyleSettings groovySettings,
-                          @NotNull AlignmentProvider alignmentProvider) {
-    super(node, indent, wrap, settings, groovySettings, alignmentProvider);
+                          FormattingContext context) {
+    super(node, indent, wrap, context);
   }
 
   @NotNull
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/FormattingContext.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/FormattingContext.java
new file mode 100644
index 0000000..8d26c02
--- /dev/null
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/FormattingContext.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2000-2013 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.groovy.formatter;
+
+import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.plugins.groovy.codeStyle.GroovyCodeStyleSettings;
+
+/**
+ * @author Max Medvedev
+ */
+public class FormattingContext {
+  private final CommonCodeStyleSettings mySettings;
+  private final GroovyCodeStyleSettings myGroovySettings;
+  private final AlignmentProvider myAlignmentProvider;
+
+  private final boolean myInsidePlainGString;
+
+  public FormattingContext(@NotNull CommonCodeStyleSettings settings,
+                           @NotNull AlignmentProvider provider,
+                           @NotNull GroovyCodeStyleSettings groovySettings, boolean insidePlainGString) {
+    mySettings = settings;
+    myAlignmentProvider = provider;
+    myGroovySettings = groovySettings;
+    myInsidePlainGString = insidePlainGString;
+  }
+
+  public CommonCodeStyleSettings getSettings() {
+    return mySettings;
+  }
+
+  public AlignmentProvider getAlignmentProvider() {
+    return myAlignmentProvider;
+  }
+
+  public GroovyCodeStyleSettings getGroovySettings() {
+    return myGroovySettings;
+  }
+
+  public FormattingContext createContext(boolean insidePlainGString) {
+    return new FormattingContext(mySettings, myAlignmentProvider, myGroovySettings, insidePlainGString);
+  }
+
+  public boolean isInsidePlainGString() {
+    return myInsidePlainGString;
+  }
+}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyBlock.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyBlock.java
index 814b227..12f7ab1 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyBlock.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyBlock.java
@@ -22,11 +22,9 @@
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.util.TextRange;
 import com.intellij.psi.*;
-import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
 import com.intellij.psi.tree.ILazyParseableElementType;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
-import org.jetbrains.plugins.groovy.codeStyle.GroovyCodeStyleSettings;
 import org.jetbrains.plugins.groovy.formatter.processors.GroovyIndentProcessor;
 import org.jetbrains.plugins.groovy.formatter.processors.GroovySpacingProcessor;
 import org.jetbrains.plugins.groovy.formatter.processors.GroovySpacingProcessorBasic;
@@ -64,25 +62,20 @@
   protected Alignment myAlignment = null;
   final protected Indent myIndent;
   final protected Wrap myWrap;
-  final protected CommonCodeStyleSettings mySettings;
-  final protected GroovyCodeStyleSettings myGroovySettings;
-  final protected AlignmentProvider myAlignmentProvider;
+
+  final protected FormattingContext myContext;
 
   protected List<Block> mySubBlocks = null;
 
   public GroovyBlock(@NotNull final ASTNode node,
                      @NotNull final Indent indent,
                      @Nullable final Wrap wrap,
-                     final CommonCodeStyleSettings settings,
-                     GroovyCodeStyleSettings groovySettings,
-                     @NotNull AlignmentProvider alignmentProvider) {
+                     FormattingContext context) {
     myNode = node;
 
     myIndent = indent;
     myWrap = wrap;
-    mySettings = settings;
-    myGroovySettings = groovySettings;
-    myAlignmentProvider = alignmentProvider;
+    myContext = context;
   }
 
   @NotNull
@@ -91,19 +84,6 @@
   }
 
   @NotNull
-  public CommonCodeStyleSettings getSettings() {
-    return mySettings;
-  }
-
-  public GroovyCodeStyleSettings getGroovySettings() {
-    return myGroovySettings;
-  }
-
-  public AlignmentProvider getAlignmentProvider() {
-    return myAlignmentProvider;
-  }
-
-  @NotNull
   public TextRange getTextRange() {
     return myNode.getTextRange();
   }
@@ -142,7 +122,7 @@
   @Nullable
   public Alignment getAlignment() {
     if (myAlignment == null) {
-      myAlignment = myAlignmentProvider.getAlignment(myNode.getPsi());
+      myAlignment = myContext.getAlignmentProvider().getAlignment(myNode.getPsi());
     }
 
     return myAlignment;
@@ -162,11 +142,11 @@
         return Spacing.getReadOnlySpacing();
       }
 
-      Spacing spacing = new GroovySpacingProcessor(((GroovyBlock)child2).getNode(), mySettings, myGroovySettings).getSpacing();
+      Spacing spacing = new GroovySpacingProcessor(((GroovyBlock)child2).getNode(), myContext).getSpacing();
       if (spacing != null) {
         return spacing;
       }
-      return GroovySpacingProcessorBasic.getSpacing(((GroovyBlock)child1), ((GroovyBlock)child2), mySettings, myGroovySettings);
+      return GroovySpacingProcessorBasic.getSpacing(((GroovyBlock)child1), ((GroovyBlock)child2), myContext);
     }
     return null;
   }
@@ -190,12 +170,12 @@
                   statement instanceof GrContinueStatement ||
                   statement instanceof GrReturnStatement ||
                   statement instanceof GrThrowStatement) {
-                return new ChildAttributes(GroovyIndentProcessor.getSwitchCaseIndent(anchorPsi), null);
+                return new ChildAttributes(GroovyIndentProcessor.getSwitchCaseIndent(myContext.getSettings()), null);
               }
             }
             @SuppressWarnings("ConstantConditions")
-            int indentSize = mySettings.getIndentOptions().INDENT_SIZE;
-            return new ChildAttributes(Indent.getSpaceIndent(mySettings.INDENT_CASE_FROM_SWITCH ? 2 * indentSize : indentSize), null);
+            int indentSize = myContext.getSettings().getIndentOptions().INDENT_SIZE;
+            return new ChildAttributes(Indent.getSpaceIndent(myContext.getSettings().INDENT_CASE_FROM_SWITCH ? 2 * indentSize : indentSize), null);
           }
         }
       }
@@ -261,4 +241,9 @@
   public String toString() {
     return getTextRange() + ": " + myNode;
   }
+
+
+  public FormattingContext getContext() {
+    return myContext;
+  }
 }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyBlockGenerator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyBlockGenerator.java
index 29bcbc0..3c6702f 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyBlockGenerator.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyBlockGenerator.java
@@ -16,10 +16,7 @@
 
 package org.jetbrains.plugins.groovy.formatter;
 
-import com.intellij.formatting.Alignment;
-import com.intellij.formatting.Block;
-import com.intellij.formatting.Indent;
-import com.intellij.formatting.Wrap;
+import com.intellij.formatting.*;
 import com.intellij.lang.ASTNode;
 import com.intellij.openapi.diagnostic.Logger;
 import com.intellij.openapi.util.TextRange;
@@ -28,7 +25,6 @@
 import com.intellij.psi.PsiComment;
 import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiFile;
-import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
 import com.intellij.psi.impl.source.tree.LeafPsiElement;
 import com.intellij.psi.templateLanguages.OuterLanguageElement;
 import com.intellij.psi.tree.IElementType;
@@ -38,8 +34,8 @@
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 import org.jetbrains.plugins.groovy.GroovyFileType;
-import org.jetbrains.plugins.groovy.codeStyle.GroovyCodeStyleSettings;
 import org.jetbrains.plugins.groovy.formatter.processors.GroovyIndentProcessor;
+import org.jetbrains.plugins.groovy.formatter.processors.GroovyWrappingProcessor;
 import org.jetbrains.plugins.groovy.lang.lexer.GroovyTokenTypes;
 import org.jetbrains.plugins.groovy.lang.lexer.TokenSets;
 import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
@@ -59,6 +55,7 @@
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrCodeBlock;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.clauses.GrTraditionalForClause;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.*;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.literals.GrString;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.path.GrMethodCallExpression;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameterList;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrExtendsClause;
@@ -88,20 +85,20 @@
 
   private final GroovyBlock myBlock;
   private final ASTNode myNode;
-  private final Alignment myAlignment;
-  private final Wrap myWrap;
-  private final CommonCodeStyleSettings mySettings;
+
   private final AlignmentProvider myAlignmentProvider;
-  private final GroovyCodeStyleSettings myGroovySettings;
+  private final GroovyWrappingProcessor myWrappingProcessor;
+
+  private final FormattingContext myContext;
 
   public GroovyBlockGenerator(GroovyBlock block) {
     myBlock = block;
     myNode = myBlock.getNode();
-    myAlignment = myBlock.getAlignment();
-    myWrap = myBlock.getWrap();
-    mySettings = myBlock.getSettings();
-    myAlignmentProvider = myBlock.getAlignmentProvider();
-    myGroovySettings = myBlock.getGroovySettings();
+
+    myContext = block.getContext();
+    myAlignmentProvider = myContext.getAlignmentProvider();
+
+    myWrappingProcessor = new GroovyWrappingProcessor(myBlock);
   }
 
   static List<ASTNode> getClosureBodyVisibleChildren(final ASTNode node) {
@@ -143,12 +140,14 @@
 
     //for gstrings
     if (elementType == GSTRING || elementType == REGEX || elementType == mREGEX_LITERAL || elementType == mDOLLAR_SLASH_REGEX_LITERAL) {
+      final FormattingContext context =
+        myNode.getPsi() instanceof GrString && ((GrString)myNode.getPsi()).isPlainString() ? myContext.createContext(true) : myContext;
+
       final ArrayList<Block> subBlocks = new ArrayList<Block>();
       ASTNode[] children = getGroovyChildren(myNode);
       for (ASTNode childNode : children) {
         if (childNode.getTextRange().getLength() > 0) {
-          final Indent indent = new GroovyIndentProcessor().getChildIndent(myBlock, childNode);
-          subBlocks.add(new GroovyBlock(childNode, indent, myWrap, mySettings, myGroovySettings, myAlignmentProvider));
+          subBlocks.add(new GroovyBlock(childNode, getIndent(childNode), Wrap.createWrap(WrapType.NONE, false), context));
         }
       }
       return subBlocks;
@@ -157,12 +156,14 @@
     // chained properties, calls, indexing, etc
     if (NESTED.contains(elementType) && blockPsi.getParent() != null && !NESTED.contains(blockPsi.getParent().getNode().getElementType())) {
       final List<Block> subBlocks = new ArrayList<Block>();
-      AlignmentProvider.Aligner dotsAligner = mySettings.ALIGN_MULTILINE_CHAINED_METHODS ? myAlignmentProvider.createAligner(true) : null;
-      addNestedChildren(myNode.getPsi(), subBlocks, dotsAligner, true);
+      AlignmentProvider.Aligner dotsAligner = myContext.getSettings().ALIGN_MULTILINE_CHAINED_METHODS ? myAlignmentProvider.createAligner(false) : null;
+
+      final Wrap wrap = myWrappingProcessor.getChainedMethodCallWrap();
+      addNestedChildren(myNode.getPsi(), subBlocks, dotsAligner, true, wrap);
       return subBlocks;
     }
 
-    if (blockPsi instanceof GrListOrMap && ((GrListOrMap)blockPsi).isMap() && myGroovySettings.ALIGN_NAMED_ARGS_IN_MAP) {
+    if (blockPsi instanceof GrListOrMap && ((GrListOrMap)blockPsi).isMap() && myContext.getGroovySettings().ALIGN_NAMED_ARGS_IN_MAP) {
       AlignmentProvider.Aligner labels = myAlignmentProvider.createAligner(false);
       AlignmentProvider.Aligner exprs = myAlignmentProvider.createAligner(true);
       GrNamedArgument[] namedArgs = ((GrListOrMap)blockPsi).getNamedArguments();
@@ -188,8 +189,7 @@
         }
       }
       for (ASTNode childNode : astNodes) {
-        final Indent indent = new GroovyIndentProcessor().getChildIndent(myBlock, childNode);
-        subBlocks.add(new GroovyBlock(childNode, indent, myWrap, mySettings, myGroovySettings, myAlignmentProvider));
+        subBlocks.add(new GroovyBlock(childNode, getIndent(childNode), getChildWrap(childNode), myContext));
       }
       return subBlocks;
     }
@@ -206,8 +206,7 @@
       PsiElement lbrace = closableBlock.getLBrace();
       if (lbrace != null) {
         ASTNode node = lbrace.getNode();
-        Indent indent = new GroovyIndentProcessor().getChildIndent(myBlock, node);
-        blocks.add(new GroovyBlock(node, indent, myWrap, mySettings, myGroovySettings, myAlignmentProvider));
+        blocks.add(new GroovyBlock(node, getIndent(node), Wrap.createWrap(WrapType.NONE, false), myContext));
       }
 
      /* {
@@ -227,15 +226,14 @@
       {
         Indent indent = Indent.getNormalIndent();
         ASTNode parameterListNode = closableBlock.getParameterList().getNode();
-        ClosureBodyBlock bodyBlock = new ClosureBodyBlock(parameterListNode, indent, myWrap, mySettings, myGroovySettings, myAlignmentProvider);
+        ClosureBodyBlock bodyBlock = new ClosureBodyBlock(parameterListNode, indent, Wrap.createWrap(WrapType.NONE, false), myContext);
         blocks.add(bodyBlock);
       }
 
       PsiElement rbrace = closableBlock.getRBrace();
       if (rbrace != null) {
         ASTNode node = rbrace.getNode();
-        Indent indent = new GroovyIndentProcessor().getChildIndent(myBlock, node);
-        blocks.add(new GroovyBlock(node, indent, myWrap, mySettings, myGroovySettings, myAlignmentProvider));
+        blocks.add(new GroovyBlock(node, getIndent(node), Wrap.createWrap(WrapType.NONE, false), myContext));
       }
 
       return blocks;
@@ -246,7 +244,7 @@
     }
 
     if (blockPsi instanceof GrMethod) {
-      if (mySettings.ALIGN_MULTILINE_METHOD_BRACKETS) {
+      if (myContext.getSettings().ALIGN_MULTILINE_METHOD_BRACKETS) {
         final ASTNode lparenth = myNode.findChildByType(mLPAREN);
         final ASTNode rparenth = myNode.findChildByType(mRPAREN);
         if (lparenth != null && rparenth != null) {
@@ -256,7 +254,7 @@
     }
 
     else if (blockPsi instanceof GrTraditionalForClause) {
-      if (mySettings.ALIGN_MULTILINE_FOR) {
+      if (myContext.getSettings().ALIGN_MULTILINE_FOR) {
         final GrTraditionalForClause clause = (GrTraditionalForClause)blockPsi;
         final AlignmentProvider.Aligner parenthesesAligner = myAlignmentProvider.createAligner(false);
         parenthesesAligner.append(clause.getInitialization());
@@ -266,7 +264,7 @@
     }
 
     else if (blockPsi instanceof GrBinaryExpression) {
-      if (mySettings.ALIGN_MULTILINE_BINARY_OPERATION) {
+      if (myContext.getSettings().ALIGN_MULTILINE_BINARY_OPERATION) {
         final GrBinaryExpression binary = (GrBinaryExpression)blockPsi;
 
         final GrExpression left = binary.getLeftOperand();
@@ -278,7 +276,7 @@
     }
 
     else if (blockPsi instanceof GrAssignmentExpression) {
-      if (mySettings.ALIGN_MULTILINE_ASSIGNMENT) {
+      if (myContext.getSettings().ALIGN_MULTILINE_ASSIGNMENT) {
         final GrAssignmentExpression assignment = (GrAssignmentExpression)blockPsi;
 
         final GrExpression lValue = assignment.getLValue();
@@ -290,7 +288,7 @@
     }
 
     else if (blockPsi instanceof GrConditionalExpression) {
-      if (mySettings.ALIGN_MULTILINE_TERNARY_OPERATION) {
+      if (myContext.getSettings().ALIGN_MULTILINE_TERNARY_OPERATION) {
         final GrConditionalExpression conditional = (GrConditionalExpression)blockPsi;
 
         final AlignmentProvider.Aligner aligner = myAlignmentProvider.createAligner(false);
@@ -305,30 +303,31 @@
     // For other cases
     final ArrayList<Block> subBlocks = new ArrayList<Block>();
     for (ASTNode childNode : visibleChildren(myNode)) {
-      final Indent indent = new GroovyIndentProcessor().getChildIndent(myBlock, childNode);
-      subBlocks.add(new GroovyBlock(childNode, indent, myWrap, mySettings, myGroovySettings, myAlignmentProvider));
+      subBlocks.add(new GroovyBlock(childNode, getIndent(childNode), getChildWrap(childNode), myContext));
     }
     return subBlocks;
   }
 
+  private Wrap getChildWrap(ASTNode childNode) {
+    final Wrap wrap = myWrappingProcessor.getChildWrap(childNode);
+    return wrap;
+  }
+
   public List<Block> generateSubBlockForCodeBlocks(boolean classLevel, final List<ASTNode> children) {
 
     calculateAlignments(children, classLevel);
     final ArrayList<Block> subBlocks = new ArrayList<Block>();
 
-    if (classLevel && myAlignment != null) {
-      final AlignmentProvider.Aligner aligner = myAlignmentProvider.createAligner(true);
-      for (ASTNode child : children) {
-        aligner.append(child.getPsi());
-      }
-    }
     for (ASTNode childNode : children) {
-      final Indent indent = new GroovyIndentProcessor().getChildIndent(myBlock, childNode);
-      subBlocks.add(new GroovyBlock(childNode, indent, myWrap, mySettings, myGroovySettings, myAlignmentProvider));
+      subBlocks.add(new GroovyBlock(childNode, getIndent(childNode), getChildWrap(childNode), myContext));
     }
     return subBlocks;
   }
 
+  private Indent getIndent(ASTNode childNode) {
+    return new GroovyIndentProcessor().getChildIndent(myBlock, childNode);
+  }
+
 
   private void calculateAlignments(List<ASTNode> children, boolean classLevel) {
     List<GrStatement> currentGroup = null;
@@ -389,7 +388,7 @@
         varName.append(variable.getNameIdentifierGroovy());
       }
 
-      if (classLevel && mySettings.ALIGN_GROUP_FIELD_DECLARATIONS) {
+      if (classLevel && myContext.getSettings().ALIGN_GROUP_FIELD_DECLARATIONS) {
         typeElement.append(varDeclaration.getTypeElementGroovy());
 
         ASTNode current_eq = variables[variables.length - 1].getNode().findChildByType(GroovyTokenTypes.mASSIGN);
@@ -426,9 +425,9 @@
   }
 
   private boolean fieldGroupEnded(PsiElement psi) {
-    if (!mySettings.ALIGN_GROUP_FIELD_DECLARATIONS) return true;
+    if (!myContext.getSettings().ALIGN_GROUP_FIELD_DECLARATIONS) return true;
     PsiElement prevSibling = psi.getPrevSibling();
-    return prevSibling != null && StringUtil.countChars(prevSibling.getText(), '\n') >= mySettings.KEEP_BLANK_LINES_IN_DECLARATIONS;
+    return prevSibling != null && StringUtil.countChars(prevSibling.getText(), '\n') >= myContext.getSettings().KEEP_BLANK_LINES_IN_DECLARATIONS;
   }
 
   private static List<LeafPsiElement> getSpockTable(GrStatement statement) {
@@ -466,7 +465,7 @@
     // foo({
     //       println 'xxx'
     //     })
-    if (blockPsi instanceof GrArgumentList && mySettings.ALIGN_MULTILINE_PARAMETERS_IN_CALLS) {
+    if (blockPsi instanceof GrArgumentList && myContext.getSettings().ALIGN_MULTILINE_PARAMETERS_IN_CALLS) {
       return !(children.size() == 3 &&
                children.get(0).getElementType() == mLPAREN &&
                (children.get(1).getElementType() == CLOSABLE_BLOCK || children.get(1).getElementType() == LIST_OR_MAP) &&
@@ -474,14 +473,14 @@
     }
 
     if (blockPsi instanceof GrAssignmentExpression && ((GrAssignmentExpression)blockPsi).getRValue() instanceof GrAssignmentExpression) {
-      return mySettings.ALIGN_MULTILINE_ASSIGNMENT;
+      return myContext.getSettings().ALIGN_MULTILINE_ASSIGNMENT;
     }
 
-    return blockPsi instanceof GrParameterList && mySettings.ALIGN_MULTILINE_PARAMETERS ||
-           blockPsi instanceof GrExtendsClause && mySettings.ALIGN_MULTILINE_EXTENDS_LIST ||
-           blockPsi instanceof GrThrowsClause && mySettings.ALIGN_MULTILINE_THROWS_LIST ||
-           blockPsi instanceof GrConditionalExpression && mySettings.ALIGN_MULTILINE_TERNARY_OPERATION ||
-           blockPsi instanceof GrListOrMap && myGroovySettings.ALIGN_MULTILINE_LIST_OR_MAP;
+    return blockPsi instanceof GrParameterList && myContext.getSettings().ALIGN_MULTILINE_PARAMETERS ||
+           blockPsi instanceof GrExtendsClause && myContext.getSettings().ALIGN_MULTILINE_EXTENDS_LIST ||
+           blockPsi instanceof GrThrowsClause && myContext.getSettings().ALIGN_MULTILINE_THROWS_LIST ||
+           blockPsi instanceof GrConditionalExpression && myContext.getSettings().ALIGN_MULTILINE_TERNARY_OPERATION ||
+           blockPsi instanceof GrListOrMap && myContext.getGroovySettings().ALIGN_MULTILINE_LIST_OR_MAP;
   }
 
   private static boolean isListLikeClause(PsiElement blockPsi) {
@@ -507,19 +506,19 @@
     final int start = myNode.getTextRange().getStartOffset();
     final int end = myNode.getTextRange().getEndOffset();
 
-    subBlocks.add(new GroovyBlock(myNode, Indent.getNoneIndent(), myWrap, mySettings, myGroovySettings, myAlignmentProvider) {
+    subBlocks.add(new GroovyBlock(myNode, Indent.getNoneIndent(), Wrap.createWrap(WrapType.NONE, false), myContext) {
       @NotNull
       public TextRange getTextRange() {
         return new TextRange(start, start + 3);
       }
     });
-    subBlocks.add(new GroovyBlock(myNode, Indent.getAbsoluteNoneIndent(), myWrap, mySettings, myGroovySettings, myAlignmentProvider) {
+    subBlocks.add(new GroovyBlock(myNode, Indent.getAbsoluteNoneIndent(), Wrap.createWrap(WrapType.NONE, false), myContext) {
       @NotNull
       public TextRange getTextRange() {
         return new TextRange(start + 3, end - 3);
       }
     });
-    subBlocks.add(new GroovyBlock(myNode, Indent.getAbsoluteNoneIndent(), myWrap, mySettings, myGroovySettings, myAlignmentProvider) {
+    subBlocks.add(new GroovyBlock(myNode, Indent.getAbsoluteNoneIndent(), Wrap.createWrap(WrapType.NONE, false), myContext) {
       @NotNull
       public TextRange getTextRange() {
         return new TextRange(end - 3, end);
@@ -533,7 +532,7 @@
    * @return true, if the current node can be myBlock node, else otherwise
    */
   private static boolean canBeCorrectBlock(final ASTNode node) {
-    return (node.getText().trim().length() > 0);
+    return node.getText().trim().length() > 0;
   }
 
 
@@ -571,7 +570,7 @@
   private List<Block> generateForBinaryExpr() {
     final ArrayList<Block> subBlocks = new ArrayList<Block>();
     AlignmentProvider.Aligner
-      alignment = mySettings.ALIGN_MULTILINE_BINARY_OPERATION ? myAlignmentProvider.createAligner(true) : null;
+      alignment = myContext.getSettings().ALIGN_MULTILINE_BINARY_OPERATION ? myAlignmentProvider.createAligner(false) : null;
 
     GrBinaryExpression binary = (GrBinaryExpression)myNode.getPsi();
     LOG.assertTrue(binary != null);
@@ -602,7 +601,7 @@
           if (op != psi && aligner != null) {
             aligner.append(psi);
           }
-          list.add(new GroovyBlock(childNode, indent, myWrap, mySettings, myGroovySettings, myAlignmentProvider));
+          list.add(new GroovyBlock(childNode, indent, getChildWrap(childNode), myContext));
         }
       }
       if (myExpr.getRightOperand() instanceof GrBinaryExpression) {
@@ -613,7 +612,11 @@
   }
 
 
-  private void addNestedChildren(final PsiElement elem, List<Block> list, @Nullable AlignmentProvider.Aligner aligner, final boolean topLevel) {
+  private void addNestedChildren(final PsiElement elem,
+                                 List<Block> list,
+                                 @Nullable AlignmentProvider.Aligner aligner,
+                                 final boolean topLevel,
+                                 Wrap wrap) {
     final List<ASTNode> children = visibleChildren(elem.getNode());
     if (elem instanceof GrMethodCallExpression) {
       GrExpression invokedExpression = ((GrMethodCallExpression)elem).getInvokedExpression();
@@ -624,11 +627,11 @@
           int i = 0;
           while (i < grandChildren.size() && nameElement != grandChildren.get(i).getPsi()) i++;
           if (i > 0) {
-            processNestedChildrenPrefix(list, aligner, false, grandChildren, i);
+            processNestedChildrenPrefix(list, aligner, false, grandChildren, i, wrap);
           }
           if (i < grandChildren.size()) {
             LOG.assertTrue(nameElement == grandChildren.get(i).getPsi());
-            list.add(new MethodCallWithoutQualifierBlock(nameElement, myWrap, mySettings, myGroovySettings, topLevel, children, elem, myAlignmentProvider));
+            list.add(new MethodCallWithoutQualifierBlock(nameElement, wrap, topLevel, children, elem, myContext));
           }
           return;
         }
@@ -636,7 +639,7 @@
     }
 
 
-    processNestedChildrenPrefix(list, aligner, topLevel, children, children.size());
+    processNestedChildrenPrefix(list, aligner, topLevel, children, children.size(), wrap);
   }
 
   private static boolean isAfterMultiLineClosure(ASTNode dot) {
@@ -654,20 +657,29 @@
     return false;
   }
 
-  private void processNestedChildrenPrefix(List<Block> list, @Nullable AlignmentProvider.Aligner aligner, boolean topLevel, List<ASTNode> children, int limit) {
+  private void processNestedChildrenPrefix(List<Block> list,
+                                           @Nullable AlignmentProvider.Aligner aligner,
+                                           boolean topLevel,
+                                           List<ASTNode> children,
+                                           int limit,
+                                           Wrap wrap) {
     ASTNode fst = children.get(0);
     LOG.assertTrue(limit > 0);
     if (NESTED.contains(fst.getElementType())) {
-      addNestedChildren(fst.getPsi(), list, aligner, false);
+      addNestedChildren(fst.getPsi(), list, aligner, false, wrap);
     }
     else {
       Indent indent = Indent.getContinuationWithoutFirstIndent();
-      list.add(new GroovyBlock(fst, indent, myWrap, mySettings, myGroovySettings, myAlignmentProvider));
+      list.add(new GroovyBlock(fst, indent, getChildWrap(fst), myContext));
     }
     addNestedChildrenSuffix(list, aligner, topLevel, children, limit);
   }
 
-  void addNestedChildrenSuffix(List<Block> list, @Nullable AlignmentProvider.Aligner aligner, boolean topLevel, List<ASTNode> children, int limit) {
+  void addNestedChildrenSuffix(List<Block> list,
+                               @Nullable AlignmentProvider.Aligner aligner,
+                               boolean topLevel,
+                               List<ASTNode> children,
+                               int limit) {
     for (int i = 1; i < limit; i++) {
       ASTNode childNode = children.get(i);
       if (canBeCorrectBlock(childNode)) {
@@ -682,7 +694,7 @@
           aligner.append(childNode.getPsi());
         }
 
-        list.add(new GroovyBlock(childNode, indent, myWrap, mySettings, myGroovySettings, myAlignmentProvider));
+        list.add(new GroovyBlock(childNode, indent, getChildWrap(childNode), myContext));
       }
     }
   }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyFormattingModelBuilder.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyFormattingModelBuilder.java
index 8e9492b..1492a28 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyFormattingModelBuilder.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyFormattingModelBuilder.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -70,7 +70,7 @@
         }
       });
     }
-    final GroovyBlock block = new GroovyBlock(astNode, Indent.getAbsoluteNoneIndent(), null, groovySettings, customSettings, alignments);
+    final GroovyBlock block = new GroovyBlock(astNode, Indent.getAbsoluteNoneIndent(), null, new FormattingContext(groovySettings, alignments, customSettings, false));
     return new GroovyFormattingModel(containingFile, block, FormattingDocumentModelImpl.createOn(containingFile));
   }
 
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/MethodCallWithoutQualifierBlock.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/MethodCallWithoutQualifierBlock.java
index 62e4fa1..1e3100d 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/MethodCallWithoutQualifierBlock.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/MethodCallWithoutQualifierBlock.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2011 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -18,12 +18,11 @@
 import com.intellij.formatting.Block;
 import com.intellij.formatting.Indent;
 import com.intellij.formatting.Wrap;
+import com.intellij.formatting.WrapType;
 import com.intellij.lang.ASTNode;
 import com.intellij.openapi.util.TextRange;
 import com.intellij.psi.PsiElement;
-import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
 import org.jetbrains.annotations.NotNull;
-import org.jetbrains.plugins.groovy.codeStyle.GroovyCodeStyleSettings;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -39,13 +38,10 @@
 
   public MethodCallWithoutQualifierBlock(PsiElement nameElement,
                                          Wrap wrap,
-                                         CommonCodeStyleSettings settings,
-                                         GroovyCodeStyleSettings groovySettings,
                                          boolean topLevel,
                                          List<ASTNode> children,
-                                         PsiElement elem,
-                                         AlignmentProvider alignmentProvider) {
-    super(nameElement.getNode(), Indent.getContinuationWithoutFirstIndent(), wrap, settings, groovySettings, alignmentProvider);
+                                         PsiElement elem, FormattingContext context) {
+    super(nameElement.getNode(), Indent.getContinuationWithoutFirstIndent(), wrap, context);
     myNameElement = nameElement;
     myTopLevel = topLevel;
     myChildren = children;
@@ -58,7 +54,7 @@
     if (mySubBlocks == null) {
       mySubBlocks = new ArrayList<Block>();
       final Indent indent = Indent.getContinuationWithoutFirstIndent();
-      mySubBlocks.add(new GroovyBlock(myNameElement.getNode(), indent, myWrap, mySettings, myGroovySettings, myAlignmentProvider));
+      mySubBlocks.add(new GroovyBlock(myNameElement.getNode(), indent, Wrap.createWrap(WrapType.NONE, false), myContext));
       new GroovyBlockGenerator(this).addNestedChildrenSuffix(mySubBlocks, null, myTopLevel, myChildren, myChildren.size());
     }
     return mySubBlocks;
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/processors/GroovyIndentProcessor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/processors/GroovyIndentProcessor.java
index 4217ddf..4d613ec 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/processors/GroovyIndentProcessor.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/processors/GroovyIndentProcessor.java
@@ -19,12 +19,10 @@
 import com.intellij.formatting.Indent;
 import com.intellij.lang.ASTNode;
 import com.intellij.psi.PsiElement;
-import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
 import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
 import com.intellij.psi.tree.IElementType;
 import com.intellij.psi.tree.TokenSet;
 import org.jetbrains.annotations.NotNull;
-import org.jetbrains.plugins.groovy.GroovyFileType;
 import org.jetbrains.plugins.groovy.formatter.ClosureBodyBlock;
 import org.jetbrains.plugins.groovy.formatter.GroovyBlock;
 import org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.GrDocComment;
@@ -52,6 +50,7 @@
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrParenthesizedExpression;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrExtendsClause;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrImplementsClause;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinitionBody;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMethod;
 
@@ -128,14 +127,14 @@
   @Override
   public void visitSwitchStatement(GrSwitchStatement switchStatement) {
     if (myChildType == CASE_SECTION) {
-      myResult = getSwitchCaseIndent(switchStatement);
+      myResult = getSwitchCaseIndent(getGroovySettings());
     }
   }
 
   @Override
   public void visitLabeledStatement(GrLabeledStatement labeledStatement) {
     if (myChildType == LABEL) {
-      CommonCodeStyleSettings.IndentOptions indentOptions = myBlock.getSettings().getIndentOptions();
+      CommonCodeStyleSettings.IndentOptions indentOptions = myBlock.getContext().getSettings().getIndentOptions();
       if (indentOptions != null && indentOptions.LABEL_INDENT_ABSOLUTE) {
         myResult = Indent.getAbsoluteLabelIndent();
       }
@@ -174,7 +173,7 @@
       myResult = Indent.getNormalIndent();
     }
     else if (myChild == ifStatement.getElseBranch()) {
-      if (getGroovySettings(ifStatement).SPECIAL_ELSE_IF_TREATMENT && myChildType == IF_STATEMENT) {
+      if (getGroovySettings().SPECIAL_ELSE_IF_TREATMENT && myChildType == IF_STATEMENT) {
         myResult = Indent.getNoneIndent();
       }
       else {
@@ -274,7 +273,14 @@
       myResult = Indent.getContinuationIndent();
     }
     else if (myChildType == THROW_CLAUSE) {
-      myResult = getGroovySettings(method).ALIGN_THROWS_KEYWORD ? Indent.getNoneIndent() : Indent.getContinuationIndent();
+      myResult = getGroovySettings().ALIGN_THROWS_KEYWORD ? Indent.getNoneIndent() : Indent.getContinuationIndent();
+    }
+  }
+
+  @Override
+  public void visitTypeDefinition(GrTypeDefinition typeDefinition) {
+    if (myChildType == EXTENDS_CLAUSE || myChildType == IMPLEMENTS_CLAUSE) {
+      myResult = Indent.getContinuationIndent();
     }
   }
 
@@ -329,8 +335,8 @@
     }
   }
 
-  private static CommonCodeStyleSettings getGroovySettings(PsiElement parent) {
-    return CodeStyleSettingsManager.getSettings(parent.getProject()).getCommonSettings(GroovyFileType.GROOVY_LANGUAGE);
+  private CommonCodeStyleSettings getGroovySettings() {
+    return myBlock.getContext().getSettings();
   }
 
   @Override
@@ -343,8 +349,8 @@
     }
   }
 
-  public static Indent getSwitchCaseIndent(PsiElement psiParent) {
-    if (getGroovySettings(psiParent).INDENT_CASE_FROM_SWITCH) {
+  public static Indent getSwitchCaseIndent(final CommonCodeStyleSettings settings) {
+    if (settings.INDENT_CASE_FROM_SWITCH) {
       return Indent.getNormalIndent();
     }
     else {
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/processors/GroovySpacingProcessor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/processors/GroovySpacingProcessor.java
index 8fb369f..27678a5 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/processors/GroovySpacingProcessor.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/processors/GroovySpacingProcessor.java
@@ -19,10 +19,7 @@
 import com.intellij.formatting.Spacing;
 import com.intellij.lang.ASTNode;
 import com.intellij.openapi.util.TextRange;
-import com.intellij.psi.PsiClass;
 import com.intellij.psi.PsiElement;
-import com.intellij.psi.PsiMethod;
-import com.intellij.psi.PsiParameter;
 import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
 import com.intellij.psi.formatter.FormatterUtil;
 import com.intellij.psi.impl.source.SourceTreeToPsiMap;
@@ -32,6 +29,7 @@
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
 import org.jetbrains.plugins.groovy.codeStyle.GroovyCodeStyleSettings;
+import org.jetbrains.plugins.groovy.formatter.FormattingContext;
 import org.jetbrains.plugins.groovy.formatter.GeeseUtil;
 import org.jetbrains.plugins.groovy.lang.groovydoc.psi.api.*;
 import org.jetbrains.plugins.groovy.lang.lexer.TokenSets;
@@ -39,7 +37,6 @@
 import org.jetbrains.plugins.groovy.lang.psi.GroovyFileBase;
 import org.jetbrains.plugins.groovy.lang.psi.GroovyPsiElement;
 import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrListOrMap;
-import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifierList;
 import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotation;
 import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotationArgumentList;
 import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotationArrayInitializer;
@@ -102,6 +99,8 @@
  */
 public class GroovySpacingProcessor extends GroovyElementVisitor {
   private PsiElement myParent;
+
+  private final GroovyCodeStyleSettings myGroovySettings;
   private final CommonCodeStyleSettings mySettings;
 
   private Spacing myResult;
@@ -109,11 +108,10 @@
   private ASTNode myChild2;
   private IElementType myType1;
   private IElementType myType2;
-  private GroovyCodeStyleSettings myGroovySettings;
 
-  public GroovySpacingProcessor(ASTNode node, CommonCodeStyleSettings settings, GroovyCodeStyleSettings groovySettings) {
-    mySettings = settings;
-    myGroovySettings = groovySettings;
+  public GroovySpacingProcessor(ASTNode node, FormattingContext context) {
+    mySettings = context.getSettings();
+    myGroovySettings = context.getGroovySettings();
 
     if (init(node)) return;
     if (manageComments()) return;
@@ -466,7 +464,7 @@
       }
     }
     else if (myType2 == TYPE_PARAMETER_LIST) {
-      manageSpaceBeforeTypeParameters();
+      createSpaceInCode(false);
     }
     else if (myType2 == ARGUMENTS) {
       manageSpaceBeforeCallLParenth();
@@ -582,11 +580,8 @@
                               new TextRange(dependencyStart, myChild1.getTextRange().getEndOffset()),
                               mySettings.KEEP_SIMPLE_METHODS_IN_ONE_LINE);
     }
-    else if (myType1 == MODIFIERS) {
-      processModifierList(myChild1);
-    }
     else if (myType2 == TYPE_PARAMETER_LIST) {
-      manageSpaceBeforeTypeParameters();
+      createSpaceInCode(true);
     }
     else {
       processParentheses(mLPAREN,
@@ -636,22 +631,6 @@
   }
 
 
-  private void manageSpaceBeforeTypeParameters() {
-    createSpaceInCode(false);
-  }
-
-  @Override
-  public void visitModifierList(GrModifierList modifierList) {
-    int annotationWrap = getAnnotationWrap(myParent.getParent());
-    if (myChild1.getElementType() == ANNOTATION && annotationWrap == CommonCodeStyleSettings.WRAP_ALWAYS) {
-      createLF(true);
-    }
-    else {
-      createSpaceProperty(true, false, 0);
-    }
-
-  }
-
   @Override
   public void visitAnnotationMethod(GrAnnotationMethod annotationMethod) {
     if (myType2 == mLPAREN) {
@@ -967,39 +946,6 @@
     }
   }
 
-
-  private void processModifierList(ASTNode modifierList) {
-    int annotationWrap = getAnnotationWrap(myParent);
-    if (modifierList.getLastChildNode().getElementType() == ANNOTATION && annotationWrap == CommonCodeStyleSettings.WRAP_ALWAYS ||
-        mySettings.MODIFIER_LIST_WRAP) {
-      createLF(true);
-    }
-    else {
-      createSpaceProperty(true, false, 0);
-    }
-  }
-
-  private int getAnnotationWrap(final PsiElement parent) {
-    if (parent instanceof PsiMethod) {
-      return mySettings.METHOD_ANNOTATION_WRAP;
-    }
-    else if (parent instanceof PsiClass) {
-      return mySettings.CLASS_ANNOTATION_WRAP;
-    }
-    else if (parent instanceof GrVariableDeclaration && parent.getParent() instanceof GrTypeDefinitionBody) {
-      return mySettings.FIELD_ANNOTATION_WRAP;
-    }
-    else if (parent instanceof GrVariableDeclaration) {
-      return mySettings.VARIABLE_ANNOTATION_WRAP;
-    }
-    else if (parent instanceof PsiParameter) {
-      return mySettings.PARAMETER_ANNOTATION_WRAP;
-    }
-    else {
-      return CommonCodeStyleSettings.DO_NOT_WRAP;
-    }
-  }
-
   public Spacing getSpacing() {
     return myResult;
   }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/processors/GroovySpacingProcessorBasic.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/processors/GroovySpacingProcessorBasic.java
index c7928d3..de51dfa 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/processors/GroovySpacingProcessorBasic.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/processors/GroovySpacingProcessorBasic.java
@@ -27,6 +27,7 @@
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.plugins.groovy.codeStyle.GroovyCodeStyleSettings;
 import org.jetbrains.plugins.groovy.formatter.ClosureBodyBlock;
+import org.jetbrains.plugins.groovy.formatter.FormattingContext;
 import org.jetbrains.plugins.groovy.formatter.GroovyBlock;
 import org.jetbrains.plugins.groovy.formatter.MethodCallWithoutQualifierBlock;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.GrStatement;
@@ -60,8 +61,7 @@
 
   public static Spacing getSpacing(GroovyBlock child1,
                                    GroovyBlock child2,
-                                   CommonCodeStyleSettings settings,
-                                   GroovyCodeStyleSettings groovySettings) {
+                                   FormattingContext context) {
 
     ASTNode leftNode = child1.getNode();
     ASTNode rightNode = child2.getNode();
@@ -71,6 +71,9 @@
     IElementType leftType = leftNode.getElementType();
     IElementType rightType = rightNode.getElementType();
 
+    final CommonCodeStyleSettings settings = context.getSettings();
+    final GroovyCodeStyleSettings groovySettings = context.getGroovySettings();
+
     if (!(mirrorsAst(child1) && mirrorsAst(child2))) {
       return NO_SPACING;
     }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/processors/GroovyWrappingProcessor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/processors/GroovyWrappingProcessor.java
new file mode 100644
index 0000000..6c640dc
--- /dev/null
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/processors/GroovyWrappingProcessor.java
@@ -0,0 +1,287 @@
+/*
+ * Copyright 2000-2013 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.groovy.formatter.processors;
+
+import com.intellij.formatting.Wrap;
+import com.intellij.formatting.WrapType;
+import com.intellij.lang.ASTNode;
+import com.intellij.openapi.util.text.StringUtil;
+import com.intellij.psi.PsiElement;
+import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
+import com.intellij.psi.tree.IElementType;
+import com.intellij.psi.tree.TokenSet;
+import org.jetbrains.annotations.Nullable;
+import org.jetbrains.plugins.groovy.formatter.FormattingContext;
+import org.jetbrains.plugins.groovy.formatter.GroovyBlock;
+import org.jetbrains.plugins.groovy.lang.lexer.TokenSets;
+import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.GrModifierList;
+import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.modifiers.annotation.GrAnnotation;
+
+import static org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes.*;
+
+/**
+ * @author Max Medvedev
+ */
+public class GroovyWrappingProcessor {
+  private final ASTNode myNode;
+  private final CommonCodeStyleSettings mySettings;
+  private final IElementType myParentType;
+  private final Wrap myCommonWrap;
+  private final FormattingContext myContext;
+  private boolean myUsedDefaultWrap = false;
+
+  public GroovyWrappingProcessor(GroovyBlock block) {
+    myContext = block.getContext();
+    mySettings = myContext.getSettings();
+    myNode = block.getNode();
+    myParentType = myNode.getElementType();
+
+    myCommonWrap = createCommonWrap();
+  }
+  
+  private static final TokenSet SKIP = TokenSet.create(
+    mCOMMA, mQUESTION, mSEMI,
+
+    mASSIGN, mBAND_ASSIGN, mBOR_ASSIGN, mBSR_ASSIGN, mBXOR_ASSIGN, mDIV_ASSIGN,
+    mMINUS_ASSIGN, mMOD_ASSIGN, mPLUS_ASSIGN, mSL_ASSIGN, mSR_ASSIGN,
+    mSTAR_ASSIGN, mSTAR_STAR_ASSIGN,
+
+    mASSIGN, mBAND_ASSIGN, mBOR_ASSIGN, mBSR_ASSIGN, mBXOR_ASSIGN, mDIV_ASSIGN,
+    mMINUS_ASSIGN, mMOD_ASSIGN, mPLUS_ASSIGN, mSL_ASSIGN, mSR_ASSIGN,
+    mSTAR_ASSIGN, mSTAR_STAR_ASSIGN,
+
+    mBAND, mBOR, mBXOR, mDIV, mEQUAL, mGE, mGT, mLOR, mLT, mLE, mMINUS, kAS, kIN,
+    mMOD, mPLUS, mSTAR, mSTAR_STAR, mNOT_EQUAL, mCOMPARE_TO, mLAND, kINSTANCEOF,
+    COMPOSITE_LSHIFT_SIGN, COMPOSITE_RSHIFT_SIGN, COMPOSITE_TRIPLE_SHIFT_SIGN,
+    mREGEX_FIND, mREGEX_MATCH, mRANGE_INCLUSIVE, mRANGE_EXCLUSIVE,
+
+    mBNOT, mLNOT, mMINUS, mDEC, mPLUS, mINC,
+
+    mSPREAD_DOT, mOPTIONAL_DOT, mMEMBER_POINTER, mDOT,
+
+    COMPOSITE_LSHIFT_SIGN, COMPOSITE_RSHIFT_SIGN, COMPOSITE_TRIPLE_SHIFT_SIGN,
+
+    mLT, mGT, mLE, mGE, kIN,
+
+    kIN, mCOLON,
+
+    mGSTRING_CONTENT, mGSTRING_END, GSTRING_INJECTION, mREGEX_CONTENT, mREGEX_END, mDOLLAR_SLASH_REGEX_CONTENT, mDOLLAR_SLASH_REGEX_END
+  );
+
+  public Wrap getChildWrap(ASTNode childNode) {
+    if (myContext.isInsidePlainGString()) return createNoneWrap();
+
+    final IElementType childType = childNode.getElementType();
+
+    if (SKIP.contains(childType)) {
+      return createNoneWrap();
+    }
+
+    if (myParentType == EXTENDS_CLAUSE || myParentType == IMPLEMENTS_CLAUSE) {
+      if (childType == kEXTENDS || childType == kIMPLEMENTS) {
+        return Wrap.createWrap(mySettings.EXTENDS_KEYWORD_WRAP, true);
+      }
+    }
+
+    if (myParentType == ARGUMENTS) {
+      if (childType == mLPAREN  || childType == mRPAREN) {
+        return createNoneWrap();
+      }
+    }
+
+    if (myParentType == THROW_CLAUSE && childType == kTHROWS) {
+      return Wrap.createWrap(mySettings.THROWS_KEYWORD_WRAP, true);
+    }
+
+    if (myParentType == MODIFIERS) {
+      if (getLeftSiblingType(childNode) == ANNOTATION) {
+        return getCommonWrap();
+      }
+      else {
+        return createNormalWrap();
+      }
+    }
+
+    if (ANNOTATION_CONTAINERS.contains(myParentType)) {
+      final ASTNode leftSibling = getLeftSibling(childNode);
+      if (leftSibling != null && leftSibling.getElementType() == MODIFIERS && endsWithAnnotation(leftSibling)) {
+        final int wrapType = getAnnotationsWrapType(childNode);
+        if (wrapType != -1) {
+          return Wrap.createWrap(wrapType, true);
+        }
+      }
+    }
+
+    return getCommonWrap();
+  }
+
+  @Nullable
+  private static IElementType getLeftSiblingType(ASTNode node) {
+    ASTNode prev = getLeftSibling(node);
+    return prev != null ? prev.getElementType() : null;
+  }
+
+  private static ASTNode getLeftSibling(ASTNode node) {
+    ASTNode prev = node.getTreePrev();
+    while (prev != null && StringUtil.isEmptyOrSpaces(prev.getText())) {
+      prev = prev.getTreePrev();
+    }
+    return prev;
+  }
+
+  private static boolean endsWithAnnotation(ASTNode modifierListNode) {
+    final PsiElement psi = modifierListNode.getPsi();
+    return psi instanceof GrModifierList && psi.getLastChild() instanceof GrAnnotation;
+  }
+
+  private Wrap getCommonWrap() {
+    if (myCommonWrap == null) {
+      return createNoneWrap();
+      //return null;
+    }
+
+    if (myUsedDefaultWrap) {
+      return myCommonWrap;
+    }
+    else {
+      myUsedDefaultWrap = true;
+      return createNoneWrap();
+      //return null;
+    }
+  }
+
+  private static Wrap createNormalWrap() {
+    return Wrap.createWrap(WrapType.NORMAL, true);
+  }
+
+  private static Wrap createNoneWrap() {
+    return Wrap.createWrap(WrapType.NONE, false);
+  }
+
+  @Nullable
+  private Wrap createCommonWrap() {
+    if (myParentType == EXTENDS_CLAUSE || myParentType == IMPLEMENTS_CLAUSE) {
+      myUsedDefaultWrap = true;
+      return Wrap.createWrap(mySettings.EXTENDS_LIST_WRAP, true);
+    }
+
+
+    if (myParentType == THROW_CLAUSE) {
+      myUsedDefaultWrap = true;
+      return Wrap.createWrap(mySettings.THROWS_LIST_WRAP, true);
+    }
+
+
+    if (myParentType == PARAMETERS_LIST) {
+      myUsedDefaultWrap = true;
+      return Wrap.createWrap(mySettings.METHOD_PARAMETERS_WRAP, true);
+    }
+
+
+    if (myParentType == ARGUMENTS || myParentType == COMMAND_ARGUMENTS) {
+      myUsedDefaultWrap = myParentType == ARGUMENTS;
+      return Wrap.createWrap(mySettings.CALL_PARAMETERS_WRAP, myUsedDefaultWrap);
+    }
+
+
+    if (myParentType == FOR_TRADITIONAL_CLAUSE || myParentType == FOR_IN_CLAUSE) {
+      myUsedDefaultWrap = true;
+      return Wrap.createWrap(mySettings.FOR_STATEMENT_WRAP, true);
+    }
+
+
+    if (TokenSets.BINARY_EXPRESSIONS.contains(myParentType)) {
+      return Wrap.createWrap(mySettings.BINARY_OPERATION_WRAP, false);
+    }
+
+
+    if (myParentType == ASSIGNMENT_EXPRESSION) {
+      return Wrap.createWrap(mySettings.ASSIGNMENT_WRAP, false);
+    }
+
+
+    if (myParentType == CONDITIONAL_EXPRESSION || myParentType == ELVIS_EXPRESSION) {
+      return Wrap.createWrap(mySettings.TERNARY_OPERATION_WRAP, false);
+    }
+
+    if (myParentType == ASSERT_STATEMENT) {
+      return Wrap.createWrap(mySettings.ASSERT_STATEMENT_WRAP, false);
+    }
+
+    if (TokenSets.BLOCK_SET.contains(myParentType)) {
+      return createNormalWrap();
+    }
+
+    if (myParentType == MODIFIERS) {
+      final int wrapType = getAnnotationsWrapType(myNode);
+      if (wrapType != -1) {
+        myUsedDefaultWrap = true;
+        return Wrap.createWrap(wrapType, true);
+      }
+    }
+
+    return null;
+  }
+
+  public Wrap getChainedMethodCallWrap() {
+    return Wrap.createWrap(mySettings.METHOD_CALL_CHAIN_WRAP, false);
+  }
+
+  private TokenSet ANNOTATION_CONTAINERS = TokenSet.create(
+    CLASS_DEFINITION, INTERFACE_DEFINITION, ENUM_DEFINITION, ANNOTATION_DEFINITION,
+    METHOD_DEFINITION, CONSTRUCTOR_DEFINITION,
+    VARIABLE_DEFINITION,
+    PARAMETER,
+    ENUM_CONSTANT,
+    IMPORT_STATEMENT
+  );
+
+  private int getAnnotationsWrapType(ASTNode modifierList) {
+    final IElementType containerType = modifierList.getTreeParent().getElementType();
+    if (TYPE_DEFINITION_TYPES.contains(containerType)) {
+      return mySettings.CLASS_ANNOTATION_WRAP;
+    }
+
+    if (METHOD_DEFS.contains(containerType)) {
+      return mySettings.METHOD_ANNOTATION_WRAP;
+    }
+
+    if (VARIABLE_DEFINITION == containerType) {
+      final IElementType pparentType = modifierList.getTreeParent().getTreeParent().getElementType();
+      if (pparentType == CLASS_BODY || pparentType == ENUM_BODY) {
+        return mySettings.FIELD_ANNOTATION_WRAP;
+      }
+      else {
+        return mySettings.VARIABLE_ANNOTATION_WRAP;
+      }
+    }
+
+    if (PARAMETER == containerType) {
+      return mySettings.PARAMETER_ANNOTATION_WRAP;
+    }
+
+    if (ENUM_CONSTANT == containerType) {
+      return mySettings.ENUM_CONSTANTS_WRAP;
+    }
+
+    if (IMPORT_STATEMENT == containerType) {
+      return myContext.getGroovySettings().IMPORT_ANNOTATION_WRAP;
+    }
+
+    return -1;
+  }
+
+}
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/lexer/TokenSets.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/lexer/TokenSets.java
index bdcd1f1..f2dcba8 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/lexer/TokenSets.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/lexer/TokenSets.java
@@ -165,6 +165,12 @@
                                                                COMPOSITE_LSHIFT_SIGN, COMPOSITE_RSHIFT_SIGN, COMPOSITE_TRIPLE_SHIFT_SIGN,
                                                                mREGEX_FIND, mREGEX_MATCH, mRANGE_INCLUSIVE, mRANGE_EXCLUSIVE);
 
+  public static final TokenSet BINARY_EXPRESSIONS = TokenSet.create(ADDITIVE_EXPRESSION, MULTIPLICATIVE_EXPRESSION, POWER_EXPRESSION,
+                                                                    POWER_EXPRESSION_SIMPLE, LOGICAL_OR_EXPRESSION, LOGICAL_AND_EXPRESSION,
+                                                                    INCLUSIVE_OR_EXPRESSION, EXCLUSIVE_OR_EXPRESSION, AND_EXPRESSION,
+                                                                    REGEX_FIND_EXPRESSION, REGEX_MATCH_EXPRESSION, EQUALITY_EXPRESSION,
+                                                                    RELATIONAL_EXPRESSION, SHIFT_EXPRESSION, RANGE_EXPRESSION);
+
   public static final TokenSet DOTS = TokenSet.create(mSPREAD_DOT, mOPTIONAL_DOT, mMEMBER_POINTER, mDOT);
 
   public static final TokenSet WHITE_SPACES_OR_COMMENTS = TokenSet.orSet(WHITE_SPACES_SET, COMMENT_SET);
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/arithmetic/MultiplicativeExpression.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/arithmetic/MultiplicativeExpression.java
index c2b25d3..5dbd53f 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/arithmetic/MultiplicativeExpression.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/arithmetic/MultiplicativeExpression.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -21,8 +21,8 @@
 import org.jetbrains.plugins.groovy.GroovyBundle;
 import org.jetbrains.plugins.groovy.lang.parser.GroovyElementTypes;
 import org.jetbrains.plugins.groovy.lang.parser.GroovyParser;
-import org.jetbrains.plugins.groovy.lang.parser.parsing.util.ParserUtils;
 import org.jetbrains.plugins.groovy.lang.parser.parsing.statements.expressions.BinaryExpression;
+import org.jetbrains.plugins.groovy.lang.parser.parsing.util.ParserUtils;
 
 /**
  * @author ilyas
@@ -47,31 +47,24 @@
   public static boolean parse(PsiBuilder builder, GroovyParser parser) {
 
     PsiBuilder.Marker marker = builder.mark();
-    if ((PREFIXES.contains(builder.getTokenType())) ? BinaryExpression.POWER.parseBinary(builder, parser) : PowerExpressionNotPlusMinus.parse(builder, parser)) {
+    if ((PREFIXES.contains(builder.getTokenType()))
+        ? BinaryExpression.POWER.parseBinary(builder, parser)
+        : PowerExpressionNotPlusMinus.parse(builder, parser)) {
       if (ParserUtils.getToken(builder, MULT_DIV)) {
-        ParserUtils.getToken(builder, mNLS);
-        if (!BinaryExpression.POWER.parseBinary(builder, parser)) {
-          builder.error(GroovyBundle.message("expression.expected"));
-        }
-        PsiBuilder.Marker newMarker = marker.precede();
-        marker.done(MULTIPLICATIVE_EXPRESSION);
-        if (MULT_DIV.contains(builder.getTokenType())) {
-          subParse(builder, newMarker, parser);
-        } else {
-          newMarker.drop();
-        }
-      } else {
+        subParse(builder, parser, marker);
+      }
+      else {
         marker.drop();
       }
       return true;
-    } else {
+    }
+    else {
       marker.drop();
       return false;
     }
   }
 
-  private static void subParse(PsiBuilder builder, PsiBuilder.Marker marker, GroovyParser parser) {
-    ParserUtils.getToken(builder, MULT_DIV);
+  private static void subParse(PsiBuilder builder, GroovyParser parser, PsiBuilder.Marker marker) {
     ParserUtils.getToken(builder, mNLS);
     if (!BinaryExpression.POWER.parseBinary(builder, parser)) {
       builder.error(GroovyBundle.message("expression.expected"));
@@ -79,10 +72,11 @@
     PsiBuilder.Marker newMarker = marker.precede();
     marker.done(MULTIPLICATIVE_EXPRESSION);
     if (MULT_DIV.contains(builder.getTokenType())) {
-      subParse(builder, newMarker, parser);
-    } else {
+      ParserUtils.getToken(builder, MULT_DIV);
+      subParse(builder, parser, newMarker);
+    }
+    else {
       newMarker.drop();
     }
   }
-
 }
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/arithmetic/PowerExpressionNotPlusMinus.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/arithmetic/PowerExpressionNotPlusMinus.java
index 98a4a69..29fc5e4 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/arithmetic/PowerExpressionNotPlusMinus.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/parser/parsing/statements/expressions/arithmetic/PowerExpressionNotPlusMinus.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -32,43 +32,29 @@
     PsiBuilder.Marker marker = builder.mark();
 
     if (UnaryExpressionNotPlusMinus.parse(builder, parser)) {
-      if (ParserUtils.getToken(builder, mSTAR_STAR)) {
-        ParserUtils.getToken(builder, mNLS);
-        if (!UnaryExpression.parse(builder, parser)) {
-          builder.error(GroovyBundle.message("expression.expected"));
-        }
-        PsiBuilder.Marker newMarker = marker.precede();
-        marker.done(POWER_EXPRESSION_SIMPLE);
-        if (mSTAR_STAR.equals(builder.getTokenType())) {
-          subParse(builder, newMarker, parser);
-        } else {
-          newMarker.drop();
-        }
-      } else {
-        marker.drop();
-      }
+      subParse(builder, parser, marker);
       return true;
-    } else {
+    }
+    else {
       marker.drop();
       return false;
     }
   }
 
-  private static void subParse(PsiBuilder builder, PsiBuilder.Marker marker, GroovyParser parser) {
-    ParserUtils.getToken(builder, mSTAR_STAR);
+  private static void subParse(PsiBuilder builder, GroovyParser parser, PsiBuilder.Marker marker) {
+    if (!ParserUtils.getToken(builder, mSTAR_STAR)) {
+      marker.drop();
+      return;
+    }
+
     ParserUtils.getToken(builder, mNLS);
     if (!UnaryExpression.parse(builder, parser)) {
       builder.error(GroovyBundle.message("expression.expected"));
     }
+
     PsiBuilder.Marker newMarker = marker.precede();
     marker.done(POWER_EXPRESSION_SIMPLE);
-    if (mSTAR_STAR.equals(builder.getTokenType())) {
-      subParse(builder, newMarker, parser);
-    } else {
-      newMarker.drop();
-    }
+    subParse(builder, parser, newMarker);
   }
-
-
 }
 
diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/GrTypeDefinitionBodyBase.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/GrTypeDefinitionBodyBase.java
index 8f25096..400be53 100644
--- a/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/GrTypeDefinitionBodyBase.java
+++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/lang/psi/impl/statements/typedef/GrTypeDefinitionBodyBase.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -29,6 +29,7 @@
 import org.jetbrains.plugins.groovy.lang.psi.GroovyElementVisitor;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.*;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrEnumDefinitionBody;
+import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinition;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrTypeDefinitionBody;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrEnumConstantList;
 import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMembersDeclaration;
@@ -191,4 +192,21 @@
       visitor.visitEnumDefinitionBody(this);
     }
   }
+
+  @Override
+  public ASTNode addInternal(ASTNode first, ASTNode last, ASTNode anchor, Boolean before) {
+    ASTNode afterLast = last.getTreeNext();
+    ASTNode next;
+    for (ASTNode child = first; child != afterLast; child = next) {
+      next = child.getTreeNext();
+      if (child.getElementType() == GroovyElementTypes.CONSTRUCTOR_DEFINITION) {
+        ASTNode oldIdentifier = child.findChildByType(GroovyTokenTypes.mIDENT);
+        ASTNode newIdentifier = ((GrTypeDefinition)getParent()).getNameIdentifierGroovy().getNode().copyElement();
+        child.replaceChild(oldIdentifier, newIdentifier);
+      }
+    }
+
+
+    return super.addInternal(first, last, anchor, before);
+  }
 }
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/formatter/FormatterTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/formatter/FormatterTest.groovy
index c398fba..114b076 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/formatter/FormatterTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/formatter/FormatterTest.groovy
@@ -30,14 +30,6 @@
 
   final String basePath = TestUtils.testDataPath + "groovy/formatter/"
 
-  @Override
-  protected void setUp() throws Exception {
-    super.setUp();
-    groovySettings.CLASS_BRACE_STYLE = CommonCodeStyleSettings.END_OF_LINE;
-    groovySettings.METHOD_BRACE_STYLE = CommonCodeStyleSettings.END_OF_LINE;
-    groovySettings.BRACE_STYLE = CommonCodeStyleSettings.END_OF_LINE;
-  }
-
   public void testAddign1() throws Throwable { doTest(); }
   public void testArg1() throws Throwable { doTest(); }
   public void testArg2() throws Throwable { doTest(); }
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/formatter/GroovyFormatterTestCase.java b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/formatter/GroovyFormatterTestCase.groovy
similarity index 63%
rename from plugins/groovy/test/org/jetbrains/plugins/groovy/lang/formatter/GroovyFormatterTestCase.java
rename to plugins/groovy/test/org/jetbrains/plugins/groovy/lang/formatter/GroovyFormatterTestCase.groovy
index 0fa20a6..dbd33b8 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/formatter/GroovyFormatterTestCase.java
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/formatter/GroovyFormatterTestCase.groovy
@@ -1,35 +1,33 @@
 /*
- * Copyright 2000-2009 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
- *  You may obtain a copy of the License at
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
  *
- *  http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
  *
- *  Unless required by applicable law or agreed to in writing, software
- *  distributed under the License is distributed on an "AS IS" BASIS,
- *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *  See the License for the specific language governing permissions and
- *  limitations under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
-package org.jetbrains.plugins.groovy.lang.formatter;
+package org.jetbrains.plugins.groovy.lang.formatter
 
-import com.intellij.openapi.application.ApplicationManager;
-import com.intellij.openapi.command.CommandProcessor;
-import com.intellij.openapi.diagnostic.Logger;
-import com.intellij.openapi.project.Project;
-import com.intellij.openapi.util.TextRange;
-import com.intellij.psi.PsiFile;
-import com.intellij.psi.codeStyle.CodeStyleManager;
-import com.intellij.psi.codeStyle.CodeStyleSettings;
-import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
-import com.intellij.psi.codeStyle.CommonCodeStyleSettings;
-import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
-import com.intellij.util.IncorrectOperationException;
-import junit.framework.Assert;
-import org.jetbrains.plugins.groovy.GroovyFileType;
-
+import com.intellij.openapi.application.ApplicationManager
+import com.intellij.openapi.command.CommandProcessor
+import com.intellij.openapi.diagnostic.Logger
+import com.intellij.openapi.project.Project
+import com.intellij.openapi.util.TextRange
+import com.intellij.psi.PsiFile
+import com.intellij.psi.codeStyle.CodeStyleManager
+import com.intellij.psi.codeStyle.CodeStyleSettings
+import com.intellij.psi.codeStyle.CodeStyleSettingsManager
+import com.intellij.psi.codeStyle.CommonCodeStyleSettings
+import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase
+import com.intellij.util.IncorrectOperationException
+import org.jetbrains.plugins.groovy.GroovyFileType
 /**
  * @author peter
  */
@@ -41,6 +39,10 @@
   protected void setUp() throws Exception {
     super.setUp();
     setSettings(getProject());
+
+    groovySettings.CLASS_BRACE_STYLE = CommonCodeStyleSettings.END_OF_LINE;
+    groovySettings.METHOD_BRACE_STYLE = CommonCodeStyleSettings.END_OF_LINE;
+    groovySettings.BRACE_STYLE = CommonCodeStyleSettings.END_OF_LINE;
   }
 
   @Override
@@ -54,12 +56,12 @@
   }
 
   protected void setSettings(Project project) {
-    Assert.assertNull(myTempSettings);
+    assertNull(myTempSettings);
     CodeStyleSettings settings = CodeStyleSettingsManager.getSettings(project);
     myTempSettings = settings.clone();
 
     CommonCodeStyleSettings.IndentOptions gr = myTempSettings.getIndentOptions(GroovyFileType.GROOVY_FILE_TYPE);
-    Assert.assertNotSame(gr, settings.OTHER_INDENT_OPTIONS);
+    assertNotSame(gr, settings.OTHER_INDENT_OPTIONS);
     gr.INDENT_SIZE = 2;
     gr.CONTINUATION_INDENT_SIZE = 4;
     gr.TAB_SIZE = 2;
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/formatter/WrappingTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/formatter/WrappingTest.groovy
new file mode 100644
index 0000000..79d79ed
--- /dev/null
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/formatter/WrappingTest.groovy
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2000-2013 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.jetbrains.plugins.groovy.lang.formatter
+
+import com.intellij.psi.codeStyle.CommonCodeStyleSettings
+
+/**
+ * @author Max Medvedev
+ */
+class WrappingTest extends GroovyFormatterTestCase {
+  @Override
+  protected void setUp() throws Exception {
+    super.setUp()
+    myTempSettings.RIGHT_MARGIN = 10
+  }
+
+  void testWrapChainedMethodCalls() {
+    groovySettings.METHOD_CALL_CHAIN_WRAP = CommonCodeStyleSettings.WRAP_ALWAYS
+
+    checkFormatting('''\
+foo().barbar().abcd()
+''', '''\
+foo().
+    barbar().
+    abcd()
+''')
+  }
+
+  void testWrappingInsideGString0() {
+    checkFormatting('''\
+"abcdefghij${a+b}"
+''', '''\
+"abcdefghij${a + b}"
+''')
+  }
+
+  void testWrappingInsideGString1() {
+    checkFormatting('''\
+"""abcdefghij${a+b}"""
+''', '''\
+"""abcdefghij${
+  a + b
+}"""
+''')
+  }
+
+  void testWrapArgumentList() {
+    groovySettings.CALL_PARAMETERS_WRAP = CommonCodeStyleSettings.WRAP_AS_NEEDED
+    checkFormatting('''\
+printxxxxxx(2)
+''', '''\
+printxxxxxx(
+    2)
+''')
+  }
+}
diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/optimizeImports/OptimizeImportsTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/optimizeImports/OptimizeImportsTest.groovy
index e38546f..1abac51 100644
--- a/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/optimizeImports/OptimizeImportsTest.groovy
+++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/refactoring/optimizeImports/OptimizeImportsTest.groovy
@@ -352,7 +352,8 @@
     doOptimizeImports()
 
     myFixture.checkResult('''\
-@Grab(group = 'org.codehaus.gpars', module = 'gpars', version = '0.12') @Grab(group = 'org.codehaus.gpars', module = 'gpars', version = '0.12')
+@Grab(group = 'org.codehaus.gpars', module = 'gpars', version = '0.12')
+@Grab(group = 'org.codehaus.gpars', module = 'gpars', version = '0.12')
 import groovyx.gpars.GParsExecutorsPool
 
 GParsExecutorsPool oi
diff --git a/plugins/groovy/testdata/groovy/formatter/fieldInColumnsAlignment.test b/plugins/groovy/testdata/groovy/formatter/fieldInColumnsAlignment.test
index 4867a3b..18ec66a 100644
--- a/plugins/groovy/testdata/groovy/formatter/fieldInColumnsAlignment.test
+++ b/plugins/groovy/testdata/groovy/formatter/fieldInColumnsAlignment.test
@@ -11,10 +11,8 @@
     char ccc3 = 'a'
     double ddd31, ddd32 = 1
 
-    private
-    final String s4 = ""
-    private
-    transient int i4 = 1
+    private final String s4 = ""
+    private transient int i4 = 1
     def o4
 
     private final String s5 = "xxx"
diff --git a/plugins/groovy/testdata/intentions/convertGStringToString/ComplicatedCase_after.groovy b/plugins/groovy/testdata/intentions/convertGStringToString/ComplicatedCase_after.groovy
index 9bda986..e824dc0 100644
--- a/plugins/groovy/testdata/intentions/convertGStringToString/ComplicatedCase_after.groovy
+++ b/plugins/groovy/testdata/intentions/convertGStringToString/ComplicatedCase_after.groovy
@@ -1,4 +1,6 @@
 def x=5;
 def y=7;
 def name="abc"
-print String.valueOf(x++ + ++y) + ' is very "strange" \'expression\'. x=' + String.valueOf(x) + String.valueOf(y) + '=y; ' + name + '   ' + String.valueOf(name.collect { true }) + ' \n wow\\'
\ No newline at end of file
+print String.valueOf(x++ + ++y) + ' is very "strange" \'expression\'. x=' + String.valueOf(x) + String.valueOf(y) + '=y; ' + name + '   ' + String.valueOf(name.collect {
+    true
+}) + ' \n wow\\'
\ No newline at end of file
diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/HgRepositoryWatcher.java b/plugins/hg4idea/src/org/zmlx/hg4idea/HgRepositoryWatcher.java
index 85fa83f..37ee98d 100644
--- a/plugins/hg4idea/src/org/zmlx/hg4idea/HgRepositoryWatcher.java
+++ b/plugins/hg4idea/src/org/zmlx/hg4idea/HgRepositoryWatcher.java
@@ -1,5 +1,5 @@
 /*
- * Copyright 2000-2012 JetBrains s.r.o.
+ * Copyright 2000-2013 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.
@@ -65,9 +65,7 @@
 
   @Override
   public void disposeComponent() {
-    for (LocalFileSystem.WatchRequest request : myWatchRequests) {
-      LocalFileSystem.getInstance().removeWatchedRoot(request);
-    }
+    LocalFileSystem.getInstance().removeWatchedRoots(myWatchRequests);
     myWatchRequests.clear();
     myRoots.clear();
   }
diff --git a/plugins/java-i18n/java-i18n.iml b/plugins/java-i18n/java-i18n.iml
index 0739eaa..eed7b0a 100644
--- a/plugins/java-i18n/java-i18n.iml
+++ b/plugins/java-i18n/java-i18n.iml
@@ -15,7 +15,7 @@
     <orderEntry type="module" module-name="lang-impl" />
     <orderEntry type="module" module-name="xml" />
     <orderEntry type="module" module-name="spellchecker" />
-    <orderEntry type="module" module-name="java-impl" />
+    <orderEntry type="module" module-name="java-impl" exported="" />
     <orderEntry type="module" module-name="jsp-base-openapi" />
     <orderEntry type="module" module-name="jsp-openapi" />
     <orderEntry type="module" module-name="testFramework-java" scope="TEST" />
diff --git a/plugins/java-i18n/src/com/intellij/codeInspection/i18n/I18nInspection.java b/plugins/java-i18n/src/com/intellij/codeInspection/i18n/I18nInspection.java
index 45da972..a779c9a 100644
--- a/plugins/java-i18n/src/com/intellij/codeInspection/i18n/I18nInspection.java
+++ b/plugins/java-i18n/src/com/intellij/codeInspection/i18n/I18nInspection.java
@@ -23,7 +23,6 @@
 import com.intellij.codeInsight.AnnotationUtil;
 import com.intellij.codeInsight.CodeInsightBundle;
 import com.intellij.codeInsight.daemon.GroupNames;
-import com.intellij.codeInsight.daemon.impl.analysis.HighlightUtil;
 import com.intellij.codeInsight.intention.AddAnnotationFix;
 import com.intellij.codeInspection.*;
 import com.intellij.codeInspection.ex.BaseLocalInspectionTool;
@@ -47,6 +46,7 @@
 import com.intellij.psi.util.PsiTreeUtil;
 import com.intellij.psi.util.PsiUtil;
 import com.intellij.refactoring.introduceField.IntroduceConstantHandler;
+import com.intellij.refactoring.util.RefactoringChangeUtil;
 import com.intellij.ui.AddDeleteListPanel;
 import com.intellij.ui.DocumentAdapter;
 import com.intellij.ui.FieldPanel;
@@ -891,7 +891,7 @@
     }
     final PsiElement grandparent = parent.getParent();
     final PsiClass aClass;
-    if (HighlightUtil.isSuperOrThisMethodCall(grandparent)) {
+    if (RefactoringChangeUtil.isSuperOrThisMethodCall(grandparent)) {
       final PsiMethod method = ((PsiMethodCallExpression)grandparent).resolveMethod();
       if (method != null) {
         aClass = method.getContainingClass();
diff --git a/plugins/java-i18n/src/com/intellij/codeInspection/i18n/SuppressByCommentOutAction.java b/plugins/java-i18n/src/com/intellij/codeInspection/i18n/SuppressByCommentOutAction.java
index 4b7f1bd..43b5ee0 100644
--- a/plugins/java-i18n/src/com/intellij/codeInspection/i18n/SuppressByCommentOutAction.java
+++ b/plugins/java-i18n/src/com/intellij/codeInspection/i18n/SuppressByCommentOutAction.java
@@ -19,7 +19,7 @@
 import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
 import com.intellij.codeInspection.InspectionsBundle;
 import com.intellij.codeInspection.SuppressIntentionAction;
-import com.intellij.lang.StdLanguages;
+import com.intellij.lang.java.JavaLanguage;
 import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.text.StringUtil;
@@ -76,13 +76,13 @@
     if (!element.isValid()) {
       return false;
     }
-    // find java code up there, going through injecttions if necessary
+    // find java code up there, going through injections if necessary
     return findJavaCodeUpThere(element) != null;
   }
 
   private static PsiElement findJavaCodeUpThere(PsiElement element) {
     while (element != null) {
-      if (element.getLanguage() == StdLanguages.JAVA) return element;
+      if (element.getLanguage() == JavaLanguage.INSTANCE) return element;
       element = element.getContext();
     }
     return null;
diff --git a/plugins/java-i18n/src/com/intellij/spellchecker/JavaSpellcheckingStrategy.java b/plugins/java-i18n/src/com/intellij/spellchecker/JavaSpellcheckingStrategy.java
index 78471ae..ee19872 100644
--- a/plugins/java-i18n/src/com/intellij/spellchecker/JavaSpellcheckingStrategy.java
+++ b/plugins/java-i18n/src/com/intellij/spellchecker/JavaSpellcheckingStrategy.java
@@ -16,8 +16,9 @@
 package com.intellij.spellchecker;
 
 import com.intellij.codeInsight.daemon.HighlightDisplayKey;
-import com.intellij.codeInspection.SuppressIntentionAction;
+import com.intellij.codeInspection.BatchSuppressManager;
 import com.intellij.codeInspection.SuppressManager;
+import com.intellij.codeInspection.SuppressQuickFix;
 import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiLiteralExpression;
 import com.intellij.psi.PsiMethod;
@@ -64,7 +65,7 @@
   }
 
   @Override
-  public SuppressIntentionAction[] getSuppressActions(@NotNull PsiElement element, @NotNull String name) {
-    return SuppressManager.getInstance().createSuppressActions(HighlightDisplayKey.find(name));
+  public SuppressQuickFix[] getSuppressActions(@NotNull PsiElement element, @NotNull String name) {
+    return BatchSuppressManager.SERVICE.getInstance().createBatchSuppressActions(HighlightDisplayKey.find(name));
   }
 }
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/actions/RunBuildAction.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/actions/RunBuildAction.java
index 77a4ad9..e524530 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/actions/RunBuildAction.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/project/actions/RunBuildAction.java
@@ -38,12 +38,12 @@
   }
 
   private static boolean checkOrPerform(DataContext context, boolean perform) {
-    final MavenProject project = MavenActionUtil.getMavenProject(context);
-    if (project == null) return false;
-
     final List<String> goals = MavenDataKeys.MAVEN_GOALS.getData(context);
     if (goals == null || goals.isEmpty()) return false;
 
+    final MavenProject project = MavenActionUtil.getMavenProject(context);
+    if (project == null) return false;
+
     if (!perform) return true;
 
     final MavenRunnerParameters params = new MavenRunnerParameters(true,
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/tasks/actions/AssignShortcutAction.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/tasks/actions/AssignShortcutAction.java
index 1fb5d6a..4b34ace 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/tasks/actions/AssignShortcutAction.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/tasks/actions/AssignShortcutAction.java
@@ -50,14 +50,14 @@
 
   @Nullable
   private static String getGoalActionId(DataContext context) {
-    MavenProject project = MavenActionUtil.getMavenProject(context);
-    if (project == null) return null;
-
     final List<String> goals = MavenDataKeys.MAVEN_GOALS.getData(context);
     if (goals == null || goals.size() != 1) {
       return null;
     }
 
+    MavenProject project = MavenActionUtil.getMavenProject(context);
+    if (project == null) return null;
+
     String goal = goals.get(0);
 
     return getShortcutsManager(context).getActionId(project.getPath(), goal);
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/tasks/actions/ToggleBeforeRunTaskAction.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/tasks/actions/ToggleBeforeRunTaskAction.java
index cbbf24f..26dea4f 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/tasks/actions/ToggleBeforeRunTaskAction.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/tasks/actions/ToggleBeforeRunTaskAction.java
@@ -58,11 +58,12 @@
 
   @Nullable
   protected static Pair<MavenProject, String> getTaskDesc(DataContext context) {
+    List<String> goals = MavenDataKeys.MAVEN_GOALS.getData(context);
+    if (goals == null || goals.size() != 1) return null;
+
     MavenProject mavenProject = MavenActionUtil.getMavenProject(context);
     if (mavenProject == null) return null;
 
-    List<String> goals = MavenDataKeys.MAVEN_GOALS.getData(context);
-    if (goals == null || goals.size() != 1) return null;
 
     return Pair.create(mavenProject, goals.get(0));
   }
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/tasks/actions/ToggleCompilerTasksAction.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/tasks/actions/ToggleCompilerTasksAction.java
index cf17db4..b610c11 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/tasks/actions/ToggleCompilerTasksAction.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/tasks/actions/ToggleCompilerTasksAction.java
@@ -53,12 +53,12 @@
   }
 
   protected static List<MavenCompilerTask> getTasks(DataContext context) {
-    MavenProject project = MavenActionUtil.getMavenProject(context);
-    if (project == null) return Collections.emptyList();
-
     final List<String> goals = MavenDataKeys.MAVEN_GOALS.getData(context);
     if (goals == null || goals.isEmpty()) return Collections.emptyList();
 
+    MavenProject project = MavenActionUtil.getMavenProject(context);
+    if (project == null) return Collections.emptyList();
+
     List<MavenCompilerTask> result = new ArrayList<MavenCompilerTask>();
     for (String each : goals) {
       result.add(new MavenCompilerTask(project.getPath(), each));
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/actions/MavenActionGroup.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/actions/MavenActionGroup.java
index 15ac77c..d3785f6 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/actions/MavenActionGroup.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/actions/MavenActionGroup.java
@@ -29,7 +29,6 @@
   }
 
   protected boolean isAvailable(AnActionEvent e) {
-    return MavenActionUtil.hasProject(e.getDataContext())
-           && !MavenActionUtil.getMavenProjects(e.getDataContext()).isEmpty();
+    return !MavenActionUtil.getMavenProjects(e.getDataContext()).isEmpty();
   }
 }
diff --git a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/actions/MavenActionUtil.java b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/actions/MavenActionUtil.java
index cf356d0..13a347f 100644
--- a/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/actions/MavenActionUtil.java
+++ b/plugins/maven/src/main/java/org/jetbrains/idea/maven/utils/actions/MavenActionUtil.java
@@ -20,6 +20,8 @@
 import com.intellij.openapi.actionSystem.PlatformDataKeys;
 import com.intellij.openapi.module.Module;
 import com.intellij.openapi.project.Project;
+import com.intellij.openapi.roots.ProjectFileIndex;
+import com.intellij.openapi.roots.ProjectRootManager;
 import com.intellij.openapi.vfs.VirtualFile;
 import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.Nullable;
@@ -84,34 +86,44 @@
   }
 
   public static List<MavenProject> getMavenProjects(DataContext context) {
-    Set<MavenProject> result = new LinkedHashSet<MavenProject>();
-    for (VirtualFile each : getFiles(context)) {
-      MavenProject project = getProjectsManager(context).findProject(each);
-      if (project != null) result.add(project);
-    }
-    if (result.isEmpty()) {
-      for (Module each : getModules(context)) {
-        MavenProject project = getProjectsManager(context).findProject(each);
-        if (project != null) result.add(project);
+    Project project = PlatformDataKeys.PROJECT.getData(context);
+    if (project == null) return Collections.emptyList();
+
+    VirtualFile[] virtualFiles = PlatformDataKeys.VIRTUAL_FILE_ARRAY.getData(context);
+    if (virtualFiles == null || virtualFiles.length == 0) return Collections.emptyList();
+
+    MavenProjectsManager projectsManager = MavenProjectsManager.getInstance(project);
+    if (!projectsManager.isMavenizedProject()) return Collections.emptyList();
+
+    Set<MavenProject> res = new LinkedHashSet<MavenProject>();
+
+    ProjectFileIndex fileIndex = ProjectRootManager.getInstance(project).getFileIndex();
+
+    for (VirtualFile file : virtualFiles) {
+      MavenProject mavenProject;
+
+      if (file.isDirectory()) {
+        VirtualFile contentRoot = fileIndex.getContentRootForFile(file);
+        if (!file.equals(contentRoot)) return Collections.emptyList();
+
+        Module module = fileIndex.getModuleForFile(file);
+        if (module == null || !projectsManager.isMavenizedModule(module)) return Collections.emptyList();
+
+        mavenProject = projectsManager.findProject(module);
       }
+      else {
+        mavenProject = projectsManager.findProject(file);
+      }
+
+      if (mavenProject == null) return Collections.emptyList();
+
+      res.add(mavenProject);
     }
-    return new ArrayList<MavenProject>(result);
+
+    return new ArrayList<MavenProject>(res);
   }
 
   public static List<VirtualFile> getMavenProjectsFiles(DataContext context) {
     return MavenUtil.collectFiles(getMavenProjects(context));
   }
-
-  private static List<VirtualFile> getFiles(DataContext context) {
-    VirtualFile[] result = PlatformDataKeys.VIRTUAL_FILE_ARRAY.getData(context);
-    return result == null ? Collections.<VirtualFile>emptyList() : Arrays.asList(result);
-  }
-
-  private static List<Module> getModules(DataContext context) {
-    Module[] result = DataKeys.MODULE_CONTEXT_ARRAY.getData(context);
-    if (result != null) return Arrays.asList(result);
-
-    Module module = getModule(context);
-    return module != null ? Collections.singletonList(module) : Collections.<Module>emptyList();
-  }
 }
diff --git a/plugins/maven/src/main/resources/META-INF/plugin.xml b/plugins/maven/src/main/resources/META-INF/plugin.xml
index 90ac562..26d2d46 100644
--- a/plugins/maven/src/main/resources/META-INF/plugin.xml
+++ b/plugins/maven/src/main/resources/META-INF/plugin.xml
@@ -429,8 +429,7 @@
       </action>
     </group>
 
-    <group id="Maven.DownloadAllGroup" popup="true" class="org.jetbrains.idea.maven.project.actions.DownloadActionGroup"
-           icon="AllIcons.Actions.Download">
+    <group id="Maven.DownloadAllGroup">
       <reference id="Maven.DownloadAllSources"/>
       <reference id="Maven.DownloadAllDocs"/>
       <reference id="Maven.DownloadAllSourcesAndDocs"/>
@@ -439,7 +438,11 @@
     <group id="Maven.NavigatorActionsToolbar">
       <reference id="Maven.Reimport"/>
       <reference id="Maven.UpdateFolders"/>
-      <reference id="Maven.DownloadAllGroup"/>
+
+      <group id="Maven.DownloadAllGroupPopup" popup="true" class="org.jetbrains.idea.maven.project.actions.DownloadActionGroup"
+             icon="AllIcons.Actions.Download">
+        <reference id="Maven.DownloadAllGroup"/>
+      </group>
       <separator/>
       <reference id="Maven.AddManagedFiles"/>
       <separator/>
@@ -486,7 +489,7 @@
       <reference id="Maven.OpenSettingsXml"/>
       <reference id="Maven.OpenProfilesXml"/>
       <separator/>
-      <reference ref="Maven.DependencyMenu"/>
+      <reference id="Maven.DownloadAllGroup"/>
       <separator/>
     </group>
 
diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnVcs.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnVcs.java
index dbc78b2..dfbf6e8 100644
--- a/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnVcs.java
+++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/SvnVcs.java
@@ -317,6 +317,7 @@
   private void cleanup17copies() {
     final Runnable callCleanupWorker = new Runnable() {
       public void run() {
+        if (myProject.isDisposed()) return;
         new CleanupWorker(new VirtualFile[]{}, myProject, "action.Subversion.cleanup.progress.title") {
           @Override
           protected void chanceToFillRoots() {
diff --git a/plugins/tasks/tasks-core/src/com/intellij/tasks/impl/LocalTaskImpl.java b/plugins/tasks/tasks-core/src/com/intellij/tasks/impl/LocalTaskImpl.java
index 9f02f4b..d3b6469 100644
--- a/plugins/tasks/tasks-core/src/com/intellij/tasks/impl/LocalTaskImpl.java
+++ b/plugins/tasks/tasks-core/src/com/intellij/tasks/impl/LocalTaskImpl.java
@@ -199,6 +199,10 @@
     return myChangeLists;
   }
 
+  public void setChangeLists(List<ChangeListInfo> changeLists) {
+    myChangeLists = changeLists;
+  }
+
   @Override
   public void addChangelist(final ChangeListInfo info) {
     if (!myChangeLists.contains(info)) {
@@ -211,10 +215,6 @@
     myChangeLists.remove(info);
   }
 
-  public void setChangeLists(List<ChangeListInfo> changeLists) {
-    myChangeLists = changeLists;
-  }
-
   public boolean isClosed() {
     return myClosed;
   }
diff --git a/plugins/tasks/tasks-tests/test/com/intellij/tasks/TaskVcsTest.java b/plugins/tasks/tasks-tests/test/com/intellij/tasks/TaskVcsTest.java
index 40207a4..4691bce 100644
--- a/plugins/tasks/tasks-tests/test/com/intellij/tasks/TaskVcsTest.java
+++ b/plugins/tasks/tasks-tests/test/com/intellij/tasks/TaskVcsTest.java
@@ -125,15 +125,18 @@
     Task task = myRepository.findTask("TEST-001");
     assertNotNull(task);
     myTaskManager.activateTask(task, false, true);
+    myChangeListManager.waitUntilRefreshed();
 
     LocalTask defaultTask = myTaskManager.findTask(LocalTaskImpl.DEFAULT_TASK_ID);
     assertNotNull(defaultTask);
     myTaskManager.activateTask(defaultTask, false, true);
+    myChangeListManager.waitUntilRefreshed();
     assertEquals(defaultTask, myTaskManager.getActiveTask());
 
     LocalTask anotherTask = myTaskManager.findTask("TEST-001");
     assertNotNull(anotherTask);
     myTaskManager.createChangeList(defaultTask, "Default (1)");
+    myChangeListManager.waitUntilRefreshed();
 
     assertEquals(1, anotherTask.getChangeLists().size());
     assertEquals(2, defaultTask.getChangeLists().size());
@@ -161,10 +164,12 @@
     Task task = myRepository.findTask("TEST-001");
     assertNotNull(task);
     myTaskManager.activateTask(task, false, true);
+    myChangeListManager.waitUntilRefreshed();
 
     LocalTask defaultTask = myTaskManager.findTask(LocalTaskImpl.DEFAULT_TASK_ID);
     assertNotNull(defaultTask);
     myTaskManager.activateTask(defaultTask, false, true);
+    myChangeListManager.waitUntilRefreshed();
     assertEquals(defaultTask, myTaskManager.getActiveTask());
 
     LocalTask anotherTask = myTaskManager.findTask("TEST-001");
@@ -188,10 +193,12 @@
     Task task = myRepository.findTask("TEST-001");
     assertNotNull(task);
     myTaskManager.activateTask(task, false, true);
+    myChangeListManager.waitUntilRefreshed();
 
     LocalTask defaultTask = myTaskManager.findTask(LocalTaskImpl.DEFAULT_TASK_ID);
     assertNotNull(defaultTask);
     myTaskManager.activateTask(defaultTask, false, true);
+    myChangeListManager.waitUntilRefreshed();
     assertEquals(defaultTask, myTaskManager.getActiveTask());
 
     LocalTask anotherTask = myTaskManager.findTask("TEST-001");
@@ -241,6 +248,7 @@
     Task task = myRepository.findTask("TEST-001");
     assertNotNull(task);
     myTaskManager.activateTask(task, false, true);
+    myChangeListManager.waitUntilRefreshed();
     LocalTask localTask = myTaskManager.getActiveTask();
     assertNotNull(localTask);
     assertEquals("TEST-001 Summary 001 TEST", localTask.getChangeLists().get(0).comment);
@@ -254,6 +262,7 @@
     Task task = myRepository.findTask("TEST-001");
     assertNotNull(task);
     myTaskManager.activateTask(task, false, true);
+    myChangeListManager.waitUntilRefreshed();
 
     assertEquals(2, myTaskManager.getLocalTasks().size());
     assertEquals(2, myChangeListManager.getChangeListsCopy().size());
diff --git a/resources-en/src/fileTemplates/includes/File Header.java.ft b/resources-en/src/fileTemplates/includes/File Header.java.ft
index c6b8d66..206b6b2 100644
--- a/resources-en/src/fileTemplates/includes/File Header.java.ft
+++ b/resources-en/src/fileTemplates/includes/File Header.java.ft
@@ -1,6 +1,3 @@
 /**
- * Created with IntelliJ IDEA.
- * User: ${USER}
- * Date: ${DATE}
- * Time: ${TIME}
+ * Created by ${USER} on ${DATE}.
  */
diff --git a/resources-en/src/inspectionDescriptions/DefaultFileTemplate.html b/resources-en/src/inspectionDescriptions/DefaultFileTemplate.html
index 0e869e6..e7c6cd2 100644
--- a/resources-en/src/inspectionDescriptions/DefaultFileTemplate.html
+++ b/resources-en/src/inspectionDescriptions/DefaultFileTemplate.html
@@ -1,11 +1,6 @@
 <html>
 <body>
-This inspections reports usages of the default file templates for
-  <ul>
-    <li>File Header,</li>
-    <li>Overridden/implemented ot created method body, and</li>
-    <li>Generated Catch block section.</li>
-  </ul>
+This inspections reports usage of the default file template for File Header.
  <p>
 Also, the inspection proposes to change default file template and its usage.
 </body>
diff --git a/resources-en/src/intentionDescriptions/CreateSubclassAction/after.java.template b/resources-en/src/intentionDescriptions/CreateSubclassAction/after.java.template
index 8bac272..b244715 100644
--- a/resources-en/src/intentionDescriptions/CreateSubclassAction/after.java.template
+++ b/resources-en/src/intentionDescriptions/CreateSubclassAction/after.java.template
@@ -1,8 +1,7 @@
 public abstract class X {
   protected abstract void f();
 }
-public class XImpl extends X {
+<spot>public class XImpl extends X {
   protected void f() {
-    //To change body of implemented methods use File | Settings | File Templates.
   }
-}
+}</spot>
diff --git a/resources-en/src/intentionDescriptions/CreateTestAction/after.java.template b/resources-en/src/intentionDescriptions/CreateTestAction/after.java.template
index 4556d16..3fe4194 100644
--- a/resources-en/src/intentionDescriptions/CreateTestAction/after.java.template
+++ b/resources-en/src/intentionDescriptions/CreateTestAction/after.java.template
@@ -2,8 +2,8 @@
   public void doSomething() {
   }
 }
-public class FooTest extends TestCase {
+<spot>public class FooTest extends TestCase {
   public void testDoSomething() {
-    <spot>//To change body of implemented methods use File | Settings | File Templates.</spot>
+
   }
-}
+}</spot>
diff --git a/resources-en/src/intentionDescriptions/ImplementAbstractMethodAction/after.java.template b/resources-en/src/intentionDescriptions/ImplementAbstractMethodAction/after.java.template
index a898642..20f0e88 100644
--- a/resources-en/src/intentionDescriptions/ImplementAbstractMethodAction/after.java.template
+++ b/resources-en/src/intentionDescriptions/ImplementAbstractMethodAction/after.java.template
@@ -2,7 +2,6 @@
     abstract void f();
 }
 abstract class Y extends X {
-    void f() {
-        //To change body of implemented methods use File | Settings | File Templates.
-    }
+    <spot>void f() {
+    }</spot>
 }
diff --git a/resources/src/META-INF/IdeaPlugin.xml b/resources/src/META-INF/IdeaPlugin.xml
index 7d52d75..604870d 100644
--- a/resources/src/META-INF/IdeaPlugin.xml
+++ b/resources/src/META-INF/IdeaPlugin.xml
@@ -610,7 +610,7 @@
                      implementationClass="com.intellij.codeInspection.AnonymousCanBeMethodReferenceInspection" />
     <localInspection language="JAVA" shortName="Convert2MethodRef" displayName="Lambda can be replaced with method reference"
                      groupName="Java language level migration aids" enabledByDefault="true" level="WARNING"
-                     implementationClass="com.intellij.codeInspection.LambdaCanBeMethReferenceInspection" />
+                     implementationClass="com.intellij.codeInspection.LambdaCanBeMethodReferenceInspection" />
     <localInspection language="JAVA" shortName="CodeBlock2Expr" displayName="Lambda code block can be replaced with expression"
                      groupName="Java language level migration aids" enabledByDefault="true" level="WARNING"
                      implementationClass="com.intellij.codeInspection.RedundantLambdaCodeBlockInspection" />
@@ -1078,6 +1078,8 @@
 
     <applicationService serviceInterface="com.intellij.codeInspection.SuppressManager"
                         serviceImplementation="com.intellij.codeInspection.SuppressManagerImpl"/>
+    <applicationService serviceInterface="com.intellij.codeInspection.BatchSuppressManager"
+                        serviceImplementation="com.intellij.codeInspection.BatchSuppressManagerImpl"/>
 
     <declarationRangeHandler key="com.intellij.psi.PsiMethod"
                              implementationClass="com.intellij.codeInsight.hint.MethodDeclarationRangeHandler"/>
diff --git a/spellchecker/src/com/intellij/spellchecker/inspections/SpellCheckingInspection.java b/spellchecker/src/com/intellij/spellchecker/inspections/SpellCheckingInspection.java
index 7f79ba8..f6f0d88 100644
--- a/spellchecker/src/com/intellij/spellchecker/inspections/SpellCheckingInspection.java
+++ b/spellchecker/src/com/intellij/spellchecker/inspections/SpellCheckingInspection.java
@@ -40,8 +40,7 @@
 import java.util.Set;
 
 
-public class SpellCheckingInspection extends LocalInspectionTool implements CustomSuppressableInspectionTool {
-
+public class SpellCheckingInspection extends LocalInspectionTool implements BatchSuppressableTool {
   public static final String SPELL_CHECKING_INSPECTION_TOOL_NAME = "SpellCheckingInspection";
 
   @Override
@@ -58,15 +57,16 @@
     return SpellCheckerBundle.message("spellchecking.inspection.name");
   }
 
+  @NotNull
   @Override
-  public SuppressIntentionAction[] getSuppressActions(@Nullable PsiElement element) {
+  public SuppressQuickFix[] getBatchSuppressActions(@Nullable PsiElement element) {
     if (element != null) {
       SpellcheckingStrategy strategy = LanguageSpellchecking.INSTANCE.forLanguage(element.getLanguage());
       if(strategy instanceof SuppressibleSpellcheckingStrategy) {
         return ((SuppressibleSpellcheckingStrategy)strategy).getSuppressActions(element, getShortName());
       }
     }
-    return SuppressIntentionAction.EMPTY_ARRAY;
+    return SuppressQuickFix.EMPTY_ARRAY;
   }
 
   @Override
diff --git a/spellchecker/src/com/intellij/spellchecker/tokenizer/SpellcheckingStrategy.java b/spellchecker/src/com/intellij/spellchecker/tokenizer/SpellcheckingStrategy.java
index 19cee09..cc70a7d 100644
--- a/spellchecker/src/com/intellij/spellchecker/tokenizer/SpellcheckingStrategy.java
+++ b/spellchecker/src/com/intellij/spellchecker/tokenizer/SpellcheckingStrategy.java
@@ -15,7 +15,7 @@
  */
 package com.intellij.spellchecker.tokenizer;
 
-import com.intellij.codeInsight.daemon.impl.actions.AbstractSuppressByNoInspectionCommentFix;
+import com.intellij.codeInspection.SuppressionUtil;
 import com.intellij.openapi.extensions.ExtensionPointName;
 import com.intellij.openapi.util.TextRange;
 import com.intellij.openapi.util.text.StringUtil;
@@ -51,7 +51,7 @@
   public Tokenizer getTokenizer(PsiElement element) {
     if (element instanceof PsiNameIdentifierOwner) return new PsiIdentifierOwnerTokenizer();
     if (element instanceof PsiComment) {
-      if (AbstractSuppressByNoInspectionCommentFix.isSuppressionComment(element)) {
+      if (SuppressionUtil.isSuppressionComment(element)) {
         return EMPTY_TOKENIZER;
       }
       return myCommentTokenizer;
diff --git a/spellchecker/src/com/intellij/spellchecker/tokenizer/SuppressibleSpellcheckingStrategy.java b/spellchecker/src/com/intellij/spellchecker/tokenizer/SuppressibleSpellcheckingStrategy.java
index c6710bf..a12272a 100644
--- a/spellchecker/src/com/intellij/spellchecker/tokenizer/SuppressibleSpellcheckingStrategy.java
+++ b/spellchecker/src/com/intellij/spellchecker/tokenizer/SuppressibleSpellcheckingStrategy.java
@@ -15,7 +15,7 @@
  */
 package com.intellij.spellchecker.tokenizer;
 
-import com.intellij.codeInspection.SuppressIntentionAction;
+import com.intellij.codeInspection.SuppressQuickFix;
 import com.intellij.psi.PsiElement;
 import org.jetbrains.annotations.NotNull;
 
@@ -30,7 +30,7 @@
   public abstract boolean isSuppressedFor(@NotNull PsiElement element, @NotNull String name);
 
   /**
-   * @see com.intellij.codeInspection.CustomSuppressableInspectionTool#getSuppressActions(com.intellij.psi.PsiElement)
+   * @see com.intellij.codeInspection.BatchSuppressableTool#getBatchSuppressActions(com.intellij.psi.PsiElement)
    */
-  public abstract SuppressIntentionAction[] getSuppressActions(@NotNull PsiElement element, @NotNull String name);
+  public abstract SuppressQuickFix[] getSuppressActions(@NotNull PsiElement element, @NotNull String name);
 }
diff --git a/spellchecker/src/com/intellij/spellchecker/xml/XmlSpellcheckingStrategy.java b/spellchecker/src/com/intellij/spellchecker/xml/XmlSpellcheckingStrategy.java
index e08897f..4747826 100644
--- a/spellchecker/src/com/intellij/spellchecker/xml/XmlSpellcheckingStrategy.java
+++ b/spellchecker/src/com/intellij/spellchecker/xml/XmlSpellcheckingStrategy.java
@@ -1,6 +1,6 @@
 package com.intellij.spellchecker.xml;
 
-import com.intellij.codeInspection.SuppressIntentionAction;
+import com.intellij.codeInspection.SuppressQuickFix;
 import com.intellij.psi.PsiElement;
 import com.intellij.spellchecker.tokenizer.SuppressibleSpellcheckingStrategy;
 import com.intellij.util.xml.DomElement;
@@ -25,7 +25,7 @@
   }
 
   @Override
-  public SuppressIntentionAction[] getSuppressActions(@NotNull PsiElement element, @NotNull String name) {
-    return SuppressIntentionAction.EMPTY_ARRAY;
+  public SuppressQuickFix[] getSuppressActions(@NotNull PsiElement element, @NotNull String name) {
+    return SuppressQuickFix.EMPTY_ARRAY;
   }
 }
diff --git a/xml/openapi/src/com/intellij/codeInspection/XmlSuppressableInspectionTool.java b/xml/openapi/src/com/intellij/codeInspection/XmlSuppressableInspectionTool.java
index 59fbf53..5292a1a 100644
--- a/xml/openapi/src/com/intellij/codeInspection/XmlSuppressableInspectionTool.java
+++ b/xml/openapi/src/com/intellij/codeInspection/XmlSuppressableInspectionTool.java
@@ -16,22 +16,22 @@
 
 package com.intellij.codeInspection;
 
-import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.project.Project;
 import com.intellij.psi.PsiElement;
 import com.intellij.psi.util.PsiTreeUtil;
 import com.intellij.psi.xml.XmlFile;
 import com.intellij.psi.xml.XmlTag;
-import com.intellij.util.IncorrectOperationException;
 import org.jetbrains.annotations.NonNls;
 import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
 
-public abstract class XmlSuppressableInspectionTool extends LocalInspectionTool implements CustomSuppressableInspectionTool {
+public abstract class XmlSuppressableInspectionTool extends LocalInspectionTool implements BatchSuppressableTool {
   @NonNls static final String ALL = "ALL";
 
+  @NotNull
   @Override
-  public SuppressIntentionAction[] getSuppressActions(final PsiElement element) {
-    return new SuppressIntentionAction[]{new SuppressTag(), new SuppressForFile(getID()), new SuppressAllForFile()};
+  public SuppressQuickFix[] getBatchSuppressActions(@Nullable PsiElement element) {
+    return new SuppressQuickFix[]{new SuppressTag(), new SuppressForFile(getID()), new SuppressAllForFile()};
   }
 
   @Override
@@ -40,81 +40,83 @@
   }
 
   public class SuppressTag extends SuppressTagStatic {
-
     public SuppressTag() {
       super(getID());
     }
   }
 
-  public static class SuppressTagStatic extends SuppressIntentionAction {
+  public static class SuppressTagStatic implements SuppressQuickFix {
     private final String id;
 
     public SuppressTagStatic(@NotNull String id) {
       this.id = id;
     }
 
-    @Override
     @NotNull
-    public String getText() {
+    @Override
+    public String getName() {
       return InspectionsBundle.message("xml.suppressable.for.tag.title");
     }
 
     @Override
+    public boolean isAvailable(@NotNull Project project, @NotNull PsiElement context) {
+      return context.isValid();
+    }
+
+    @Override
+    public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
+      PsiElement element = descriptor.getPsiElement();
+      if (PsiTreeUtil.getParentOfType(element, XmlTag.class) == null) return;
+      XmlSuppressionProvider.getProvider(element.getContainingFile()).suppressForTag(element, id);
+    }
+
+    @Override
     @NotNull
     public String getFamilyName() {
-      return getText();
-    }
-
-    @Override
-    public boolean isAvailable(@NotNull final Project project, final Editor editor, @NotNull final PsiElement element) {
-      return PsiTreeUtil.getParentOfType(element, XmlTag.class) != null;
-    }
-
-    @Override
-    public void invoke(@NotNull final Project project, final Editor editor, @NotNull final PsiElement element) throws IncorrectOperationException {
-      XmlSuppressionProvider.getProvider(element.getContainingFile()).suppressForTag(element, id);
+      return getName();
     }
   }
 
-  public static class SuppressForFile extends SuppressIntentionAction {
+  public static class SuppressForFile implements SuppressQuickFix {
     private final String myInspectionId;
 
     public SuppressForFile(@NotNull String inspectionId) {
       myInspectionId = inspectionId;
     }
 
-    @Override
     @NotNull
-    public String getText() {
+    @Override
+    public String getName() {
       return InspectionsBundle.message("xml.suppressable.for.file.title");
     }
 
     @Override
+    public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
+      PsiElement element = descriptor.getPsiElement();
+      if (element == null || !element.isValid() || !(element.getContainingFile() instanceof XmlFile)) return;
+      XmlSuppressionProvider.getProvider(element.getContainingFile()).suppressForFile(element, myInspectionId);
+    }
+
+    @Override
+    public boolean isAvailable(@NotNull Project project, @NotNull PsiElement context) {
+      return context.isValid();
+    }
+
+    @Override
     @NotNull
     public String getFamilyName() {
-      return getText();
-    }
-
-    @Override
-    public void invoke(@NotNull final Project project, final Editor editor, @NotNull final PsiElement element) throws IncorrectOperationException {
-      XmlSuppressionProvider.getProvider(element.getContainingFile()).suppressForFile(element, myInspectionId);
-    }
-
-    @Override
-    public boolean isAvailable(@NotNull final Project project, final Editor editor, @NotNull final PsiElement element) {
-      return  element.isValid() && element.getContainingFile() instanceof XmlFile;
+      return getName();
     }
   }
 
   public static class SuppressAllForFile extends SuppressForFile {
-
     public SuppressAllForFile() {
       super(ALL);
     }
 
-    @Override
     @NotNull
-    public String getText() {
+    @Override
+    public String getName() {
       return InspectionsBundle.message("xml.suppressable.all.for.file.title");
     }
   }
diff --git a/xml/relaxng/src/org/intellij/plugins/relaxNG/inspections/BaseInspection.java b/xml/relaxng/src/org/intellij/plugins/relaxNG/inspections/BaseInspection.java
index e429e56..03916fc 100644
--- a/xml/relaxng/src/org/intellij/plugins/relaxNG/inspections/BaseInspection.java
+++ b/xml/relaxng/src/org/intellij/plugins/relaxNG/inspections/BaseInspection.java
@@ -16,11 +16,8 @@
 
 package org.intellij.plugins.relaxNG.inspections;
 
-import com.intellij.codeInspection.ProblemsHolder;
-import com.intellij.codeInspection.SuppressIntentionAction;
-import com.intellij.codeInspection.XmlSuppressableInspectionTool;
+import com.intellij.codeInspection.*;
 import com.intellij.openapi.editor.Document;
-import com.intellij.openapi.editor.Editor;
 import com.intellij.openapi.fileTypes.StdFileTypes;
 import com.intellij.openapi.project.Project;
 import com.intellij.openapi.util.TextRange;
@@ -31,7 +28,6 @@
 import com.intellij.psi.util.PsiTreeUtil;
 import com.intellij.util.ArrayUtil;
 import com.intellij.util.Function;
-import com.intellij.util.IncorrectOperationException;
 import com.intellij.util.containers.ContainerUtil;
 import org.intellij.plugins.relaxNG.compact.psi.*;
 import org.jetbrains.annotations.Nls;
@@ -45,6 +41,7 @@
  * Date: 25.11.2007
  */
 public abstract class BaseInspection extends XmlSuppressableInspectionTool {
+  @Override
   @Nls
   @NotNull
   public final String getGroupDisplayName() {
@@ -88,65 +85,69 @@
     return false;
   }
 
+  @NotNull
   @Override
-  @Nullable
-  public SuppressIntentionAction[] getSuppressActions(PsiElement element) {
+  public SuppressQuickFix[] getBatchSuppressActions(@Nullable PsiElement element) {
     if (element.getContainingFile() instanceof RncFile) {
-      return ArrayUtil.mergeArrays(new SuppressIntentionAction[]{
+      return ArrayUtil.mergeArrays(new SuppressQuickFix[] {
               new SuppressAction("Define") {
+                @Override
                 protected PsiElement getTarget(PsiElement element) {
                   return PsiTreeUtil.getParentOfType(element, RncDefine.class, false);
                 }
               },
               new SuppressAction("Grammar") {
+                @Override
                 protected PsiElement getTarget(PsiElement element) {
                   final RncDefine define = PsiTreeUtil.getParentOfType(element, RncDefine.class, false);
-                  return define != null ? PsiTreeUtil.getParentOfType(define, RncGrammar.class, false) : null;
-                }
-
-                @SuppressWarnings({ "SSBasedInspection" })
-                public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement element) {
-                  return super.isAvailable(project, editor, element) && getTarget(element).getText().startsWith("grammar ");
+                  RncGrammar target = define != null ? PsiTreeUtil.getParentOfType(define, RncGrammar.class, false) : null;
+                  return target != null && target.getText().startsWith("grammar ") ? target : null;
                 }
               }
       }, getXmlOnlySuppressions(element));
-    } else {
-      return super.getSuppressActions(element);
+    }
+    else {
+      return super.getBatchSuppressActions(element);
     }
   }
 
-  private SuppressIntentionAction[] getXmlOnlySuppressions(PsiElement element) {
-    return ContainerUtil.map(super.getSuppressActions(element), new Function<SuppressIntentionAction, SuppressIntentionAction>() {
-      public SuppressIntentionAction fun(final SuppressIntentionAction action) {
-        return new SuppressIntentionAction() {
-          public void invoke(@NotNull Project project, Editor editor, @NotNull PsiElement element) throws IncorrectOperationException {
-            action.invoke(project, editor, element);
-          }
-
-          public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement element) {
-            return element.getContainingFile().getFileType() == StdFileTypes.XML && action.isAvailable(project, editor, element);
-          }
-
+  private SuppressQuickFix[] getXmlOnlySuppressions(PsiElement element) {
+    return ContainerUtil.map(super.getBatchSuppressActions(element), new Function<SuppressQuickFix, SuppressQuickFix>() {
+      @Override
+      public SuppressQuickFix fun(final SuppressQuickFix action) {
+        return new SuppressQuickFix() {
           @NotNull
-          public String getText() {
-            return action.getText();
+          @Override
+          public String getName() {
+            return action.getName();
           }
 
-          public boolean startInWriteAction() {
-            return action.startInWriteAction();
+          @Override
+          public boolean isAvailable(@NotNull Project project, @NotNull PsiElement context) {
+            return context.isValid();
           }
 
+          @Override
+          public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
+            PsiElement element = descriptor.getPsiElement();
+            PsiFile file = element == null ? null : element.getContainingFile();
+            if (file == null || file.getFileType() != StdFileTypes.XML) return;
+            action.applyFix(project, descriptor);
+          }
+
+          @Override
           @NotNull
           public String getFamilyName() {
             return action.getFamilyName();
           }
         };
       }
-    }, new SuppressIntentionAction[0]);
+    }, SuppressQuickFix.EMPTY_ARRAY);
   }
 
   private void suppress(PsiFile file, @NotNull PsiElement location) {
     suppress(file, location, "#suppress " + getID(), new Function<String, String>() {
+      @Override
       public String fun(final String text) {
         return text + ", " + getID();
       }
@@ -160,7 +161,7 @@
     if (vfile == null || ReadonlyStatusHandler.getInstance(project).ensureFilesWritable(vfile).hasReadonlyFiles()) {
       return;
     }
-    
+
     final Document doc = PsiDocumentManager.getInstance(project).getDocument(file);
     assert doc != null;
 
@@ -188,7 +189,7 @@
   @NotNull
   public abstract RncElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly);
 
-  private abstract class SuppressAction extends SuppressIntentionAction {
+  private abstract class SuppressAction implements SuppressQuickFix {
     private final String myLocation;
 
     public SuppressAction(String location) {
@@ -196,21 +197,28 @@
     }
 
     @NotNull
-    public String getText() {
+    @Override
+    public String getName() {
       return "Suppress for " + myLocation;
     }
 
+    @Override
     @NotNull
     public String getFamilyName() {
       return getDisplayName();
     }
 
-    public void invoke(@NotNull Project project, Editor editor, @NotNull PsiElement element) throws IncorrectOperationException {
-      suppress(element.getContainingFile(), getTarget(element));
+    @Override
+    public boolean isAvailable(@NotNull Project project, @NotNull PsiElement context) {
+      return context.isValid();
     }
 
-    public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement element) {
-      return getTarget(element) != null;
+    @Override
+    public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
+      PsiElement element = descriptor.getPsiElement();
+      PsiElement target = getTarget(element);
+      if (target == null) return;
+      suppress(element.getContainingFile(), target);
     }
 
     protected abstract PsiElement getTarget(PsiElement element);