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

Change-Id: I756af70fb2910aa2687e94e28338fb9727bce518
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;